spl.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011
  4. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  5. */
  6. #include <common.h>
  7. #include <config.h>
  8. #include <spl.h>
  9. #include <asm/u-boot.h>
  10. #include <asm/utils.h>
  11. #include <nand.h>
  12. #include <asm/arch/dm365_lowlevel.h>
  13. #include <ns16550.h>
  14. #include <malloc.h>
  15. #include <spi_flash.h>
  16. #include <mmc.h>
  17. #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
  18. void puts(const char *str)
  19. {
  20. while (*str)
  21. putc(*str++);
  22. }
  23. void putc(char c)
  24. {
  25. if (c == '\n')
  26. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
  27. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
  28. }
  29. #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
  30. void spl_board_init(void)
  31. {
  32. #ifdef CONFIG_SOC_DM365
  33. dm36x_lowlevel_init(0);
  34. #endif
  35. #ifdef CONFIG_SOC_DA8XX
  36. arch_cpu_init();
  37. #endif
  38. preloader_console_init();
  39. }
  40. u32 spl_boot_device(void)
  41. {
  42. switch (davinci_syscfg_regs->bootcfg) {
  43. #ifdef CONFIG_SPL_NAND_SUPPORT
  44. case DAVINCI_NAND8_BOOT:
  45. case DAVINCI_NAND16_BOOT:
  46. return BOOT_DEVICE_NAND;
  47. #endif
  48. #ifdef CONFIG_SPL_MMC_SUPPORT
  49. case DAVINCI_SD_OR_MMC_BOOT:
  50. case DAVINCI_MMC_ONLY_BOOT:
  51. return BOOT_DEVICE_MMC1;
  52. #endif
  53. #ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
  54. case DAVINCI_SPI0_FLASH_BOOT:
  55. case DAVINCI_SPI1_FLASH_BOOT:
  56. return BOOT_DEVICE_SPI;
  57. #endif
  58. default:
  59. puts("Unknown boot device\n");
  60. hang();
  61. }
  62. }