From patchwork Wed Jun 11 11:58:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 4335981 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 297549F314 for ; Wed, 11 Jun 2014 12:03:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5AD420256 for ; Wed, 11 Jun 2014 12:03:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B6D2F2022A for ; Wed, 11 Jun 2014 12:03:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WuhDq-0003Zi-GC; Wed, 11 Jun 2014 12:01:42 +0000 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WuhDj-0003US-Tv for linux-arm-kernel@lists.infradead.org; Wed, 11 Jun 2014 12:01:39 +0000 Received: by mail-we0-f176.google.com with SMTP id u56so4553439wes.35 for ; Wed, 11 Jun 2014 05:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BEbqW4dvK+oArC5v0IXScK9W6eAFxzAzDHlfPlKQ4Bo=; b=cRO5d6I4jj2woPLxqh0bSAMHq39paBmvT/RuWYDxtpmKg4I/8QcCeMJHKk4Mz8ditm w6mMSq9/jZStN1ONYgjvUuSPihIrQO1wXtIMFgPYikljnX1hJd3kPCPtCDWSKi4le+yf tIzqH/NTvE+G11LIW4D9626VSWkZ05hKg/k7fCByS6J+jykhKweSFyO6gBXCYUTHIQMw HM3QQC5QFcBN9s8K5O4p1PL47s2YHAMmIrb+NG791EJWeVyufExSSWd10xP8Z/iBu5uY 5U8sQ5H5dfvr7tXcdTcizuZCLtloz5A3qOJt3w/9UBj33kNnLMHZRhZbHTu+NgII27La Bxeg== X-Received: by 10.194.77.39 with SMTP id p7mr4126656wjw.85.1402488072901; Wed, 11 Jun 2014 05:01:12 -0700 (PDT) Received: from localhost (port-92861.pppoe.wtnet.de. [84.46.75.57]) by mx.google.com with ESMTPSA id cj5sm11533137wib.0.2014.06.11.05.01.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 05:01:12 -0700 (PDT) From: Thierry Reding To: Stephen Warren Subject: [PATCH 2/2] ARM: tegra: Initialize flow controller from DT Date: Wed, 11 Jun 2014 13:58:11 +0200 Message-Id: <1402487891-6493-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1402487891-6493-1-git-send-email-thierry.reding@gmail.com> References: <1402487891-6493-1-git-send-email-thierry.reding@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140611_050136_123020_2561919F X-CRM114-Status: GOOD ( 17.34 ) X-Spam-Score: -0.8 (/) Cc: linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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: Thierry Reding Use a matching device tree node to initialize the flow controller driver instead of hard-coding the I/O address. This is necessary to get rid of the iomap.h include, which in turn make it easier to share this code with 64-bit Tegra SoCs. Signed-off-by: Thierry Reding --- Note that this doesn't provide a fallback option for compatibility with old device trees. Any kind of fallback would require either the iomap.h file to remain included or copying out some parts verbatim, which to a large degree defies the whole purpose of this patch. The ultimate goal is to move this code into drivers/soc/tegra in order to allow sharing between 32- and 64-bit Tegra SoCs. If we absolutely must have backwards compatibility with device trees that don't have the flow controller node and still want to share this code with ARM64, I don't see any other way than moving iomap.h to drivers/soc/tegra along with all the other code. arch/arm/mach-tegra/flowctrl.c | 36 +++++++++++++++++++++++++++--------- arch/arm/mach-tegra/flowctrl.h | 2 ++ arch/arm/mach-tegra/tegra.c | 2 ++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-tegra/flowctrl.c b/arch/arm/mach-tegra/flowctrl.c index ce8ab8abf061..5f84320a91d4 100644 --- a/arch/arm/mach-tegra/flowctrl.c +++ b/arch/arm/mach-tegra/flowctrl.c @@ -18,13 +18,14 @@ * along with this program. If not, see . */ +#include #include -#include #include -#include +#include +#include +#include #include "flowctrl.h" -#include "iomap.h" #include "fuse.h" static u8 flowctrl_offset_halt_cpu[] = { @@ -41,23 +42,22 @@ static u8 flowctrl_offset_cpu_csr[] = { FLOW_CTRL_CPU1_CSR + 16, }; +static void __iomem *tegra_flowctrl_base; + static void flowctrl_update(u8 offset, u32 value) { - void __iomem *addr = IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + offset; - - writel(value, addr); + writel(value, tegra_flowctrl_base + offset); /* ensure the update has reached the flow controller */ wmb(); - readl_relaxed(addr); + readl_relaxed(tegra_flowctrl_base + offset); } u32 flowctrl_read_cpu_csr(unsigned int cpuid) { u8 offset = flowctrl_offset_cpu_csr[cpuid]; - void __iomem *addr = IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + offset; - return readl(addr); + return readl(tegra_flowctrl_base + offset); } void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value) @@ -138,3 +138,21 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid) reg |= FLOW_CTRL_CSR_EVENT_FLAG; /* clear event */ flowctrl_write_cpu_csr(cpuid, reg); } + +static const struct of_device_id matches[] __initconst = { + { .compatible = "nvidia,tegra124-flowctrl" }, + { .compatible = "nvidia,tegra114-flowctrl" }, + { .compatible = "nvidia,tegra30-flowctrl" }, + { .compatible = "nvidia,tegra20-flowctrl" }, + { } +}; + +void __init tegra_flowctrl_init(void) +{ + struct device_node *np; + + np = of_find_matching_node(NULL, matches); + BUG_ON(!np); + + tegra_flowctrl_base = of_iomap(np, 0); +} diff --git a/arch/arm/mach-tegra/flowctrl.h b/arch/arm/mach-tegra/flowctrl.h index c89aac60a143..73a9c5016c1a 100644 --- a/arch/arm/mach-tegra/flowctrl.h +++ b/arch/arm/mach-tegra/flowctrl.h @@ -59,6 +59,8 @@ void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value); void flowctrl_cpu_suspend_enter(unsigned int cpuid); void flowctrl_cpu_suspend_exit(unsigned int cpuid); + +void tegra_flowctrl_init(void); #endif #endif diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 972fc87ec185..d008adf558b8 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -46,6 +46,7 @@ #include "board.h" #include "common.h" #include "cpuidle.h" +#include "flowctrl.h" #include "fuse.h" #include "iomap.h" #include "irq.h" @@ -80,6 +81,7 @@ static void __init tegra_init_early(void) tegra_cpu_reset_handler_init(); tegra_powergate_init(); tegra_hotplug_init(); + tegra_flowctrl_init(); } static void __init tegra_dt_init_irq(void)