From patchwork Mon Nov 28 14:31:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9449641 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 D32F6600CB for ; Mon, 28 Nov 2016 14:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA70D205AB for ; Mon, 28 Nov 2016 14:35:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF0D5275A2; Mon, 28 Nov 2016 14:35:36 +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 7A6E6205AB for ; Mon, 28 Nov 2016 14:35:36 +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 1cBN0R-0000Ng-Tj; Mon, 28 Nov 2016 14:34:07 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBMyI-0007ZZ-SY; Mon, 28 Nov 2016 14:31:57 +0000 Received: by mail-lf0-x243.google.com with SMTP id 98so9631174lfs.0; Mon, 28 Nov 2016 06:31:39 -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=EgLXg+GdLvzxFSSXYLRGjTi8y2xDAqJ8V4tPvZlgRTK7mwESikchDdSlDD7V+z3LUo v1Estimp9aPAKiLXBp2Mz10pEF30mRA/olK4juYfXV1fRAut8ahxHt4cueanF7QI0pbE GW2mPYHWcdRMAhyKjvr8ehHSADZtsDs2R/wZzCZoUedvYmoQPE+jcrcIPznxnalsumxj G3OxN2AAbTl0D7f5BhNZRrrVUbdEmnuUXeKFvGSxwD8r8Js86nhBZEa7yNFttMOssDFi 2AipyHD9zulkSsweRCJxmh9g5gKECyJhhT9iR5R//gDjgC5KB+3QfejodTTihRORjZYv KmlQ== 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=MqdWQzinVLXJy0fkKYSF8yjuYpzUtYcMxfQ8+qfVOThCKV23ee+PyetcPBmO5wOMXS TXZnHWtJPXtcuNdg+26BRHnsQ4dFQRoX0HwnxToaAAnQZHzLqjqNbFLiuFEwH84MrHBZ RFkMPnnPvxQzhgxgS2BbGitN+DXLA12YHleZd/mUcZFrKnC79EWdzJQNOCErxouzeh3Y MAkpcOMMVzGoieYpBStxqwJt4uVd6wlJw2fEOa07Pt+K38qCU5h5YyJZHi6LNjnpWKj9 IviPdUX3KugiPktol+jn44D9FEAvq9DNgZilIm57/gagJ7K9lX5F33WTmrQc3ExERLpG NVoQ== X-Gm-Message-State: AKaTC00YRc8J3mChf/R6lmMCfiHXQbTvkGb922okcUIGKk4sM9sMoVTCGbbKNbU42Upokw== X-Received: by 10.25.154.199 with SMTP id c190mr6523318lfe.76.1480343497577; Mon, 28 Nov 2016 06:31:37 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id h30sm12816162lji.28.2016.11.28.06.31.36 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 06:31:36 -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: [PATCHv2 06/11] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Date: Mon, 28 Nov 2016 17:31:21 +0300 Message-Id: <1480343486-25539-7-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1480343486-25539-1-git-send-email-al.kochet@gmail.com> References: <1480343486-25539-1-git-send-email-al.kochet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_063155_190387_75C9D96F X-CRM114-Status: GOOD ( 12.02 ) 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) {