From patchwork Tue Aug 20 21:27:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 2847344 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 993B09F239 for ; Tue, 20 Aug 2013 21:28:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9757820445 for ; Tue, 20 Aug 2013 21:28:23 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 673D62042C for ; Tue, 20 Aug 2013 21:28:22 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBtTP-0002Iy-Qo; Tue, 20 Aug 2013 21:28:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBtTN-00006R-FT; Tue, 20 Aug 2013 21:28:17 +0000 Received: from avon.wwwdotorg.org ([2001:470:1f0f:bd7::2]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBtTJ-0008W9-Fo for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2013 21:28:14 +0000 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 7AF6C6351; Tue, 20 Aug 2013 15:27:52 -0600 (MDT) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id E5CE2E461B; Tue, 20 Aug 2013 15:27:50 -0600 (MDT) From: Stephen Warren To: Sebastian Hesselbarth Subject: [PATCH] ARM: tegra: split tegra_pmc_init() in two Date: Tue, 20 Aug 2013 15:27:45 -0600 Message-Id: <1377034065-26373-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.8 at avon.wwwdotorg.org X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130820_172813_674314_5B87450B X-CRM114-Status: GOOD ( 17.48 ) X-Spam-Score: -4.7 (----) Cc: linux-tegra@vger.kernel.org, Peter De Schrijver , Stephen Warren , linux-arm-kernel@lists.infradead.org, Joseph Lo 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 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Stephen Warren Tegra's board file currently initializes clocks much earlier than those for most other ARM SoCs. The reason is: * The PMC HW block is involved in the path of some interrupts (i.e. it inverts, or not, the IRQ input pin dedicated to the PMIC). * So, that part of the PMC must be initialized early so that the IRQ polarity is correct. * The PMC initialization is currently monolithic, and the PMC has some clock inputs, so the init routine ends up calling of_clk_get_by_name(), and hence clocks must be set up early too. In order to defer clock initialization to the more typical location, split out the portions of tegra_pmc_init() that are truly IRQ-related into a separate tegra_pmc_init_irq(), which can be called from the machine descriptor's .init_irq() function, and defer the rest until the machine descriptor's .init_machine() function. This allows the clock initiliazation to happen from the machine descriptor's .init_time() function, as is typical. Signed-off-by: Stephen Warren --- Sebastian, this should help with your of_clock_init() series. Feel free to include this patch in your series unless someone raises objections to it. It's based on next-20130819, but I think it should apply many other places without any issue, and certainly on top of wherever Tegra's for-3.12/soc branch got applies within the arm-soc git repo. If you want me to take it for 3.13, just let me know. arch/arm/mach-tegra/common.c | 4 +--- arch/arm/mach-tegra/pmc.c | 41 ++++++++++++++++++++++------------------- arch/arm/mach-tegra/pmc.h | 1 + arch/arm/mach-tegra/tegra.c | 12 +++++++++++- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c index 94a119a..58dc91c5 100644 --- a/arch/arm/mach-tegra/common.c +++ b/arch/arm/mach-tegra/common.c @@ -24,7 +24,6 @@ #include #include #include -#include #include @@ -61,8 +60,7 @@ u32 tegra_uart_config[4] = { #ifdef CONFIG_OF void __init tegra_dt_init_irq(void) { - of_clk_init(NULL); - tegra_pmc_init(); + tegra_pmc_init_irq(); tegra_init_irq(); irqchip_init(); tegra_legacy_irq_syscore_init(); diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c index 8acb881..7916ff9 100644 --- a/arch/arm/mach-tegra/pmc.c +++ b/arch/arm/mach-tegra/pmc.c @@ -285,13 +285,10 @@ static const struct of_device_id matches[] __initconst = { { } }; -static void __init tegra_pmc_parse_dt(void) +void __init tegra_pmc_init_irq(void) { struct device_node *np; - u32 prop; - enum tegra_suspend_mode suspend_mode; - u32 core_good_time[2] = {0, 0}; - u32 lp0_vec[2] = {0, 0}; + u32 val; np = of_find_matching_node(NULL, matches); BUG_ON(!np); @@ -300,6 +297,26 @@ static void __init tegra_pmc_parse_dt(void) tegra_pmc_invert_interrupt = of_property_read_bool(np, "nvidia,invert-interrupt"); + + val = tegra_pmc_readl(PMC_CTRL); + if (tegra_pmc_invert_interrupt) + val |= PMC_CTRL_INTR_LOW; + else + val &= ~PMC_CTRL_INTR_LOW; + tegra_pmc_writel(val, PMC_CTRL); +} + +void __init tegra_pmc_init(void) +{ + struct device_node *np; + u32 prop; + enum tegra_suspend_mode suspend_mode; + u32 core_good_time[2] = {0, 0}; + u32 lp0_vec[2] = {0, 0}; + + np = of_find_matching_node(NULL, matches); + BUG_ON(!np); + tegra_pclk = of_clk_get_by_name(np, "pclk"); WARN_ON(IS_ERR(tegra_pclk)); @@ -365,17 +382,3 @@ static void __init tegra_pmc_parse_dt(void) pmc_pm_data.suspend_mode = suspend_mode; } - -void __init tegra_pmc_init(void) -{ - u32 val; - - tegra_pmc_parse_dt(); - - val = tegra_pmc_readl(PMC_CTRL); - if (tegra_pmc_invert_interrupt) - val |= PMC_CTRL_INTR_LOW; - else - val &= ~PMC_CTRL_INTR_LOW; - tegra_pmc_writel(val, PMC_CTRL); -} diff --git a/arch/arm/mach-tegra/pmc.h b/arch/arm/mach-tegra/pmc.h index 549f8c7..4d5f8f3 100644 --- a/arch/arm/mach-tegra/pmc.h +++ b/arch/arm/mach-tegra/pmc.h @@ -39,6 +39,7 @@ bool tegra_pmc_cpu_is_powered(int cpuid); int tegra_pmc_cpu_power_on(int cpuid); int tegra_pmc_cpu_remove_clamping(int cpuid); +void tegra_pmc_init_irq(void); void tegra_pmc_init(void); #endif diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 5b86055..4da271d 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,7 @@ #include "common.h" #include "fuse.h" #include "iomap.h" +#include "pmc.h" static void __init tegra_dt_init(void) { @@ -51,6 +53,8 @@ static void __init tegra_dt_init(void) struct soc_device *soc_dev; struct device *parent = NULL; + tegra_pmc_init(); + tegra_clocks_apply_init_table(); soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); @@ -80,6 +84,12 @@ out: of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); } +static void __init tegra_dt_init_time(void) +{ + of_clk_init(NULL); + clocksource_of_init(); +} + static void __init paz00_init(void) { if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) @@ -119,7 +129,7 @@ DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") .smp = smp_ops(tegra_smp_ops), .init_early = tegra_init_early, .init_irq = tegra_dt_init_irq, - .init_time = clocksource_of_init, + .init_time = tegra_dt_init_time, .init_machine = tegra_dt_init, .init_late = tegra_dt_init_late, .restart = tegra_assert_system_reset,