]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/tegra2/board.c
microblaze: Fix strict-aliasing rules for in_be32
[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 <asm/arch/sys_proto.h>
27 #include <asm/arch/tegra2.h>
28 #include <asm/arch/pmc.h>
29
30 DECLARE_GLOBAL_DATA_PTR;
31
32 /*
33  * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
34  * so we are using this value to identify memory size.
35  */
36
37 unsigned int query_sdram_size(void)
38 {
39         struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
40         u32 reg;
41
42         reg = readl(&pmc->pmc_scratch20);
43         debug("pmc->pmc_scratch20 (ODMData) = 0x%08lX\n", reg);
44
45         /* bits 31:28 in OdmData are used for RAM size  */
46         switch ((reg) >> 28) {
47         case 1:
48                 return 0x10000000;      /* 256 MB */
49         case 2:
50                 return 0x20000000;      /* 512 MB */
51         case 3:
52         default:
53                 return 0x40000000;      /* 1GB */
54         }
55 }
56
57 void s_init(void)
58 {
59 #ifndef CONFIG_ICACHE_OFF
60         icache_enable();
61 #endif
62         invalidate_dcache();
63 }
64
65 int dram_init(void)
66 {
67         unsigned long rs;
68
69         /* We do not initialise DRAM here. We just query the size */
70         gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
71         gd->bd->bi_dram[0].size = gd->ram_size = query_sdram_size();
72
73         /* Now check it dynamically */
74         rs = get_ram_size(CONFIG_SYS_SDRAM_BASE, gd->ram_size);
75         if (rs) {
76                 printf("dynamic ram_size = %lu\n", rs);
77                 gd->bd->bi_dram[0].size = gd->ram_size = rs;
78         }
79         return 0;
80 }
81
82 #ifdef CONFIG_DISPLAY_BOARDINFO
83 int checkboard(void)
84 {
85         printf("Board: %s\n", sysinfo.board_string);
86         return 0;
87 }
88 #endif  /* CONFIG_DISPLAY_BOARDINFO */