blob: f16fe68a66492cfc3f9e605cdfa5789b0b8f1ef2 [file] [log] [blame]
Tom Warren41b68382011-01-27 10:58:05 +00001/*
Tom Warrene5ffffd2014-01-24 12:46:16 -07002 * (C) Copyright 2010-2014
Tom Warren41b68382011-01-27 10:58:05 +00003 * NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Tom Warren41b68382011-01-27 10:58:05 +00006 */
7
8#include <common.h>
9#include <asm/io.h>
Simon Glass96b7c432011-11-28 15:04:39 +000010#include <asm/arch/clock.h>
11#include <asm/arch/funcmux.h>
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020012#include <asm/arch/mc.h>
Tom Warrenab371962012-09-19 15:50:56 -070013#include <asm/arch/tegra.h>
Lucas Stache80f7ca2012-09-29 10:02:08 +000014#include <asm/arch-tegra/board.h>
Tom Warrenab371962012-09-19 15:50:56 -070015#include <asm/arch-tegra/pmc.h>
16#include <asm/arch-tegra/sys_proto.h>
17#include <asm/arch-tegra/warmboot.h>
Tom Warren41b68382011-01-27 10:58:05 +000018
19DECLARE_GLOBAL_DATA_PTR;
20
Simon Glass96b7c432011-11-28 15:04:39 +000021enum {
22 /* UARTs which we can enable */
23 UARTA = 1 << 0,
24 UARTB = 1 << 1,
Tom Warrene3d95bc2013-01-28 13:32:10 +000025 UARTC = 1 << 2,
Simon Glass96b7c432011-11-28 15:04:39 +000026 UARTD = 1 << 3,
Tom Warrene3d95bc2013-01-28 13:32:10 +000027 UARTE = 1 << 4,
28 UART_COUNT = 5,
Simon Glass96b7c432011-11-28 15:04:39 +000029};
30
Stephen Warren1b4af6b2014-07-02 14:12:30 -060031/* Read the RAM size directly from the memory controller */
32unsigned int query_sdram_size(void)
33{
34 struct mc_ctlr *const mc = (struct mc_ctlr *)NV_PA_MC_BASE;
Stephen Warren210bdb22014-12-23 10:34:50 -070035 u32 emem_cfg, size_bytes;
Stephen Warren1b4af6b2014-07-02 14:12:30 -060036
Stephen Warren210bdb22014-12-23 10:34:50 -070037 emem_cfg = readl(&mc->mc_emem_cfg);
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020038#if defined(CONFIG_TEGRA20)
Stephen Warren210bdb22014-12-23 10:34:50 -070039 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);
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020041#else
Stephen Warren210bdb22014-12-23 10:34:50 -070042 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);
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020044#endif
Stephen Warren1b4af6b2014-07-02 14:12:30 -060045
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020046#if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114)
47 /* External memory limited to 2047 MB due to IROM/HI-VEC */
Stephen Warren210bdb22014-12-23 10:34:50 -070048 if (size_bytes == SZ_2G)
49 size_bytes -= SZ_1M;
Stephen Warren1b4af6b2014-07-02 14:12:30 -060050#endif
Tom Warren41b68382011-01-27 10:58:05 +000051
Stephen Warren210bdb22014-12-23 10:34:50 -070052 return size_bytes;
Marcel Ziswilerc5ecf272014-10-10 23:32:32 +020053}
54
Tom Warren41b68382011-01-27 10:58:05 +000055int dram_init(void)
56{
Tom Warren41b68382011-01-27 10:58:05 +000057 /* We do not initialise DRAM here. We just query the size */
Simon Glassf6fcbbd2011-11-05 03:56:57 +000058 gd->ram_size = query_sdram_size();
Tom Warren41b68382011-01-27 10:58:05 +000059 return 0;
60}
61
62#ifdef CONFIG_DISPLAY_BOARDINFO
63int checkboard(void)
64{
65 printf("Board: %s\n", sysinfo.board_string);
66 return 0;
67}
68#endif /* CONFIG_DISPLAY_BOARDINFO */
Simon Glass5f3a8992011-11-05 03:56:49 +000069
Stephen Warren59f90102012-05-14 13:13:45 +000070static int uart_configs[] = {
Tom Warren61c6d0e2012-12-11 13:34:15 +000071#if defined(CONFIG_TEGRA20)
72 #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
Stephen Warren59f90102012-05-14 13:13:45 +000073 FUNCMUX_UART1_UAA_UAB,
Tom Warren61c6d0e2012-12-11 13:34:15 +000074 #elif defined(CONFIG_TEGRA_UARTA_GPU)
Stephen Warrene4c01a82012-05-16 05:59:59 +000075 FUNCMUX_UART1_GPU,
Tom Warren61c6d0e2012-12-11 13:34:15 +000076 #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
Lucas Stach4de6eec2012-05-16 08:21:02 +000077 FUNCMUX_UART1_SDIO1,
Tom Warren61c6d0e2012-12-11 13:34:15 +000078 #else
Stephen Warren59f90102012-05-14 13:13:45 +000079 FUNCMUX_UART1_IRRX_IRTX,
Stephen Warren811af732013-01-22 06:20:08 +000080#endif
81 FUNCMUX_UART2_UAD,
Stephen Warren59f90102012-05-14 13:13:45 +000082 -1,
83 FUNCMUX_UART4_GMC,
84 -1,
Tom Warrene3d95bc2013-01-28 13:32:10 +000085#elif defined(CONFIG_TEGRA30)
Tom Warren61c6d0e2012-12-11 13:34:15 +000086 FUNCMUX_UART1_ULPI, /* UARTA */
87 -1,
88 -1,
89 -1,
90 -1,
Tom Warrene5ffffd2014-01-24 12:46:16 -070091#elif defined(CONFIG_TEGRA114)
Tom Warrene3d95bc2013-01-28 13:32:10 +000092 -1,
93 -1,
94 -1,
95 FUNCMUX_UART4_GMI, /* UARTD */
96 -1,
Tom Warrene5ffffd2014-01-24 12:46:16 -070097#else /* Tegra124 */
98 FUNCMUX_UART1_KBC, /* UARTA */
99 -1,
100 -1,
101 FUNCMUX_UART4_GPIO, /* UARTD */
102 -1,
Tom Warren61c6d0e2012-12-11 13:34:15 +0000103#endif
Stephen Warren59f90102012-05-14 13:13:45 +0000104};
105
Simon Glass96b7c432011-11-28 15:04:39 +0000106/**
107 * Set up the specified uarts
108 *
109 * @param uarts_ids Mask containing UARTs to init (UARTx)
110 */
111static void setup_uarts(int uart_ids)
112{
113 static enum periph_id id_for_uart[] = {
114 PERIPH_ID_UART1,
115 PERIPH_ID_UART2,
116 PERIPH_ID_UART3,
117 PERIPH_ID_UART4,
Tom Warrene3d95bc2013-01-28 13:32:10 +0000118 PERIPH_ID_UART5,
Simon Glass96b7c432011-11-28 15:04:39 +0000119 };
120 size_t i;
121
122 for (i = 0; i < UART_COUNT; i++) {
123 if (uart_ids & (1 << i)) {
124 enum periph_id id = id_for_uart[i];
125
Stephen Warren59f90102012-05-14 13:13:45 +0000126 funcmux_select(id, uart_configs[i]);
Simon Glass96b7c432011-11-28 15:04:39 +0000127 clock_ll_start_uart(id);
128 }
129 }
130}
131
132void board_init_uart_f(void)
133{
134 int uart_ids = 0; /* bit mask of which UART ids to enable */
135
Tom Warren22562a42012-09-04 17:00:24 -0700136#ifdef CONFIG_TEGRA_ENABLE_UARTA
Simon Glass96b7c432011-11-28 15:04:39 +0000137 uart_ids |= UARTA;
138#endif
Tom Warren22562a42012-09-04 17:00:24 -0700139#ifdef CONFIG_TEGRA_ENABLE_UARTB
Simon Glass96b7c432011-11-28 15:04:39 +0000140 uart_ids |= UARTB;
141#endif
Tom Warrene3d95bc2013-01-28 13:32:10 +0000142#ifdef CONFIG_TEGRA_ENABLE_UARTC
143 uart_ids |= UARTC;
144#endif
Tom Warren22562a42012-09-04 17:00:24 -0700145#ifdef CONFIG_TEGRA_ENABLE_UARTD
Simon Glass96b7c432011-11-28 15:04:39 +0000146 uart_ids |= UARTD;
147#endif
Tom Warrene3d95bc2013-01-28 13:32:10 +0000148#ifdef CONFIG_TEGRA_ENABLE_UARTE
149 uart_ids |= UARTE;
150#endif
Simon Glass96b7c432011-11-28 15:04:39 +0000151 setup_uarts(uart_ids);
152}
Simon Glass410012f2012-01-09 13:22:15 +0000153
154#ifndef CONFIG_SYS_DCACHE_OFF
155void enable_caches(void)
156{
157 /* Enable D-cache. I-cache is already enabled in start.S */
158 dcache_enable();
159}
160#endif