spl_nor.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2012 Stefan Roese <sr@denx.de>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <spl.h>
  8. int spl_nor_load_image(void)
  9. {
  10. /*
  11. * Loading of the payload to SDRAM is done with skipping of
  12. * the mkimage header in this SPL NOR driver
  13. */
  14. spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
  15. #ifdef CONFIG_SPL_OS_BOOT
  16. if (!spl_start_uboot()) {
  17. const struct image_header *header;
  18. /*
  19. * Load Linux from its location in NOR flash to its defined
  20. * location in SDRAM
  21. */
  22. header = (const struct image_header *)CONFIG_SYS_OS_BASE;
  23. if (image_get_os(header) == IH_OS_LINUX) {
  24. /* happy - was a Linux */
  25. spl_parse_image_header(header);
  26. memcpy((void *)spl_image.load_addr,
  27. (void *)(CONFIG_SYS_OS_BASE +
  28. sizeof(struct image_header)),
  29. spl_image.size);
  30. /*
  31. * Copy DT blob (fdt) to SDRAM. Passing pointer to
  32. * flash doesn't work (16 KiB should be enough for DT)
  33. */
  34. memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
  35. (void *)(CONFIG_SYS_FDT_BASE),
  36. (16 << 10));
  37. return 0;
  38. } else {
  39. puts("The Expected Linux image was not found.\n"
  40. "Please check your NOR configuration.\n"
  41. "Trying to start u-boot now...\n");
  42. }
  43. }
  44. #endif
  45. /*
  46. * Load real U-Boot from its location in NOR flash to its
  47. * defined location in SDRAM
  48. */
  49. spl_parse_image_header(
  50. (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
  51. memcpy((void *)spl_image.load_addr,
  52. (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
  53. spl_image.size);
  54. return 0;
  55. }