Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Common functions for OMAP4 based boards |
| 4 | * |
| 5 | * (C) Copyright 2010 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Author : |
| 9 | * Aneesh V <aneesh@ti.com> |
| 10 | * Steve Sakoman <steve@sakoman.com> |
| 11 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 12 | * SPDX-License-Identifier: GPL-2.0+ |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 13 | */ |
| 14 | #include <common.h> |
| 15 | #include <asm/armv7.h> |
| 16 | #include <asm/arch/cpu.h> |
| 17 | #include <asm/arch/sys_proto.h> |
Alexey Brodkin | 1ace402 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 18 | #include <linux/sizes.h> |
Sricharan | bb772a5 | 2011-11-15 09:50:00 -0500 | [diff] [blame] | 19 | #include <asm/emif.h> |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 20 | #include <asm/arch/gpio.h> |
SRICHARAN R | f92f227 | 2013-04-24 00:41:22 +0000 | [diff] [blame] | 21 | #include <asm/omap_common.h> |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
SRICHARAN R | f92f227 | 2013-04-24 00:41:22 +0000 | [diff] [blame] | 25 | u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 26 | |
| 27 | static const struct gpio_bank gpio_bank_44xx[6] = { |
| 28 | { (void *)OMAP44XX_GPIO1_BASE, METHOD_GPIO_24XX }, |
| 29 | { (void *)OMAP44XX_GPIO2_BASE, METHOD_GPIO_24XX }, |
| 30 | { (void *)OMAP44XX_GPIO3_BASE, METHOD_GPIO_24XX }, |
| 31 | { (void *)OMAP44XX_GPIO4_BASE, METHOD_GPIO_24XX }, |
| 32 | { (void *)OMAP44XX_GPIO5_BASE, METHOD_GPIO_24XX }, |
| 33 | { (void *)OMAP44XX_GPIO6_BASE, METHOD_GPIO_24XX }, |
| 34 | }; |
| 35 | |
| 36 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx; |
| 37 | |
| 38 | #ifdef CONFIG_SPL_BUILD |
| 39 | /* |
| 40 | * Some tuning of IOs for optimal power and performance |
| 41 | */ |
| 42 | void do_io_settings(void) |
| 43 | { |
| 44 | u32 lpddr2io; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 45 | |
| 46 | u32 omap4_rev = omap_revision(); |
| 47 | |
| 48 | if (omap4_rev == OMAP4430_ES1_0) |
| 49 | lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN; |
| 50 | else if (omap4_rev == OMAP4430_ES2_0) |
| 51 | lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER; |
| 52 | else |
| 53 | lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN; |
| 54 | |
| 55 | /* EMIF1 */ |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 56 | writel(lpddr2io, (*ctrl)->control_lpddr2io1_0); |
| 57 | writel(lpddr2io, (*ctrl)->control_lpddr2io1_1); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 58 | /* No pull for GR10 as per hw team's recommendation */ |
| 59 | writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK, |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 60 | (*ctrl)->control_lpddr2io1_2); |
| 61 | writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 62 | |
| 63 | /* EMIF2 */ |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 64 | writel(lpddr2io, (*ctrl)->control_lpddr2io2_0); |
| 65 | writel(lpddr2io, (*ctrl)->control_lpddr2io2_1); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 66 | /* No pull for GR10 as per hw team's recommendation */ |
| 67 | writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK, |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 68 | (*ctrl)->control_lpddr2io2_2); |
| 69 | writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | * Some of these settings (TRIM values) come from eFuse and are |
| 73 | * in turn programmed in the eFuse at manufacturing time after |
| 74 | * calibration of the device. Do the software over-ride only if |
| 75 | * the device is not correctly trimmed |
| 76 | */ |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 77 | if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) { |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 78 | |
| 79 | writel(LDOSRAM_VOLT_CTRL_OVERRIDE, |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 80 | (*ctrl)->control_ldosram_iva_voltage_ctrl); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 81 | |
| 82 | writel(LDOSRAM_VOLT_CTRL_OVERRIDE, |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 83 | (*ctrl)->control_ldosram_mpu_voltage_ctrl); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 84 | |
| 85 | writel(LDOSRAM_VOLT_CTRL_OVERRIDE, |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 86 | (*ctrl)->control_ldosram_core_voltage_ctrl); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 87 | } |
| 88 | |
Aneesh V | 23e9f07 | 2011-11-21 23:39:05 +0000 | [diff] [blame] | 89 | /* |
| 90 | * Over-ride the register |
| 91 | * i. unconditionally for all 4430 |
| 92 | * ii. only if un-trimmed for 4460 |
| 93 | */ |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 94 | if (!readl((*ctrl)->control_efuse_1)) |
| 95 | writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 96 | |
Lokesh Vutla | c43c833 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 97 | if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2)) |
| 98 | writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 99 | } |
Robert P. J. Day | f281f29 | 2012-11-13 08:12:08 +0000 | [diff] [blame] | 100 | #endif /* CONFIG_SPL_BUILD */ |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 101 | |
Lokesh Vutla | 784ab7c | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 102 | /* dummy fuction for omap4 */ |
| 103 | void config_data_eye_leveling_samples(u32 emif_base) |
| 104 | { |
| 105 | } |
| 106 | |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 107 | void init_omap_revision(void) |
| 108 | { |
| 109 | /* |
| 110 | * For some of the ES2/ES1 boards ID_CODE is not reliable: |
| 111 | * Also, ES1 and ES2 have different ARM revisions |
| 112 | * So use ARM revision for identification |
| 113 | */ |
| 114 | unsigned int arm_rev = cortex_rev(); |
| 115 | |
| 116 | switch (arm_rev) { |
| 117 | case MIDR_CORTEX_A9_R0P1: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 118 | *omap_si_rev = OMAP4430_ES1_0; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 119 | break; |
| 120 | case MIDR_CORTEX_A9_R1P2: |
| 121 | switch (readl(CONTROL_ID_CODE)) { |
| 122 | case OMAP4_CONTROL_ID_CODE_ES2_0: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 123 | *omap_si_rev = OMAP4430_ES2_0; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 124 | break; |
| 125 | case OMAP4_CONTROL_ID_CODE_ES2_1: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 126 | *omap_si_rev = OMAP4430_ES2_1; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 127 | break; |
| 128 | case OMAP4_CONTROL_ID_CODE_ES2_2: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 129 | *omap_si_rev = OMAP4430_ES2_2; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 130 | break; |
| 131 | default: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 132 | *omap_si_rev = OMAP4430_ES2_0; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 133 | break; |
| 134 | } |
| 135 | break; |
| 136 | case MIDR_CORTEX_A9_R1P3: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 137 | *omap_si_rev = OMAP4430_ES2_3; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 138 | break; |
| 139 | case MIDR_CORTEX_A9_R2P10: |
Aneesh V | 9404758 | 2011-11-21 23:39:03 +0000 | [diff] [blame] | 140 | switch (readl(CONTROL_ID_CODE)) { |
Taras Kondratiuk | 696f81f | 2013-08-06 15:18:48 +0300 | [diff] [blame] | 141 | case OMAP4470_CONTROL_ID_CODE_ES1_0: |
| 142 | *omap_si_rev = OMAP4470_ES1_0; |
| 143 | break; |
Aneesh V | 9404758 | 2011-11-21 23:39:03 +0000 | [diff] [blame] | 144 | case OMAP4460_CONTROL_ID_CODE_ES1_1: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 145 | *omap_si_rev = OMAP4460_ES1_1; |
Aneesh V | 9404758 | 2011-11-21 23:39:03 +0000 | [diff] [blame] | 146 | break; |
| 147 | case OMAP4460_CONTROL_ID_CODE_ES1_0: |
| 148 | default: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 149 | *omap_si_rev = OMAP4460_ES1_0; |
Aneesh V | 9404758 | 2011-11-21 23:39:03 +0000 | [diff] [blame] | 150 | break; |
| 151 | } |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 152 | break; |
| 153 | default: |
SRICHARAN R | 087189f | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 154 | *omap_si_rev = OMAP4430_SILICON_ID_INVALID; |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 155 | break; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | #ifndef CONFIG_SYS_L2CACHE_OFF |
| 160 | void v7_outer_cache_enable(void) |
| 161 | { |
Nishanth Menon | 6d8abe6 | 2015-03-09 17:12:03 -0500 | [diff] [blame] | 162 | omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 1); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | void v7_outer_cache_disable(void) |
| 166 | { |
Nishanth Menon | 6d8abe6 | 2015-03-09 17:12:03 -0500 | [diff] [blame] | 167 | omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 168 | } |
Robert P. J. Day | f281f29 | 2012-11-13 08:12:08 +0000 | [diff] [blame] | 169 | #endif /* !CONFIG_SYS_L2CACHE_OFF */ |