board.c 3.4 KB

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