summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c28
-rw-r--r--drivers/core/root.c6
-rw-r--r--drivers/core/simple-bus.c4
3 files changed, 31 insertions, 7 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index a7408d9c76..476133f172 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -248,10 +248,11 @@ int device_bind_ofnode(struct udevice *parent, const struct driver *drv,
}
int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
- const struct driver_info *info, struct udevice **devp)
+ struct driver_info *info, struct udevice **devp)
{
struct driver *drv;
uint platdata_size = 0;
+ int ret;
drv = lists_driver_lookup_name(info->name);
if (!drv)
@@ -262,9 +263,16 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
#if CONFIG_IS_ENABLED(OF_PLATDATA)
platdata_size = info->platdata_size;
#endif
- return device_bind_common(parent, drv, info->name,
- (void *)info->platdata, 0, ofnode_null(), platdata_size,
- devp);
+ ret = device_bind_common(parent, drv, info->name,
+ (void *)info->platdata, 0, ofnode_null(),
+ platdata_size, devp);
+ if (ret)
+ return ret;
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+ info->dev = *devp;
+#endif
+
+ return ret;
}
static void *alloc_priv(int size, uint flags)
@@ -729,6 +737,18 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)
return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
}
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+int device_get_by_driver_info(const struct driver_info *info,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+
+ dev = info->dev;
+
+ return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
+}
+#endif
+
int device_find_first_child(const struct udevice *parent, struct udevice **devp)
{
if (list_empty(&parent->child_head)) {
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 7d257ea887..0de5d7c70d 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -26,7 +26,7 @@
DECLARE_GLOBAL_DATA_PTR;
-static const struct driver_info root_info = {
+static struct driver_info root_info = {
.name = "root_driver",
};
@@ -347,6 +347,10 @@ int dm_init_and_scan(bool pre_reloc_only)
{
int ret;
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+ dm_populate_phandle_data();
+#endif
+
ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE));
if (ret) {
debug("dm_init() failed: %d\n", ret);
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index 7fc23ef82d..7cc1d46009 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -56,8 +56,8 @@ static const struct udevice_id generic_simple_bus_ids[] = {
{ }
};
-U_BOOT_DRIVER(simple_bus_drv) = {
- .name = "generic_simple_bus",
+U_BOOT_DRIVER(simple_bus) = {
+ .name = "simple_bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = generic_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,