board.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. /* bits 31:28 in OdmData are used for RAM size */
  51. switch ((reg) >> 28) {
  52. case 1:
  53. return 0x10000000; /* 256 MB */
  54. case 2:
  55. default:
  56. return 0x20000000; /* 512 MB */
  57. case 3:
  58. return 0x40000000; /* 1GB */
  59. }
  60. }
  61. int dram_init(void)
  62. {
  63. /* We do not initialise DRAM here. We just query the size */
  64. gd->ram_size = query_sdram_size();
  65. return 0;
  66. }
  67. #ifdef CONFIG_DISPLAY_BOARDINFO
  68. int checkboard(void)
  69. {
  70. printf("Board: %s\n", sysinfo.board_string);
  71. return 0;
  72. }
  73. #endif /* CONFIG_DISPLAY_BOARDINFO */
  74. static int uart_configs[] = {
  75. #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
  76. FUNCMUX_UART1_UAA_UAB,
  77. #elif defined(CONFIG_TEGRA_UARTA_GPU)
  78. FUNCMUX_UART1_GPU,
  79. #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
  80. FUNCMUX_UART1_SDIO1,
  81. #else
  82. FUNCMUX_UART1_IRRX_IRTX,
  83. #endif
  84. FUNCMUX_UART2_IRDA,
  85. -1,
  86. FUNCMUX_UART4_GMC,
  87. -1,
  88. };
  89. /**
  90. * Set up the specified uarts
  91. *
  92. * @param uarts_ids Mask containing UARTs to init (UARTx)
  93. */
  94. static void setup_uarts(int uart_ids)
  95. {
  96. static enum periph_id id_for_uart[] = {
  97. PERIPH_ID_UART1,
  98. PERIPH_ID_UART2,
  99. PERIPH_ID_UART3,
  100. PERIPH_ID_UART4,
  101. };
  102. size_t i;
  103. for (i = 0; i < UART_COUNT; i++) {
  104. if (uart_ids & (1 << i)) {
  105. enum periph_id id = id_for_uart[i];
  106. funcmux_select(id, uart_configs[i]);
  107. clock_ll_start_uart(id);
  108. }
  109. }
  110. }
  111. void board_init_uart_f(void)
  112. {
  113. int uart_ids = 0; /* bit mask of which UART ids to enable */
  114. #ifdef CONFIG_TEGRA_ENABLE_UARTA
  115. uart_ids |= UARTA;
  116. #endif
  117. #ifdef CONFIG_TEGRA_ENABLE_UARTB
  118. uart_ids |= UARTB;
  119. #endif
  120. #ifdef CONFIG_TEGRA_ENABLE_UARTD
  121. uart_ids |= UARTD;
  122. #endif
  123. setup_uarts(uart_ids);
  124. }
  125. #ifndef CONFIG_SYS_DCACHE_OFF
  126. void enable_caches(void)
  127. {
  128. /* Enable D-cache. I-cache is already enabled in start.S */
  129. dcache_enable();
  130. }
  131. #endif