summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c31
-rw-r--r--drivers/core/root.c21
2 files changed, 41 insertions, 11 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 758f390..7a02a93 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -597,22 +597,31 @@ 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 configure a translation
+ * offset in the DM by calling dm_set_translation_offset() that
+ * will get added to all addresses returned by dev_get_addr().
*/
- 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 += dm_get_translation_offset();
return addr;
#else
diff --git a/drivers/core/root.c b/drivers/core/root.c
index e7b1f24..13c2713 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -23,6 +23,10 @@
DECLARE_GLOBAL_DATA_PTR;
+struct root_priv {
+ fdt_addr_t translation_offset; /* optional translation offset */
+};
+
static const struct driver_info root_info = {
.name = "root_driver",
};
@@ -37,6 +41,22 @@ struct udevice *dm_root(void)
return gd->dm_root;
}
+fdt_addr_t dm_get_translation_offset(void)
+{
+ struct udevice *root = dm_root();
+ struct root_priv *priv = dev_get_priv(root);
+
+ return priv->translation_offset;
+}
+
+void dm_set_translation_offset(fdt_addr_t offs)
+{
+ struct udevice *root = dm_root();
+ struct root_priv *priv = dev_get_priv(root);
+
+ priv->translation_offset = offs;
+}
+
#if defined(CONFIG_NEEDS_MANUAL_RELOC)
void fix_drivers(void)
{
@@ -228,6 +248,7 @@ int dm_init_and_scan(bool pre_reloc_only)
U_BOOT_DRIVER(root_driver) = {
.name = "root_driver",
.id = UCLASS_ROOT,
+ .priv_auto_alloc_size = sizeof(struct root_priv),
};
/* This is the root uclass */