2 * (C) Copyright 2010-2011
3 * NVIDIA Corporation <www.nvidia.com>
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
24 /* Tegra AP (Application Processor) code */
28 #include <asm/arch/gp_padctrl.h>
29 #include <asm/arch-tegra/ap.h>
30 #include <asm/arch-tegra/clock.h>
31 #include <asm/arch-tegra/fuse.h>
32 #include <asm/arch-tegra/pmc.h>
33 #include <asm/arch-tegra/scu.h>
34 #include <asm/arch-tegra/tegra.h>
35 #include <asm/arch-tegra/warmboot.h>
37 int tegra_get_chip_type(void)
39 struct apb_misc_gp_ctlr *gp;
40 struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
41 uint tegra_sku_id, rev;
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
46 * Tegra30, and 0x35 for T114.
48 gp = (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
49 rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
51 tegra_sku_id = readl(&fuse->sku_info) & 0xff;
55 switch (tegra_sku_id) {
67 switch (tegra_sku_id) {
74 switch (tegra_sku_id) {
76 return TEGRA_SOC_T114;
81 return TEGRA_SOC_UNKNOWN;
84 static void enable_scu(void)
86 struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE;
89 /* If SCU already setup/enabled, return */
90 if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE)
93 /* Invalidate all ways for all processors */
94 writel(0xFFFF, &scu->scu_inv_all);
96 /* Enable SCU - bit 0 */
97 reg = readl(&scu->scu_ctrl);
98 reg |= SCU_CTRL_ENABLE;
99 writel(reg, &scu->scu_ctrl);
102 static u32 get_odmdata(void)
105 * ODMDATA is stored in the BCT in IRAM by the BootROM.
106 * The BCT start and size are stored in the BIT in IRAM.
107 * Read the data @ bct_start + (bct_size - 12). This works
108 * on T20 and T30 BCTs, which are locked down. If this changes
109 * in new chips (T114, etc.), we can revisit this algorithm.
112 u32 bct_start, odmdata;
114 bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR);
115 odmdata = readl(bct_start + BCT_ODMDATA_OFFSET);
120 static void init_pmc_scratch(void)
122 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
126 /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */
127 for (i = 0; i < 23; i++)
128 writel(0, &pmc->pmc_scratch1+i);
130 /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */
131 odmdata = get_odmdata();
132 writel(odmdata, &pmc->pmc_scratch20);
137 /* Init PMC scratch memory */