blob: 2367b33da9cb2bfa95709c79e6265fb7f1ea468d [file] [log] [blame]
Simon Glass9985e9c2023-01-17 10:47:45 -07001// 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 <init.h>
13#include <scsi.h>
14
15static int scsi_bootdev_bind(struct udevice *dev)
16{
17 struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
18
19 ucp->prio = BOOTDEVP_2_SCAN_FAST;
20
21 return 0;
22}
23
24static int scsi_bootdev_hunt(struct bootdev_hunter *info, bool show)
25{
26 int ret;
27
28 if (IS_ENABLED(CONFIG_PCI)) {
29 ret = pci_init();
30 if (ret)
31 return log_msg_ret("pci", ret);
32 }
33
34 ret = scsi_scan(true);
35 if (ret)
36 return log_msg_ret("scs", ret);
37
38 return 0;
39}
40
41struct bootdev_ops scsi_bootdev_ops = {
42};
43
44static const struct udevice_id scsi_bootdev_ids[] = {
45 { .compatible = "u-boot,bootdev-scsi" },
46 { }
47};
48
49U_BOOT_DRIVER(scsi_bootdev) = {
50 .name = "scsi_bootdev",
51 .id = UCLASS_BOOTDEV,
52 .ops = &scsi_bootdev_ops,
53 .bind = scsi_bootdev_bind,
54 .of_match = scsi_bootdev_ids,
55};
56
57BOOTDEV_HUNTER(scsi_bootdev_hunter) = {
58 .prio = BOOTDEVP_2_SCAN_FAST,
59 .uclass = UCLASS_SCSI,
60 .hunt = scsi_bootdev_hunt,
61 .drv = DM_DRIVER_REF(scsi_bootdev),
62};