[U-Boot] [PATCH] dm: core: Add platform specific bus translation function
Stefan Roese
sr at denx.de
Fri Nov 27 11:22:28 CET 2015
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 at denx.de>
Cc: Simon Glass <sjg at chromium.org>
Cc: Luka Perkov <luka.perkov at sartura.hr>
Cc: Dirk Eibach <dirk.eibach at 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
More information about the U-Boot
mailing list