2011-04-14 12:18:06 +00:00
|
|
|
/*
|
2015-03-04 23:36:00 +00:00
|
|
|
* (C) Copyright 2010-2015
|
2011-04-14 12:18:06 +00:00
|
|
|
* NVIDIA Corporation <www.nvidia.com>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-04-14 12:18:06 +00:00
|
|
|
*/
|
2012-12-11 13:34:15 +00:00
|
|
|
|
|
|
|
/* Tegra AP (Application Processor) code */
|
|
|
|
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <common.h>
|
2016-01-24 14:27:48 +00:00
|
|
|
#include <linux/bug.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>
|
2015-04-21 05:18:36 +00:00
|
|
|
#include <asm/arch/mc.h>
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch-tegra/ap.h>
|
2012-12-11 13:34:15 +00:00
|
|
|
#include <asm/arch-tegra/clock.h>
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch-tegra/fuse.h>
|
|
|
|
#include <asm/arch-tegra/pmc.h>
|
|
|
|
#include <asm/arch-tegra/scu.h>
|
2013-01-28 13:32:10 +00:00
|
|
|
#include <asm/arch-tegra/tegra.h>
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch-tegra/warmboot.h>
|
2011-04-14 12:18:06 +00:00
|
|
|
|
2013-04-10 17:32:32 +00:00
|
|
|
int tegra_get_chip(void)
|
2012-04-02 13:18:50 +00:00
|
|
|
{
|
2013-04-10 17:32:32 +00:00
|
|
|
int rev;
|
|
|
|
struct apb_misc_gp_ctlr *gp =
|
|
|
|
(struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
|
2012-04-02 13:18:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is undocumented, Chip ID is bits 15:8 of the register
|
|
|
|
* APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for
|
2014-01-24 19:46:16 +00:00
|
|
|
* Tegra30, 0x35 for T114, and 0x40 for Tegra124.
|
2012-04-02 13:18:50 +00:00
|
|
|
*/
|
|
|
|
rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
|
2013-04-10 17:32:32 +00:00
|
|
|
debug("%s: CHIPID is 0x%02X\n", __func__, rev);
|
|
|
|
|
|
|
|
return rev;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tegra_get_sku_info(void)
|
|
|
|
{
|
|
|
|
int sku_id;
|
|
|
|
struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
|
|
|
|
|
|
|
|
sku_id = readl(&fuse->sku_info) & 0xff;
|
|
|
|
debug("%s: SKU info byte is 0x%02X\n", __func__, sku_id);
|
|
|
|
|
|
|
|
return sku_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tegra_get_chip_sku(void)
|
|
|
|
{
|
|
|
|
uint sku_id, chip_id;
|
2012-04-02 13:18:50 +00:00
|
|
|
|
2013-04-10 17:32:32 +00:00
|
|
|
chip_id = tegra_get_chip();
|
|
|
|
sku_id = tegra_get_sku_info();
|
2012-04-02 13:18:50 +00:00
|
|
|
|
2013-04-10 17:32:32 +00:00
|
|
|
switch (chip_id) {
|
2012-08-31 08:30:00 +00:00
|
|
|
case CHIPID_TEGRA20:
|
2013-04-10 17:32:32 +00:00
|
|
|
switch (sku_id) {
|
2013-05-17 14:10:15 +00:00
|
|
|
case SKU_ID_T20_7:
|
2012-04-02 13:18:50 +00:00
|
|
|
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;
|
2012-12-11 13:34:15 +00:00
|
|
|
case CHIPID_TEGRA30:
|
2013-04-10 17:32:32 +00:00
|
|
|
switch (sku_id) {
|
2013-03-27 09:37:02 +00:00
|
|
|
case SKU_ID_T33:
|
2012-12-11 13:34:15 +00:00
|
|
|
case SKU_ID_T30:
|
2013-11-13 16:27:18 +00:00
|
|
|
case SKU_ID_TM30MQS_P_A3:
|
2014-01-22 00:19:19 +00:00
|
|
|
default:
|
2012-12-11 13:34:15 +00:00
|
|
|
return TEGRA_SOC_T30;
|
|
|
|
}
|
|
|
|
break;
|
2013-01-28 13:32:10 +00:00
|
|
|
case CHIPID_TEGRA114:
|
2013-04-10 17:32:32 +00:00
|
|
|
switch (sku_id) {
|
2013-01-28 13:32:10 +00:00
|
|
|
case SKU_ID_T114_ENG:
|
2013-05-17 14:10:14 +00:00
|
|
|
case SKU_ID_T114_1:
|
2014-01-22 00:19:19 +00:00
|
|
|
default:
|
2013-01-28 13:32:10 +00:00
|
|
|
return TEGRA_SOC_T114;
|
|
|
|
}
|
|
|
|
break;
|
2014-01-24 19:46:16 +00:00
|
|
|
case CHIPID_TEGRA124:
|
|
|
|
switch (sku_id) {
|
|
|
|
case SKU_ID_T124_ENG:
|
|
|
|
default:
|
|
|
|
return TEGRA_SOC_T124;
|
|
|
|
}
|
|
|
|
break;
|
2015-03-04 23:36:00 +00:00
|
|
|
case CHIPID_TEGRA210:
|
|
|
|
switch (sku_id) {
|
|
|
|
case SKU_ID_T210_ENG:
|
|
|
|
default:
|
|
|
|
return TEGRA_SOC_T210;
|
|
|
|
}
|
|
|
|
break;
|
2012-04-02 13:18:50 +00:00
|
|
|
}
|
2014-01-24 19:46:16 +00:00
|
|
|
|
2013-04-10 17:32:32 +00:00
|
|
|
/* unknown chip/sku id */
|
|
|
|
printf("%s: ERROR: UNKNOWN CHIP/SKU ID COMBO (0x%02X/0x%02X)\n",
|
|
|
|
__func__, chip_id, sku_id);
|
2012-04-02 13:18:50 +00:00
|
|
|
return TEGRA_SOC_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2015-03-04 23:36:00 +00:00
|
|
|
#ifndef CONFIG_ARM64
|
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;
|
|
|
|
|
ARM: tegra: only enable SCU on Tegra20
The non-SPL build of U-Boot on Tegra only runs on a single CPU, and
hence there is no need to enable the SCU when running U-Boot. If an
SMP OS is booted, and it needs the SCU enabled, it will enable the SCU
itself. U-Boot doing so is redundant.
The one exception is Tegra20, where an enabled SCU is required for some
aspects of PCIe to work correctly.
Some Tegra SoCs contain CPUs without a software-controlled SCU. In this
case, attempting to turn it on actively causes problems. This is the case
for Tegra114. For example, when running Linux, the first (or at least
some very early) user-space process will trigger the following kernel
message:
Unhandled fault: imprecise external abort (0x406) at 0x00000000
This is typically accompanied by that process receving a fatal signal,
and exiting. Since this process is usually pid 1, this causes total
system boot failure.
Signed-off-by: Tom Warren <twarren@nvidia.com>
[swarren, fleshed out description, ported to upstream chipid APIs]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
2013-05-23 12:26:18 +00:00
|
|
|
/* Only enable the SCU on T20/T25 */
|
|
|
|
if (tegra_get_chip() != CHIPID_TEGRA20)
|
|
|
|
return;
|
|
|
|
|
2011-04-14 12:18:06 +00:00
|
|
|
/* 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
|
2014-01-24 19:46:16 +00:00
|
|
|
* on BCTs for currently supported SoCs, which are locked down.
|
|
|
|
* If this changes in new chips, we can revisit this algorithm.
|
2012-05-30 21:06:09 +00:00
|
|
|
*/
|
2015-07-22 21:58:05 +00:00
|
|
|
unsigned long bct_start;
|
|
|
|
u32 odmdata;
|
2012-05-30 21:06:09 +00:00
|
|
|
|
2012-12-11 13:34:15 +00:00
|
|
|
bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR);
|
2012-05-30 21:06:09 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-04-21 05:18:36 +00:00
|
|
|
#ifdef CONFIG_ARMV7_SECURE_RESERVE_SIZE
|
|
|
|
void protect_secure_section(void)
|
|
|
|
{
|
|
|
|
struct mc_ctlr *mc = (struct mc_ctlr *)NV_PA_MC_BASE;
|
|
|
|
|
|
|
|
/* Must be MB aligned */
|
|
|
|
BUILD_BUG_ON(CONFIG_ARMV7_SECURE_BASE & 0xFFFFF);
|
|
|
|
BUILD_BUG_ON(CONFIG_ARMV7_SECURE_RESERVE_SIZE & 0xFFFFF);
|
|
|
|
|
|
|
|
writel(CONFIG_ARMV7_SECURE_BASE, &mc->mc_security_cfg0);
|
|
|
|
writel(CONFIG_ARMV7_SECURE_RESERVE_SIZE >> 20, &mc->mc_security_cfg1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-21 05:18:38 +00:00
|
|
|
#if defined(CONFIG_ARMV7_NONSEC)
|
|
|
|
static void smmu_flush(struct mc_ctlr *mc)
|
|
|
|
{
|
|
|
|
(void)readl(&mc->mc_smmu_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smmu_enable(void)
|
|
|
|
{
|
|
|
|
struct mc_ctlr *mc = (struct mc_ctlr *)NV_PA_MC_BASE;
|
|
|
|
u32 value;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable translation for all clients since access to this register
|
|
|
|
* is restricted to TrustZone-secured requestors. The kernel will use
|
|
|
|
* the per-SWGROUP enable bits to enable or disable translations.
|
|
|
|
*/
|
|
|
|
writel(0xffffffff, &mc->mc_smmu_translation_enable_0);
|
|
|
|
writel(0xffffffff, &mc->mc_smmu_translation_enable_1);
|
|
|
|
writel(0xffffffff, &mc->mc_smmu_translation_enable_2);
|
|
|
|
writel(0xffffffff, &mc->mc_smmu_translation_enable_3);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable SMMU globally since access to this register is restricted
|
|
|
|
* to TrustZone-secured requestors.
|
|
|
|
*/
|
|
|
|
value = readl(&mc->mc_smmu_config);
|
|
|
|
value |= TEGRA_MC_SMMU_CONFIG_ENABLE;
|
|
|
|
writel(value, &mc->mc_smmu_config);
|
|
|
|
|
|
|
|
smmu_flush(mc);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void smmu_enable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2013-03-25 23:22:26 +00:00
|
|
|
/* init the cache */
|
|
|
|
config_cache();
|
2014-06-24 02:45:29 +00:00
|
|
|
|
2015-04-21 05:18:38 +00:00
|
|
|
/* enable SMMU */
|
|
|
|
smmu_enable();
|
2011-04-14 12:18:06 +00:00
|
|
|
}
|
2015-03-04 23:36:00 +00:00
|
|
|
#endif
|