board.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * (C) Copyright 2010,2011
  3. * NVIDIA Corporation <www.nvidia.com>
  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 <ns16550.h>
  25. #include <linux/compiler.h>
  26. #include <asm/io.h>
  27. #include <asm/arch/tegra2.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/arch/board.h>
  30. #include <asm/arch/clk_rst.h>
  31. #include <asm/arch/clock.h>
  32. #include <asm/arch/emc.h>
  33. #include <asm/arch/pinmux.h>
  34. #include <asm/arch/pmc.h>
  35. #include <asm/arch/pmu.h>
  36. #include <asm/arch/uart.h>
  37. #include <asm/arch/warmboot.h>
  38. #include <spi.h>
  39. #include <asm/arch/usb.h>
  40. #include <i2c.h>
  41. #include "board.h"
  42. #include "emc.h"
  43. DECLARE_GLOBAL_DATA_PTR;
  44. const struct tegra2_sysinfo sysinfo = {
  45. CONFIG_TEGRA2_BOARD_STRING
  46. };
  47. /*
  48. * Routine: timer_init
  49. * Description: init the timestamp and lastinc value
  50. */
  51. int timer_init(void)
  52. {
  53. return 0;
  54. }
  55. void __pin_mux_usb(void)
  56. {
  57. }
  58. void pin_mux_usb(void) __attribute__((weak, alias("__pin_mux_usb")));
  59. /*
  60. * Routine: power_det_init
  61. * Description: turn off power detects
  62. */
  63. static void power_det_init(void)
  64. {
  65. #if defined(CONFIG_TEGRA2)
  66. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)TEGRA2_PMC_BASE;
  67. /* turn off power detects */
  68. writel(0, &pmc->pmc_pwr_det_latch);
  69. writel(0, &pmc->pmc_pwr_det);
  70. #endif
  71. }
  72. /*
  73. * Routine: board_init
  74. * Description: Early hardware init.
  75. */
  76. int board_init(void)
  77. {
  78. __maybe_unused int err;
  79. /* Do clocks and UART first so that printf() works */
  80. clock_init();
  81. clock_verify();
  82. #ifdef CONFIG_SPI_UART_SWITCH
  83. gpio_config_uart();
  84. #endif
  85. #ifdef CONFIG_TEGRA2_SPI
  86. spi_init();
  87. #endif
  88. /* boot param addr */
  89. gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100);
  90. power_det_init();
  91. #ifdef CONFIG_TEGRA_I2C
  92. #ifndef CONFIG_SYS_I2C_INIT_BOARD
  93. #error "You must define CONFIG_SYS_I2C_INIT_BOARD to use i2c on Nvidia boards"
  94. #endif
  95. i2c_init_board();
  96. # ifdef CONFIG_TEGRA_PMU
  97. if (pmu_set_nominal())
  98. debug("Failed to select nominal voltages\n");
  99. # ifdef CONFIG_TEGRA_CLOCK_SCALING
  100. err = board_emc_init();
  101. if (err)
  102. debug("Memory controller init failed: %d\n", err);
  103. # endif
  104. # endif /* CONFIG_TEGRA_PMU */
  105. #endif /* CONFIG_TEGRA_I2C */
  106. #ifdef CONFIG_USB_EHCI_TEGRA
  107. pin_mux_usb();
  108. board_usb_init(gd->fdt_blob);
  109. #endif
  110. #ifdef CONFIG_TEGRA2_LP0
  111. /* prepare the WB code to LP0 location */
  112. warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE);
  113. #endif
  114. return 0;
  115. }
  116. #ifdef CONFIG_BOARD_EARLY_INIT_F
  117. static void __gpio_early_init(void)
  118. {
  119. }
  120. void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
  121. int board_early_init_f(void)
  122. {
  123. board_init_uart_f();
  124. /* Initialize periph GPIOs */
  125. gpio_early_init();
  126. #ifdef CONFIG_SPI_UART_SWITCH
  127. gpio_early_init_uart();
  128. #else
  129. gpio_config_uart();
  130. #endif
  131. return 0;
  132. }
  133. #endif /* EARLY_INIT */