blob: 28e4612f337c4524637be2d185762e9ff0bcd73d [file] [log] [blame]
Simon Glass8f090b62023-01-17 10:47:45 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
Simon Glass4de979f2023-07-12 09:04:32 -06003 * Bootdev for SCSI
Simon Glass8f090b62023-01-17 10:47:45 -07004 *
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
Simon Glass8f090b62023-01-17 10:47:45 -07009#include <bootdev.h>
10#include <dm.h>
11#include <init.h>
12#include <scsi.h>
13
14static int scsi_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_4_SCAN_FAST;
Simon Glass8f090b62023-01-17 10:47:45 -070019
20 return 0;
21}
22
23static int scsi_bootdev_hunt(struct bootdev_hunter *info, bool show)
24{
25 int ret;
26
27 if (IS_ENABLED(CONFIG_PCI)) {
28 ret = pci_init();
29 if (ret)
30 return log_msg_ret("pci", ret);
31 }
32
33 ret = scsi_scan(true);
34 if (ret)
35 return log_msg_ret("scs", ret);
36
37 return 0;
38}
39
40struct bootdev_ops scsi_bootdev_ops = {
41};
42
43static const struct udevice_id scsi_bootdev_ids[] = {
44 { .compatible = "u-boot,bootdev-scsi" },
45 { }
46};
47
48U_BOOT_DRIVER(scsi_bootdev) = {
49 .name = "scsi_bootdev",
50 .id = UCLASS_BOOTDEV,
51 .ops = &scsi_bootdev_ops,
52 .bind = scsi_bootdev_bind,
53 .of_match = scsi_bootdev_ids,
54};
55
56BOOTDEV_HUNTER(scsi_bootdev_hunter) = {
Simon Glasseacc2612023-01-17 10:48:08 -070057 .prio = BOOTDEVP_4_SCAN_FAST,
Simon Glass8f090b62023-01-17 10:47:45 -070058 .uclass = UCLASS_SCSI,
59 .hunt = scsi_bootdev_hunt,
60 .drv = DM_DRIVER_REF(scsi_bootdev),
61};