summaryrefslogtreecommitdiff
path: root/boot/bootstd-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-04-25 08:31:08 +0300
committerTom Rini <trini@konsulko.com>2022-04-25 17:00:04 +0300
commita950d31abe980ba40a0a94fbf41136550187f8cd (patch)
tree121c65da447165502e8a210924a5ab02635bfd27 /boot/bootstd-uclass.c
parent201417d700a2ab09f247c1be9952176970c0f6bd (diff)
downloadu-boot-a950d31abe980ba40a0a94fbf41136550187f8cd.tar.xz
bootstd: Add the bootmeth uclass and helpers
A bootmeth is a method of locating an operating system. For now, just add the uclass itself. Drivers for particular bootmeths are added later. If no bootmeths devices are included in the devicetree, create them automatically. This avoids the need for boilerplate in the devicetree files. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootstd-uclass.c')
-rw-r--r--boot/bootstd-uclass.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index 615cd89bf0..4c71c2829e 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -109,8 +109,10 @@ static int bootstd_probe(struct udevice *dev)
/* For now, bind the boormethod device if none are found in the devicetree */
int dm_scan_other(bool pre_reloc_only)
{
- struct udevice *bootstd;
- int ret;
+ struct driver *drv = ll_entry_start(struct driver, driver);
+ const int n_ents = ll_entry_count(struct driver, driver);
+ struct udevice *dev, *bootstd;
+ int i, ret;
/* These are not needed before relocation */
if (!(gd->flags & GD_FLG_RELOC))
@@ -125,6 +127,29 @@ int dm_scan_other(bool pre_reloc_only)
return log_msg_ret("bootstd", ret);
}
+ /* If there are no bootmeth devices, create them */
+ uclass_find_first_device(UCLASS_BOOTMETH, &dev);
+ if (dev)
+ return 0;
+
+ for (i = 0; i < n_ents; i++, drv++) {
+ /*
+ * Disable EFI Manager for now as no one uses it so it is
+ * confusing
+ */
+ if (drv->id == UCLASS_BOOTMETH &&
+ strcmp("efi_mgr_bootmeth", drv->name)) {
+ const char *name = drv->name;
+
+ if (!strncmp("bootmeth_", name, 9))
+ name += 9;
+ ret = device_bind(bootstd, drv, name, 0, ofnode_null(),
+ &dev);
+ if (ret)
+ return log_msg_ret("meth", ret);
+ }
+ }
+
return 0;
}