aboutsummaryrefslogtreecommitdiff
path: root/drivers/core/root.c
diff options
context:
space:
mode:
authorTom Rini2020-10-30 15:24:30 -0400
committerTom Rini2020-10-30 15:24:30 -0400
commit63d4607e03e5f1f7ab9a18bc640e31f7d28874b4 (patch)
treebdea1f28ad176fcd44f209bf943d25c8bddbe8d2 /drivers/core/root.c
parent096912b5fe9bb2fd90599d86a714001df6924198 (diff)
parent2424057b2ad0eacdd2d81e35e7bea5df97802b8f (diff)
Merge tag 'dm-pull-30oct20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
of-platdata and dtoc improvements sandbox SPL tests binman support for compressed sections
Diffstat (limited to 'drivers/core/root.c')
-rw-r--r--drivers/core/root.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 0726be6b795..5f10d7a39c7 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -50,7 +50,6 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
}
}
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
void fix_drivers(void)
{
struct driver *drv =
@@ -61,7 +60,7 @@ void fix_drivers(void)
for (entry = drv; entry != drv + n_ents; entry++) {
if (entry->of_match)
entry->of_match = (const struct udevice_id *)
- ((u32)entry->of_match + gd->reloc_off);
+ ((ulong)entry->of_match + gd->reloc_off);
if (entry->bind)
entry->bind += gd->reloc_off;
if (entry->probe)
@@ -129,8 +128,6 @@ void fix_devices(void)
}
}
-#endif
-
int dm_init(bool of_live)
{
int ret;
@@ -141,21 +138,19 @@ int dm_init(bool of_live)
}
INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
- fix_drivers();
- fix_uclass();
- fix_devices();
-#endif
+ if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
+ fix_drivers();
+ fix_uclass();
+ fix_devices();
+ }
ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
if (ret)
return ret;
#if CONFIG_IS_ENABLED(OF_CONTROL)
-# if CONFIG_IS_ENABLED(OF_LIVE)
- if (of_live)
- DM_ROOT_NON_CONST->node = np_to_ofnode(gd->of_root);
+ if (CONFIG_IS_ENABLED(OF_LIVE) && of_live)
+ DM_ROOT_NON_CONST->node = np_to_ofnode(gd_of_root());
else
-#endif
DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
#endif
ret = device_probe(DM_ROOT_NON_CONST);
@@ -187,6 +182,17 @@ int dm_scan_platdata(bool pre_reloc_only)
{
int ret;
+ if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
+ struct driver_rt *dyn;
+ int n_ents;
+
+ n_ents = ll_entry_count(struct driver_info, driver_info);
+ dyn = calloc(n_ents, sizeof(struct driver_rt));
+ if (!dyn)
+ return -ENOMEM;
+ gd_set_dm_driver_rt(dyn);
+ }
+
ret = lists_bind_drivers(DM_ROOT_NON_CONST, pre_reloc_only);
if (ret == -ENOENT) {
dm_warn("Some drivers were not found\n");
@@ -196,7 +202,7 @@ int dm_scan_platdata(bool pre_reloc_only)
return ret;
}
-#if CONFIG_IS_ENABLED(OF_LIVE)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
static int dm_scan_fdt_live(struct udevice *parent,
const struct device_node *node_parent,
bool pre_reloc_only)
@@ -223,9 +229,7 @@ static int dm_scan_fdt_live(struct udevice *parent,
return ret;
}
-#endif /* CONFIG_IS_ENABLED(OF_LIVE) */
-#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
/**
* dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
*
@@ -272,24 +276,20 @@ int dm_scan_fdt_dev(struct udevice *dev)
if (!dev_of_valid(dev))
return 0;
-#if CONFIG_IS_ENABLED(OF_LIVE)
if (of_live_active())
return dm_scan_fdt_live(dev, dev_np(dev),
gd->flags & GD_FLG_RELOC ? false : true);
- else
-#endif
+
return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev),
gd->flags & GD_FLG_RELOC ? false : true);
}
int dm_scan_fdt(const void *blob, bool pre_reloc_only)
{
-#if CONFIG_IS_ENABLED(OF_LIVE)
if (of_live_active())
- return dm_scan_fdt_live(gd->dm_root, gd->of_root,
+ return dm_scan_fdt_live(gd->dm_root, gd_of_root(),
pre_reloc_only);
- else
-#endif
+
return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
}
@@ -302,10 +302,9 @@ static int dm_scan_fdt_ofnode_path(const void *blob, const char *path,
if (!ofnode_valid(node))
return 0;
-#if CONFIG_IS_ENABLED(OF_LIVE)
if (of_live_active())
return dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only);
-#endif
+
return dm_scan_fdt_node(gd->dm_root, blob, node.of_offset,
pre_reloc_only);
}
@@ -348,11 +347,10 @@ int dm_init_and_scan(bool pre_reloc_only)
{
int ret;
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
- dm_populate_phandle_data();
-#endif
+ if (CONFIG_IS_ENABLED(OF_PLATDATA))
+ dm_populate_phandle_data();
- ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE));
+ ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
if (ret) {
debug("dm_init() failed: %d\n", ret);
return ret;