blob: 218221fa30622704c22ab29ab02121bb0095eef3 [file] [log] [blame]
Simon Glass9985e9c2023-01-17 10:47:45 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
Simon Glass41571582023-07-12 09:04:32 -06003 * Bootdev for SCSI
Simon Glass9985e9c2023-01-17 10:47:45 -07004 *
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
Simon Glass7e1f6a42023-01-17 10:48:08 -070019 ucp->prio = BOOTDEVP_4_SCAN_FAST;
Simon Glass9985e9c2023-01-17 10:47:45 -070020
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) = {
Simon Glass7e1f6a42023-01-17 10:48:08 -070058 .prio = BOOTDEVP_4_SCAN_FAST,
Simon Glass9985e9c2023-01-17 10:47:45 -070059 .uclass = UCLASS_SCSI,
60 .hunt = scsi_bootdev_hunt,
61 .drv = DM_DRIVER_REF(scsi_bootdev),
62};