From patchwork Tue Nov 29 13:45:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9452139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C519660710 for ; Tue, 29 Nov 2016 13:52:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6A1E2811E for ; Tue, 29 Nov 2016 13:52:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2D1428339; Tue, 29 Nov 2016 13:52:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DAF12811E for ; Tue, 29 Nov 2016 13:52:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBinf-0003VU-4r; Tue, 29 Nov 2016 13:50:23 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBijJ-0007aF-SE; Tue, 29 Nov 2016 13:46:00 +0000 Received: by mail-lf0-x242.google.com with SMTP id o141so12750501lff.1; Tue, 29 Nov 2016 05:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hzyVL/t+siRCrZNEq0R5nOZ3+SudYBaLSZTlRsn2nQ8=; b=Y7LcAAG5fwApJLb1smlA9X8IJN/KlNClt2WAtSqkrpIW8OLp497MXEBUJrwchRq0jk MudN2Hs1kq88DUTFvk3tCoZ7La0U4zbnGBHu9bsRi5u/TsFzjIepkeNenCIvc30BvzH3 vvZVuB7zFG0hCVQ6JXnKPIb3c7Sotc2w7kggRyIZ3h8qa395AL3+CSpTkCXmEoymvLb2 wQAgSILl6HOv03iVpPjOgRQ1vLtWhlUq0ZIzI+P4/+AHC3f+jg6BYqd07Bok8aJfBWz1 uwA/Lm6GhGtmMv6ESFmlnRPM8KPly0D24SVc2vFt/OQ/keISU5eFG35RjCsfzCNhHjbB +o3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hzyVL/t+siRCrZNEq0R5nOZ3+SudYBaLSZTlRsn2nQ8=; b=gS4K7nhgxyibA14xRLlrIOIuee2JrBHj8HPEwGwIfYZ32wqPTpuiIm1fsGZ0MEmO0R 5LwxA49TIMC+9Y8wDwexpdBiWDFicLiz2zTSK12Twbef9d4Azi+T7qB1WG+DVTdHugZL SIu+tAnO3P9N2yvwHWB8msqXC9cq3r0KpzAMFw8DXDYMVmTit908FXsmZXE0d5zYSzeL mb1Dinryv+0sXf6jQAlWJlE4Y7z0Z5lQkAo/9HlsdvpG/SE8F/mMspX9db5vf3Kqlx+R Fa8V2a17HEcoeSusgvwlC11k5XH0WDUyJnSWgMubvou2D0RBwcrDAV3KZ1l80pj0YVoq hGaw== X-Gm-Message-State: AKaTC029hO/h3fULyhDaHIpZw8IFoCYrykHKNs7b2a4iXCNaW8u4d0o0eH68S266qdoIkg== X-Received: by 10.25.92.131 with SMTP id u3mr10549340lfi.15.1480427131632; Tue, 29 Nov 2016 05:45:31 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id y3sm250543lfj.42.2016.11.29.05.45.30 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 05:45:31 -0800 (PST) From: Alexander Kochetkov To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v3 07/13] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Date: Tue, 29 Nov 2016 16:45:12 +0300 Message-Id: <1480427118-5126-8-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1480427118-5126-1-git-send-email-al.kochet@gmail.com> References: <1480343486-25539-1-git-send-email-al.kochet@gmail.com> <1480427118-5126-1-git-send-email-al.kochet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_054554_514438_D79DBE1B X-CRM114-Status: GOOD ( 12.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Huang Tao , Heiko Stuebner , Alexander Kochetkov , Daniel Lezcano , Russell King , Rob Herring , Thomas Gleixner , Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Pass rk_timer instead of clock_event_device to low lever timer routines. So that code could be reused by clocksource implementation. This is refactoring step without functional changes. Signed-off-by: Alexander Kochetkov --- drivers/clocksource/rockchip_timer.c | 47 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index 6d68d4c..aa9ccd1 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -63,60 +63,67 @@ static inline void __iomem *rk_ctrl(struct clock_event_device *ce) return rk_timer(ce)->ctrl; } -static inline void rk_timer_disable(struct clock_event_device *ce) +static inline void rk_timer_disable(struct rk_timer *timer) { - writel_relaxed(TIMER_DISABLE, rk_ctrl(ce)); + writel_relaxed(TIMER_DISABLE, timer->ctrl); } -static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags) +static inline void rk_timer_enable(struct rk_timer *timer, u32 flags) { writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags, - rk_ctrl(ce)); + timer->ctrl); } static void rk_timer_update_counter(unsigned long cycles, - struct clock_event_device *ce) + struct rk_timer *timer) { - writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0); - writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1); + writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0); + writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1); } -static void rk_timer_interrupt_clear(struct clock_event_device *ce) +static void rk_timer_interrupt_clear(struct rk_timer *timer) { - writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS); + writel_relaxed(1, timer->base + TIMER_INT_STATUS); } static inline int rk_timer_set_next_event(unsigned long cycles, struct clock_event_device *ce) { - rk_timer_disable(ce); - rk_timer_update_counter(cycles, ce); - rk_timer_enable(ce, TIMER_MODE_USER_DEFINED_COUNT); + struct rk_timer *timer = rk_timer(ce); + + rk_timer_disable(timer); + rk_timer_update_counter(cycles, timer); + rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT); return 0; } static int rk_timer_shutdown(struct clock_event_device *ce) { - rk_timer_disable(ce); + struct rk_timer *timer = rk_timer(ce); + + rk_timer_disable(timer); return 0; } static int rk_timer_set_periodic(struct clock_event_device *ce) { - rk_timer_disable(ce); - rk_timer_update_counter(rk_timer(ce)->freq / HZ - 1, ce); - rk_timer_enable(ce, TIMER_MODE_FREE_RUNNING); + struct rk_timer *timer = rk_timer(ce); + + rk_timer_disable(timer); + rk_timer_update_counter(timer->freq / HZ - 1, timer); + rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING); return 0; } static irqreturn_t rk_timer_interrupt(int irq, void *dev_id) { struct clock_event_device *ce = dev_id; + struct rk_timer *timer = rk_timer(ce); - rk_timer_interrupt_clear(ce); + rk_timer_interrupt_clear(timer); if (clockevent_state_oneshot(ce)) - rk_timer_disable(ce); + rk_timer_disable(timer); ce->event_handler(ce); @@ -183,8 +190,8 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) ce->cpumask = cpu_possible_mask; ce->rating = 250; - rk_timer_interrupt_clear(ce); - rk_timer_disable(ce); + rk_timer_interrupt_clear(timer); + rk_timer_disable(timer); ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce); if (ret) {