From patchwork Sat May 28 09:33:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 68787 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp508486qge; Sat, 28 May 2016 02:35:43 -0700 (PDT) X-Received: by 10.66.183.69 with SMTP id ek5mr29093111pac.153.1464428143470; Sat, 28 May 2016 02:35:43 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r123si15810587pfr.68.2016.05.28.02.35.42; Sat, 28 May 2016 02:35:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753228AbcE1Jfa (ORCPT + 30 others); Sat, 28 May 2016 05:35:30 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:37437 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbcE1Jf2 (ORCPT ); Sat, 28 May 2016 05:35:28 -0400 Received: from 172.24.1.47 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCH96854; Sat, 28 May 2016 17:35:14 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Sat, 28 May 2016 17:35:01 +0800 From: Kefeng Wang To: Thomas Gleixner , Daniel Lezcano , Rob Herring CC: , , , , Sudeep Holla , Arnd Bergmann , Subject: [PATCH 2/4] clocksource: sp804: introduce helper sp804_load_mode_set() Date: Sat, 28 May 2016 17:33:51 +0800 Message-ID: <1464428033-52106-3-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1464428033-52106-1-git-send-email-wangkefeng.wang@huawei.com> References: <1464428033-52106-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.57496652.00B8, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 0dd3e262c1617812922067a7427485d8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce helper sp804_load_mode_set(), and use it, prepare for 64bit mode timer support. Signed-off-by: Kefeng Wang --- drivers/clocksource/timer-sp804.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) -- 1.7.12.4 diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index 362e5d0..b8848e5 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -73,6 +73,15 @@ static long __init sp804_get_clock_rate(struct clk *clk, const char *name) return rate; } +static inline void sp804_load_mode_set(void __iomem *base, unsigned long load, int mode) +{ + unsigned long ctrl = TIMER_CTRL_32BIT | TIMER_CTRL_IE | + mode | TIMER_CTRL_ENABLE; + + writel(load, base + TIMER_LOAD); + writel(ctrl, base + TIMER_CTRL); +} + static void __iomem *sched_clock_base; static u64 notrace sp804_read(void) @@ -97,10 +106,8 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, /* setup timer 0 as free-running clocksource */ writel(0, base + TIMER_CTRL); - writel(0xffffffff, base + TIMER_LOAD); writel(0xffffffff, base + TIMER_VALUE); - writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC, - base + TIMER_CTRL); + sp804_load_mode_set(base, 0xffffffff, TIMER_CTRL_PERIODIC & ~TIMER_CTRL_IE); clocksource_mmio_init(base + TIMER_VALUE, name, rate, 200, 32, clocksource_mmio_readl_down); @@ -143,24 +150,16 @@ static int sp804_shutdown(struct clock_event_device *evt) static int sp804_set_periodic(struct clock_event_device *evt) { - unsigned long ctrl = TIMER_CTRL_32BIT | TIMER_CTRL_IE | - TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; - timer_shutdown(evt); - writel(clkevt_reload, clkevt_base + TIMER_LOAD); - writel(ctrl, clkevt_base + TIMER_CTRL); + sp804_load_mode_set(clkevt_base, clkevt_reload, TIMER_CTRL_PERIODIC); return 0; } static int sp804_set_next_event(unsigned long next, - struct clock_event_device *evt) + struct clock_event_device *evt) { - unsigned long ctrl = TIMER_CTRL_32BIT | TIMER_CTRL_IE | - TIMER_CTRL_ONESHOT | TIMER_CTRL_ENABLE; - - writel(next, clkevt_base + TIMER_LOAD); - writel(ctrl, clkevt_base + TIMER_CTRL); + sp804_load_mode_set(clkevt_base, next, TIMER_CTRL_ONESHOT); return 0; }