blob: 32919f99286501b64d6cc140fc78f0757ddae4a4 [file] [log] [blame]
Simon Glass0ccb0ac2022-04-24 23:31:23 -06001// 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 Glass0ccb0ac2022-04-24 23:31:23 -060014static int usb_bootdev_bind(struct udevice *dev)
15{
16 struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
17
Simon Glasseacc2612023-01-17 10:48:08 -070018 ucp->prio = BOOTDEVP_5_SCAN_SLOW;
Simon Glass0ccb0ac2022-04-24 23:31:23 -060019
20 return 0;
21}
22
Simon Glass04fb2b62023-01-17 10:47:37 -070023static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show)
24{
25 return usb_init();
26}
27
Simon Glass0ccb0ac2022-04-24 23:31:23 -060028struct bootdev_ops usb_bootdev_ops = {
Simon Glass0ccb0ac2022-04-24 23:31:23 -060029};
30
31static const struct udevice_id usb_bootdev_ids[] = {
32 { .compatible = "u-boot,bootdev-usb" },
33 { }
34};
35
36U_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 Glass04fb2b62023-01-17 10:47:37 -070043
44BOOTDEV_HUNTER(usb_bootdev_hunter) = {
Simon Glasseacc2612023-01-17 10:48:08 -070045 .prio = BOOTDEVP_5_SCAN_SLOW,
Simon Glass04fb2b62023-01-17 10:47:37 -070046 .uclass = UCLASS_USB,
47 .hunt = usb_bootdev_hunt,
48 .drv = DM_DRIVER_REF(usb_bootdev),
49};