board.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. UARTD = 1 << 3,
  38. UART_COUNT = 4,
  39. };
  40. /*
  41. * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
  42. * so we are using this value to identify memory size.
  43. */
  44. unsigned int query_sdram_size(void)
  45. {
  46. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
  47. u32 reg;
  48. reg = readl(&pmc->pmc_scratch20);
  49. debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
  50. #if defined(CONFIG_TEGRA20)
  51. /* bits 30:28 in OdmData are used for RAM size on T20 */
  52. reg &= 0x70000000;
  53. switch ((reg) >> 28) {
  54. case 1:
  55. return 0x10000000; /* 256 MB */
  56. case 0:
  57. case 2:
  58. default:
  59. return 0x20000000; /* 512 MB */
  60. case 3:
  61. return 0x40000000; /* 1GB */
  62. }
  63. #else /* Tegra30 */
  64. /* bits 31:28 in OdmData are used for RAM size on T30 */
  65. switch ((reg) >> 28) {
  66. case 0:
  67. case 1:
  68. default:
  69. return 0x10000000; /* 256 MB */
  70. case 2:
  71. return 0x20000000; /* 512 MB */
  72. case 3:
  73. return 0x30000000; /* 768 MB */
  74. case 4:
  75. return 0x40000000; /* 1GB */
  76. case 8:
  77. return 0x7ff00000; /* 2GB - 1MB */
  78. }
  79. #endif
  80. }
  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_UARTB,
  106. -1,
  107. FUNCMUX_UART4_GMC,
  108. -1,
  109. #else /* Tegra30 */
  110. FUNCMUX_UART1_ULPI, /* UARTA */
  111. -1,
  112. -1,
  113. -1,
  114. -1,
  115. #endif
  116. };
  117. /**
  118. * Set up the specified uarts
  119. *
  120. * @param uarts_ids Mask containing UARTs to init (UARTx)
  121. */
  122. static void setup_uarts(int uart_ids)
  123. {
  124. static enum periph_id id_for_uart[] = {
  125. PERIPH_ID_UART1,
  126. PERIPH_ID_UART2,
  127. PERIPH_ID_UART3,
  128. PERIPH_ID_UART4,
  129. };
  130. size_t i;
  131. for (i = 0; i < UART_COUNT; i++) {
  132. if (uart_ids & (1 << i)) {
  133. enum periph_id id = id_for_uart[i];
  134. funcmux_select(id, uart_configs[i]);
  135. clock_ll_start_uart(id);
  136. }
  137. }
  138. }
  139. void board_init_uart_f(void)
  140. {
  141. int uart_ids = 0; /* bit mask of which UART ids to enable */
  142. #ifdef CONFIG_TEGRA_ENABLE_UARTA
  143. uart_ids |= UARTA;
  144. #endif
  145. #ifdef CONFIG_TEGRA_ENABLE_UARTB
  146. uart_ids |= UARTB;
  147. #endif
  148. #ifdef CONFIG_TEGRA_ENABLE_UARTD
  149. uart_ids |= UARTD;
  150. #endif
  151. setup_uarts(uart_ids);
  152. }
  153. #ifndef CONFIG_SYS_DCACHE_OFF
  154. void enable_caches(void)
  155. {
  156. /* Enable D-cache. I-cache is already enabled in start.S */
  157. dcache_enable();
  158. }
  159. #endif