From patchwork Fri Nov 27 10:22:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 549370 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 07F4E140306 for ; Fri, 27 Nov 2015 21:22:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 61B414B8F7; Fri, 27 Nov 2015 11:22:38 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JxiFqP9OXHVF; Fri, 27 Nov 2015 11:22:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D57304B8F3; Fri, 27 Nov 2015 11:22:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B133F4B8F3 for ; Fri, 27 Nov 2015 11:22:33 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MUKmZ5BeNNBi for ; Fri, 27 Nov 2015 11:22:33 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo4-p05-ob.smtp.rzone.de (mo4-p05-ob.smtp.rzone.de [81.169.146.181]) by theia.denx.de (Postfix) with ESMTPS id 738244B8F1 for ; Fri, 27 Nov 2015 11:22:29 +0100 (CET) X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohfvxEndrDXKjzPMsB3oimjD61I4fPQhgcz213 X-RZG-CLASS-ID: mo05 Received: from stefan-work.domain_not_set.invalid (b9168f50.cgn.dg-w.de [185.22.143.80]) by post.strato.de (RZmta 37.14 AUTH) with ESMTPA id z03c67rARAMS5Ge; Fri, 27 Nov 2015 11:22:28 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Date: Fri, 27 Nov 2015 11:22:28 +0100 Message-Id: <1448619748-26759-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 2.6.3 Cc: Luka Perkov Subject: [U-Boot] [PATCH] dm: core: Add platform specific bus translation function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds the additional platform_translate_address() call to dev_get_addr(). A weak default with a 1-to-1 translation is also provided. Platforms that need a special address translation can overwrite this function. Here the explanation, why this is needed for MVEBU: When using DM with DT address translation, this does not work with the standard fdt_translate_address() function on MVEBU in SPL. Since the DT translates to the 0xf100.0000 base address for the internal registers. But SPL still has the registers mapped to the 0xd000.0000 (SOC_REGS_PHY_BASE) address that is used by the BootROM. This is because SPL may return to the BootROM for boot continuation (e.g. UART xmodem boot mode). Signed-off-by: Stefan Roese Cc: Simon Glass Cc: Luka Perkov Cc: Dirk Eibach --- drivers/core/device.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 758f390..27c4288 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -581,6 +581,12 @@ const char *dev_get_uclass_name(struct udevice *dev) return dev->uclass->uc_drv->name; } +__weak fdt_addr_t platform_translate_address(void *blob, int node_offset, + fdt_addr_t addr) +{ + return addr; +} + fdt_addr_t dev_get_addr(struct udevice *dev) { #if CONFIG_IS_ENABLED(OF_CONTROL) @@ -597,22 +603,30 @@ fdt_addr_t dev_get_addr(struct udevice *dev) * Use the full-fledged translate function for complex * bus setups. */ - return fdt_translate_address((void *)gd->fdt_blob, + addr = fdt_translate_address((void *)gd->fdt_blob, dev->of_offset, reg); + } else { + /* + * Use the "simple" translate function for less complex + * bus setups. + */ + addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, + dev->parent->of_offset, + dev->of_offset, "reg", + 0, NULL); + if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) { + if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS) + addr = simple_bus_translate(dev->parent, addr); + } } /* - * Use the "simple" translate function for less complex - * bus setups. + * Some platforms need a special address translation. Those + * platforms (e.g. mvebu in SPL) can provide a platform specific + * translation function which is called now. */ - addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, - dev->parent->of_offset, - dev->of_offset, "reg", - 0, NULL); - if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) { - if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS) - addr = simple_bus_translate(dev->parent, addr); - } + addr = platform_translate_address((void *)gd->fdt_blob, + dev->of_offset, addr); return addr; #else