blob: 598023aba9a1885f8075a632734896324162bf52 [file] [log] [blame]
Tom Warren41b68382011-01-27 10:58:05 +00001/*
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
24#include <common.h>
25#include <asm/io.h>
Simon Glass96b7c432011-11-28 15:04:39 +000026#include <asm/arch/clock.h>
27#include <asm/arch/funcmux.h>
Simon Glass84a8dcf2012-04-02 13:18:46 +000028#include <asm/arch/pmc.h>
Tom Warren41b68382011-01-27 10:58:05 +000029#include <asm/arch/sys_proto.h>
Allen Martin55d98a12012-08-31 08:30:00 +000030#include <asm/arch/tegra20.h>
Allen Martinc9c98462012-08-31 08:30:12 +000031#include <asm/arch/warmboot.h>
Tom Warren41b68382011-01-27 10:58:05 +000032
33DECLARE_GLOBAL_DATA_PTR;
34
Simon Glass96b7c432011-11-28 15:04:39 +000035enum {
36 /* UARTs which we can enable */
37 UARTA = 1 << 0,
38 UARTB = 1 << 1,
39 UARTD = 1 << 3,
40 UART_COUNT = 4,
41};
42
Tom Warren41b68382011-01-27 10:58:05 +000043/*
44 * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
45 * so we are using this value to identify memory size.
46 */
47
48unsigned int query_sdram_size(void)
49{
Allen Martin55d98a12012-08-31 08:30:00 +000050 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)TEGRA20_PMC_BASE;
Tom Warren41b68382011-01-27 10:58:05 +000051 u32 reg;
52
53 reg = readl(&pmc->pmc_scratch20);
Marek Vasut8148e112011-10-24 23:41:39 +000054 debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
Tom Warren41b68382011-01-27 10:58:05 +000055
56 /* bits 31:28 in OdmData are used for RAM size */
57 switch ((reg) >> 28) {
58 case 1:
59 return 0x10000000; /* 256 MB */
60 case 2:
Stephen Warrenb60fa392012-01-06 12:14:41 +000061 default:
Tom Warren41b68382011-01-27 10:58:05 +000062 return 0x20000000; /* 512 MB */
63 case 3:
Tom Warren41b68382011-01-27 10:58:05 +000064 return 0x40000000; /* 1GB */
65 }
66}
67
Tom Warren41b68382011-01-27 10:58:05 +000068int dram_init(void)
69{
Tom Warren41b68382011-01-27 10:58:05 +000070 /* We do not initialise DRAM here. We just query the size */
Simon Glassf6fcbbd2011-11-05 03:56:57 +000071 gd->ram_size = query_sdram_size();
Tom Warren41b68382011-01-27 10:58:05 +000072 return 0;
73}
74
75#ifdef CONFIG_DISPLAY_BOARDINFO
76int checkboard(void)
77{
78 printf("Board: %s\n", sysinfo.board_string);
79 return 0;
80}
81#endif /* CONFIG_DISPLAY_BOARDINFO */
Simon Glass5f3a8992011-11-05 03:56:49 +000082
Stephen Warren59f90102012-05-14 13:13:45 +000083static int uart_configs[] = {
Allen Martin55d98a12012-08-31 08:30:00 +000084#if defined(CONFIG_TEGRA20_UARTA_UAA_UAB)
Stephen Warren59f90102012-05-14 13:13:45 +000085 FUNCMUX_UART1_UAA_UAB,
Allen Martin55d98a12012-08-31 08:30:00 +000086#elif defined(CONFIG_TEGRA20_UARTA_GPU)
Stephen Warrene4c01a82012-05-16 05:59:59 +000087 FUNCMUX_UART1_GPU,
Allen Martin55d98a12012-08-31 08:30:00 +000088#elif defined(CONFIG_TEGRA20_UARTA_SDIO1)
Lucas Stach4de6eec2012-05-16 08:21:02 +000089 FUNCMUX_UART1_SDIO1,
Stephen Warren59f90102012-05-14 13:13:45 +000090#else
91 FUNCMUX_UART1_IRRX_IRTX,
92#endif
93 FUNCMUX_UART2_IRDA,
94 -1,
95 FUNCMUX_UART4_GMC,
96 -1,
97};
98
Simon Glass96b7c432011-11-28 15:04:39 +000099/**
100 * Set up the specified uarts
101 *
102 * @param uarts_ids Mask containing UARTs to init (UARTx)
103 */
104static void setup_uarts(int uart_ids)
105{
106 static enum periph_id id_for_uart[] = {
107 PERIPH_ID_UART1,
108 PERIPH_ID_UART2,
109 PERIPH_ID_UART3,
110 PERIPH_ID_UART4,
111 };
112 size_t i;
113
114 for (i = 0; i < UART_COUNT; i++) {
115 if (uart_ids & (1 << i)) {
116 enum periph_id id = id_for_uart[i];
117
Stephen Warren59f90102012-05-14 13:13:45 +0000118 funcmux_select(id, uart_configs[i]);
Simon Glass96b7c432011-11-28 15:04:39 +0000119 clock_ll_start_uart(id);
120 }
121 }
122}
123
124void board_init_uart_f(void)
125{
126 int uart_ids = 0; /* bit mask of which UART ids to enable */
127
Allen Martin55d98a12012-08-31 08:30:00 +0000128#ifdef CONFIG_TEGRA20_ENABLE_UARTA
Simon Glass96b7c432011-11-28 15:04:39 +0000129 uart_ids |= UARTA;
130#endif
Allen Martin55d98a12012-08-31 08:30:00 +0000131#ifdef CONFIG_TEGRA20_ENABLE_UARTB
Simon Glass96b7c432011-11-28 15:04:39 +0000132 uart_ids |= UARTB;
133#endif
Allen Martin55d98a12012-08-31 08:30:00 +0000134#ifdef CONFIG_TEGRA20_ENABLE_UARTD
Simon Glass96b7c432011-11-28 15:04:39 +0000135 uart_ids |= UARTD;
136#endif
137 setup_uarts(uart_ids);
138}
Simon Glass410012f2012-01-09 13:22:15 +0000139
140#ifndef CONFIG_SYS_DCACHE_OFF
141void enable_caches(void)
142{
143 /* Enable D-cache. I-cache is already enabled in start.S */
144 dcache_enable();
145}
146#endif