blob: 1ec6c0677d561088b716df275b1121abb9c24af9 [file] [log] [blame]
Tom Warren3f82b1d2011-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 Glassbb6997f2011-11-28 15:04:39 +000026#include <asm/arch/clock.h>
27#include <asm/arch/funcmux.h>
Tom Warren150c2492012-09-19 15:50:56 -070028#include <asm/arch/tegra.h>
Lucas Stach516f00b2012-09-29 10:02:08 +000029#include <asm/arch-tegra/board.h>
Tom Warren150c2492012-09-19 15:50:56 -070030#include <asm/arch-tegra/pmc.h>
31#include <asm/arch-tegra/sys_proto.h>
32#include <asm/arch-tegra/warmboot.h>
Tom Warren3f82b1d2011-01-27 10:58:05 +000033
34DECLARE_GLOBAL_DATA_PTR;
35
Simon Glassbb6997f2011-11-28 15:04:39 +000036enum {
37 /* UARTs which we can enable */
38 UARTA = 1 << 0,
39 UARTB = 1 << 1,
40 UARTD = 1 << 3,
41 UART_COUNT = 4,
42};
43
Tom Warren3f82b1d2011-01-27 10:58:05 +000044/*
45 * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
46 * so we are using this value to identify memory size.
47 */
48
49unsigned int query_sdram_size(void)
50{
Tom Warren29f3e3f2012-09-04 17:00:24 -070051 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
Tom Warren3f82b1d2011-01-27 10:58:05 +000052 u32 reg;
53
54 reg = readl(&pmc->pmc_scratch20);
Marek Vasut4a34af72011-10-24 23:41:39 +000055 debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
Tom Warren3f82b1d2011-01-27 10:58:05 +000056
Tom Warrenb2871032012-12-11 13:34:15 +000057#if defined(CONFIG_TEGRA20)
58 /* bits 30:28 in OdmData are used for RAM size on T20 */
59 reg &= 0x70000000;
60
Tom Warren3f82b1d2011-01-27 10:58:05 +000061 switch ((reg) >> 28) {
62 case 1:
63 return 0x10000000; /* 256 MB */
Tom Warrenb2871032012-12-11 13:34:15 +000064 case 0:
Tom Warren3f82b1d2011-01-27 10:58:05 +000065 case 2:
Stephen Warren9057e652012-01-06 12:14:41 +000066 default:
Tom Warren3f82b1d2011-01-27 10:58:05 +000067 return 0x20000000; /* 512 MB */
68 case 3:
Tom Warren3f82b1d2011-01-27 10:58:05 +000069 return 0x40000000; /* 1GB */
70 }
Tom Warrenb2871032012-12-11 13:34:15 +000071#else /* Tegra30 */
72 /* bits 31:28 in OdmData are used for RAM size on T30 */
73 switch ((reg) >> 28) {
74 case 0:
75 case 1:
76 default:
77 return 0x10000000; /* 256 MB */
78 case 2:
79 return 0x20000000; /* 512 MB */
80 case 3:
81 return 0x30000000; /* 768 MB */
82 case 4:
83 return 0x40000000; /* 1GB */
84 case 8:
85 return 0x7ff00000; /* 2GB - 1MB */
86 }
87#endif
Tom Warren3f82b1d2011-01-27 10:58:05 +000088}
89
Tom Warren3f82b1d2011-01-27 10:58:05 +000090int dram_init(void)
91{
Tom Warren3f82b1d2011-01-27 10:58:05 +000092 /* We do not initialise DRAM here. We just query the size */
Simon Glass7f8c0702011-11-05 03:56:57 +000093 gd->ram_size = query_sdram_size();
Tom Warren3f82b1d2011-01-27 10:58:05 +000094 return 0;
95}
96
97#ifdef CONFIG_DISPLAY_BOARDINFO
98int checkboard(void)
99{
100 printf("Board: %s\n", sysinfo.board_string);
101 return 0;
102}
103#endif /* CONFIG_DISPLAY_BOARDINFO */
Simon Glasse43d6ed2011-11-05 03:56:49 +0000104
Stephen Warrenb9607e72012-05-14 13:13:45 +0000105static int uart_configs[] = {
Tom Warrenb2871032012-12-11 13:34:15 +0000106#if defined(CONFIG_TEGRA20)
107 #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
Stephen Warrenb9607e72012-05-14 13:13:45 +0000108 FUNCMUX_UART1_UAA_UAB,
Tom Warrenb2871032012-12-11 13:34:15 +0000109 #elif defined(CONFIG_TEGRA_UARTA_GPU)
Stephen Warrene21649b2012-05-16 05:59:59 +0000110 FUNCMUX_UART1_GPU,
Tom Warrenb2871032012-12-11 13:34:15 +0000111 #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
Lucas Stacha2cfe632012-05-16 08:21:02 +0000112 FUNCMUX_UART1_SDIO1,
Tom Warrenb2871032012-12-11 13:34:15 +0000113 #else
Stephen Warrenb9607e72012-05-14 13:13:45 +0000114 FUNCMUX_UART1_IRRX_IRTX,
Tom Warrenb2871032012-12-11 13:34:15 +0000115 #endif
Allen Martind08b9e92013-01-09 10:52:23 +0000116 FUNCMUX_UART2_UARTB,
Stephen Warrenb9607e72012-05-14 13:13:45 +0000117 -1,
118 FUNCMUX_UART4_GMC,
119 -1,
Tom Warrenb2871032012-12-11 13:34:15 +0000120#else /* Tegra30 */
121 FUNCMUX_UART1_ULPI, /* UARTA */
122 -1,
123 -1,
124 -1,
125 -1,
126#endif
Stephen Warrenb9607e72012-05-14 13:13:45 +0000127};
128
Simon Glassbb6997f2011-11-28 15:04:39 +0000129/**
130 * Set up the specified uarts
131 *
132 * @param uarts_ids Mask containing UARTs to init (UARTx)
133 */
134static void setup_uarts(int uart_ids)
135{
136 static enum periph_id id_for_uart[] = {
137 PERIPH_ID_UART1,
138 PERIPH_ID_UART2,
139 PERIPH_ID_UART3,
140 PERIPH_ID_UART4,
141 };
142 size_t i;
143
144 for (i = 0; i < UART_COUNT; i++) {
145 if (uart_ids & (1 << i)) {
146 enum periph_id id = id_for_uart[i];
147
Stephen Warrenb9607e72012-05-14 13:13:45 +0000148 funcmux_select(id, uart_configs[i]);
Simon Glassbb6997f2011-11-28 15:04:39 +0000149 clock_ll_start_uart(id);
150 }
151 }
152}
153
154void board_init_uart_f(void)
155{
156 int uart_ids = 0; /* bit mask of which UART ids to enable */
157
Tom Warren29f3e3f2012-09-04 17:00:24 -0700158#ifdef CONFIG_TEGRA_ENABLE_UARTA
Simon Glassbb6997f2011-11-28 15:04:39 +0000159 uart_ids |= UARTA;
160#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700161#ifdef CONFIG_TEGRA_ENABLE_UARTB
Simon Glassbb6997f2011-11-28 15:04:39 +0000162 uart_ids |= UARTB;
163#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700164#ifdef CONFIG_TEGRA_ENABLE_UARTD
Simon Glassbb6997f2011-11-28 15:04:39 +0000165 uart_ids |= UARTD;
166#endif
167 setup_uarts(uart_ids);
168}
Simon Glassbd29cb02012-01-09 13:22:15 +0000169
170#ifndef CONFIG_SYS_DCACHE_OFF
171void enable_caches(void)
172{
173 /* Enable D-cache. I-cache is already enabled in start.S */
174 dcache_enable();
175}
176#endif