Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 1 | /* |
| 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 Warren | 61c6d0e | 2012-12-11 13:34:15 +0000 | [diff] [blame^] | 23 | |
| 24 | /* Tegra AP (Application Processor) code */ |
| 25 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 26 | #include <common.h> |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 27 | #include <asm/io.h> |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 28 | #include <asm/arch/gp_padctrl.h> |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 29 | #include <asm/arch-tegra/ap.h> |
Tom Warren | 61c6d0e | 2012-12-11 13:34:15 +0000 | [diff] [blame^] | 30 | #include <asm/arch-tegra/clock.h> |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 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/warmboot.h> |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 35 | |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 36 | int tegra_get_chip_type(void) |
| 37 | { |
| 38 | struct apb_misc_gp_ctlr *gp; |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 39 | struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE; |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 40 | uint tegra_sku_id, rev; |
| 41 | |
| 42 | /* |
| 43 | * This is undocumented, Chip ID is bits 15:8 of the register |
| 44 | * APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for |
| 45 | * Tegra30 |
| 46 | */ |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 47 | gp = (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE; |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 48 | rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT; |
| 49 | |
| 50 | tegra_sku_id = readl(&fuse->sku_info) & 0xff; |
| 51 | |
| 52 | switch (rev) { |
Allen Martin | 55d98a1 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 53 | case CHIPID_TEGRA20: |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 54 | switch (tegra_sku_id) { |
| 55 | case SKU_ID_T20: |
| 56 | return TEGRA_SOC_T20; |
| 57 | case SKU_ID_T25SE: |
| 58 | case SKU_ID_AP25: |
| 59 | case SKU_ID_T25: |
| 60 | case SKU_ID_AP25E: |
| 61 | case SKU_ID_T25E: |
| 62 | return TEGRA_SOC_T25; |
| 63 | } |
| 64 | break; |
Tom Warren | 61c6d0e | 2012-12-11 13:34:15 +0000 | [diff] [blame^] | 65 | case CHIPID_TEGRA30: |
| 66 | switch (tegra_sku_id) { |
| 67 | case SKU_ID_T30: |
| 68 | return TEGRA_SOC_T30; |
| 69 | } |
| 70 | break; |
Simon Glass | 1fed82a | 2012-04-02 13:18:50 +0000 | [diff] [blame] | 71 | } |
| 72 | /* unknown sku id */ |
| 73 | return TEGRA_SOC_UNKNOWN; |
| 74 | } |
| 75 | |
Allen Martin | c9c9846 | 2012-08-31 08:30:12 +0000 | [diff] [blame] | 76 | static void enable_scu(void) |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 77 | { |
| 78 | struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE; |
| 79 | u32 reg; |
| 80 | |
| 81 | /* If SCU already setup/enabled, return */ |
| 82 | if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE) |
| 83 | return; |
| 84 | |
| 85 | /* Invalidate all ways for all processors */ |
| 86 | writel(0xFFFF, &scu->scu_inv_all); |
| 87 | |
| 88 | /* Enable SCU - bit 0 */ |
| 89 | reg = readl(&scu->scu_ctrl); |
| 90 | reg |= SCU_CTRL_ENABLE; |
| 91 | writel(reg, &scu->scu_ctrl); |
| 92 | } |
| 93 | |
Tom Warren | 7ee52b0 | 2012-05-30 14:06:09 -0700 | [diff] [blame] | 94 | static u32 get_odmdata(void) |
| 95 | { |
| 96 | /* |
| 97 | * ODMDATA is stored in the BCT in IRAM by the BootROM. |
| 98 | * The BCT start and size are stored in the BIT in IRAM. |
| 99 | * Read the data @ bct_start + (bct_size - 12). This works |
| 100 | * on T20 and T30 BCTs, which are locked down. If this changes |
| 101 | * in new chips (T114, etc.), we can revisit this algorithm. |
| 102 | */ |
| 103 | |
| 104 | u32 bct_start, odmdata; |
| 105 | |
Tom Warren | 61c6d0e | 2012-12-11 13:34:15 +0000 | [diff] [blame^] | 106 | bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR); |
Tom Warren | 7ee52b0 | 2012-05-30 14:06:09 -0700 | [diff] [blame] | 107 | odmdata = readl(bct_start + BCT_ODMDATA_OFFSET); |
| 108 | |
| 109 | return odmdata; |
| 110 | } |
| 111 | |
Allen Martin | c9c9846 | 2012-08-31 08:30:12 +0000 | [diff] [blame] | 112 | static void init_pmc_scratch(void) |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 113 | { |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 114 | struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE; |
Tom Warren | 7ee52b0 | 2012-05-30 14:06:09 -0700 | [diff] [blame] | 115 | u32 odmdata; |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 116 | int i; |
| 117 | |
| 118 | /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */ |
| 119 | for (i = 0; i < 23; i++) |
| 120 | writel(0, &pmc->pmc_scratch1+i); |
| 121 | |
| 122 | /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */ |
Tom Warren | 7ee52b0 | 2012-05-30 14:06:09 -0700 | [diff] [blame] | 123 | odmdata = get_odmdata(); |
| 124 | writel(odmdata, &pmc->pmc_scratch20); |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Allen Martin | c9c9846 | 2012-08-31 08:30:12 +0000 | [diff] [blame] | 127 | void s_init(void) |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 128 | { |
Simon Glass | ec8dab4 | 2011-11-05 03:56:50 +0000 | [diff] [blame] | 129 | /* Init PMC scratch memory */ |
| 130 | init_pmc_scratch(); |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 131 | |
Simon Glass | ec8dab4 | 2011-11-05 03:56:50 +0000 | [diff] [blame] | 132 | enable_scu(); |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 133 | |
Simon Glass | ec8dab4 | 2011-11-05 03:56:50 +0000 | [diff] [blame] | 134 | /* enable SMP mode and FW for CPU0, by writing to Auxiliary Ctl reg */ |
| 135 | asm volatile( |
| 136 | "mrc p15, 0, r0, c1, c0, 1\n" |
| 137 | "orr r0, r0, #0x41\n" |
| 138 | "mcr p15, 0, r0, c1, c0, 1\n"); |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 139 | |
Tom Warren | 61c6d0e | 2012-12-11 13:34:15 +0000 | [diff] [blame^] | 140 | /* FIXME: should have SoC's L2 disabled too? */ |
Tom Warren | 112a188 | 2011-04-14 12:18:06 +0000 | [diff] [blame] | 141 | } |