Simon Glass | 8f090b6 | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Simon Glass | 4de979f | 2023-07-12 09:04:32 -0600 | [diff] [blame] | 3 | * Bootdev for SCSI |
Simon Glass | 8f090b6 | 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 | |
| 9 | #include <common.h> |
| 10 | #include <bootdev.h> |
| 11 | #include <dm.h> |
| 12 | #include <init.h> |
| 13 | #include <scsi.h> |
| 14 | |
| 15 | static int scsi_bootdev_bind(struct udevice *dev) |
| 16 | { |
| 17 | struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); |
| 18 | |
Simon Glass | eacc261 | 2023-01-17 10:48:08 -0700 | [diff] [blame] | 19 | ucp->prio = BOOTDEVP_4_SCAN_FAST; |
Simon Glass | 8f090b6 | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 20 | |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | static 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 | |
| 41 | struct bootdev_ops scsi_bootdev_ops = { |
| 42 | }; |
| 43 | |
| 44 | static const struct udevice_id scsi_bootdev_ids[] = { |
| 45 | { .compatible = "u-boot,bootdev-scsi" }, |
| 46 | { } |
| 47 | }; |
| 48 | |
| 49 | U_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 | |
| 57 | BOOTDEV_HUNTER(scsi_bootdev_hunter) = { |
Simon Glass | eacc261 | 2023-01-17 10:48:08 -0700 | [diff] [blame] | 58 | .prio = BOOTDEVP_4_SCAN_FAST, |
Simon Glass | 8f090b6 | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 59 | .uclass = UCLASS_SCSI, |
| 60 | .hunt = scsi_bootdev_hunt, |
| 61 | .drv = DM_DRIVER_REF(scsi_bootdev), |
| 62 | }; |