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