]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/tegra-common/board.c
Merge branch 'u-boot-samsung/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / arch / arm / cpu / tegra-common / board.c
1 /*
2  *  (C) Copyright 2010-2014
3  *  NVIDIA Corporation <www.nvidia.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <asm/io.h>
10 #include <asm/arch/clock.h>
11 #include <asm/arch/funcmux.h>
12 #include <asm/arch/tegra.h>
13 #include <asm/arch-tegra/board.h>
14 #include <asm/arch-tegra/pmc.h>
15 #include <asm/arch-tegra/sys_proto.h>
16 #include <asm/arch-tegra/warmboot.h>
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 enum {
21         /* UARTs which we can enable */
22         UARTA   = 1 << 0,
23         UARTB   = 1 << 1,
24         UARTC   = 1 << 2,
25         UARTD   = 1 << 3,
26         UARTE   = 1 << 4,
27         UART_COUNT = 5,
28 };
29
30 /*
31  * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
32  * so we are using this value to identify memory size.
33  */
34
35 unsigned int query_sdram_size(void)
36 {
37         struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
38         u32 reg;
39
40         reg = readl(&pmc->pmc_scratch20);
41         debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
42
43 #if defined(CONFIG_TEGRA20)
44         /* bits 30:28 in OdmData are used for RAM size on T20  */
45         reg &= 0x70000000;
46
47         switch ((reg) >> 28) {
48         case 1:
49                 return 0x10000000;      /* 256 MB */
50         case 0:
51         case 2:
52         default:
53                 return 0x20000000;      /* 512 MB */
54         case 3:
55                 return 0x40000000;      /* 1GB */
56         }
57 #else   /* Tegra30/Tegra114 */
58         /* 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
74 }
75
76 int dram_init(void)
77 {
78         /* We do not initialise DRAM here. We just query the size */
79         gd->ram_size = query_sdram_size();
80         return 0;
81 }
82
83 #ifdef CONFIG_DISPLAY_BOARDINFO
84 int checkboard(void)
85 {
86         printf("Board: %s\n", sysinfo.board_string);
87         return 0;
88 }
89 #endif  /* CONFIG_DISPLAY_BOARDINFO */
90
91 static int uart_configs[] = {
92 #if defined(CONFIG_TEGRA20)
93  #if defined(CONFIG_TEGRA_UARTA_UAA_UAB)
94         FUNCMUX_UART1_UAA_UAB,
95  #elif defined(CONFIG_TEGRA_UARTA_GPU)
96         FUNCMUX_UART1_GPU,
97  #elif defined(CONFIG_TEGRA_UARTA_SDIO1)
98         FUNCMUX_UART1_SDIO1,
99  #else
100         FUNCMUX_UART1_IRRX_IRTX,
101 #endif
102         FUNCMUX_UART2_UAD,
103         -1,
104         FUNCMUX_UART4_GMC,
105         -1,
106 #elif defined(CONFIG_TEGRA30)
107         FUNCMUX_UART1_ULPI,     /* UARTA */
108         -1,
109         -1,
110         -1,
111         -1,
112 #elif defined(CONFIG_TEGRA114)
113         -1,
114         -1,
115         -1,
116         FUNCMUX_UART4_GMI,      /* UARTD */
117         -1,
118 #else   /* Tegra124 */
119         FUNCMUX_UART1_KBC,      /* UARTA */
120         -1,
121         -1,
122         FUNCMUX_UART4_GPIO,     /* UARTD */
123         -1,
124 #endif
125 };
126
127 /**
128  * Set up the specified uarts
129  *
130  * @param uarts_ids     Mask containing UARTs to init (UARTx)
131  */
132 static void setup_uarts(int uart_ids)
133 {
134         static enum periph_id id_for_uart[] = {
135                 PERIPH_ID_UART1,
136                 PERIPH_ID_UART2,
137                 PERIPH_ID_UART3,
138                 PERIPH_ID_UART4,
139                 PERIPH_ID_UART5,
140         };
141         size_t i;
142
143         for (i = 0; i < UART_COUNT; i++) {
144                 if (uart_ids & (1 << i)) {
145                         enum periph_id id = id_for_uart[i];
146
147                         funcmux_select(id, uart_configs[i]);
148                         clock_ll_start_uart(id);
149                 }
150         }
151 }
152
153 void board_init_uart_f(void)
154 {
155         int uart_ids = 0;       /* bit mask of which UART ids to enable */
156
157 #ifdef CONFIG_TEGRA_ENABLE_UARTA
158         uart_ids |= UARTA;
159 #endif
160 #ifdef CONFIG_TEGRA_ENABLE_UARTB
161         uart_ids |= UARTB;
162 #endif
163 #ifdef CONFIG_TEGRA_ENABLE_UARTC
164         uart_ids |= UARTC;
165 #endif
166 #ifdef CONFIG_TEGRA_ENABLE_UARTD
167         uart_ids |= UARTD;
168 #endif
169 #ifdef CONFIG_TEGRA_ENABLE_UARTE
170         uart_ids |= UARTE;
171 #endif
172         setup_uarts(uart_ids);
173 }
174
175 #ifndef CONFIG_SYS_DCACHE_OFF
176 void enable_caches(void)
177 {
178         /* Enable D-cache. I-cache is already enabled in start.S */
179         dcache_enable();
180 }
181 #endif