Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 Google, Inc |
| 3 | * |
| 4 | * (C) Copyright 2012 |
| 5 | * Pavel Herrmann <morpheus.ibis@gmail.com> |
| 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <errno.h> |
Simon Glass | 528b1ef | 2015-01-25 08:27:16 -0700 | [diff] [blame] | 12 | #include <fdtdec.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 13 | #include <malloc.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 14 | #include <linux/libfdt.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 15 | #include <dm/device.h> |
| 16 | #include <dm/device-internal.h> |
| 17 | #include <dm/lists.h> |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 18 | #include <dm/of.h> |
| 19 | #include <dm/of_access.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 20 | #include <dm/platdata.h> |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 21 | #include <dm/read.h> |
Jeroen Hofstee | cf0cf82 | 2014-06-25 21:57:45 +0200 | [diff] [blame] | 22 | #include <dm/root.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 23 | #include <dm/uclass.h> |
| 24 | #include <dm/util.h> |
| 25 | #include <linux/list.h> |
| 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
Stefan Roese | a0ea0f9 | 2015-12-14 16:18:15 +0100 | [diff] [blame] | 29 | struct root_priv { |
| 30 | fdt_addr_t translation_offset; /* optional translation offset */ |
| 31 | }; |
| 32 | |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 33 | static const struct driver_info root_info = { |
| 34 | .name = "root_driver", |
| 35 | }; |
| 36 | |
Heiko Schocher | b74fcb4 | 2014-05-22 12:43:05 +0200 | [diff] [blame] | 37 | struct udevice *dm_root(void) |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 38 | { |
| 39 | if (!gd->dm_root) { |
| 40 | dm_warn("Virtual root driver does not exist!\n"); |
| 41 | return NULL; |
| 42 | } |
| 43 | |
| 44 | return gd->dm_root; |
| 45 | } |
| 46 | |
Simon Glass | 1b0deee | 2016-11-13 14:21:58 -0700 | [diff] [blame] | 47 | void dm_fixup_for_gd_move(struct global_data *new_gd) |
| 48 | { |
| 49 | /* The sentinel node has moved, so update things that point to it */ |
Lokesh Vutla | 02ba17f | 2017-02-13 09:21:22 +0530 | [diff] [blame] | 50 | if (gd->dm_root) { |
| 51 | new_gd->uclass_root.next->prev = &new_gd->uclass_root; |
| 52 | new_gd->uclass_root.prev->next = &new_gd->uclass_root; |
| 53 | } |
Simon Glass | 1b0deee | 2016-11-13 14:21:58 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Stefan Roese | a0ea0f9 | 2015-12-14 16:18:15 +0100 | [diff] [blame] | 56 | fdt_addr_t dm_get_translation_offset(void) |
| 57 | { |
| 58 | struct udevice *root = dm_root(); |
| 59 | struct root_priv *priv = dev_get_priv(root); |
| 60 | |
| 61 | return priv->translation_offset; |
| 62 | } |
| 63 | |
| 64 | void dm_set_translation_offset(fdt_addr_t offs) |
| 65 | { |
| 66 | struct udevice *root = dm_root(); |
| 67 | struct root_priv *priv = dev_get_priv(root); |
| 68 | |
| 69 | priv->translation_offset = offs; |
| 70 | } |
| 71 | |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 72 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) |
| 73 | void fix_drivers(void) |
| 74 | { |
| 75 | struct driver *drv = |
| 76 | ll_entry_start(struct driver, driver); |
| 77 | const int n_ents = ll_entry_count(struct driver, driver); |
| 78 | struct driver *entry; |
| 79 | |
| 80 | for (entry = drv; entry != drv + n_ents; entry++) { |
| 81 | if (entry->of_match) |
| 82 | entry->of_match = (const struct udevice_id *) |
| 83 | ((u32)entry->of_match + gd->reloc_off); |
| 84 | if (entry->bind) |
| 85 | entry->bind += gd->reloc_off; |
| 86 | if (entry->probe) |
| 87 | entry->probe += gd->reloc_off; |
| 88 | if (entry->remove) |
| 89 | entry->remove += gd->reloc_off; |
| 90 | if (entry->unbind) |
| 91 | entry->unbind += gd->reloc_off; |
| 92 | if (entry->ofdata_to_platdata) |
| 93 | entry->ofdata_to_platdata += gd->reloc_off; |
Michal Simek | 61809f5 | 2015-10-27 13:48:08 +0100 | [diff] [blame] | 94 | if (entry->child_post_bind) |
| 95 | entry->child_post_bind += gd->reloc_off; |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 96 | if (entry->child_pre_probe) |
| 97 | entry->child_pre_probe += gd->reloc_off; |
| 98 | if (entry->child_post_remove) |
| 99 | entry->child_post_remove += gd->reloc_off; |
| 100 | /* OPS are fixed in every uclass post_probe function */ |
| 101 | if (entry->ops) |
| 102 | entry->ops += gd->reloc_off; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | void fix_uclass(void) |
| 107 | { |
| 108 | struct uclass_driver *uclass = |
| 109 | ll_entry_start(struct uclass_driver, uclass); |
| 110 | const int n_ents = ll_entry_count(struct uclass_driver, uclass); |
| 111 | struct uclass_driver *entry; |
| 112 | |
| 113 | for (entry = uclass; entry != uclass + n_ents; entry++) { |
| 114 | if (entry->post_bind) |
| 115 | entry->post_bind += gd->reloc_off; |
| 116 | if (entry->pre_unbind) |
| 117 | entry->pre_unbind += gd->reloc_off; |
Michal Simek | 61809f5 | 2015-10-27 13:48:08 +0100 | [diff] [blame] | 118 | if (entry->pre_probe) |
| 119 | entry->pre_probe += gd->reloc_off; |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 120 | if (entry->post_probe) |
| 121 | entry->post_probe += gd->reloc_off; |
| 122 | if (entry->pre_remove) |
| 123 | entry->pre_remove += gd->reloc_off; |
Michal Simek | 61809f5 | 2015-10-27 13:48:08 +0100 | [diff] [blame] | 124 | if (entry->child_post_bind) |
| 125 | entry->child_post_bind += gd->reloc_off; |
| 126 | if (entry->child_pre_probe) |
| 127 | entry->child_pre_probe += gd->reloc_off; |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 128 | if (entry->init) |
| 129 | entry->init += gd->reloc_off; |
| 130 | if (entry->destroy) |
| 131 | entry->destroy += gd->reloc_off; |
| 132 | /* FIXME maybe also need to fix these ops */ |
| 133 | if (entry->ops) |
| 134 | entry->ops += gd->reloc_off; |
| 135 | } |
| 136 | } |
Angelo Dureghello | f4d193b | 2016-05-21 12:05:49 +0200 | [diff] [blame] | 137 | |
| 138 | void fix_devices(void) |
| 139 | { |
| 140 | struct driver_info *dev = |
| 141 | ll_entry_start(struct driver_info, driver_info); |
| 142 | const int n_ents = ll_entry_count(struct driver_info, driver_info); |
| 143 | struct driver_info *entry; |
| 144 | |
| 145 | for (entry = dev; entry != dev + n_ents; entry++) { |
| 146 | if (entry->platdata) |
| 147 | entry->platdata += gd->reloc_off; |
| 148 | } |
| 149 | } |
| 150 | |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 151 | #endif |
| 152 | |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 153 | int dm_init(bool of_live) |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 154 | { |
| 155 | int ret; |
| 156 | |
| 157 | if (gd->dm_root) { |
| 158 | dm_warn("Virtual root driver already exists!\n"); |
| 159 | return -EINVAL; |
| 160 | } |
Simon Glass | 34a1d35 | 2014-06-11 23:29:49 -0600 | [diff] [blame] | 161 | INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST); |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 162 | |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 163 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) |
| 164 | fix_drivers(); |
| 165 | fix_uclass(); |
Angelo Dureghello | f4d193b | 2016-05-21 12:05:49 +0200 | [diff] [blame] | 166 | fix_devices(); |
Michal Simek | 0ec473b | 2015-02-02 16:31:59 +0100 | [diff] [blame] | 167 | #endif |
| 168 | |
Simon Glass | fef72b7 | 2014-07-23 06:55:03 -0600 | [diff] [blame] | 169 | ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST); |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 170 | if (ret) |
| 171 | return ret; |
Masahiro Yamada | 366b24f | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 172 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 173 | # if CONFIG_IS_ENABLED(OF_LIVE) |
| 174 | if (of_live) |
| 175 | DM_ROOT_NON_CONST->node = np_to_ofnode(gd->of_root); |
| 176 | else |
| 177 | #endif |
| 178 | DM_ROOT_NON_CONST->node = offset_to_ofnode(0); |
Simon Glass | cc7cf94 | 2015-01-25 08:26:58 -0700 | [diff] [blame] | 179 | #endif |
Simon Glass | 6d3b3e2 | 2014-07-23 06:55:00 -0600 | [diff] [blame] | 180 | ret = device_probe(DM_ROOT_NON_CONST); |
| 181 | if (ret) |
| 182 | return ret; |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 183 | |
| 184 | return 0; |
| 185 | } |
| 186 | |
Simon Glass | 0019758 | 2014-07-23 06:55:01 -0600 | [diff] [blame] | 187 | int dm_uninit(void) |
| 188 | { |
Stefan Roese | 80b5bc9 | 2017-03-20 12:51:48 +0100 | [diff] [blame] | 189 | device_remove(dm_root(), DM_REMOVE_NORMAL); |
Simon Glass | 0019758 | 2014-07-23 06:55:01 -0600 | [diff] [blame] | 190 | device_unbind(dm_root()); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
Stefan Roese | 505045d | 2017-03-27 10:58:53 +0200 | [diff] [blame] | 195 | #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE) |
| 196 | int dm_remove_devices_flags(uint flags) |
| 197 | { |
| 198 | device_remove(dm_root(), flags); |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | #endif |
| 203 | |
Simon Glass | fef72b7 | 2014-07-23 06:55:03 -0600 | [diff] [blame] | 204 | int dm_scan_platdata(bool pre_reloc_only) |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 205 | { |
| 206 | int ret; |
| 207 | |
Simon Glass | fef72b7 | 2014-07-23 06:55:03 -0600 | [diff] [blame] | 208 | ret = lists_bind_drivers(DM_ROOT_NON_CONST, pre_reloc_only); |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 209 | if (ret == -ENOENT) { |
| 210 | dm_warn("Some drivers were not found\n"); |
| 211 | ret = 0; |
| 212 | } |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 213 | |
Masahiro Yamada | 6cac81a | 2014-11-17 17:19:38 +0900 | [diff] [blame] | 214 | return ret; |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 217 | #if CONFIG_IS_ENABLED(OF_LIVE) |
| 218 | static int dm_scan_fdt_live(struct udevice *parent, |
| 219 | const struct device_node *node_parent, |
| 220 | bool pre_reloc_only) |
| 221 | { |
| 222 | struct device_node *np; |
| 223 | int ret = 0, err; |
| 224 | |
| 225 | for (np = node_parent->child; np; np = np->sibling) { |
| 226 | if (pre_reloc_only && |
| 227 | !of_find_property(np, "u-boot,dm-pre-reloc", NULL)) |
| 228 | continue; |
| 229 | if (!of_device_is_available(np)) { |
Masahiro Yamada | f70f39f | 2017-09-29 12:31:20 +0900 | [diff] [blame] | 230 | pr_debug(" - ignoring disabled device\n"); |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 231 | continue; |
| 232 | } |
| 233 | err = lists_bind_fdt(parent, np_to_ofnode(np), NULL); |
| 234 | if (err && !ret) { |
| 235 | ret = err; |
| 236 | debug("%s: ret=%d\n", np->name, ret); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | if (ret) |
| 241 | dm_warn("Some drivers failed to bind\n"); |
| 242 | |
| 243 | return ret; |
| 244 | } |
| 245 | #endif /* CONFIG_IS_ENABLED(OF_LIVE) */ |
| 246 | |
Simon Glass | 8d7e816 | 2016-07-04 11:57:58 -0600 | [diff] [blame] | 247 | #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | a4dbe25 | 2017-05-17 17:18:08 -0600 | [diff] [blame] | 248 | /** |
| 249 | * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node |
| 250 | * |
| 251 | * This scans the subnodes of a device tree node and and creates a driver |
| 252 | * for each one. |
| 253 | * |
| 254 | * @parent: Parent device for the devices that will be created |
| 255 | * @blob: Pointer to device tree blob |
| 256 | * @offset: Offset of node to scan |
| 257 | * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC |
| 258 | * flag. If false bind all drivers. |
| 259 | * @return 0 if OK, -ve on error |
| 260 | */ |
| 261 | static int dm_scan_fdt_node(struct udevice *parent, const void *blob, |
| 262 | int offset, bool pre_reloc_only) |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 263 | { |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 264 | int ret = 0, err; |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 265 | |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 266 | for (offset = fdt_first_subnode(blob, offset); |
| 267 | offset > 0; |
| 268 | offset = fdt_next_subnode(blob, offset)) { |
Rob Clark | a471b67 | 2018-01-10 11:33:30 +0100 | [diff] [blame] | 269 | /* "chosen" node isn't a device itself but may contain some: */ |
| 270 | if (!strcmp(fdt_get_name(blob, offset, NULL), "chosen")) { |
| 271 | pr_debug("parsing subnodes of \"chosen\"\n"); |
| 272 | |
| 273 | err = dm_scan_fdt_node(parent, blob, offset, |
| 274 | pre_reloc_only); |
| 275 | if (err && !ret) |
| 276 | ret = err; |
| 277 | continue; |
| 278 | } |
| 279 | |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 280 | if (pre_reloc_only && |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 281 | !dm_fdt_pre_reloc(blob, offset)) |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 282 | continue; |
Simon Glass | 528b1ef | 2015-01-25 08:27:16 -0700 | [diff] [blame] | 283 | if (!fdtdec_get_is_enabled(blob, offset)) { |
Masahiro Yamada | f70f39f | 2017-09-29 12:31:20 +0900 | [diff] [blame] | 284 | pr_debug(" - ignoring disabled device\n"); |
Simon Glass | 528b1ef | 2015-01-25 08:27:16 -0700 | [diff] [blame] | 285 | continue; |
| 286 | } |
Simon Glass | 802b2c6 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 287 | err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL); |
Simon Glass | c90b917 | 2015-08-30 16:55:17 -0600 | [diff] [blame] | 288 | if (err && !ret) { |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 289 | ret = err; |
Simon Glass | c90b917 | 2015-08-30 16:55:17 -0600 | [diff] [blame] | 290 | debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL), |
| 291 | ret); |
| 292 | } |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 293 | } |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 294 | |
| 295 | if (ret) |
| 296 | dm_warn("Some drivers failed to bind\n"); |
| 297 | |
| 298 | return ret; |
| 299 | } |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 300 | |
Simon Glass | 5d5388d | 2016-07-05 17:10:08 -0600 | [diff] [blame] | 301 | int dm_scan_fdt_dev(struct udevice *dev) |
| 302 | { |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 303 | if (!dev_of_valid(dev)) |
Simon Glass | 5d5388d | 2016-07-05 17:10:08 -0600 | [diff] [blame] | 304 | return 0; |
| 305 | |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 306 | #if CONFIG_IS_ENABLED(OF_LIVE) |
| 307 | if (of_live_active()) |
| 308 | return dm_scan_fdt_live(dev, dev_np(dev), |
| 309 | gd->flags & GD_FLG_RELOC ? false : true); |
| 310 | else |
| 311 | #endif |
Simon Glass | dd79d6e | 2017-01-17 16:52:55 -0700 | [diff] [blame] | 312 | return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), |
Simon Glass | 5d5388d | 2016-07-05 17:10:08 -0600 | [diff] [blame] | 313 | gd->flags & GD_FLG_RELOC ? false : true); |
| 314 | } |
| 315 | |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 316 | int dm_scan_fdt(const void *blob, bool pre_reloc_only) |
| 317 | { |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 318 | #if CONFIG_IS_ENABLED(OF_LIVE) |
| 319 | if (of_live_active()) |
| 320 | return dm_scan_fdt_live(gd->dm_root, gd->of_root, |
| 321 | pre_reloc_only); |
| 322 | else |
| 323 | #endif |
Simon Glass | 4071742 | 2014-07-23 06:55:18 -0600 | [diff] [blame] | 324 | return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only); |
| 325 | } |
Patrice Chotard | bb3a45b | 2017-09-04 14:55:56 +0200 | [diff] [blame] | 326 | #else |
| 327 | static int dm_scan_fdt_node(struct udevice *parent, const void *blob, |
| 328 | int offset, bool pre_reloc_only) |
| 329 | { |
| 330 | return 0; |
| 331 | } |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 332 | #endif |
| 333 | |
Patrice Chotard | bb3a45b | 2017-09-04 14:55:56 +0200 | [diff] [blame] | 334 | int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) |
| 335 | { |
| 336 | int node, ret; |
| 337 | |
| 338 | ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only); |
| 339 | if (ret) { |
| 340 | debug("dm_scan_fdt() failed: %d\n", ret); |
| 341 | return ret; |
| 342 | } |
| 343 | |
| 344 | /* bind fixed-clock */ |
| 345 | node = ofnode_to_offset(ofnode_path("/clocks")); |
| 346 | /* if no DT "clocks" node, no need to go further */ |
| 347 | if (node < 0) |
| 348 | return ret; |
| 349 | |
| 350 | ret = dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node, |
| 351 | pre_reloc_only); |
| 352 | if (ret) |
| 353 | debug("dm_scan_fdt_node() failed: %d\n", ret); |
| 354 | |
| 355 | return ret; |
| 356 | } |
| 357 | |
Simon Glass | 97e22e3 | 2014-07-23 06:55:23 -0600 | [diff] [blame] | 358 | __weak int dm_scan_other(bool pre_reloc_only) |
| 359 | { |
| 360 | return 0; |
| 361 | } |
| 362 | |
Simon Glass | a730c5d | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 363 | int dm_init_and_scan(bool pre_reloc_only) |
| 364 | { |
| 365 | int ret; |
| 366 | |
Simon Glass | f19d9f2 | 2017-05-18 20:09:08 -0600 | [diff] [blame] | 367 | ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE)); |
Simon Glass | a730c5d | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 368 | if (ret) { |
| 369 | debug("dm_init() failed: %d\n", ret); |
| 370 | return ret; |
| 371 | } |
| 372 | ret = dm_scan_platdata(pre_reloc_only); |
| 373 | if (ret) { |
| 374 | debug("dm_scan_platdata() failed: %d\n", ret); |
| 375 | return ret; |
| 376 | } |
Simon Glass | 0704b85 | 2015-02-27 22:06:41 -0700 | [diff] [blame] | 377 | |
Simon Glass | 8d7e816 | 2016-07-04 11:57:58 -0600 | [diff] [blame] | 378 | if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { |
Patrice Chotard | bb3a45b | 2017-09-04 14:55:56 +0200 | [diff] [blame] | 379 | ret = dm_extended_scan_fdt(gd->fdt_blob, pre_reloc_only); |
Simon Glass | 0704b85 | 2015-02-27 22:06:41 -0700 | [diff] [blame] | 380 | if (ret) { |
Patrice Chotard | bb3a45b | 2017-09-04 14:55:56 +0200 | [diff] [blame] | 381 | debug("dm_extended_scan_dt() failed: %d\n", ret); |
Simon Glass | 0704b85 | 2015-02-27 22:06:41 -0700 | [diff] [blame] | 382 | return ret; |
| 383 | } |
Simon Glass | a730c5d | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 384 | } |
Simon Glass | 0704b85 | 2015-02-27 22:06:41 -0700 | [diff] [blame] | 385 | |
Simon Glass | 97e22e3 | 2014-07-23 06:55:23 -0600 | [diff] [blame] | 386 | ret = dm_scan_other(pre_reloc_only); |
| 387 | if (ret) |
| 388 | return ret; |
Simon Glass | a730c5d | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 393 | /* This is the root driver - all drivers are children of this */ |
| 394 | U_BOOT_DRIVER(root_driver) = { |
| 395 | .name = "root_driver", |
| 396 | .id = UCLASS_ROOT, |
Stefan Roese | a0ea0f9 | 2015-12-14 16:18:15 +0100 | [diff] [blame] | 397 | .priv_auto_alloc_size = sizeof(struct root_priv), |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 398 | }; |
| 399 | |
| 400 | /* This is the root uclass */ |
| 401 | UCLASS_DRIVER(root) = { |
| 402 | .name = "root", |
| 403 | .id = UCLASS_ROOT, |
| 404 | }; |