board.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/mc.h>
  12. #include <asm/arch/tegra.h>
  13. #include <asm/arch-tegra/board.h>
  14. #include <asm/arch-tegra/pmc.h>
  15. #include <asm/arch-tegra/sys_proto.h>
  16. #include <asm/arch-tegra/warmboot.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. enum {
  19. /* UARTs which we can enable */
  20. UARTA = 1 << 0,
  21. UARTB = 1 << 1,
  22. UARTC = 1 << 2,
  23. UARTD = 1 << 3,
  24. UARTE = 1 << 4,
  25. UART_COUNT = 5,
  26. };
  27. /* Read the RAM size directly from the memory controller */
  28. unsigned int query_sdram_size(void)
  29. {
  30. struct mc_ctlr *const mc = (struct mc_ctlr *)NV_PA_MC_BASE;
  31. u32 size_mb;
  32. size_mb = readl(&mc->mc_emem_cfg);
  33. #if defined(CONFIG_TEGRA20)
  34. debug("mc->mc_emem_cfg (MEM_SIZE_KB) = 0x%08x\n", size_mb);
  35. size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024);
  36. #else
  37. debug("mc->mc_emem_cfg (MEM_SIZE_MB) = 0x%08x\n", size_mb);
  38. size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024 * 1024);
  39. #endif
  40. #if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114)
  41. /* External memory limited to 2047 MB due to IROM/HI-VEC */
  42. if (size_mb == SZ_2G) size_mb -= SZ_1M;
  43. #endif
  44. return size_mb;
  45. }
  46. int dram_init(void)
  47. {
  48. /* We do not initialise DRAM here. We just query the size */
  49. gd->ram_size = query_sdram_size();
  50. return 0;
  51. }
  52. #ifdef CONFIG_DISPLAY_BOARDINFO
  53. int checkboard(void)
  54. {
  55. printf("Board: %s\n", sysinfo.board_string);
  56. return 0;
  57. }
  58. #endif /* CONFIG_DISPLAY_BOARDINFO */
  59. static int uart_configs[] = {
  60. #if defined(CONFIG_TEGRA20)
  61. #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
  62. FUNCMUX_UART1_UAA_UAB,
  63. #elif defined(CONFIG_TEGRA_UARTA_GPU)
  64. FUNCMUX_UART1_GPU,
  65. #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
  66. FUNCMUX_UART1_SDIO1,
  67. #else
  68. FUNCMUX_UART1_IRRX_IRTX,
  69. #endif
  70. FUNCMUX_UART2_UAD,
  71. -1,
  72. FUNCMUX_UART4_GMC,
  73. -1,
  74. #elif defined(CONFIG_TEGRA30)
  75. FUNCMUX_UART1_ULPI, /* UARTA */
  76. -1,
  77. -1,
  78. -1,
  79. -1,
  80. #elif defined(CONFIG_TEGRA114)
  81. -1,
  82. -1,
  83. -1,
  84. FUNCMUX_UART4_GMI, /* UARTD */
  85. -1,
  86. #else /* Tegra124 */
  87. FUNCMUX_UART1_KBC, /* UARTA */
  88. -1,
  89. -1,
  90. FUNCMUX_UART4_GPIO, /* UARTD */
  91. -1,
  92. #endif
  93. };
  94. /**
  95. * Set up the specified uarts
  96. *
  97. * @param uarts_ids Mask containing UARTs to init (UARTx)
  98. */
  99. static void setup_uarts(int uart_ids)
  100. {
  101. static enum periph_id id_for_uart[] = {
  102. PERIPH_ID_UART1,
  103. PERIPH_ID_UART2,
  104. PERIPH_ID_UART3,
  105. PERIPH_ID_UART4,
  106. PERIPH_ID_UART5,
  107. };
  108. size_t i;
  109. for (i = 0; i < UART_COUNT; i++) {
  110. if (uart_ids & (1 << i)) {
  111. enum periph_id id = id_for_uart[i];
  112. funcmux_select(id, uart_configs[i]);
  113. clock_ll_start_uart(id);
  114. }
  115. }
  116. }
  117. void board_init_uart_f(void)
  118. {
  119. int uart_ids = 0; /* bit mask of which UART ids to enable */
  120. #ifdef CONFIG_TEGRA_ENABLE_UARTA
  121. uart_ids |= UARTA;
  122. #endif
  123. #ifdef CONFIG_TEGRA_ENABLE_UARTB
  124. uart_ids |= UARTB;
  125. #endif
  126. #ifdef CONFIG_TEGRA_ENABLE_UARTC
  127. uart_ids |= UARTC;
  128. #endif
  129. #ifdef CONFIG_TEGRA_ENABLE_UARTD
  130. uart_ids |= UARTD;
  131. #endif
  132. #ifdef CONFIG_TEGRA_ENABLE_UARTE
  133. uart_ids |= UARTE;
  134. #endif
  135. setup_uarts(uart_ids);
  136. }
  137. #ifndef CONFIG_SYS_DCACHE_OFF
  138. void enable_caches(void)
  139. {
  140. /* Enable D-cache. I-cache is already enabled in start.S */
  141. dcache_enable();
  142. }
  143. #endif