public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm: core: Add platform specific bus translation function
@ 2015-11-27 10:22 Stefan Roese
  2015-11-27 18:36 ` Simon Glass
  0 siblings, 1 reply; 23+ messages in thread
From: Stefan Roese @ 2015-11-27 10:22 UTC (permalink / raw)
  To: 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 <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
---
 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
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2015-12-11 13:30 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27 10:22 [U-Boot] [PATCH] dm: core: Add platform specific bus translation function Stefan Roese
2015-11-27 18:36 ` Simon Glass
2015-11-30  6:52   ` Stefan Roese
2015-11-30 23:17     ` Simon Glass
2015-12-01  6:05       ` Stefan Roese
2015-12-01 20:02         ` Simon Glass
2015-12-02 14:11           ` Stefan Roese
2015-12-02 14:49             ` Simon Glass
2015-12-02 15:24               ` Stefan Roese
2015-12-02 15:50                 ` Simon Glass
2015-12-02 16:00                   ` Stefan Roese
2015-12-02 16:53                     ` Simon Glass
2015-12-02 17:43                       ` Stefan Roese
2015-12-02 17:45                         ` Simon Glass
2015-12-03 11:31                           ` Stefan Roese
2015-12-03 17:21                             ` Simon Glass
2015-12-04  7:45                               ` Stefan Roese
2015-12-08  2:46                                 ` Simon Glass
2015-12-10  6:58                                   ` Stefan Roese
2015-12-10 15:36                                     ` Simon Glass
2015-12-11  4:45                                       ` Stefan Roese
2015-12-11  5:54                                         ` Stefan Roese
2015-12-11 13:30                                           ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox