From patchwork Tue Mar 17 08:32:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Walmsley X-Patchwork-Id: 6027921 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A9E79F2A9 for ; Tue, 17 Mar 2015 08:45:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A38920459 for ; Tue, 17 Mar 2015 08:45:20 +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 A5A482014A for ; Tue, 17 Mar 2015 08:45:19 +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 1YXn5r-0003y7-M7; Tue, 17 Mar 2015 08:43:19 +0000 Received: from utopia.booyaka.com ([74.50.51.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YXn4c-00035T-Oe for linux-arm-kernel@lists.infradead.org; Tue, 17 Mar 2015 08:42:06 +0000 Received: (qmail 15766 invoked by uid 1019); 17 Mar 2015 08:41:39 -0000 MBOX-Line: From nobody Tue Mar 17 01:32:21 2015 Subject: [PATCHv2 2/3] amba: tegra-ahb: use correct base address for future chip support From: Paul Walmsley To: linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Tue, 17 Mar 2015 01:32:21 -0700 Message-ID: <20150317083221.32662.7448.stgit@baseline> In-Reply-To: <20150317083221.32662.14647.stgit@baseline> References: <20150317083221.32662.14647.stgit@baseline> User-Agent: StGit/0.17.1-4-g4a0c1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150317_014203_006099_C0FA2801 X-CRM114-Status: GOOD ( 13.52 ) X-Spam-Score: -0.0 (/) Cc: Alexandre Courbot , Russell King , Stephen Warren , linux-kernel@vger.kernel.org, Thierry Reding , Paul Walmsley , Hiroshi DOYU 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 a hardware SoC integration point of view, the starting address of this IP block in our existing DT files is off by 4 bytes from the actual base address. Since we attempt to make old DT files forward-compatible with newer kernels, we cannot fix the IP block base address in old DT data. However, we can fix this for DT files for newer chips that have not yet been added to the kernel. This patch defines a new DT 'compatible' string that doesn't require the 4 byte variance from the hardware integration data. SoC DT data for future Tegra chips should use this new 'compatible' string and the correct Tegra AHB base address. Signed-off-by: Paul Walmsley Cc: Paul Walmsley Cc: Alexandre Courbot Cc: Hiroshi DOYU Cc: Russell King Cc: Stephen Warren Cc: Thierry Reding Cc: linux-kernel@vger.kernel.org --- drivers/amba/tegra-ahb.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c index 30759a5..eac6934 100644 --- a/drivers/amba/tegra-ahb.c +++ b/drivers/amba/tegra-ahb.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -120,16 +121,17 @@ struct tegra_ahb { void __iomem *regs; struct device *dev; u32 ctx[0]; + short offset; }; static inline u32 gizmo_readl(struct tegra_ahb *ahb, u32 offset) { - return readl(ahb->regs - 4 + offset); + return readl(ahb->regs + ahb->offset + offset); } static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset) { - writel(value, ahb->regs - 4 + offset); + writel(value, ahb->regs + ahb->offset + offset); } #ifdef CONFIG_TEGRA_IOMMU_SMMU @@ -246,11 +248,30 @@ static void tegra_ahb_gizmo_init(struct tegra_ahb *ahb) gizmo_writel(ahb, val, AHB_MEM_PREFETCH_CFG4); } +struct ahb_data { + short offset; +}; + +static const struct ahb_data correct_offset; +static const struct ahb_data broken_offset = { + .offset = -4, +}; + +static const struct of_device_id tegra_ahb_of_match[] = { + { .compatible = "nvidia,tegra132-ahb", .data = &correct_offset }, + { .compatible = "nvidia,tegra30-ahb", .data = &broken_offset }, + { .compatible = "nvidia,tegra20-ahb", .data = &broken_offset }, + {}, +}; + static int tegra_ahb_probe(struct platform_device *pdev) { struct resource *res; struct tegra_ahb *ahb; size_t bytes; + const struct of_device_id *of_id = + of_match_device(tegra_ahb_of_match, &pdev->dev); + const struct ahb_data *ad; bytes = sizeof(*ahb) + sizeof(u32) * ARRAY_SIZE(tegra_ahb_gizmo); ahb = devm_kzalloc(&pdev->dev, bytes, GFP_KERNEL); @@ -262,18 +283,15 @@ static int tegra_ahb_probe(struct platform_device *pdev) if (IS_ERR(ahb->regs)) return PTR_ERR(ahb->regs); + ad = of_id->data; ahb->dev = &pdev->dev; + ahb->offset = ad->offset; + platform_set_drvdata(pdev, ahb); tegra_ahb_gizmo_init(ahb); return 0; } -static const struct of_device_id tegra_ahb_of_match[] = { - { .compatible = "nvidia,tegra30-ahb", }, - { .compatible = "nvidia,tegra20-ahb", }, - {}, -}; - static struct platform_driver tegra_ahb_driver = { .probe = tegra_ahb_probe, .driver = {