Simon Glass | e1917ef | 2022-04-24 23:31:23 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Bootdevice for USB |
| 4 | * |
| 5 | * Copyright 2021 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <bootdev.h> |
| 11 | #include <dm.h> |
| 12 | #include <usb.h> |
| 13 | |
Simon Glass | e1917ef | 2022-04-24 23:31:23 -0600 | [diff] [blame] | 14 | static int usb_bootdev_bind(struct udevice *dev) |
| 15 | { |
| 16 | struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); |
| 17 | |
Simon Glass | 7e1f6a4 | 2023-01-17 10:48:08 -0700 | [diff] [blame] | 18 | ucp->prio = BOOTDEVP_5_SCAN_SLOW; |
Simon Glass | e1917ef | 2022-04-24 23:31:23 -0600 | [diff] [blame] | 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
Simon Glass | f3cb89f | 2023-01-17 10:47:37 -0700 | [diff] [blame] | 23 | static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show) |
| 24 | { |
| 25 | return usb_init(); |
| 26 | } |
| 27 | |
Simon Glass | e1917ef | 2022-04-24 23:31:23 -0600 | [diff] [blame] | 28 | struct bootdev_ops usb_bootdev_ops = { |
Simon Glass | e1917ef | 2022-04-24 23:31:23 -0600 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | static const struct udevice_id usb_bootdev_ids[] = { |
| 32 | { .compatible = "u-boot,bootdev-usb" }, |
| 33 | { } |
| 34 | }; |
| 35 | |
| 36 | U_BOOT_DRIVER(usb_bootdev) = { |
| 37 | .name = "usb_bootdev", |
| 38 | .id = UCLASS_BOOTDEV, |
| 39 | .ops = &usb_bootdev_ops, |
| 40 | .bind = usb_bootdev_bind, |
| 41 | .of_match = usb_bootdev_ids, |
| 42 | }; |
Simon Glass | f3cb89f | 2023-01-17 10:47:37 -0700 | [diff] [blame] | 43 | |
| 44 | BOOTDEV_HUNTER(usb_bootdev_hunter) = { |
Simon Glass | 7e1f6a4 | 2023-01-17 10:48:08 -0700 | [diff] [blame] | 45 | .prio = BOOTDEVP_5_SCAN_SLOW, |
Simon Glass | f3cb89f | 2023-01-17 10:47:37 -0700 | [diff] [blame] | 46 | .uclass = UCLASS_USB, |
| 47 | .hunt = usb_bootdev_hunt, |
| 48 | .drv = DM_DRIVER_REF(usb_bootdev), |
| 49 | }; |