Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Simon Glass | 4157158 | 2023-07-12 09:04:32 -0600 | [diff] [blame] | 3 | * Bootdev for SCSI |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 4 | * |
| 5 | * Copyright 2021 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 9 | #include <bootdev.h> |
| 10 | #include <dm.h> |
| 11 | #include <init.h> |
| 12 | #include <scsi.h> |
| 13 | |
| 14 | static int scsi_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_4_SCAN_FAST; |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | static 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 | |
| 40 | struct bootdev_ops scsi_bootdev_ops = { |
| 41 | }; |
| 42 | |
| 43 | static const struct udevice_id scsi_bootdev_ids[] = { |
| 44 | { .compatible = "u-boot,bootdev-scsi" }, |
| 45 | { } |
| 46 | }; |
| 47 | |
| 48 | U_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 | |
| 56 | BOOTDEV_HUNTER(scsi_bootdev_hunter) = { |
Simon Glass | 7e1f6a4 | 2023-01-17 10:48:08 -0700 | [diff] [blame] | 57 | .prio = BOOTDEVP_4_SCAN_FAST, |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 58 | .uclass = UCLASS_SCSI, |
| 59 | .hunt = scsi_bootdev_hunt, |
| 60 | .drv = DM_DRIVER_REF(scsi_bootdev), |
| 61 | }; |