blob: d9cbda8a749f8a0825badb6aff89be226089b8e0 [file] [log] [blame]
Tom Warren3f82b1d2011-01-27 10:58:05 +00001/*
2 * (C) Copyright 2010,2011
3 * 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>
Tom Warren150c2492012-09-19 15:50:56 -070012#include <asm/arch/tegra.h>
Lucas Stach516f00b2012-09-29 10:02:08 +000013#include <asm/arch-tegra/board.h>
Tom Warren150c2492012-09-19 15:50:56 -070014#include <asm/arch-tegra/pmc.h>
15#include <asm/arch-tegra/sys_proto.h>
16#include <asm/arch-tegra/warmboot.h>
Tom Warren3f82b1d2011-01-27 10:58:05 +000017
18DECLARE_GLOBAL_DATA_PTR;
19
Simon Glassbb6997f2011-11-28 15:04:39 +000020enum {
21 /* UARTs which we can enable */
22 UARTA = 1 << 0,
23 UARTB = 1 << 1,
Tom Warrene23bb6a2013-01-28 13:32:10 +000024 UARTC = 1 << 2,
Simon Glassbb6997f2011-11-28 15:04:39 +000025 UARTD = 1 << 3,
Tom Warrene23bb6a2013-01-28 13:32:10 +000026 UARTE = 1 << 4,
27 UART_COUNT = 5,
Simon Glassbb6997f2011-11-28 15:04:39 +000028};
29
Tom Warren3f82b1d2011-01-27 10:58:05 +000030/*
31 * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
32 * so we are using this value to identify memory size.
33 */
34
35unsigned int query_sdram_size(void)
36{
Tom Warren29f3e3f2012-09-04 17:00:24 -070037 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
Tom Warren3f82b1d2011-01-27 10:58:05 +000038 u32 reg;
39
40 reg = readl(&pmc->pmc_scratch20);
Marek Vasut4a34af72011-10-24 23:41:39 +000041 debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
Tom Warren3f82b1d2011-01-27 10:58:05 +000042
Tom Warrenb2871032012-12-11 13:34:15 +000043#if defined(CONFIG_TEGRA20)
44 /* bits 30:28 in OdmData are used for RAM size on T20 */
45 reg &= 0x70000000;
46
Tom Warren3f82b1d2011-01-27 10:58:05 +000047 switch ((reg) >> 28) {
48 case 1:
49 return 0x10000000; /* 256 MB */
Tom Warrenb2871032012-12-11 13:34:15 +000050 case 0:
Tom Warren3f82b1d2011-01-27 10:58:05 +000051 case 2:
Stephen Warren9057e652012-01-06 12:14:41 +000052 default:
Tom Warren3f82b1d2011-01-27 10:58:05 +000053 return 0x20000000; /* 512 MB */
54 case 3:
Tom Warren3f82b1d2011-01-27 10:58:05 +000055 return 0x40000000; /* 1GB */
56 }
Tom Warrene23bb6a2013-01-28 13:32:10 +000057#else /* Tegra30/Tegra114 */
Tom Warrenb2871032012-12-11 13:34:15 +000058 /* bits 31:28 in OdmData are used for RAM size on T30 */
59 switch ((reg) >> 28) {
60 case 0:
61 case 1:
62 default:
63 return 0x10000000; /* 256 MB */
64 case 2:
65 return 0x20000000; /* 512 MB */
66 case 3:
67 return 0x30000000; /* 768 MB */
68 case 4:
69 return 0x40000000; /* 1GB */
70 case 8:
71 return 0x7ff00000; /* 2GB - 1MB */
72 }
73#endif
Tom Warren3f82b1d2011-01-27 10:58:05 +000074}
75
Tom Warren3f82b1d2011-01-27 10:58:05 +000076int dram_init(void)
77{
Tom Warren3f82b1d2011-01-27 10:58:05 +000078 /* We do not initialise DRAM here. We just query the size */
Simon Glass7f8c0702011-11-05 03:56:57 +000079 gd->ram_size = query_sdram_size();
Tom Warren3f82b1d2011-01-27 10:58:05 +000080 return 0;
81}
82
83#ifdef CONFIG_DISPLAY_BOARDINFO
84int checkboard(void)
85{
86 printf("Board: %s\n", sysinfo.board_string);
87 return 0;
88}
89#endif /* CONFIG_DISPLAY_BOARDINFO */
Simon Glasse43d6ed2011-11-05 03:56:49 +000090
Stephen Warrenb9607e72012-05-14 13:13:45 +000091static int uart_configs[] = {
Tom Warrenb2871032012-12-11 13:34:15 +000092#if defined(CONFIG_TEGRA20)
93 #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
Stephen Warrenb9607e72012-05-14 13:13:45 +000094 FUNCMUX_UART1_UAA_UAB,
Tom Warrenb2871032012-12-11 13:34:15 +000095 #elif defined(CONFIG_TEGRA_UARTA_GPU)
Stephen Warrene21649b2012-05-16 05:59:59 +000096 FUNCMUX_UART1_GPU,
Tom Warrenb2871032012-12-11 13:34:15 +000097 #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
Lucas Stacha2cfe632012-05-16 08:21:02 +000098 FUNCMUX_UART1_SDIO1,
Tom Warrenb2871032012-12-11 13:34:15 +000099 #else
Stephen Warrenb9607e72012-05-14 13:13:45 +0000100 FUNCMUX_UART1_IRRX_IRTX,
Stephen Warren4727a132013-01-22 06:20:08 +0000101#endif
102 FUNCMUX_UART2_UAD,
Stephen Warrenb9607e72012-05-14 13:13:45 +0000103 -1,
104 FUNCMUX_UART4_GMC,
105 -1,
Tom Warrene23bb6a2013-01-28 13:32:10 +0000106#elif defined(CONFIG_TEGRA30)
Tom Warrenb2871032012-12-11 13:34:15 +0000107 FUNCMUX_UART1_ULPI, /* UARTA */
108 -1,
109 -1,
110 -1,
111 -1,
Tom Warrene23bb6a2013-01-28 13:32:10 +0000112#else /* Tegra114 */
113 -1,
114 -1,
115 -1,
116 FUNCMUX_UART4_GMI, /* UARTD */
117 -1,
Tom Warrenb2871032012-12-11 13:34:15 +0000118#endif
Stephen Warrenb9607e72012-05-14 13:13:45 +0000119};
120
Simon Glassbb6997f2011-11-28 15:04:39 +0000121/**
122 * Set up the specified uarts
123 *
124 * @param uarts_ids Mask containing UARTs to init (UARTx)
125 */
126static void setup_uarts(int uart_ids)
127{
128 static enum periph_id id_for_uart[] = {
129 PERIPH_ID_UART1,
130 PERIPH_ID_UART2,
131 PERIPH_ID_UART3,
132 PERIPH_ID_UART4,
Tom Warrene23bb6a2013-01-28 13:32:10 +0000133 PERIPH_ID_UART5,
Simon Glassbb6997f2011-11-28 15:04:39 +0000134 };
135 size_t i;
136
137 for (i = 0; i < UART_COUNT; i++) {
138 if (uart_ids & (1 << i)) {
139 enum periph_id id = id_for_uart[i];
140
Stephen Warrenb9607e72012-05-14 13:13:45 +0000141 funcmux_select(id, uart_configs[i]);
Simon Glassbb6997f2011-11-28 15:04:39 +0000142 clock_ll_start_uart(id);
143 }
144 }
145}
146
147void board_init_uart_f(void)
148{
149 int uart_ids = 0; /* bit mask of which UART ids to enable */
150
Tom Warren29f3e3f2012-09-04 17:00:24 -0700151#ifdef CONFIG_TEGRA_ENABLE_UARTA
Simon Glassbb6997f2011-11-28 15:04:39 +0000152 uart_ids |= UARTA;
153#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700154#ifdef CONFIG_TEGRA_ENABLE_UARTB
Simon Glassbb6997f2011-11-28 15:04:39 +0000155 uart_ids |= UARTB;
156#endif
Tom Warrene23bb6a2013-01-28 13:32:10 +0000157#ifdef CONFIG_TEGRA_ENABLE_UARTC
158 uart_ids |= UARTC;
159#endif
Tom Warren29f3e3f2012-09-04 17:00:24 -0700160#ifdef CONFIG_TEGRA_ENABLE_UARTD
Simon Glassbb6997f2011-11-28 15:04:39 +0000161 uart_ids |= UARTD;
162#endif
Tom Warrene23bb6a2013-01-28 13:32:10 +0000163#ifdef CONFIG_TEGRA_ENABLE_UARTE
164 uart_ids |= UARTE;
165#endif
Simon Glassbb6997f2011-11-28 15:04:39 +0000166 setup_uarts(uart_ids);
167}
Simon Glassbd29cb02012-01-09 13:22:15 +0000168
169#ifndef CONFIG_SYS_DCACHE_OFF
170void enable_caches(void)
171{
172 /* Enable D-cache. I-cache is already enabled in start.S */
173 dcache_enable();
174}
175#endif