scsi_bootdev.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Bootdev for SCSI
  4. *
  5. * Copyright 2021 Google LLC
  6. * Written by Simon Glass <sjg@chromium.org>
  7. */
  8. #include <common.h>
  9. #include <bootdev.h>
  10. #include <dm.h>
  11. #include <init.h>
  12. #include <scsi.h>
  13. static int scsi_bootdev_bind(struct udevice *dev)
  14. {
  15. struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
  16. ucp->prio = BOOTDEVP_4_SCAN_FAST;
  17. return 0;
  18. }
  19. static int scsi_bootdev_hunt(struct bootdev_hunter *info, bool show)
  20. {
  21. int ret;
  22. if (IS_ENABLED(CONFIG_PCI)) {
  23. ret = pci_init();
  24. if (ret)
  25. return log_msg_ret("pci", ret);
  26. }
  27. ret = scsi_scan(true);
  28. if (ret)
  29. return log_msg_ret("scs", ret);
  30. return 0;
  31. }
  32. struct bootdev_ops scsi_bootdev_ops = {
  33. };
  34. static const struct udevice_id scsi_bootdev_ids[] = {
  35. { .compatible = "u-boot,bootdev-scsi" },
  36. { }
  37. };
  38. U_BOOT_DRIVER(scsi_bootdev) = {
  39. .name = "scsi_bootdev",
  40. .id = UCLASS_BOOTDEV,
  41. .ops = &scsi_bootdev_ops,
  42. .bind = scsi_bootdev_bind,
  43. .of_match = scsi_bootdev_ids,
  44. };
  45. BOOTDEV_HUNTER(scsi_bootdev_hunter) = {
  46. .prio = BOOTDEVP_4_SCAN_FAST,
  47. .uclass = UCLASS_SCSI,
  48. .hunt = scsi_bootdev_hunt,
  49. .drv = DM_DRIVER_REF(scsi_bootdev),
  50. };