2011-04-14 12:18:06 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010-2011
|
|
|
|
* NVIDIA Corporation <www.nvidia.com>
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <common.h>
|
2011-04-14 12:18:06 +00:00
|
|
|
#include <asm/io.h>
|
2012-04-02 13:18:50 +00:00
|
|
|
#include <asm/arch/gp_padctrl.h>
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch-tegra/ap.h>
|
|
|
|
#include <asm/arch-tegra/fuse.h>
|
|
|
|
#include <asm/arch-tegra/pmc.h>
|
|
|
|
#include <asm/arch-tegra/scu.h>
|
|
|
|
#include <asm/arch-tegra/warmboot.h>
|
2011-04-14 12:18:06 +00:00
|
|
|
|
2012-04-02 13:18:50 +00:00
|
|
|
int tegra_get_chip_type(void)
|
|
|
|
{
|
|
|
|
struct apb_misc_gp_ctlr *gp;
|
2012-09-05 00:00:24 +00:00
|
|
|
struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
|
2012-04-02 13:18:50 +00:00
|
|
|
uint tegra_sku_id, rev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is undocumented, Chip ID is bits 15:8 of the register
|
|
|
|
* APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for
|
|
|
|
* Tegra30
|
|
|
|
*/
|
2012-09-05 00:00:24 +00:00
|
|
|
gp = (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
|
2012-04-02 13:18:50 +00:00
|
|
|
rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
|
|
|
|
|
|
|
|
tegra_sku_id = readl(&fuse->sku_info) & 0xff;
|
|
|
|
|
|
|
|
switch (rev) {
|
2012-08-31 08:30:00 +00:00
|
|
|
case CHIPID_TEGRA20:
|
2012-04-02 13:18:50 +00:00
|
|
|
switch (tegra_sku_id) {
|
|
|
|
case SKU_ID_T20:
|
|
|
|
return TEGRA_SOC_T20;
|
|
|
|
case SKU_ID_T25SE:
|
|
|
|
case SKU_ID_AP25:
|
|
|
|
case SKU_ID_T25:
|
|
|
|
case SKU_ID_AP25E:
|
|
|
|
case SKU_ID_T25E:
|
|
|
|
return TEGRA_SOC_T25;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* unknown sku id */
|
|
|
|
return TEGRA_SOC_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2012-08-31 08:30:12 +00:00
|
|
|
static void enable_scu(void)
|
2011-04-14 12:18:06 +00:00
|
|
|
{
|
|
|
|
struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE;
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
/* If SCU already setup/enabled, return */
|
|
|
|
if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Invalidate all ways for all processors */
|
|
|
|
writel(0xFFFF, &scu->scu_inv_all);
|
|
|
|
|
|
|
|
/* Enable SCU - bit 0 */
|
|
|
|
reg = readl(&scu->scu_ctrl);
|
|
|
|
reg |= SCU_CTRL_ENABLE;
|
|
|
|
writel(reg, &scu->scu_ctrl);
|
|
|
|
}
|
|
|
|
|
2012-05-30 21:06:09 +00:00
|
|
|
static u32 get_odmdata(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* ODMDATA is stored in the BCT in IRAM by the BootROM.
|
|
|
|
* The BCT start and size are stored in the BIT in IRAM.
|
|
|
|
* Read the data @ bct_start + (bct_size - 12). This works
|
|
|
|
* on T20 and T30 BCTs, which are locked down. If this changes
|
|
|
|
* in new chips (T114, etc.), we can revisit this algorithm.
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32 bct_start, odmdata;
|
|
|
|
|
|
|
|
bct_start = readl(AP20_BASE_PA_SRAM + NVBOOTINFOTABLE_BCTPTR);
|
|
|
|
odmdata = readl(bct_start + BCT_ODMDATA_OFFSET);
|
|
|
|
|
|
|
|
return odmdata;
|
|
|
|
}
|
|
|
|
|
2012-08-31 08:30:12 +00:00
|
|
|
static void init_pmc_scratch(void)
|
2011-04-14 12:18:06 +00:00
|
|
|
{
|
2012-09-05 00:00:24 +00:00
|
|
|
struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
|
2012-05-30 21:06:09 +00:00
|
|
|
u32 odmdata;
|
2011-04-14 12:18:06 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */
|
|
|
|
for (i = 0; i < 23; i++)
|
|
|
|
writel(0, &pmc->pmc_scratch1+i);
|
|
|
|
|
|
|
|
/* ODMDATA is for kernel use to determine RAM size, LP config, etc. */
|
2012-05-30 21:06:09 +00:00
|
|
|
odmdata = get_odmdata();
|
|
|
|
writel(odmdata, &pmc->pmc_scratch20);
|
2011-04-14 12:18:06 +00:00
|
|
|
}
|
|
|
|
|
2012-08-31 08:30:12 +00:00
|
|
|
void s_init(void)
|
2011-04-14 12:18:06 +00:00
|
|
|
{
|
2011-11-05 03:56:50 +00:00
|
|
|
/* Init PMC scratch memory */
|
|
|
|
init_pmc_scratch();
|
2011-04-14 12:18:06 +00:00
|
|
|
|
2011-11-05 03:56:50 +00:00
|
|
|
enable_scu();
|
2011-04-14 12:18:06 +00:00
|
|
|
|
2011-11-05 03:56:50 +00:00
|
|
|
/* enable SMP mode and FW for CPU0, by writing to Auxiliary Ctl reg */
|
|
|
|
asm volatile(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 1\n"
|
|
|
|
"orr r0, r0, #0x41\n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 1\n");
|
2011-04-14 12:18:06 +00:00
|
|
|
|
2011-11-05 03:56:50 +00:00
|
|
|
/* FIXME: should have ap20's L2 disabled too? */
|
2011-04-14 12:18:06 +00:00
|
|
|
}
|