board.c 3.8 KB

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