board.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 "ap20.h"
  26. #include <asm/arch/clock.h>
  27. #include <asm/arch/funcmux.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/arch/tegra2.h>
  30. #include <asm/arch/pmc.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 *)NV_PA_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. #ifdef CONFIG_ARCH_CPU_INIT
  74. /*
  75. * Note this function is executed by the ARM7TDMI AVP. It does not return
  76. * in this case. It is also called once the A9 starts up, but does nothing in
  77. * that case.
  78. */
  79. int arch_cpu_init(void)
  80. {
  81. /* Fire up the Cortex A9 */
  82. tegra2_start();
  83. /* We didn't do this init in start.S, so do it now */
  84. cpu_init_cp15();
  85. /* Initialize essential common plls */
  86. clock_early_init();
  87. return 0;
  88. }
  89. #endif
  90. /**
  91. * Set up the specified uarts
  92. *
  93. * @param uarts_ids Mask containing UARTs to init (UARTx)
  94. */
  95. static void setup_uarts(int uart_ids)
  96. {
  97. static enum periph_id id_for_uart[] = {
  98. PERIPH_ID_UART1,
  99. PERIPH_ID_UART2,
  100. PERIPH_ID_UART3,
  101. PERIPH_ID_UART4,
  102. };
  103. size_t i;
  104. for (i = 0; i < UART_COUNT; i++) {
  105. if (uart_ids & (1 << i)) {
  106. enum periph_id id = id_for_uart[i];
  107. funcmux_select(id, FUNCMUX_DEFAULT);
  108. clock_ll_start_uart(id);
  109. }
  110. }
  111. }
  112. void board_init_uart_f(void)
  113. {
  114. int uart_ids = 0; /* bit mask of which UART ids to enable */
  115. #ifdef CONFIG_TEGRA2_ENABLE_UARTA
  116. uart_ids |= UARTA;
  117. #endif
  118. #ifdef CONFIG_TEGRA2_ENABLE_UARTB
  119. uart_ids |= UARTB;
  120. #endif
  121. #ifdef CONFIG_TEGRA2_ENABLE_UARTD
  122. uart_ids |= UARTD;
  123. #endif
  124. setup_uarts(uart_ids);
  125. }