blob: 236cda8419fc0ce5c4444d201cee35308b35c17a [file] [log] [blame]
Tom Warren74652cf2011-04-14 12:18:06 +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*/
Tom Warrenb2871032012-12-11 13:34:15 +000023
24/* Tegra AP (Application Processor) code */
25
Tom Warren74652cf2011-04-14 12:18:06 +000026#include <common.h>
Tom Warren150c2492012-09-19 15:50:56 -070027#include <asm/io.h>
28#include <asm/arch/gp_padctrl.h>
29#include <asm/arch-tegra/ap.h>
Tom Warrenb2871032012-12-11 13:34:15 +000030#include <asm/arch-tegra/clock.h>
Tom Warren150c2492012-09-19 15:50:56 -070031#include <asm/arch-tegra/fuse.h>
32#include <asm/arch-tegra/pmc.h>
33#include <asm/arch-tegra/scu.h>
Tom Warrene23bb6a2013-01-28 13:32:10 +000034#include <asm/arch-tegra/tegra.h>
Tom Warren150c2492012-09-19 15:50:56 -070035#include <asm/arch-tegra/warmboot.h>
Tom Warren74652cf2011-04-14 12:18:06 +000036
Simon Glassd5153622012-04-02 13:18:50 +000037int tegra_get_chip_type(void)
38{
39 struct apb_misc_gp_ctlr *gp;
Tom Warren29f3e3f2012-09-04 17:00:24 -070040 struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
Simon Glassd5153622012-04-02 13:18:50 +000041 uint tegra_sku_id, rev;
42
43 /*
44 * This is undocumented, Chip ID is bits 15:8 of the register
45 * APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for
Tom Warrene23bb6a2013-01-28 13:32:10 +000046 * Tegra30, and 0x35 for T114.
Simon Glassd5153622012-04-02 13:18:50 +000047 */
Tom Warren29f3e3f2012-09-04 17:00:24 -070048 gp = (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
Simon Glassd5153622012-04-02 13:18:50 +000049 rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
50
51 tegra_sku_id = readl(&fuse->sku_info) & 0xff;
52
53 switch (rev) {
Allen Martin00a27492012-08-31 08:30:00 +000054 case CHIPID_TEGRA20:
Simon Glassd5153622012-04-02 13:18:50 +000055 switch (tegra_sku_id) {
56 case SKU_ID_T20:
57 return TEGRA_SOC_T20;
58 case SKU_ID_T25SE:
59 case SKU_ID_AP25:
60 case SKU_ID_T25:
61 case SKU_ID_AP25E:
62 case SKU_ID_T25E:
63 return TEGRA_SOC_T25;
64 }
65 break;
Tom Warrenb2871032012-12-11 13:34:15 +000066 case CHIPID_TEGRA30:
67 switch (tegra_sku_id) {
68 case SKU_ID_T30:
69 return TEGRA_SOC_T30;
70 }
71 break;
Tom Warrene23bb6a2013-01-28 13:32:10 +000072 case CHIPID_TEGRA114:
73 switch (tegra_sku_id) {
74 case SKU_ID_T114_ENG:
75 return TEGRA_SOC_T114;
76 }
77 break;
Simon Glassd5153622012-04-02 13:18:50 +000078 }
79 /* unknown sku id */
80 return TEGRA_SOC_UNKNOWN;
81}
82
Allen Martin12b7b702012-08-31 08:30:12 +000083static void enable_scu(void)
Tom Warren74652cf2011-04-14 12:18:06 +000084{
85 struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE;
86 u32 reg;
87
88 /* If SCU already setup/enabled, return */
89 if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE)
90 return;
91
92 /* Invalidate all ways for all processors */
93 writel(0xFFFF, &scu->scu_inv_all);
94
95 /* Enable SCU - bit 0 */
96 reg = readl(&scu->scu_ctrl);
97 reg |= SCU_CTRL_ENABLE;
98 writel(reg, &scu->scu_ctrl);
99}
100
Tom Warren76e350b2012-05-30 14:06:09 -0700101static u32 get_odmdata(void)
102{
103 /*
104 * ODMDATA is stored in the BCT in IRAM by the BootROM.
105 * The BCT start and size are stored in the BIT in IRAM.
106 * Read the data @ bct_start + (bct_size - 12). This works
107 * on T20 and T30 BCTs, which are locked down. If this changes
108 * in new chips (T114, etc.), we can revisit this algorithm.
109 */
110
111 u32 bct_start, odmdata;
112
Tom Warrenb2871032012-12-11 13:34:15 +0000113 bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR);
Tom Warren76e350b2012-05-30 14:06:09 -0700114 odmdata = readl(bct_start + BCT_ODMDATA_OFFSET);
115
116 return odmdata;
117}
118
Allen Martin12b7b702012-08-31 08:30:12 +0000119static void init_pmc_scratch(void)
Tom Warren74652cf2011-04-14 12:18:06 +0000120{
Tom Warren29f3e3f2012-09-04 17:00:24 -0700121 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
Tom Warren76e350b2012-05-30 14:06:09 -0700122 u32 odmdata;
Tom Warren74652cf2011-04-14 12:18:06 +0000123 int i;
124
125 /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */
126 for (i = 0; i < 23; i++)
127 writel(0, &pmc->pmc_scratch1+i);
128
129 /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */
Tom Warren76e350b2012-05-30 14:06:09 -0700130 odmdata = get_odmdata();
131 writel(odmdata, &pmc->pmc_scratch20);
Tom Warren74652cf2011-04-14 12:18:06 +0000132}
133
Allen Martin12b7b702012-08-31 08:30:12 +0000134void s_init(void)
Tom Warren74652cf2011-04-14 12:18:06 +0000135{
Simon Glass210576f2011-11-05 03:56:50 +0000136 /* Init PMC scratch memory */
137 init_pmc_scratch();
Tom Warren74652cf2011-04-14 12:18:06 +0000138
Simon Glass210576f2011-11-05 03:56:50 +0000139 enable_scu();
140
141 /* enable SMP mode and FW for CPU0, by writing to Auxiliary Ctl reg */
142 asm volatile(
143 "mrc p15, 0, r0, c1, c0, 1\n"
144 "orr r0, r0, #0x41\n"
145 "mcr p15, 0, r0, c1, c0, 1\n");
146
Tom Warrenb2871032012-12-11 13:34:15 +0000147 /* FIXME: should have SoC's L2 disabled too? */
Tom Warren74652cf2011-04-14 12:18:06 +0000148}