]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/tegra2/board.c
tegra2: Don't use board pointer before it is set up
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / tegra2 / board.c
1 /*
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>
26 #include "ap20.h"
27 #include <asm/arch/sys_proto.h>
28 #include <asm/arch/tegra2.h>
29 #include <asm/arch/pmc.h>
30
31 DECLARE_GLOBAL_DATA_PTR;
32
33 /*
34  * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
35  * so we are using this value to identify memory size.
36  */
37
38 unsigned int query_sdram_size(void)
39 {
40         struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
41         u32 reg;
42
43         reg = readl(&pmc->pmc_scratch20);
44         debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
45
46         /* bits 31:28 in OdmData are used for RAM size  */
47         switch ((reg) >> 28) {
48         case 1:
49                 return 0x10000000;      /* 256 MB */
50         case 2:
51                 return 0x20000000;      /* 512 MB */
52         case 3:
53         default:
54                 return 0x40000000;      /* 1GB */
55         }
56 }
57
58 int dram_init(void)
59 {
60         /* We do not initialise DRAM here. We just query the size */
61         gd->ram_size = query_sdram_size();
62         return 0;
63 }
64
65 #ifdef CONFIG_DISPLAY_BOARDINFO
66 int checkboard(void)
67 {
68         printf("Board: %s\n", sysinfo.board_string);
69         return 0;
70 }
71 #endif  /* CONFIG_DISPLAY_BOARDINFO */
72
73 #ifdef CONFIG_ARCH_CPU_INIT
74 /*
75  * Note this function is executed by the ARM7TDMI AVP. It does not return
76  * in this case. It is also called once the A9 starts up, but does nothing in
77  * that case.
78  */
79 int arch_cpu_init(void)
80 {
81         /* Fire up the Cortex A9 */
82         tegra2_start();
83         return 0;
84 }
85 #endif