blob: b6a84a577478a11374ad3e46ed75bc2c437f59ea [file] [log] [blame]
Tom Warren3f82b1d2011-01-27 10:58:05 +00001/*
Tom Warren2f5dac92014-01-24 12:46:16 -07002 * (C) Copyright 2010-2014
Tom Warren3f82b1d2011-01-27 10:58:05 +00003 * NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Tom Warren3f82b1d2011-01-27 10:58:05 +00006 */
7
8#include <common.h>
9#include <asm/io.h>
Simon Glassbb6997f2011-11-28 15:04:39 +000010#include <asm/arch/clock.h>
11#include <asm/arch/funcmux.h>
Marcel Ziswiler8c33ba72014-10-10 23:32:32 +020012#include <asm/arch/mc.h>
Tom Warren150c2492012-09-19 15:50:56 -070013#include <asm/arch/tegra.h>
Lucas Stach516f00b2012-09-29 10:02:08 +000014#include <asm/arch-tegra/board.h>
Tom Warren150c2492012-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 Warren3f82b1d2011-01-27 10:58:05 +000018
19DECLARE_GLOBAL_DATA_PTR;
20
Simon Glassbb6997f2011-11-28 15:04:39 +000021enum {
22 /* UARTs which we can enable */
23 UARTA = 1 << 0,
24 UARTB = 1 << 1,
Tom Warrene23bb6a2013-01-28 13:32:10 +000025 UARTC = 1 << 2,
Simon Glassbb6997f2011-11-28 15:04:39 +000026 UARTD = 1 << 3,
Tom Warrene23bb6a2013-01-28 13:32:10 +000027 UARTE = 1 << 4,
28 UART_COUNT = 5,
Simon Glassbb6997f2011-11-28 15:04:39 +000029};
30
Stephen Warrenaeb3fcb2014-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;
35 u32 size_mb;
36
37 size_mb = readl(&mc->mc_emem_cfg);
Marcel Ziswiler8c33ba72014-10-10 23:32:32 +020038#if defined(CONFIG_TEGRA20)
39 debug("mc->mc_emem_cfg (MEM_SIZE_KB) = 0x%08x\n", size_mb);
40 size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024);
41#else
Stephen Warrenaeb3fcb2014-07-02 14:12:30 -060042 debug("mc->mc_emem_cfg (MEM_SIZE_MB) = 0x%08x\n", size_mb);
Marcel Ziswiler8c33ba72014-10-10 23:32:32 +020043 size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024 * 1024);
Stephen Warrenaeb3fcb2014-07-02 14:12:30 -060044#endif
Tom Warren3f82b1d2011-01-27 10:58:05 +000045
Marcel Ziswiler8c33ba72014-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 */
48 if (size_mb == SZ_2G) size_mb -= SZ_1M;
49#endif
50
51 return size_mb;
52}
53
Tom Warren3f82b1d2011-01-27 10:58:05 +000054int dram_init(void)
55{
Tom Warren3f82b1d2011-01-27 10:58:05 +000056 /* We do not initialise DRAM here. We just query the size */
Simon Glass7f8c0702011-11-05 03:56:57 +000057 gd->ram_size = query_sdram_size();
Tom Warren3f82b1d2011-01-27 10:58:05 +000058 return 0;
59}
60
61#ifdef CONFIG_DISPLAY_BOARDINFO
62int checkboard(void)
63{
64 printf("Board: %s\n", sysinfo.board_string);
65 return 0;
66}
67#endif /* CONFIG_DISPLAY_BOARDINFO */
Simon Glasse43d6ed2011-11-05 03:56:49 +000068
Stephen Warrenb9607e72012-05-14 13:13:45 +000069static int uart_configs[] = {
Tom Warrenb2871032012-12-11 13:34:15 +000070#if defined(CONFIG_TEGRA20)
71 #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
Stephen Warrenb9607e72012-05-14 13:13:45 +000072 FUNCMUX_UART1_UAA_UAB,
Tom Warrenb2871032012-12-11 13:34:15 +000073 #elif defined(CONFIG_TEGRA_UARTA_GPU)
Stephen Warrene21649b2012-05-16 05:59:59 +000074 FUNCMUX_UART1_GPU,
Tom Warrenb2871032012-12-11 13:34:15 +000075 #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
Lucas Stacha2cfe632012-05-16 08:21:02 +000076 FUNCMUX_UART1_SDIO1,
Tom Warrenb2871032012-12-11 13:34:15 +000077 #else
Stephen Warrenb9607e72012-05-14 13:13:45 +000078 FUNCMUX_UART1_IRRX_IRTX,
Stephen Warren4727a132013-01-22 06:20:08 +000079#endif
80 FUNCMUX_UART2_UAD,
Stephen Warrenb9607e72012-05-14 13:13:45 +000081 -1,
82 FUNCMUX_UART4_GMC,
83 -1,
Tom Warrene23bb6a2013-01-28 13:32:10 +000084#elif defined(CONFIG_TEGRA30)
Tom Warrenb2871032012-12-11 13:34:15 +000085 FUNCMUX_UART1_ULPI, /* UARTA */
86 -1,
87 -1,
88 -1,
89 -1,
Tom Warren2f5dac92014-01-24 12:46:16 -070090#elif defined(CONFIG_TEGRA114)
Tom Warrene23bb6a2013-01-28 13:32:10 +000091 -1,
92 -1,
93 -1,
94 FUNCMUX_UART4_GMI, /* UARTD */
95 -1,
Tom Warren2f5dac92014-01-24 12:46:16 -070096#else /* Tegra124 */
97 FUNCMUX_UART1_KBC, /* UARTA */
98 -1,
99 -1,
100 FUNCMUX_UART4_GPIO, /* UARTD */
101 -1,
Tom Warrenb2871032012-12-11 13:34:15 +0000102#endif
Stephen Warrenb9607e72012-05-14 13:13:45 +0000103};
104
Simon Glassbb6997f2011-11-28 15:04:39 +0000105/**
106 * Set up the specified uarts
107 *
108 * @param uarts_ids Mask containing UARTs to init (UARTx)
109 */
110static void setup_uarts(int uart_ids)
111{
112 static enum periph_id id_for_uart[] = {
113 PERIPH_ID_UART1,
114 PERIPH_ID_UART2,
115 PERIPH_ID_UART3,
116 PERIPH_ID_UART4,
Tom Warrene23bb6a2013-01-28 13:32:10 +0000117 PERIPH_ID_UART5,
Simon Glassbb6997f2011-11-28 15:04:39 +0000118 };
119 size_t i;
120
121 for (i = 0; i < UART_COUNT; i++) {
122 if (uart_ids & (1 << i)) {
123 enum periph_id id = id_for_uart[i];
124
Stephen Warrenb9607e72012-05-14 13:13:45 +0000125 funcmux_select(id, uart_configs[i]);
Simon Glassbb6997f2011-11-28 15:04:39 +0000126 clock_ll_start_uart(id);
127 }
128 }
129}
130
131void board_init_uart_f(void)
132{
133 int uart_ids = 0; /* bit mask of which UART ids to enable */
134
Tom Warren29f3e3f2012-09-04 17:00:24 -0700135#ifdef CONFIG_TEGRA_ENABLE_UARTA
Simon Glassbb6997f2011-11-28 15:04:39 +0000136 uart_ids |= UARTA;
137#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700138#ifdef CONFIG_TEGRA_ENABLE_UARTB
Simon Glassbb6997f2011-11-28 15:04:39 +0000139 uart_ids |= UARTB;
140#endif
Tom Warrene23bb6a2013-01-28 13:32:10 +0000141#ifdef CONFIG_TEGRA_ENABLE_UARTC
142 uart_ids |= UARTC;
143#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700144#ifdef CONFIG_TEGRA_ENABLE_UARTD
Simon Glassbb6997f2011-11-28 15:04:39 +0000145 uart_ids |= UARTD;
146#endif
Tom Warrene23bb6a2013-01-28 13:32:10 +0000147#ifdef CONFIG_TEGRA_ENABLE_UARTE
148 uart_ids |= UARTE;
149#endif
Simon Glassbb6997f2011-11-28 15:04:39 +0000150 setup_uarts(uart_ids);
151}
Simon Glassbd29cb02012-01-09 13:22:15 +0000152
153#ifndef CONFIG_SYS_DCACHE_OFF
154void enable_caches(void)
155{
156 /* Enable D-cache. I-cache is already enabled in start.S */
157 dcache_enable();
158}
159#endif