blob: d7d1df1b13805af637b5f830307ea8e49df09a68 [file] [log] [blame]
Tom Warren112a1882011-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 Warren61c6d0e2012-12-11 13:34:15 +000023
24/* Tegra AP (Application Processor) code */
25
Tom Warrenab371962012-09-19 15:50:56 -070026#include <common.h>
Tom Warren112a1882011-04-14 12:18:06 +000027#include <asm/io.h>
Simon Glass1fed82a2012-04-02 13:18:50 +000028#include <asm/arch/gp_padctrl.h>
Tom Warrenab371962012-09-19 15:50:56 -070029#include <asm/arch-tegra/ap.h>
Tom Warren61c6d0e2012-12-11 13:34:15 +000030#include <asm/arch-tegra/clock.h>
Tom Warrenab371962012-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 Warrene3d95bc2013-01-28 13:32:10 +000034#include <asm/arch-tegra/tegra.h>
Tom Warrenab371962012-09-19 15:50:56 -070035#include <asm/arch-tegra/warmboot.h>
Tom Warren112a1882011-04-14 12:18:06 +000036
Tom Warren8b817112013-04-10 10:32:32 -070037int tegra_get_chip(void)
Simon Glass1fed82a2012-04-02 13:18:50 +000038{
Tom Warren8b817112013-04-10 10:32:32 -070039 int rev;
40 struct apb_misc_gp_ctlr *gp =
41 (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
Simon Glass1fed82a2012-04-02 13:18:50 +000042
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 Warrene3d95bc2013-01-28 13:32:10 +000046 * Tegra30, and 0x35 for T114.
Simon Glass1fed82a2012-04-02 13:18:50 +000047 */
Simon Glass1fed82a2012-04-02 13:18:50 +000048 rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
Tom Warren8b817112013-04-10 10:32:32 -070049 debug("%s: CHIPID is 0x%02X\n", __func__, rev);
50
51 return rev;
52}
53
54int tegra_get_sku_info(void)
55{
56 int sku_id;
57 struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
Simon Glass1fed82a2012-04-02 13:18:50 +000058
Tom Warren8b817112013-04-10 10:32:32 -070059 sku_id = readl(&fuse->sku_info) & 0xff;
60 debug("%s: SKU info byte is 0x%02X\n", __func__, sku_id);
Simon Glass1fed82a2012-04-02 13:18:50 +000061
Tom Warren8b817112013-04-10 10:32:32 -070062 return sku_id;
63}
64
65int tegra_get_chip_sku(void)
66{
67 uint sku_id, chip_id;
68
69 chip_id = tegra_get_chip();
70 sku_id = tegra_get_sku_info();
71
72 switch (chip_id) {
Allen Martin55d98a12012-08-31 08:30:00 +000073 case CHIPID_TEGRA20:
Tom Warren8b817112013-04-10 10:32:32 -070074 switch (sku_id) {
Simon Glass1fed82a2012-04-02 13:18:50 +000075 case SKU_ID_T20:
76 return TEGRA_SOC_T20;
77 case SKU_ID_T25SE:
78 case SKU_ID_AP25:
79 case SKU_ID_T25:
80 case SKU_ID_AP25E:
81 case SKU_ID_T25E:
82 return TEGRA_SOC_T25;
83 }
84 break;
Tom Warren61c6d0e2012-12-11 13:34:15 +000085 case CHIPID_TEGRA30:
Tom Warren8b817112013-04-10 10:32:32 -070086 switch (sku_id) {
Stephen Warrend9cd5022013-03-27 09:37:02 +000087 case SKU_ID_T33:
Tom Warren61c6d0e2012-12-11 13:34:15 +000088 case SKU_ID_T30:
89 return TEGRA_SOC_T30;
90 }
91 break;
Tom Warrene3d95bc2013-01-28 13:32:10 +000092 case CHIPID_TEGRA114:
Tom Warren8b817112013-04-10 10:32:32 -070093 switch (sku_id) {
Tom Warrene3d95bc2013-01-28 13:32:10 +000094 case SKU_ID_T114_ENG:
Stephen Warrenb08795a2013-05-17 14:10:14 +000095 case SKU_ID_T114_1:
Tom Warrene3d95bc2013-01-28 13:32:10 +000096 return TEGRA_SOC_T114;
97 }
98 break;
Simon Glass1fed82a2012-04-02 13:18:50 +000099 }
Tom Warren8b817112013-04-10 10:32:32 -0700100 /* unknown chip/sku id */
101 printf("%s: ERROR: UNKNOWN CHIP/SKU ID COMBO (0x%02X/0x%02X)\n",
102 __func__, chip_id, sku_id);
Simon Glass1fed82a2012-04-02 13:18:50 +0000103 return TEGRA_SOC_UNKNOWN;
104}
105
Allen Martinc9c98462012-08-31 08:30:12 +0000106static void enable_scu(void)
Tom Warren112a1882011-04-14 12:18:06 +0000107{
108 struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE;
109 u32 reg;
110
111 /* If SCU already setup/enabled, return */
112 if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE)
113 return;
114
115 /* Invalidate all ways for all processors */
116 writel(0xFFFF, &scu->scu_inv_all);
117
118 /* Enable SCU - bit 0 */
119 reg = readl(&scu->scu_ctrl);
120 reg |= SCU_CTRL_ENABLE;
121 writel(reg, &scu->scu_ctrl);
122}
123
Tom Warren7ee52b02012-05-30 14:06:09 -0700124static u32 get_odmdata(void)
125{
126 /*
127 * ODMDATA is stored in the BCT in IRAM by the BootROM.
128 * The BCT start and size are stored in the BIT in IRAM.
129 * Read the data @ bct_start + (bct_size - 12). This works
130 * on T20 and T30 BCTs, which are locked down. If this changes
131 * in new chips (T114, etc.), we can revisit this algorithm.
132 */
133
134 u32 bct_start, odmdata;
135
Tom Warren61c6d0e2012-12-11 13:34:15 +0000136 bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR);
Tom Warren7ee52b02012-05-30 14:06:09 -0700137 odmdata = readl(bct_start + BCT_ODMDATA_OFFSET);
138
139 return odmdata;
140}
141
Allen Martinc9c98462012-08-31 08:30:12 +0000142static void init_pmc_scratch(void)
Tom Warren112a1882011-04-14 12:18:06 +0000143{
Tom Warren22562a42012-09-04 17:00:24 -0700144 struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
Tom Warren7ee52b02012-05-30 14:06:09 -0700145 u32 odmdata;
Tom Warren112a1882011-04-14 12:18:06 +0000146 int i;
147
148 /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */
149 for (i = 0; i < 23; i++)
150 writel(0, &pmc->pmc_scratch1+i);
151
152 /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */
Tom Warren7ee52b02012-05-30 14:06:09 -0700153 odmdata = get_odmdata();
154 writel(odmdata, &pmc->pmc_scratch20);
Tom Warren112a1882011-04-14 12:18:06 +0000155}
156
Allen Martinc9c98462012-08-31 08:30:12 +0000157void s_init(void)
Tom Warren112a1882011-04-14 12:18:06 +0000158{
Simon Glassec8dab42011-11-05 03:56:50 +0000159 /* Init PMC scratch memory */
160 init_pmc_scratch();
Tom Warren112a1882011-04-14 12:18:06 +0000161
Simon Glassec8dab42011-11-05 03:56:50 +0000162 enable_scu();
Tom Warren112a1882011-04-14 12:18:06 +0000163
Tom Warren82b51342013-03-25 16:22:26 -0700164 /* init the cache */
165 config_cache();
Tom Warren112a1882011-04-14 12:18:06 +0000166}