spl_sdp.c 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2016 Toradex
  4. * Author: Stefan Agner <stefan.agner@toradex.com>
  5. */
  6. #include <common.h>
  7. #include <spl.h>
  8. #include <usb.h>
  9. #include <g_dnl.h>
  10. #include <sdp.h>
  11. static int spl_sdp_load_image(struct spl_image_info *spl_image,
  12. struct spl_boot_device *bootdev)
  13. {
  14. int ret;
  15. const int controller_index = 0;
  16. g_dnl_clear_detach();
  17. ret = g_dnl_register("usb_dnl_sdp");
  18. if (ret) {
  19. pr_err("SDP dnl register failed: %d\n", ret);
  20. return ret;
  21. }
  22. ret = sdp_init(controller_index);
  23. if (ret) {
  24. pr_err("SDP init failed: %d\n", ret);
  25. return -ENODEV;
  26. }
  27. /*
  28. * This command either loads a legacy image, jumps and never returns,
  29. * or it loads a FIT image and returns it to be handled by the SPL
  30. * code.
  31. */
  32. ret = spl_sdp_handle(controller_index, spl_image);
  33. debug("SDP ended\n");
  34. return ret;
  35. }
  36. SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);