spl_nor.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2012 Stefan Roese <sr@denx.de>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <common.h>
  18. #include <spl.h>
  19. void spl_nor_load_image(void)
  20. {
  21. /*
  22. * Loading of the payload to SDRAM is done with skipping of
  23. * the mkimage header in this SPL NOR driver
  24. */
  25. spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
  26. if (spl_start_uboot()) {
  27. /*
  28. * Load real U-Boot from its location in NOR flash to its
  29. * defined location in SDRAM
  30. */
  31. spl_parse_image_header(
  32. (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
  33. memcpy((void *)spl_image.load_addr,
  34. (void *)(CONFIG_SYS_UBOOT_BASE +
  35. sizeof(struct image_header)),
  36. spl_image.size);
  37. } else {
  38. /*
  39. * Load Linux from its location in NOR flash to its defined
  40. * location in SDRAM
  41. */
  42. spl_parse_image_header(
  43. (const struct image_header *)CONFIG_SYS_OS_BASE);
  44. memcpy((void *)spl_image.load_addr,
  45. (void *)(CONFIG_SYS_OS_BASE +
  46. sizeof(struct image_header)),
  47. spl_image.size);
  48. /*
  49. * Copy DT blob (fdt) to SDRAM. Passing pointer to flash
  50. * doesn't work (16 KiB should be enough for DT)
  51. */
  52. memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
  53. (void *)(CONFIG_SYS_FDT_BASE),
  54. (16 << 10));
  55. }
  56. }