spl.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2011
  3. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <config.h>
  9. #include <spl.h>
  10. #include <asm/u-boot.h>
  11. #include <asm/utils.h>
  12. #include <nand.h>
  13. #include <asm/arch/dm365_lowlevel.h>
  14. #include <ns16550.h>
  15. #include <malloc.h>
  16. #include <spi_flash.h>
  17. #include <mmc.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
  20. void puts(const char *str)
  21. {
  22. while (*str)
  23. putc(*str++);
  24. }
  25. void putc(char c)
  26. {
  27. if (c == '\n')
  28. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
  29. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
  30. }
  31. #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
  32. void board_init_f(ulong dummy)
  33. {
  34. /* First, setup our stack pointer. */
  35. asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
  36. /* Second, perform our low-level init. */
  37. #ifdef CONFIG_SOC_DM365
  38. dm36x_lowlevel_init(0);
  39. #endif
  40. #ifdef CONFIG_SOC_DA8XX
  41. arch_cpu_init();
  42. #endif
  43. /* Third, we clear the BSS. */
  44. memset(__bss_start, 0, __bss_end - __bss_start);
  45. /* Finally, setup gd and move to the next step. */
  46. gd = &gdata;
  47. board_init_r(NULL, 0);
  48. }
  49. void spl_board_init(void)
  50. {
  51. preloader_console_init();
  52. }
  53. u32 spl_boot_mode(void)
  54. {
  55. return MMCSD_MODE_RAW;
  56. }
  57. u32 spl_boot_device(void)
  58. {
  59. #ifdef CONFIG_SPL_NAND_SIMPLE
  60. return BOOT_DEVICE_NAND;
  61. #elif defined(CONFIG_SPL_SPI_LOAD)
  62. return BOOT_DEVICE_SPI;
  63. #elif defined(CONFIG_SPL_MMC_LOAD)
  64. return BOOT_DEVICE_MMC1;
  65. #else
  66. puts("Unknown boot device\n");
  67. hang();
  68. #endif
  69. }