board.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 <asm/io.h>
  26. #include <asm/arch/tegra2.h>
  27. #include <asm/arch/sys_proto.h>
  28. #include <asm/arch/clk_rst.h>
  29. #include <asm/arch/pinmux.h>
  30. #include <asm/arch/uart.h>
  31. #include "board.h"
  32. DECLARE_GLOBAL_DATA_PTR;
  33. const struct tegra2_sysinfo sysinfo = {
  34. CONFIG_TEGRA2_BOARD_STRING
  35. };
  36. #ifdef CONFIG_BOARD_EARLY_INIT_F
  37. int board_early_init_f(void)
  38. {
  39. debug("Board Early Init\n");
  40. tegra2_start();
  41. return 0;
  42. }
  43. #endif /* EARLY_INIT */
  44. /*
  45. * Routine: timer_init
  46. * Description: init the timestamp and lastinc value
  47. */
  48. int timer_init(void)
  49. {
  50. reset_timer();
  51. return 0;
  52. }
  53. /*
  54. * Routine: clock_init_uart
  55. * Description: init the PLL and clock for the UART(s)
  56. */
  57. static void clock_init_uart(void)
  58. {
  59. struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
  60. static int pllp_init_done;
  61. u32 reg;
  62. if (!pllp_init_done) {
  63. /* Override pllp setup for 216MHz operation. */
  64. reg = (PLL_BYPASS | PLL_BASE_OVRRIDE | PLL_DIVP);
  65. reg |= (((NVRM_PLLP_FIXED_FREQ_KHZ/500) << 8) | PLL_DIVM);
  66. writel(reg, &clkrst->crc_pllp_base);
  67. reg |= PLL_ENABLE;
  68. writel(reg, &clkrst->crc_pllp_base);
  69. reg &= ~PLL_BYPASS;
  70. writel(reg, &clkrst->crc_pllp_base);
  71. pllp_init_done++;
  72. }
  73. /* Now do the UART reset/clock enable */
  74. #if defined(CONFIG_TEGRA2_ENABLE_UARTA)
  75. /* Assert Reset to UART */
  76. reg = readl(&clkrst->crc_rst_dev_l);
  77. reg |= SWR_UARTA_RST; /* SWR_UARTA_RST = 1 */
  78. writel(reg, &clkrst->crc_rst_dev_l);
  79. /* Enable clk to UART */
  80. reg = readl(&clkrst->crc_clk_out_enb_l);
  81. reg |= CLK_ENB_UARTA; /* CLK_ENB_UARTA = 1 */
  82. writel(reg, &clkrst->crc_clk_out_enb_l);
  83. /* Enable pllp_out0 to UART */
  84. reg = readl(&clkrst->crc_clk_src_uarta);
  85. reg &= 0x3FFFFFFF; /* UARTA_CLK_SRC = 00, PLLP_OUT0 */
  86. writel(reg, &clkrst->crc_clk_src_uarta);
  87. /* wait for 2us */
  88. udelay(2);
  89. /* De-assert reset to UART */
  90. reg = readl(&clkrst->crc_rst_dev_l);
  91. reg &= ~SWR_UARTA_RST; /* SWR_UARTA_RST = 0 */
  92. writel(reg, &clkrst->crc_rst_dev_l);
  93. #endif /* CONFIG_TEGRA2_ENABLE_UARTA */
  94. #if defined(CONFIG_TEGRA2_ENABLE_UARTD)
  95. /* Assert Reset to UART */
  96. reg = readl(&clkrst->crc_rst_dev_u);
  97. reg |= SWR_UARTD_RST; /* SWR_UARTD_RST = 1 */
  98. writel(reg, &clkrst->crc_rst_dev_u);
  99. /* Enable clk to UART */
  100. reg = readl(&clkrst->crc_clk_out_enb_u);
  101. reg |= CLK_ENB_UARTD; /* CLK_ENB_UARTD = 1 */
  102. writel(reg, &clkrst->crc_clk_out_enb_u);
  103. /* Enable pllp_out0 to UART */
  104. reg = readl(&clkrst->crc_clk_src_uartd);
  105. reg &= 0x3FFFFFFF; /* UARTD_CLK_SRC = 00, PLLP_OUT0 */
  106. writel(reg, &clkrst->crc_clk_src_uartd);
  107. /* wait for 2us */
  108. udelay(2);
  109. /* De-assert reset to UART */
  110. reg = readl(&clkrst->crc_rst_dev_u);
  111. reg &= ~SWR_UARTD_RST; /* SWR_UARTD_RST = 0 */
  112. writel(reg, &clkrst->crc_rst_dev_u);
  113. #endif /* CONFIG_TEGRA2_ENABLE_UARTD */
  114. }
  115. /*
  116. * Routine: pin_mux_uart
  117. * Description: setup the pin muxes/tristate values for the UART(s)
  118. */
  119. static void pin_mux_uart(void)
  120. {
  121. struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
  122. u32 reg;
  123. #if defined(CONFIG_TEGRA2_ENABLE_UARTA)
  124. reg = readl(&pmt->pmt_ctl_c);
  125. reg &= 0xFFF0FFFF; /* IRRX_/IRTX_SEL [19:16] = 00 UARTA */
  126. writel(reg, &pmt->pmt_ctl_c);
  127. reg = readl(&pmt->pmt_tri_a);
  128. reg &= ~Z_IRRX; /* Z_IRRX = normal (0) */
  129. reg &= ~Z_IRTX; /* Z_IRTX = normal (0) */
  130. writel(reg, &pmt->pmt_tri_a);
  131. #endif /* CONFIG_TEGRA2_ENABLE_UARTA */
  132. #if defined(CONFIG_TEGRA2_ENABLE_UARTD)
  133. reg = readl(&pmt->pmt_ctl_b);
  134. reg &= 0xFFFFFFF3; /* GMC_SEL [3:2] = 00, UARTD */
  135. writel(reg, &pmt->pmt_ctl_b);
  136. reg = readl(&pmt->pmt_tri_a);
  137. reg &= ~Z_GMC; /* Z_GMC = normal (0) */
  138. writel(reg, &pmt->pmt_tri_a);
  139. #endif /* CONFIG_TEGRA2_ENABLE_UARTD */
  140. }
  141. /*
  142. * Routine: clock_init
  143. * Description: Do individual peripheral clock reset/enables
  144. */
  145. void clock_init(void)
  146. {
  147. clock_init_uart();
  148. }
  149. /*
  150. * Routine: pinmux_init
  151. * Description: Do individual peripheral pinmux configs
  152. */
  153. void pinmux_init(void)
  154. {
  155. pin_mux_uart();
  156. }
  157. /*
  158. * Routine: board_init
  159. * Description: Early hardware init.
  160. */
  161. int board_init(void)
  162. {
  163. /* boot param addr */
  164. gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100);
  165. /* board id for Linux */
  166. gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
  167. /* Initialize peripheral clocks */
  168. clock_init();
  169. /* Initialize periph pinmuxes */
  170. pinmux_init();
  171. return 0;
  172. }