From patchwork Wed Mar 20 11:41:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 2306991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 7FF87DF24C for ; Wed, 20 Mar 2013 11:45:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIHOc-0004xn-EQ; Wed, 20 Mar 2013 11:41:30 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIHOX-0004t2-D2 for linux-arm-kernel@lists.infradead.org; Wed, 20 Mar 2013 11:41:27 +0000 Received: from wuerfel.lan (HSI-KBW-46-223-90-92.hsi.kabel-badenwuerttemberg.de [46.223.90.92]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0Lm8JB-1Ur4BG1WKn-00ZLyD; Wed, 20 Mar 2013 12:41:23 +0100 From: Arnd Bergmann To: Barry Song Subject: [PATCH 6/8] ARM: sirf: use clocksource_of infrastructure Date: Wed, 20 Mar 2013 12:41:17 +0100 Message-Id: <1363779679-16880-7-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1363779679-16880-1-git-send-email-arnd@arndb.de> References: <1363779679-16880-1-git-send-email-arnd@arndb.de> X-Provags-ID: V02:K0:/1YcnPN7QMJ15pLVBryplZIK3yl9LR84vkPL1ru5oLu zdhku0CHw92v15iNqQbq/+dcRklk8e++04H1W8erb9ORVztT0V UrkeP9xn7u2hZiuVbd6Gh9XIq1IN5CdQetx9wlxc22eiYVR9r4 iK+p+NGzkfGoafNsTJVY2vKU5ik9/xLgTiUL6MH3uXwrSATNa6 FxMStLjaXhKwvYacvW1OakzthaxKBckOyOxOk0kfifT3QVsIO+ ZmYBV0qrD4uPPnaYgdheSsr6m+e6TcftLI6c1/rJPIKum+YEG/ Gik8FiKXgLoHFDCHf5X5jJemIaR/yBcV9QnIODto4VhX2sC9RC kovWHvHNjug4mNFW6KbOmzybHLNN1Hm9kCF7VVO07 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130320_074125_701294_4E84D7D7 X-CRM114-Status: GOOD ( 15.62 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.8 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Arnd Bergmann , workgroup.linux@csr.com, John Stultz , olof@lixom.net, Thomas Gleixner , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This moves the two sirf clocksource drivers to drivers/clocksource and integrates them into the framework for locating the clock sources automatically. Signed-off-by: Arnd Bergmann Cc: John Stultz Cc: Thomas Gleixner Tested-by: Barry Song --- arch/arm/mach-prima2/Makefile | 2 -- arch/arm/mach-prima2/common.c | 14 ++++++-- arch/arm/mach-prima2/common.h | 3 -- drivers/clocksource/Makefile | 2 ++ .../clocksource}/timer-marco.c | 25 +++----------- .../clocksource}/timer-prima2.c | 38 ++++------------------ 6 files changed, 24 insertions(+), 60 deletions(-) rename {arch/arm/mach-prima2 => drivers/clocksource}/timer-marco.c (94%) rename {arch/arm/mach-prima2 => drivers/clocksource}/timer-prima2.c (92%) diff --git a/arch/arm/mach-prima2/Makefile b/arch/arm/mach-prima2/Makefile index bfe360c..4e1d3d2 100644 --- a/arch/arm/mach-prima2/Makefile +++ b/arch/arm/mach-prima2/Makefile @@ -7,5 +7,3 @@ obj-$(CONFIG_SUSPEND) += pm.o sleep.o obj-$(CONFIG_SIRF_IRQ) += irq.o obj-$(CONFIG_SMP) += platsmp.o headsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o -obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o -obj-$(CONFIG_ARCH_MARCO) += timer-marco.o diff --git a/arch/arm/mach-prima2/common.c b/arch/arm/mach-prima2/common.c index 15c14df..944d8ca 100644 --- a/arch/arm/mach-prima2/common.c +++ b/arch/arm/mach-prima2/common.c @@ -6,6 +6,7 @@ * Licensed under GPLv2 or later. */ +#include #include #include #include @@ -31,6 +32,13 @@ void __init sirfsoc_init_late(void) sirfsoc_pm_init(); } +static __init void sirfsoc_init_time(void) +{ + /* initialize clocking early, we want to set the OS timer */ + sirfsoc_of_clk_init(); + clocksource_of_init(); +} + static __init void sirfsoc_map_io(void) { sirfsoc_map_lluart(); @@ -47,7 +55,7 @@ DT_MACHINE_START(ATLAS6_DT, "Generic ATLAS6 (Flattened Device Tree)") /* Maintainer: Barry Song */ .map_io = sirfsoc_map_io, .init_irq = irqchip_init, - .init_time = sirfsoc_prima2_timer_init, + .init_time = sirfsoc_init_time, .init_machine = sirfsoc_mach_init, .init_late = sirfsoc_init_late, .dt_compat = atlas6_dt_match, @@ -65,7 +73,7 @@ DT_MACHINE_START(PRIMA2_DT, "Generic PRIMA2 (Flattened Device Tree)") /* Maintainer: Barry Song */ .map_io = sirfsoc_map_io, .init_irq = irqchip_init, - .init_time = sirfsoc_prima2_timer_init, + .init_time = sirfsoc_init_time, .dma_zone_size = SZ_256M, .init_machine = sirfsoc_mach_init, .init_late = sirfsoc_init_late, @@ -85,7 +93,7 @@ DT_MACHINE_START(MARCO_DT, "Generic MARCO (Flattened Device Tree)") .smp = smp_ops(sirfsoc_smp_ops), .map_io = sirfsoc_map_io, .init_irq = irqchip_init, - .init_time = sirfsoc_marco_timer_init, + .init_time = sirfsoc_init_time, .init_machine = sirfsoc_mach_init, .init_late = sirfsoc_init_late, .dt_compat = marco_dt_match, diff --git a/arch/arm/mach-prima2/common.h b/arch/arm/mach-prima2/common.h index b7c26b6..54262cf 100644 --- a/arch/arm/mach-prima2/common.h +++ b/arch/arm/mach-prima2/common.h @@ -13,9 +13,6 @@ #include #include -extern void sirfsoc_prima2_timer_init(void); -extern void sirfsoc_marco_timer_init(void); - extern struct smp_operations sirfsoc_smp_ops; extern void sirfsoc_secondary_startup(void); extern void sirfsoc_cpu_die(unsigned int cpu); diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 4d8283a..5e2176f 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -16,6 +16,8 @@ obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o +obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUNXI_TIMER) += sunxi_timer.o obj-$(CONFIG_ARCH_TEGRA) += tegra20_timer.o obj-$(CONFIG_VT8500_TIMER) += vt8500_timer.o diff --git a/arch/arm/mach-prima2/timer-marco.c b/drivers/clocksource/timer-marco.c similarity index 94% rename from arch/arm/mach-prima2/timer-marco.c rename to drivers/clocksource/timer-marco.c index f4eea2e..97738db 100644 --- a/arch/arm/mach-prima2/timer-marco.c +++ b/drivers/clocksource/timer-marco.c @@ -21,8 +21,6 @@ #include #include -#include "common.h" - #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 #define SIRFSOC_TIMER_MATCH_0 0x0018 @@ -53,7 +51,6 @@ static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; static void __iomem *sirfsoc_timer_base; -static void __init sirfsoc_of_timer_map(void); /* disable count and interrupt */ static inline void sirfsoc_timer_count_disable(int idx) @@ -242,15 +239,12 @@ static void __init sirfsoc_clockevent_init(void) } /* initialize the kernel jiffy timer source */ -void __init sirfsoc_marco_timer_init(void) +static void __init sirfsoc_marco_timer_init(void) { unsigned long rate; u32 timer_div; struct clk *clk; - /* initialize clocking early, we want to set the OS timer */ - sirfsoc_of_clk_init(); - /* timer's input clock is io clock */ clk = clk_get_sys("io", NULL); @@ -260,8 +254,6 @@ void __init sirfsoc_marco_timer_init(void) BUG_ON(rate < CLOCK_TICK_RATE); BUG_ON(rate % CLOCK_TICK_RATE); - sirfsoc_of_timer_map(); - /* Initialize the timer dividers */ timer_div = rate / CLOCK_TICK_RATE - 1; writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); @@ -286,18 +278,8 @@ void __init sirfsoc_marco_timer_init(void) sirfsoc_clockevent_init(); } -static struct of_device_id timer_ids[] = { - { .compatible = "sirf,marco-tick" }, - {}, -}; - -static void __init sirfsoc_of_timer_map(void) +static void __init sirfsoc_of_timer_init(struct device_node *np) { - struct device_node *np; - - np = of_find_matching_node(NULL, timer_ids); - if (!np) - return; sirfsoc_timer_base = of_iomap(np, 0); if (!sirfsoc_timer_base) panic("unable to map timer cpu registers\n"); @@ -312,5 +294,6 @@ static void __init sirfsoc_of_timer_map(void) panic("No irq passed for timer1 via DT\n"); #endif - of_node_put(np); + sirfsoc_marco_timer_init(); } +CLOCKSOURCE_OF_DECLARE(sirfsoc_marco_timer, "sirf,marco-tick", sirfsoc_of_timer_init ); diff --git a/arch/arm/mach-prima2/timer-prima2.c b/drivers/clocksource/timer-prima2.c similarity index 92% rename from arch/arm/mach-prima2/timer-prima2.c rename to drivers/clocksource/timer-prima2.c index 9829083..7608826 100644 --- a/arch/arm/mach-prima2/timer-prima2.c +++ b/drivers/clocksource/timer-prima2.c @@ -18,12 +18,9 @@ #include #include #include -#include #include #include -#include "common.h" - #define SIRFSOC_TIMER_COUNTER_LO 0x0000 #define SIRFSOC_TIMER_COUNTER_HI 0x0004 #define SIRFSOC_TIMER_MATCH_0 0x0008 @@ -56,7 +53,6 @@ static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; static void __iomem *sirfsoc_timer_base; -static void __init sirfsoc_of_timer_map(void); /* timer0 interrupt handler */ static irqreturn_t sirfsoc_timer_interrupt(int irq, void *dev_id) @@ -182,14 +178,11 @@ static void __init sirfsoc_clockevent_init(void) } /* initialize the kernel jiffy timer source */ -void __init sirfsoc_prima2_timer_init(void) +static void __init sirfsoc_prima2_timer_init(struct device_node *np) { unsigned long rate; struct clk *clk; - /* initialize clocking early, we want to set the OS timer */ - sirfsoc_of_clk_init(); - /* timer's input clock is io clock */ clk = clk_get_sys("io", NULL); @@ -200,7 +193,11 @@ void __init sirfsoc_prima2_timer_init(void) BUG_ON(rate < CLOCK_TICK_RATE); BUG_ON(rate % CLOCK_TICK_RATE); - sirfsoc_of_timer_map(); + sirfsoc_timer_base = of_iomap(np, 0); + if (!sirfsoc_timer_base) + panic("unable to map timer cpu registers\n"); + + sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); writel_relaxed(rate / CLOCK_TICK_RATE / 2 - 1, sirfsoc_timer_base + SIRFSOC_TIMER_DIV); writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO); @@ -215,25 +212,4 @@ void __init sirfsoc_prima2_timer_init(void) sirfsoc_clockevent_init(); } - -static struct of_device_id timer_ids[] = { - { .compatible = "sirf,prima2-tick" }, - {}, -}; - -static void __init sirfsoc_of_timer_map(void) -{ - struct device_node *np; - - np = of_find_matching_node(NULL, timer_ids); - if (!np) - return; - sirfsoc_timer_base = of_iomap(np, 0); - if (!sirfsoc_timer_base) - panic("unable to map timer cpu registers\n"); - - /* Get the interrupts property */ - sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); - - of_node_put(np); -} +CLOCKSOURCE_OF_DECLARE(sirfsoc_prima2_timer, "sirf,prima2-tick", sirfsoc_prima2_timer_init);