spl.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * (C) Copyright 2012
  3. * NVIDIA Inc, <www.nvidia.com>
  4. *
  5. * Allen Martin <amartin@nvidia.com>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <asm/u-boot.h>
  27. #include <asm/utils.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/arch/clock.h>
  30. #include <nand.h>
  31. #include <mmc.h>
  32. #include <fat.h>
  33. #include <version.h>
  34. #include <i2c.h>
  35. #include <image.h>
  36. #include <malloc.h>
  37. #include <linux/compiler.h>
  38. #include "board.h"
  39. #include "cpu.h"
  40. #include <asm/io.h>
  41. #include <asm/arch/tegra20.h>
  42. #include <asm/arch/clk_rst.h>
  43. #include <asm/arch/clock.h>
  44. #include <asm/arch/pmc.h>
  45. #include <asm/arch/pinmux.h>
  46. #include <asm/arch/scu.h>
  47. #include <common.h>
  48. DECLARE_GLOBAL_DATA_PTR;
  49. /* Define global data structure pointer to it*/
  50. static gd_t gdata __attribute__ ((section(".data")));
  51. static bd_t bdata __attribute__ ((section(".data")));
  52. inline void hang(void)
  53. {
  54. puts("### ERROR ### Please RESET the board ###\n");
  55. for (;;)
  56. ;
  57. }
  58. void board_init_f(ulong dummy)
  59. {
  60. board_init_uart_f();
  61. /* Initialize periph GPIOs */
  62. #ifdef CONFIG_SPI_UART_SWITCH
  63. gpio_early_init_uart();
  64. #else
  65. gpio_config_uart();
  66. #endif
  67. /*
  68. * We call relocate_code() with relocation target same as the
  69. * CONFIG_SYS_SPL_TEXT_BASE. This will result in relocation getting
  70. * skipped. Instead, only .bss initialization will happen. That's
  71. * all we need
  72. */
  73. debug(">>board_init_f()\n");
  74. relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
  75. }
  76. /* This requires UART clocks to be enabled */
  77. static void preloader_console_init(void)
  78. {
  79. const char *u_boot_rev = U_BOOT_VERSION;
  80. gd = &gdata;
  81. gd->bd = &bdata;
  82. gd->flags |= GD_FLG_RELOC;
  83. gd->baudrate = CONFIG_BAUDRATE;
  84. serial_init(); /* serial communications setup */
  85. gd->have_console = 1;
  86. /* Avoid a second "U-Boot" coming from this string */
  87. u_boot_rev = &u_boot_rev[7];
  88. printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE,
  89. U_BOOT_TIME);
  90. }
  91. void board_init_r(gd_t *id, ulong dummy)
  92. {
  93. struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
  94. /* enable JTAG */
  95. writel(0xC0, &pmt->pmt_cfg_ctl);
  96. debug(">>spl:board_init_r()\n");
  97. mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
  98. CONFIG_SYS_SPL_MALLOC_SIZE);
  99. #ifdef CONFIG_SPL_BOARD_INIT
  100. spl_board_init();
  101. #endif
  102. clock_early_init();
  103. serial_init();
  104. preloader_console_init();
  105. start_cpu((u32)CONFIG_SYS_TEXT_BASE);
  106. halt_avp();
  107. /* not reached */
  108. }
  109. int board_usb_init(const void *blob)
  110. {
  111. return 0;
  112. }