spl.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2011
  3. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <config.h>
  25. #include <spl.h>
  26. #include <asm/u-boot.h>
  27. #include <asm/utils.h>
  28. #include <nand.h>
  29. #include <asm/arch/dm365_lowlevel.h>
  30. #include <ns16550.h>
  31. #include <malloc.h>
  32. #include <spi_flash.h>
  33. #include <mmc.h>
  34. DECLARE_GLOBAL_DATA_PTR;
  35. #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
  36. void puts(const char *str)
  37. {
  38. while (*str)
  39. putc(*str++);
  40. }
  41. void putc(char c)
  42. {
  43. if (c == '\n')
  44. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
  45. NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
  46. }
  47. #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
  48. void board_init_f(ulong dummy)
  49. {
  50. /* First, setup our stack pointer. */
  51. asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
  52. /* Second, perform our low-level init. */
  53. #ifdef CONFIG_SOC_DM365
  54. dm36x_lowlevel_init(0);
  55. #endif
  56. #ifdef CONFIG_SOC_DA8XX
  57. arch_cpu_init();
  58. #endif
  59. /* Third, we clear the BSS. */
  60. memset(__bss_start, 0, __bss_end__ - __bss_start);
  61. /* Finally, setup gd and move to the next step. */
  62. gd = &gdata;
  63. board_init_r(NULL, 0);
  64. }
  65. void spl_board_init(void)
  66. {
  67. preloader_console_init();
  68. }
  69. u32 spl_boot_mode(void)
  70. {
  71. return MMCSD_MODE_RAW;
  72. }
  73. u32 spl_boot_device(void)
  74. {
  75. #ifdef CONFIG_SPL_NAND_SIMPLE
  76. return BOOT_DEVICE_NAND;
  77. #elif defined(CONFIG_SPL_SPI_LOAD)
  78. return BOOT_DEVICE_SPI;
  79. #elif defined(CONFIG_SPL_MMC_LOAD)
  80. return BOOT_DEVICE_MMC1;
  81. #else
  82. puts("Unknown boot device\n");
  83. hang();
  84. #endif
  85. }