From patchwork Tue Dec 11 01:18:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 1860691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 803B33FCA5 for ; Tue, 11 Dec 2012 01:22:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TiEUY-0005bP-W6; Tue, 11 Dec 2012 01:18:39 +0000 Received: from quartz.orcorp.ca ([184.70.90.242]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TiEUG-0005aD-Qs for linux-arm-kernel@lists.infradead.org; Tue, 11 Dec 2012 01:18:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=vIFcibbeegF4WxHgt1tyYU+T/SIx1u17tCZ7+1i5HXs=; b=Yn8EtjkH+MvuOjJYTUlrLDA0H1UfnPD5kcMGFOIy6LfJRur3hDZjr955KEG7Cd2yVAK6lguJhL7eQi9ZMQljRb+/c1dYhba0VyiIhKFXw+ZkIyinXKgywBfx42IWPboc7i9yLjd2HYXbQK9nTc0Dc9yVsr1lPSawItPDYtZH9IA=; Received: from [10.0.0.162] (helo=localhost.localdomain) by quartz.orcorp.ca with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1TiEU7-00017h-3Y; Mon, 10 Dec 2012 18:18:11 -0700 From: Jason Gunthorpe To: Sebastian Hesselbarth , Andrew Lunn , Thomas Petazzoni , Jason Cooper , Arnd Bergmann , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] ARM: Orion: Bind the orion timer through DT Date: Mon, 10 Dec 2012 18:18:03 -0700 Message-Id: <1355188683-18208-3-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1355188683-18208-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1355188683-18208-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.162 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121210_201821_083764_B722B57E X-CRM114-Status: GOOD ( 22.03 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Jason Gunthorpe X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This adds the common DT code and board support for kirkwood and dove - Add the marvell,orion-timer DT node to the DTSI file - Adjust the call paths for dove/kirkwood_timer_init so it only happens on non-dt - Eliminate redundant logging calls of kirkwood_tclk for simplicity. These days the tclk frequency is logged here: sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 21474ms - The DT stanza was choosen to simplify future merging with time-armada-370-xp.c Signed-off-by: Jason Gunthorpe --- arch/arm/boot/dts/dove.dtsi | 8 ++++++ arch/arm/boot/dts/kirkwood-dns320.dts | 3 ++ arch/arm/boot/dts/kirkwood-lschlv2.dts | 3 ++ arch/arm/boot/dts/kirkwood.dtsi | 9 ++++++ arch/arm/mach-dove/common.c | 30 +++++++++++----------- arch/arm/mach-kirkwood/board-dt.c | 10 ++++++- arch/arm/mach-kirkwood/common.c | 42 ++++++++++++++----------------- arch/arm/mach-kirkwood/common.h | 1 - arch/arm/plat-orion/include/plat/time.h | 1 + arch/arm/plat-orion/time.c | 32 +++++++++++++++++++++++ 10 files changed, 98 insertions(+), 41 deletions(-) diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi index b726ba8..da6539b 100644 --- a/arch/arm/boot/dts/dove.dtsi +++ b/arch/arm/boot/dts/dove.dtsi @@ -31,6 +31,14 @@ reg = <0x20204 0x04>, <0x20214 0x04>; }; + timer@20300 { + compatible = "marvell,orion-timer"; + reg = <0x20300 0x20>; + interrupt-parent = <&bridge_intc>; + interrupts = <1>, <2>; + clock-frequency = <166666667>; + }; + uart0: serial@12000 { compatible = "ns16550a"; reg = <0x12000 0x100>; diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts index 5bb0bf3..5bffd7c 100644 --- a/arch/arm/boot/dts/kirkwood-dns320.dts +++ b/arch/arm/boot/dts/kirkwood-dns320.dts @@ -41,6 +41,9 @@ }; ocp@f1000000 { + timer@20300 { + clock-frequency = <166666667>; + }; serial@12000 { clock-frequency = <166666667>; status = "okay"; diff --git a/arch/arm/boot/dts/kirkwood-lschlv2.dts b/arch/arm/boot/dts/kirkwood-lschlv2.dts index 9510c9e..3b68d92 100644 --- a/arch/arm/boot/dts/kirkwood-lschlv2.dts +++ b/arch/arm/boot/dts/kirkwood-lschlv2.dts @@ -12,6 +12,9 @@ }; ocp@f1000000 { + timer@20300 { + clock-frequency = <166666667>; + }; serial@12000 { clock-frequency = <166666667>; status = "okay"; diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi index 854e532..278f8ac 100644 --- a/arch/arm/boot/dts/kirkwood.dtsi +++ b/arch/arm/boot/dts/kirkwood.dtsi @@ -47,6 +47,15 @@ reg = <0x20110 0x08>; }; + timer@20300 { + compatible = "marvell,orion-timer"; + reg = <0x20300 0x20>; + interrupt-parent = <&bridge_intc>; + interrupts = <1>, <2>; + /* override clock-frequency in board dts */ + clock-frequency = <200000000>; + }; + serial@12000 { compatible = "ns16550a"; reg = <0x12000 0x100>; diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c index b570211..43062ea 100644 --- a/arch/arm/mach-dove/common.c +++ b/arch/arm/mach-dove/common.c @@ -62,7 +62,6 @@ void __init dove_map_io(void) /***************************************************************************** * CLK tree ****************************************************************************/ -static int dove_tclk; static DEFINE_SPINLOCK(gating_lock); static struct clk *tclk; @@ -75,6 +74,11 @@ static struct clk __init *dove_register_gate(const char *name, bit_idx, 0, &gating_lock); } +static int __init dove_find_tclk(void) +{ + return 166666667; +} + static void __init dove_clk_init(void) { struct clk *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1; @@ -82,7 +86,7 @@ static void __init dove_clk_init(void) struct clk *xor0, *xor1, *ge, *gephy; tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT, - dove_tclk); + dove_find_tclk()); usb0 = dove_register_gate("usb0", "tclk", CLOCK_GATING_BIT_USB0); usb1 = dove_register_gate("usb1", "tclk", CLOCK_GATING_BIT_USB1); @@ -232,18 +236,12 @@ void __init dove_i2c_init(void) ****************************************************************************/ void __init dove_init_early(void) { - orion_time_set_base(TIMER_VIRT_BASE); -} - -static int __init dove_find_tclk(void) -{ - return 166666667; } static void __init dove_timer_init(void) { - dove_tclk = dove_find_tclk(); - orion_time_init(IRQ_DOVE_BRIDGE_TIMER1, dove_tclk); + orion_time_set_base(TIMER_VIRT_BASE); + orion_time_init(IRQ_DOVE_BRIDGE_TIMER1, dove_find_tclk()); } struct sys_timer dove_timer = { @@ -340,8 +338,7 @@ void __init dove_sdio1_init(void) void __init dove_init(void) { - pr_info("Dove 88AP510 SoC, TCLK = %d MHz.\n", - (dove_tclk + 499999) / 1000000); + pr_info("Dove 88AP510 SoC\n"); #ifdef CONFIG_CACHE_TAUROS2 tauros2_init(0); @@ -395,8 +392,7 @@ static struct mv643xx_eth_platform_data dove_dt_ge00_data = { static void __init dove_dt_init(void) { - pr_info("Dove 88AP510 SoC, TCLK = %d MHz.\n", - (dove_tclk + 499999) / 1000000); + pr_info("Dove 88AP510 SoC\n"); #ifdef CONFIG_CACHE_TAUROS2 tauros2_init(0); @@ -425,11 +421,15 @@ static const char * const dove_dt_board_compat[] = { NULL }; +static struct sys_timer dove_dt_timer = { + .init = orion_time_init_dt, +}; + DT_MACHINE_START(DOVE_DT, "Marvell Dove (Flattened Device Tree)") .map_io = dove_map_io, .init_early = dove_init_early, .init_irq = orion_dt_init_irq, - .timer = &dove_timer, + .timer = &dove_dt_timer, .init_machine = dove_dt_init, .restart = dove_restart, .dt_compat = dove_dt_board_compat, diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index ecbb26f..c49146c 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c @@ -17,8 +17,10 @@ #include #include #include +#include #include #include +#include #include "common.h" static struct of_device_id kirkwood_dt_match_table[] __initdata = { @@ -41,7 +43,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = { static void __init kirkwood_dt_init(void) { - pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk); + pr_info("Kirkwood: %s\n", kirkwood_id()); /* * Disable propagation of mbus errors to the CPU local bus, @@ -115,12 +117,16 @@ static const char *kirkwood_dt_board_compat[] = { NULL }; +static struct sys_timer kirkwood_dt_timer = { + .init = orion_time_init_dt, +}; + DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)") /* Maintainer: Jason Cooper */ .map_io = kirkwood_map_io, .init_early = kirkwood_init_early, .init_irq = orion_dt_init_irq, - .timer = &kirkwood_timer, + .timer = &kirkwood_dt_timer, .init_machine = kirkwood_dt_init, .restart = kirkwood_restart, .dt_compat = kirkwood_dt_board_compat, diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c index 7398f8b..aeb0458 100644 --- a/arch/arm/mach-kirkwood/common.c +++ b/arch/arm/mach-kirkwood/common.c @@ -221,13 +221,28 @@ static struct clk __init *kirkwood_register_gate_fn(const char *name, static struct clk *ge0, *ge1; +/* FIXME: The tclk frequency is in the DT now, this should fetch it from + * there. */ +static int __init kirkwood_find_tclk(void) +{ + u32 dev, rev; + + kirkwood_pcie_id(&dev, &rev); + + if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID) + if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0) + return 200000000; + + return 166666667; +} + void __init kirkwood_clk_init(void) { struct clk *runit, *sata0, *sata1, *usb0, *sdio; struct clk *crypto, *xor0, *xor1, *pex0, *pex1, *audio; tclk = clk_register_fixed_rate(NULL, "tclk", NULL, - CLK_IS_ROOT, kirkwood_tclk); + CLK_IS_ROOT, kirkwood_find_tclk()); runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT); ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0); @@ -506,8 +521,6 @@ void __init kirkwood_wdt_init(void) ****************************************************************************/ void __init kirkwood_init_early(void) { - orion_time_set_base(TIMER_VIRT_BASE); - /* * Some Kirkwood devices allocate their coherent buffers from atomic * context. Increase size of atomic coherent pool to make sure such @@ -516,26 +529,10 @@ void __init kirkwood_init_early(void) init_dma_coherent_pool_size(SZ_1M); } -int kirkwood_tclk; - -static int __init kirkwood_find_tclk(void) -{ - u32 dev, rev; - - kirkwood_pcie_id(&dev, &rev); - - if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID) - if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0) - return 200000000; - - return 166666667; -} - static void __init kirkwood_timer_init(void) { - kirkwood_tclk = kirkwood_find_tclk(); - - orion_time_init(IRQ_KIRKWOOD_BRIDGE_TIMER1, kirkwood_tclk); + orion_time_set_base(TIMER_VIRT_BASE); + orion_time_init(IRQ_KIRKWOOD_BRIDGE_TIMER1, kirkwood_find_tclk()); } struct sys_timer kirkwood_timer = { @@ -647,8 +644,7 @@ void __init kirkwood_l2_init(void) void __init kirkwood_init(void) { - printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", - kirkwood_id(), kirkwood_tclk); + pr_info("Kirkwood: %s\n", kirkwood_id()); /* * Disable propagation of mbus errors to the CPU local bus, diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h index bcffd7c..a92fde9 100644 --- a/arch/arm/mach-kirkwood/common.h +++ b/arch/arm/mach-kirkwood/common.h @@ -120,7 +120,6 @@ void kirkwood_xor0_init(void); void kirkwood_xor1_init(void); void kirkwood_crypto_init(void); -extern int kirkwood_tclk; extern struct sys_timer kirkwood_timer; #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) diff --git a/arch/arm/plat-orion/include/plat/time.h b/arch/arm/plat-orion/include/plat/time.h index c5ccc0a..9a4b142 100644 --- a/arch/arm/plat-orion/include/plat/time.h +++ b/arch/arm/plat-orion/include/plat/time.h @@ -14,5 +14,6 @@ void orion_time_set_base(void __iomem *timer_base); void orion_time_init(unsigned int irq, unsigned int tclk); +void __init orion_time_init_dt(void); #endif diff --git a/arch/arm/plat-orion/time.c b/arch/arm/plat-orion/time.c index da22aa4..600e8ee 100644 --- a/arch/arm/plat-orion/time.c +++ b/arch/arm/plat-orion/time.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -199,3 +201,33 @@ orion_time_init(unsigned int irq, unsigned int tclk) orion_clkevt.cpumask = cpumask_of(0); clockevents_register_device(&orion_clkevt); } + +#ifdef CONFIG_OF +void __init +orion_time_init_dt(void) +{ + struct device_node *np; + int ret; + int irq; + u32 clk; + + np = of_find_compatible_node(NULL, NULL, "marvell,orion-timer"); + if (!np) + panic("Bad marvell,orion-timer DT block"); + + timer_base = of_iomap(np, 0); + if (!timer_base) + panic("Bad marvell,orion-timer DT block"); + + /* We use timer 0 as clocksource, and timer 1 for clockevents */ + irq = irq_of_parse_and_map(np, 1); + if (!irq) + panic("Bad marvell,orion-timer DT block"); + + ret = of_property_read_u32(np, "clock-frequency", &clk); + if (ret < 0 || clk == 0) + panic("Bad marvell,orion-timer DT block"); + + orion_time_init(irq, clk); +} +#endif