2 * (C) Copyright 2010-2014
3 * NVIDIA Corporation <www.nvidia.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/clock.h>
11 #include <asm/arch/funcmux.h>
12 #include <asm/arch/mc.h>
13 #include <asm/arch/tegra.h>
14 #include <asm/arch-tegra/board.h>
15 #include <asm/arch-tegra/pmc.h>
16 #include <asm/arch-tegra/sys_proto.h>
17 #include <asm/arch-tegra/warmboot.h>
19 DECLARE_GLOBAL_DATA_PTR;
22 /* UARTs which we can enable */
31 /* Read the RAM size directly from the memory controller */
32 unsigned int query_sdram_size(void)
34 struct mc_ctlr *const mc = (struct mc_ctlr *)NV_PA_MC_BASE;
35 u32 emem_cfg, size_bytes;
37 emem_cfg = readl(&mc->mc_emem_cfg);
38 #if defined(CONFIG_TEGRA20)
39 debug("mc->mc_emem_cfg (MEM_SIZE_KB) = 0x%08x\n", emem_cfg);
40 size_bytes = get_ram_size((void *)PHYS_SDRAM_1, emem_cfg * 1024);
42 debug("mc->mc_emem_cfg (MEM_SIZE_MB) = 0x%08x\n", emem_cfg);
43 size_bytes = get_ram_size((void *)PHYS_SDRAM_1, emem_cfg * 1024 * 1024);
46 #if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114)
47 /* External memory limited to 2047 MB due to IROM/HI-VEC */
48 if (size_bytes == SZ_2G)
57 /* We do not initialise DRAM here. We just query the size */
58 gd->ram_size = query_sdram_size();
62 #ifdef CONFIG_DISPLAY_BOARDINFO
65 printf("Board: %s\n", sysinfo.board_string);
68 #endif /* CONFIG_DISPLAY_BOARDINFO */
70 static int uart_configs[] = {
71 #if defined(CONFIG_TEGRA20)
72 #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
73 FUNCMUX_UART1_UAA_UAB,
74 #elif defined(CONFIG_TEGRA_UARTA_GPU)
76 #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
79 FUNCMUX_UART1_IRRX_IRTX,
85 #elif defined(CONFIG_TEGRA30)
86 FUNCMUX_UART1_ULPI, /* UARTA */
91 #elif defined(CONFIG_TEGRA114)
95 FUNCMUX_UART4_GMI, /* UARTD */
98 FUNCMUX_UART1_KBC, /* UARTA */
101 FUNCMUX_UART4_GPIO, /* UARTD */
107 * Set up the specified uarts
109 * @param uarts_ids Mask containing UARTs to init (UARTx)
111 static void setup_uarts(int uart_ids)
113 static enum periph_id id_for_uart[] = {
122 for (i = 0; i < UART_COUNT; i++) {
123 if (uart_ids & (1 << i)) {
124 enum periph_id id = id_for_uart[i];
126 funcmux_select(id, uart_configs[i]);
127 clock_ll_start_uart(id);
132 void board_init_uart_f(void)
134 int uart_ids = 0; /* bit mask of which UART ids to enable */
136 #ifdef CONFIG_TEGRA_ENABLE_UARTA
139 #ifdef CONFIG_TEGRA_ENABLE_UARTB
142 #ifdef CONFIG_TEGRA_ENABLE_UARTC
145 #ifdef CONFIG_TEGRA_ENABLE_UARTD
148 #ifdef CONFIG_TEGRA_ENABLE_UARTE
151 setup_uarts(uart_ids);
154 #ifndef CONFIG_SYS_DCACHE_OFF
155 void enable_caches(void)
157 /* Enable D-cache. I-cache is already enabled in start.S */