spl_boot.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. DECLARE_GLOBAL_DATA_PTR;
  9. /*
  10. * Needed to align size SPL image to a 4-byte length
  11. */
  12. u32 end_align __attribute__ ((section(".end_align")));
  13. /*
  14. * Return selected boot device. On MPC5200 its only NOR flash right now.
  15. */
  16. u32 spl_boot_device(void)
  17. {
  18. return BOOT_DEVICE_NOR;
  19. }
  20. /*
  21. * SPL version of board_init_f()
  22. */
  23. void board_init_f(ulong bootflag)
  24. {
  25. end_align = (u32)__spl_flash_end;
  26. /*
  27. * On MPC5200, the initial RAM (and gd) is located in the internal
  28. * SRAM. So we can actually call the preloader console init code
  29. * before calling dram_init(). This makes serial output (printf)
  30. * available very early, even before SDRAM init, which has been
  31. * an U-Boot priciple from day 1.
  32. */
  33. /*
  34. * Init global_data pointer. Has to be done before calling
  35. * get_clocks(), as it stores some clock values into gd needed
  36. * later on in the serial driver.
  37. */
  38. /* Pointer is writable since we allocated a register for it */
  39. gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
  40. /* Clear initial global data */
  41. memset((void *)gd, 0, sizeof(gd_t));
  42. /*
  43. * get_clocks() needs to be called so that the serial driver
  44. * works correctly
  45. */
  46. get_clocks();
  47. /*
  48. * Do rudimental console / serial setup
  49. */
  50. preloader_console_init();
  51. /*
  52. * First we need to initialize the SDRAM, so that the real
  53. * U-Boot or the OS (Linux) can be loaded
  54. */
  55. dram_init();
  56. /* Clear bss */
  57. memset(__bss_start, '\0', __bss_end - __bss_start);
  58. /*
  59. * Call board_init_r() (SPL framework version) to load and boot
  60. * real U-Boot or OS
  61. */
  62. board_init_r(NULL, 0);
  63. /* Does not return!!! */
  64. }