From patchwork Tue Nov 29 16:14:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9452641 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 B70406071E for ; Tue, 29 Nov 2016 16:18:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9492283EC for ; Tue, 29 Nov 2016 16:18:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BB87283FE; Tue, 29 Nov 2016 16:18:47 +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 30544283EC for ; Tue, 29 Nov 2016 16:18:47 +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 1cBl5m-0002CK-O7; Tue, 29 Nov 2016 16:17:14 +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 1cBl4M-0001SS-E3; Tue, 29 Nov 2016 16:15:48 +0000 Received: by mail-lf0-x242.google.com with SMTP id o20so13143635lfg.3; Tue, 29 Nov 2016 08:15:26 -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=au38ER76T8SNPJng7a/WLwoIp7FL6Var4cF/SfdwXaA=; b=gwO8spogX8if1LzT9imWJewiynmHVusvDGmWS4XMZ4n8+2KHTDCvo8O88Y9/PZdME7 pKVGfl2pfqbnJha80DK/1PokVC4A590J2h0uwGiavacOozhsgadzR74RXfig8q494Kwn kgEJ7uwLq/MBFTy1UzQfk7NlpJz4tgCcRUyS0jnVyV9HOFLK22YhJOxFezIddnfqYXsg C1RgnMGkddAMqBTUB8UJ87wMBzQAuJmpm0F3X+HaLXjRTeCO5J5eZ16Zibhy8bcpJA8G x8QKsQFDkQjzt+tIKA9R8QWa9zCsXz/KMaqs9sjAJN5ldPQmfzFkN4rzUop7M9PukXPW AFUw== 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=au38ER76T8SNPJng7a/WLwoIp7FL6Var4cF/SfdwXaA=; b=eApoO0J+GEcJBWS7YatcFWrFCjJ+sJHqbVfPnfJDhyXcxBp/qtXeG9KtSN7MwLUCxd yF4dQ+PMMJQFrcvyWyoKY8pHPCMTMPq5+yrDpSRJuwJH0wBCFa1Lj9QtynYQI8S3sD7+ 5d9QnungXiDbxS4Tik5EpT2e4q1/FJUvxEsfr+6Dwp1l8JkE7vde9NmvgV2QYWazmTpv aV3rv0UgTlyAZE7TMJZrfVsqrRzI/XuoJPogOrek5NjdYIfxHaeth+LetQ5ak3q5IkQU WZ1OMFt3nfg/iudZ/FdNmVRnBTYuUu2ykQjWUGk9hLVfRrtVKynX8moM6E09Fd2D04WD s42Q== X-Gm-Message-State: AKaTC01vwk7Xm1s16mwTCSsv1zMPe297vN+pcUYba/6OVSbVCi4JSjeNAvu5LfUuyQAhew== X-Received: by 10.46.0.87 with SMTP id 84mr12945236lja.1.1480436124682; Tue, 29 Nov 2016 08:15:24 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id e78sm13771566lfg.23.2016.11.29.08.15.23 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 08:15:24 -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 v4 7/9] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Date: Tue, 29 Nov 2016 19:14:50 +0300 Message-Id: <1480436092-10728-8-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1480436092-10728-1-git-send-email-al.kochet@gmail.com> References: <1480343486-25539-1-git-send-email-al.kochet@gmail.com> <1480436092-10728-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_081546_920013_5D70C357 X-CRM114-Status: GOOD ( 12.88 ) 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. Drop rk_base() and rk_ctrl(). This is refactoring step without functional changes. Signed-off-by: Alexander Kochetkov --- drivers/clocksource/rockchip_timer.c | 57 ++++++++++++++++------------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index 6d68d4c..a17dc61 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -53,70 +53,67 @@ static inline struct rk_timer *rk_timer(struct clock_event_device *ce) return &rk_clock_event_device(ce)->timer; } -static inline void __iomem *rk_base(struct clock_event_device *ce) +static inline void rk_timer_disable(struct rk_timer *timer) { - return rk_timer(ce)->base; + writel_relaxed(TIMER_DISABLE, timer->ctrl); } -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) -{ - writel_relaxed(TIMER_DISABLE, rk_ctrl(ce)); -} - -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 +180,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) {