board.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/pmc.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/arch/tegra20.h>
  30. #include <asm/arch/warmboot.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. enum {
  33. /* UARTs which we can enable */
  34. UARTA = 1 << 0,
  35. UARTB = 1 << 1,
  36. UARTD = 1 << 3,
  37. UART_COUNT = 4,
  38. };
  39. /*
  40. * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
  41. * so we are using this value to identify memory size.
  42. */
  43. unsigned int query_sdram_size(void)
  44. {
  45. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)TEGRA20_PMC_BASE;
  46. u32 reg;
  47. reg = readl(&pmc->pmc_scratch20);
  48. debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
  49. /* bits 31:28 in OdmData are used for RAM size */
  50. switch ((reg) >> 28) {
  51. case 1:
  52. return 0x10000000; /* 256 MB */
  53. case 2:
  54. default:
  55. return 0x20000000; /* 512 MB */
  56. case 3:
  57. return 0x40000000; /* 1GB */
  58. }
  59. }
  60. int dram_init(void)
  61. {
  62. /* We do not initialise DRAM here. We just query the size */
  63. gd->ram_size = query_sdram_size();
  64. return 0;
  65. }
  66. #ifdef CONFIG_DISPLAY_BOARDINFO
  67. int checkboard(void)
  68. {
  69. printf("Board: %s\n", sysinfo.board_string);
  70. return 0;
  71. }
  72. #endif /* CONFIG_DISPLAY_BOARDINFO */
  73. static int uart_configs[] = {
  74. #if defined(CONFIG_TEGRA20_UARTA_UAA_UAB)
  75. FUNCMUX_UART1_UAA_UAB,
  76. #elif defined(CONFIG_TEGRA20_UARTA_GPU)
  77. FUNCMUX_UART1_GPU,
  78. #elif defined(CONFIG_TEGRA20_UARTA_SDIO1)
  79. FUNCMUX_UART1_SDIO1,
  80. #else
  81. FUNCMUX_UART1_IRRX_IRTX,
  82. #endif
  83. FUNCMUX_UART2_IRDA,
  84. -1,
  85. FUNCMUX_UART4_GMC,
  86. -1,
  87. };
  88. /**
  89. * Set up the specified uarts
  90. *
  91. * @param uarts_ids Mask containing UARTs to init (UARTx)
  92. */
  93. static void setup_uarts(int uart_ids)
  94. {
  95. static enum periph_id id_for_uart[] = {
  96. PERIPH_ID_UART1,
  97. PERIPH_ID_UART2,
  98. PERIPH_ID_UART3,
  99. PERIPH_ID_UART4,
  100. };
  101. size_t i;
  102. for (i = 0; i < UART_COUNT; i++) {
  103. if (uart_ids & (1 << i)) {
  104. enum periph_id id = id_for_uart[i];
  105. funcmux_select(id, uart_configs[i]);
  106. clock_ll_start_uart(id);
  107. }
  108. }
  109. }
  110. void board_init_uart_f(void)
  111. {
  112. int uart_ids = 0; /* bit mask of which UART ids to enable */
  113. #ifdef CONFIG_TEGRA20_ENABLE_UARTA
  114. uart_ids |= UARTA;
  115. #endif
  116. #ifdef CONFIG_TEGRA20_ENABLE_UARTB
  117. uart_ids |= UARTB;
  118. #endif
  119. #ifdef CONFIG_TEGRA20_ENABLE_UARTD
  120. uart_ids |= UARTD;
  121. #endif
  122. setup_uarts(uart_ids);
  123. }
  124. #ifndef CONFIG_SYS_DCACHE_OFF
  125. void enable_caches(void)
  126. {
  127. /* Enable D-cache. I-cache is already enabled in start.S */
  128. dcache_enable();
  129. }
  130. #endif