blob: 4530194bf7ecaa76e1457d4bbb03ae90167ba796 [file] [log] [blame]
Tom Warren41b68382011-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 Glass5f3a8992011-11-05 03:56:49 +000026#include "ap20.h"
Tom Warren41b68382011-01-27 10:58:05 +000027#include <asm/arch/sys_proto.h>
28#include <asm/arch/tegra2.h>
29#include <asm/arch/pmc.h>
30
31DECLARE_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
38unsigned 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);
Marek Vasut8148e112011-10-24 23:41:39 +000044 debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
Tom Warren41b68382011-01-27 10:58:05 +000045
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
58void s_init(void)
59{
60#ifndef CONFIG_ICACHE_OFF
61 icache_enable();
62#endif
63 invalidate_dcache();
64}
65
66int dram_init(void)
67{
68 unsigned long rs;
69
70 /* We do not initialise DRAM here. We just query the size */
71 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
72 gd->bd->bi_dram[0].size = gd->ram_size = query_sdram_size();
73
74 /* Now check it dynamically */
75 rs = get_ram_size(CONFIG_SYS_SDRAM_BASE, gd->ram_size);
76 if (rs) {
77 printf("dynamic ram_size = %lu\n", rs);
78 gd->bd->bi_dram[0].size = gd->ram_size = rs;
79 }
80 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 Glass5f3a8992011-11-05 03:56:49 +000090
91#ifdef CONFIG_ARCH_CPU_INIT
92/*
93 * Note this function is executed by the ARM7TDMI AVP. It does not return
94 * in this case. It is also called once the A9 starts up, but does nothing in
95 * that case.
96 */
97int arch_cpu_init(void)
98{
99 /* Fire up the Cortex A9 */
100 tegra2_start();
101 return 0;
102}
103#endif