board.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 <asm/io.h>
  25. #include <asm/arch/clock.h>
  26. #include <asm/arch/funcmux.h>
  27. #include <asm/arch/tegra.h>
  28. #include <asm/arch-tegra/board.h>
  29. #include <asm/arch-tegra/pmc.h>
  30. #include <asm/arch-tegra/sys_proto.h>
  31. #include <asm/arch-tegra/warmboot.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. enum {
  34. /* UARTs which we can enable */
  35. UARTA = 1 << 0,
  36. UARTB = 1 << 1,
  37. UARTC = 1 << 2,
  38. UARTD = 1 << 3,
  39. UARTE = 1 << 4,
  40. UART_COUNT = 5,
  41. };
  42. /*
  43. * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
  44. * so we are using this value to identify memory size.
  45. */
  46. unsigned int query_sdram_size(void)
  47. {
  48. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
  49. u32 reg;
  50. reg = readl(&pmc->pmc_scratch20);
  51. debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
  52. #if defined(CONFIG_TEGRA20)
  53. /* bits 30:28 in OdmData are used for RAM size on T20 */
  54. reg &= 0x70000000;
  55. switch ((reg) >> 28) {
  56. case 1:
  57. return 0x10000000; /* 256 MB */
  58. case 0:
  59. case 2:
  60. default:
  61. return 0x20000000; /* 512 MB */
  62. case 3:
  63. return 0x40000000; /* 1GB */
  64. }
  65. #else /* Tegra30/Tegra114 */
  66. /* bits 31:28 in OdmData are used for RAM size on T30 */
  67. switch ((reg) >> 28) {
  68. case 0:
  69. case 1:
  70. default:
  71. return 0x10000000; /* 256 MB */
  72. case 2:
  73. return 0x20000000; /* 512 MB */
  74. case 3:
  75. return 0x30000000; /* 768 MB */
  76. case 4:
  77. return 0x40000000; /* 1GB */
  78. case 8:
  79. return 0x7ff00000; /* 2GB - 1MB */
  80. }
  81. #endif
  82. }
  83. int dram_init(void)
  84. {
  85. /* We do not initialise DRAM here. We just query the size */
  86. gd->ram_size = query_sdram_size();
  87. return 0;
  88. }
  89. #ifdef CONFIG_DISPLAY_BOARDINFO
  90. int checkboard(void)
  91. {
  92. printf("Board: %s\n", sysinfo.board_string);
  93. return 0;
  94. }
  95. #endif /* CONFIG_DISPLAY_BOARDINFO */
  96. static int uart_configs[] = {
  97. #if defined(CONFIG_TEGRA20)
  98. #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
  99. FUNCMUX_UART1_UAA_UAB,
  100. #elif defined(CONFIG_TEGRA_UARTA_GPU)
  101. FUNCMUX_UART1_GPU,
  102. #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
  103. FUNCMUX_UART1_SDIO1,
  104. #else
  105. FUNCMUX_UART1_IRRX_IRTX,
  106. #endif
  107. FUNCMUX_UART2_UAD,
  108. -1,
  109. FUNCMUX_UART4_GMC,
  110. -1,
  111. #elif defined(CONFIG_TEGRA30)
  112. FUNCMUX_UART1_ULPI, /* UARTA */
  113. -1,
  114. -1,
  115. -1,
  116. -1,
  117. #else /* Tegra114 */
  118. -1,
  119. -1,
  120. -1,
  121. FUNCMUX_UART4_GMI, /* UARTD */
  122. -1,
  123. #endif
  124. };
  125. /**
  126. * Set up the specified uarts
  127. *
  128. * @param uarts_ids Mask containing UARTs to init (UARTx)
  129. */
  130. static void setup_uarts(int uart_ids)
  131. {
  132. static enum periph_id id_for_uart[] = {
  133. PERIPH_ID_UART1,
  134. PERIPH_ID_UART2,
  135. PERIPH_ID_UART3,
  136. PERIPH_ID_UART4,
  137. PERIPH_ID_UART5,
  138. };
  139. size_t i;
  140. for (i = 0; i < UART_COUNT; i++) {
  141. if (uart_ids & (1 << i)) {
  142. enum periph_id id = id_for_uart[i];
  143. funcmux_select(id, uart_configs[i]);
  144. clock_ll_start_uart(id);
  145. }
  146. }
  147. }
  148. void board_init_uart_f(void)
  149. {
  150. int uart_ids = 0; /* bit mask of which UART ids to enable */
  151. #ifdef CONFIG_TEGRA_ENABLE_UARTA
  152. uart_ids |= UARTA;
  153. #endif
  154. #ifdef CONFIG_TEGRA_ENABLE_UARTB
  155. uart_ids |= UARTB;
  156. #endif
  157. #ifdef CONFIG_TEGRA_ENABLE_UARTC
  158. uart_ids |= UARTC;
  159. #endif
  160. #ifdef CONFIG_TEGRA_ENABLE_UARTD
  161. uart_ids |= UARTD;
  162. #endif
  163. #ifdef CONFIG_TEGRA_ENABLE_UARTE
  164. uart_ids |= UARTE;
  165. #endif
  166. setup_uarts(uart_ids);
  167. }
  168. #ifndef CONFIG_SYS_DCACHE_OFF
  169. void enable_caches(void)
  170. {
  171. /* Enable D-cache. I-cache is already enabled in start.S */
  172. dcache_enable();
  173. }
  174. #endif