summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 07:25:17 +0300
committerSimon Glass <sjg@chromium.org>2021-03-22 09:23:28 +0300
commit967a7d483ac5b9075d83c59507c8020636000842 (patch)
tree4381c72e1499da6b2cfccab735d790a2b43792f8
parent3fa9f553c0c0418b9abf93c2f33a44c98380beaf (diff)
downloadu-boot-967a7d483ac5b9075d83c59507c8020636000842.tar.xz
dm: core: Set up driver model for OF_PLATDATA_INST
With this we don't need to scan and bind drivers, not even the root device. We just need to locate the root device that was set up at build time, then set our root in global_data to point to it. Update the code to handle this case. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/root.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 3feadb77b5..3e52452cd8 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -129,6 +129,13 @@ void fix_devices(void)
}
}
+static int dm_setup_inst(void)
+{
+ DM_ROOT_NON_CONST = DM_DEVICE_GET(root);
+
+ return 0;
+}
+
int dm_init(bool of_live)
{
int ret;
@@ -153,14 +160,23 @@ int dm_init(bool of_live)
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))
- dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
- ret = device_probe(DM_ROOT_NON_CONST);
- if (ret)
- return ret;
+ if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+ ret = dm_setup_inst();
+ if (ret) {
+ log_debug("dm_setup_inst() failed: %d\n", ret);
+ return ret;
+ }
+ } else {
+ ret = device_bind_by_name(NULL, false, &root_info,
+ &DM_ROOT_NON_CONST);
+ if (ret)
+ return ret;
+ if (CONFIG_IS_ENABLED(OF_CONTROL))
+ dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
+ ret = device_probe(DM_ROOT_NON_CONST);
+ if (ret)
+ return ret;
+ }
return 0;
}
@@ -351,10 +367,12 @@ int dm_init_and_scan(bool pre_reloc_only)
debug("dm_init() failed: %d\n", ret);
return ret;
}
- ret = dm_scan(pre_reloc_only);
- if (ret) {
- log_debug("dm_scan() failed: %d\n", ret);
- return ret;
+ if (!CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+ ret = dm_scan(pre_reloc_only);
+ if (ret) {
+ log_debug("dm_scan() failed: %d\n", ret);
+ return ret;
+ }
}
return 0;