From patchwork Tue Jan 24 12:16:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9535105 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 324D66042C for ; Tue, 24 Jan 2017 12:20:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214E926E3E for ; Tue, 24 Jan 2017 12:20:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14F0F27F10; Tue, 24 Jan 2017 12:20:59 +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=-1.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0CC726E3E for ; Tue, 24 Jan 2017 12:20:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cW05o-0002aP-Ii; Tue, 24 Jan 2017 12:20:56 +0000 Received: from mail-lf0-f67.google.com ([209.85.215.67]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cW03D-0007co-Eg; Tue, 24 Jan 2017 12:18:19 +0000 Received: by mail-lf0-f67.google.com with SMTP id x1so17099413lff.0; Tue, 24 Jan 2017 04:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BRj6ZA56KGr6BGpn9CcWc/bLcxudGYWe+kMmkBA5kvE=; b=Od7ptaneeoh8Y3CGR8I0/JgUdz7fEe/VNLENdyOV+EhvKL1p44srZS04pFlPkCGK/N LTTBstIkaWnIik6Mk9Uu1BNP2gJqU8CiC3IYBq55ZHIXB+lXQRRnqP9MnTKXijW+QKyu k+6JQXj9lAh2PMWfmXemgOC860dCBMmmHyg4EobVR0TE1cula9hdXl+MM0FHTLEsvlEL 3kAelnhLar6XAcWTOE05ByFUwmDXL3a4qavxcJuHzHoaT3t1t0x39YvZjB5idwiZqZGh suujVK7LHBoJlILSt2sKvobnY3YxMiBdXY6chtnlnI6+Zw8rsyLNCI0sBu14c1O04FBu uXjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BRj6ZA56KGr6BGpn9CcWc/bLcxudGYWe+kMmkBA5kvE=; b=Ct/9POgnJ3HoWuvMTgNuvur7MWK2KA5+JTda1zaK4dU1sNWoYdMzy/VFuv78Xqae3P r4Phz20+1pmSTBwYl5oFihBKzHhFzo9T/UzOdKdJWBh3P6io07d/e7M2Ap2d6qgc3jzg tvk7MpL+FvZBqq+V7x2jqpE+aOXRYuTlGtVJRen9Jq8JYgCE1xAlB0k383Rdfgfa5xc5 Dg8xVM2ykq788eqxcW9cyFkr5C2qNeH16XORrR844JHoOTL+LI7q2EGGg/QzEfv2YlQX oj0iSPWFGdcNrYWBor9TlRaadn1R2CrFphslNjJ/ZQCqfYudF6KuR7lK5ohyhDRcZmjp j6mA== X-Gm-Message-State: AIkVDXI86DS1lOddmwq4SdBKZyrVabaE27Pzyq0lRfv5nZuakGiZ7Mpz6qcRixyr3G5wrA== X-Received: by 10.25.0.140 with SMTP id 134mr10635550lfa.156.1485260217409; Tue, 24 Jan 2017 04:16:57 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id e86sm7348934lji.32.2017.01.24.04.16.56 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 04:16:56 -0800 (PST) From: Alexander Kochetkov To: Daniel Lezcano , Heiko Stuebner , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v5 6/8] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Date: Tue, 24 Jan 2017 15:16:41 +0300 Message-Id: <1485260203-14216-7-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1485260203-14216-1-git-send-email-al.kochet@gmail.com> References: <1485260203-14216-1-git-send-email-al.kochet@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_041815_814392_45C87D8E X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Huang Tao , Alexander Kochetkov , Russell King , Rob Herring , Thomas Gleixner , Caesar Wang 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 Reviwed-by: Heiko Stübner --- 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) {