Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * Functions for omap5 based boards. |
| 5 | * |
| 6 | * (C) Copyright 2011 |
| 7 | * Texas Instruments, <www.ti.com> |
| 8 | * |
| 9 | * Author : |
| 10 | * Aneesh V <aneesh@ti.com> |
| 11 | * Steve Sakoman <steve@sakoman.com> |
| 12 | * Sricharan <r.sricharan@ti.com> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 13 | */ |
Simon Glass | afb0215 | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 14 | #include <cpu_func.h> |
Lokesh Vutla | d999d05 | 2016-11-23 13:25:28 +0530 | [diff] [blame] | 15 | #include <palmas.h> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 16 | #include <asm/armv7.h> |
| 17 | #include <asm/arch/cpu.h> |
| 18 | #include <asm/arch/sys_proto.h> |
Lokesh Vutla | 61c517f | 2013-05-30 02:54:32 +0000 | [diff] [blame] | 19 | #include <asm/arch/clock.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 20 | #include <linux/delay.h> |
Alexey Brodkin | 267d8e2 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 21 | #include <linux/sizes.h> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 22 | #include <asm/utils.h> |
| 23 | #include <asm/arch/gpio.h> |
Lokesh Vutla | 0f42de6 | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 24 | #include <asm/emif.h> |
SRICHARAN R | 4b1b61c | 2013-04-24 00:41:22 +0000 | [diff] [blame] | 25 | #include <asm/omap_common.h> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 26 | |
SRICHARAN R | 4b1b61c | 2013-04-24 00:41:22 +0000 | [diff] [blame] | 27 | u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV; |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 28 | |
Simon Glass | fa4689a | 2019-12-06 21:41:35 -0700 | [diff] [blame] | 29 | #if !CONFIG_IS_ENABLED(DM_GPIO) |
Axel Lin | 01a461f | 2013-06-21 18:54:25 +0800 | [diff] [blame] | 30 | static struct gpio_bank gpio_bank_54xx[8] = { |
Tom Rini | 7bc2bca | 2015-07-31 19:55:09 -0400 | [diff] [blame] | 31 | { (void *)OMAP54XX_GPIO1_BASE }, |
| 32 | { (void *)OMAP54XX_GPIO2_BASE }, |
| 33 | { (void *)OMAP54XX_GPIO3_BASE }, |
| 34 | { (void *)OMAP54XX_GPIO4_BASE }, |
| 35 | { (void *)OMAP54XX_GPIO5_BASE }, |
| 36 | { (void *)OMAP54XX_GPIO6_BASE }, |
| 37 | { (void *)OMAP54XX_GPIO7_BASE }, |
| 38 | { (void *)OMAP54XX_GPIO8_BASE }, |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_54xx; |
Tom Rini | 7bc2bca | 2015-07-31 19:55:09 -0400 | [diff] [blame] | 42 | #endif |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 43 | |
Lokesh Vutla | 5dedc17 | 2015-06-04 16:42:33 +0530 | [diff] [blame] | 44 | void do_set_mux32(u32 base, struct pad_conf_entry const *array, int size) |
| 45 | { |
| 46 | int i; |
| 47 | struct pad_conf_entry *pad = (struct pad_conf_entry *)array; |
| 48 | |
| 49 | for (i = 0; i < size; i++, pad++) |
| 50 | writel(pad->val, base + pad->offset); |
| 51 | } |
| 52 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 53 | #ifdef CONFIG_SPL_BUILD |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 54 | /* LPDDR2 specific IO settings */ |
| 55 | static void io_settings_lpddr2(void) |
| 56 | { |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 57 | const struct ctrl_ioregs *ioregs; |
| 58 | |
| 59 | get_ioregs(&ioregs); |
| 60 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_0); |
| 61 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_1); |
| 62 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_0); |
| 63 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_1); |
| 64 | writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_0); |
| 65 | writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_1); |
| 66 | writel(ioregs->ctrl_ddrio_0, (*ctrl)->control_ddrio_0); |
| 67 | writel(ioregs->ctrl_ddrio_1, (*ctrl)->control_ddrio_1); |
| 68 | writel(ioregs->ctrl_ddrio_2, (*ctrl)->control_ddrio_2); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* DDR3 specific IO settings */ |
| 72 | static void io_settings_ddr3(void) |
| 73 | { |
| 74 | u32 io_settings = 0; |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 75 | const struct ctrl_ioregs *ioregs; |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 76 | |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 77 | get_ioregs(&ioregs); |
| 78 | writel(ioregs->ctrl_ddr3ch, (*ctrl)->control_ddr3ch1_0); |
| 79 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_0); |
| 80 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_1); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 81 | |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 82 | writel(ioregs->ctrl_ddr3ch, (*ctrl)->control_ddr3ch2_0); |
| 83 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_0); |
| 84 | writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_1); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 85 | |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 86 | writel(ioregs->ctrl_ddrio_0, (*ctrl)->control_ddrio_0); |
| 87 | writel(ioregs->ctrl_ddrio_1, (*ctrl)->control_ddrio_1); |
Lokesh Vutla | 8c74b90 | 2015-06-03 14:43:26 +0530 | [diff] [blame] | 88 | |
| 89 | if (!is_dra7xx()) { |
| 90 | writel(ioregs->ctrl_ddrio_2, (*ctrl)->control_ddrio_2); |
| 91 | writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_1); |
| 92 | } |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 93 | |
| 94 | /* omap5432 does not use lpddr2 */ |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 95 | writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_0); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 96 | |
Lokesh Vutla | d8ac050 | 2013-02-04 04:22:05 +0000 | [diff] [blame] | 97 | writel(ioregs->ctrl_emif_sdram_config_ext, |
| 98 | (*ctrl)->control_emif1_sdram_config_ext); |
Lokesh Vutla | 8c74b90 | 2015-06-03 14:43:26 +0530 | [diff] [blame] | 99 | if (!is_dra72x()) |
| 100 | writel(ioregs->ctrl_emif_sdram_config_ext, |
| 101 | (*ctrl)->control_emif2_sdram_config_ext); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 102 | |
Sricharan R | ffa9818 | 2013-05-30 03:19:39 +0000 | [diff] [blame] | 103 | if (is_omap54xx()) { |
| 104 | /* Disable DLL select */ |
| 105 | io_settings = (readl((*ctrl)->control_port_emif1_sdram_config) |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 106 | & 0xFFEFFFFF); |
Sricharan R | ffa9818 | 2013-05-30 03:19:39 +0000 | [diff] [blame] | 107 | writel(io_settings, |
| 108 | (*ctrl)->control_port_emif1_sdram_config); |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 109 | |
Sricharan R | ffa9818 | 2013-05-30 03:19:39 +0000 | [diff] [blame] | 110 | io_settings = (readl((*ctrl)->control_port_emif2_sdram_config) |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 111 | & 0xFFEFFFFF); |
Sricharan R | ffa9818 | 2013-05-30 03:19:39 +0000 | [diff] [blame] | 112 | writel(io_settings, |
| 113 | (*ctrl)->control_port_emif2_sdram_config); |
| 114 | } else { |
| 115 | writel(ioregs->ctrl_ddr_ctrl_ext_0, |
| 116 | (*ctrl)->control_ddr_control_ext_0); |
| 117 | } |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 120 | /* |
| 121 | * Some tuning of IOs for optimal power and performance |
| 122 | */ |
| 123 | void do_io_settings(void) |
| 124 | { |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 125 | u32 io_settings = 0, mask = 0; |
Tom Rini | be8d635 | 2015-06-05 15:51:11 +0530 | [diff] [blame] | 126 | struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE; |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 127 | |
| 128 | /* Impedance settings EMMC, C2C 1,2, hsi2 */ |
| 129 | mask = (ds_mask << 2) | (ds_mask << 8) | |
| 130 | (ds_mask << 16) | (ds_mask << 18); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 131 | io_settings = readl((*ctrl)->control_smart1io_padconf_0) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 132 | (~mask); |
| 133 | io_settings |= (ds_60_ohm << 8) | (ds_45_ohm << 16) | |
| 134 | (ds_45_ohm << 18) | (ds_60_ohm << 2); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 135 | writel(io_settings, (*ctrl)->control_smart1io_padconf_0); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 136 | |
| 137 | /* Impedance settings Mcspi2 */ |
| 138 | mask = (ds_mask << 30); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 139 | io_settings = readl((*ctrl)->control_smart1io_padconf_1) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 140 | (~mask); |
| 141 | io_settings |= (ds_60_ohm << 30); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 142 | writel(io_settings, (*ctrl)->control_smart1io_padconf_1); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 143 | |
| 144 | /* Impedance settings C2C 3,4 */ |
| 145 | mask = (ds_mask << 14) | (ds_mask << 16); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 146 | io_settings = readl((*ctrl)->control_smart1io_padconf_2) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 147 | (~mask); |
| 148 | io_settings |= (ds_45_ohm << 14) | (ds_45_ohm << 16); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 149 | writel(io_settings, (*ctrl)->control_smart1io_padconf_2); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 150 | |
| 151 | /* Slew rate settings EMMC, C2C 1,2 */ |
| 152 | mask = (sc_mask << 8) | (sc_mask << 16) | (sc_mask << 18); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 153 | io_settings = readl((*ctrl)->control_smart2io_padconf_0) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 154 | (~mask); |
| 155 | io_settings |= (sc_fast << 8) | (sc_na << 16) | (sc_na << 18); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 156 | writel(io_settings, (*ctrl)->control_smart2io_padconf_0); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 157 | |
| 158 | /* Slew rate settings hsi2, Mcspi2 */ |
| 159 | mask = (sc_mask << 24) | (sc_mask << 28); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 160 | io_settings = readl((*ctrl)->control_smart2io_padconf_1) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 161 | (~mask); |
| 162 | io_settings |= (sc_fast << 28) | (sc_fast << 24); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 163 | writel(io_settings, (*ctrl)->control_smart2io_padconf_1); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 164 | |
| 165 | /* Slew rate settings C2C 3,4 */ |
| 166 | mask = (sc_mask << 16) | (sc_mask << 18); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 167 | io_settings = readl((*ctrl)->control_smart2io_padconf_2) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 168 | (~mask); |
| 169 | io_settings |= (sc_na << 16) | (sc_na << 18); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 170 | writel(io_settings, (*ctrl)->control_smart2io_padconf_2); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 171 | |
| 172 | /* impedance and slew rate settings for usb */ |
| 173 | mask = (usb_i_mask << 29) | (usb_i_mask << 26) | (usb_i_mask << 23) | |
| 174 | (usb_i_mask << 20) | (usb_i_mask << 17) | (usb_i_mask << 14); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 175 | io_settings = readl((*ctrl)->control_smart3io_padconf_1) & |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 176 | (~mask); |
| 177 | io_settings |= (ds_60_ohm << 29) | (ds_60_ohm << 26) | |
| 178 | (ds_60_ohm << 23) | (sc_fast << 20) | |
| 179 | (sc_fast << 17) | (sc_fast << 14); |
Lokesh Vutla | 834b6b0 | 2013-02-04 04:22:04 +0000 | [diff] [blame] | 180 | writel(io_settings, (*ctrl)->control_smart3io_padconf_1); |
SRICHARAN R | 8ec587d | 2012-03-12 02:25:36 +0000 | [diff] [blame] | 181 | |
Tom Rini | be8d635 | 2015-06-05 15:51:11 +0530 | [diff] [blame] | 182 | if (emif_sdram_type(emif->emif_sdram_config) == EMIF_SDRAM_TYPE_LPDDR2) |
Lokesh Vutla | ff7b2a9 | 2012-05-22 00:03:23 +0000 | [diff] [blame] | 183 | io_settings_lpddr2(); |
| 184 | else |
| 185 | io_settings_ddr3(); |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 186 | } |
Lokesh Vutla | 2804963 | 2013-02-12 01:33:45 +0000 | [diff] [blame] | 187 | |
| 188 | static const struct srcomp_params srcomp_parameters[NUM_SYS_CLKS] = { |
| 189 | {0x45, 0x1}, /* 12 MHz */ |
| 190 | {-1, -1}, /* 13 MHz */ |
| 191 | {0x63, 0x2}, /* 16.8 MHz */ |
| 192 | {0x57, 0x2}, /* 19.2 MHz */ |
| 193 | {0x20, 0x1}, /* 26 MHz */ |
| 194 | {-1, -1}, /* 27 MHz */ |
| 195 | {0x41, 0x3} /* 38.4 MHz */ |
| 196 | }; |
| 197 | |
| 198 | void srcomp_enable(void) |
| 199 | { |
| 200 | u32 srcomp_value, mul_factor, div_factor, clk_val, i; |
| 201 | u32 sysclk_ind = get_sys_clk_index(); |
| 202 | u32 omap_rev = omap_revision(); |
| 203 | |
Lokesh Vutla | 51bc17a | 2013-05-30 03:19:32 +0000 | [diff] [blame] | 204 | if (!is_omap54xx()) |
| 205 | return; |
| 206 | |
Lokesh Vutla | 2804963 | 2013-02-12 01:33:45 +0000 | [diff] [blame] | 207 | mul_factor = srcomp_parameters[sysclk_ind].multiply_factor; |
| 208 | div_factor = srcomp_parameters[sysclk_ind].divide_factor; |
| 209 | |
| 210 | for (i = 0; i < 4; i++) { |
| 211 | srcomp_value = readl((*ctrl)->control_srcomp_north_side + i*4); |
| 212 | srcomp_value &= |
| 213 | ~(MULTIPLY_FACTOR_XS_MASK | DIVIDE_FACTOR_XS_MASK); |
| 214 | srcomp_value |= (mul_factor << MULTIPLY_FACTOR_XS_SHIFT) | |
| 215 | (div_factor << DIVIDE_FACTOR_XS_SHIFT); |
| 216 | writel(srcomp_value, (*ctrl)->control_srcomp_north_side + i*4); |
| 217 | } |
| 218 | |
| 219 | if ((omap_rev == OMAP5430_ES1_0) || (omap_rev == OMAP5432_ES1_0)) { |
| 220 | clk_val = readl((*prcm)->cm_coreaon_io_srcomp_clkctrl); |
| 221 | clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK; |
| 222 | writel(clk_val, (*prcm)->cm_coreaon_io_srcomp_clkctrl); |
| 223 | |
| 224 | for (i = 0; i < 4; i++) { |
| 225 | srcomp_value = |
| 226 | readl((*ctrl)->control_srcomp_north_side + i*4); |
| 227 | srcomp_value &= ~PWRDWN_XS_MASK; |
| 228 | writel(srcomp_value, |
| 229 | (*ctrl)->control_srcomp_north_side + i*4); |
| 230 | |
| 231 | while (((readl((*ctrl)->control_srcomp_north_side + i*4) |
| 232 | & SRCODE_READ_XS_MASK) >> |
| 233 | SRCODE_READ_XS_SHIFT) == 0) |
| 234 | ; |
| 235 | |
| 236 | srcomp_value = |
| 237 | readl((*ctrl)->control_srcomp_north_side + i*4); |
| 238 | srcomp_value &= ~OVERRIDE_XS_MASK; |
| 239 | writel(srcomp_value, |
| 240 | (*ctrl)->control_srcomp_north_side + i*4); |
| 241 | } |
| 242 | } else { |
| 243 | srcomp_value = readl((*ctrl)->control_srcomp_east_side_wkup); |
| 244 | srcomp_value &= ~(MULTIPLY_FACTOR_XS_MASK | |
| 245 | DIVIDE_FACTOR_XS_MASK); |
| 246 | srcomp_value |= (mul_factor << MULTIPLY_FACTOR_XS_SHIFT) | |
| 247 | (div_factor << DIVIDE_FACTOR_XS_SHIFT); |
| 248 | writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup); |
| 249 | |
| 250 | for (i = 0; i < 4; i++) { |
| 251 | srcomp_value = |
| 252 | readl((*ctrl)->control_srcomp_north_side + i*4); |
| 253 | srcomp_value |= SRCODE_OVERRIDE_SEL_XS_MASK; |
| 254 | writel(srcomp_value, |
| 255 | (*ctrl)->control_srcomp_north_side + i*4); |
| 256 | |
| 257 | srcomp_value = |
| 258 | readl((*ctrl)->control_srcomp_north_side + i*4); |
| 259 | srcomp_value &= ~OVERRIDE_XS_MASK; |
| 260 | writel(srcomp_value, |
| 261 | (*ctrl)->control_srcomp_north_side + i*4); |
| 262 | } |
| 263 | |
| 264 | srcomp_value = |
| 265 | readl((*ctrl)->control_srcomp_east_side_wkup); |
| 266 | srcomp_value |= SRCODE_OVERRIDE_SEL_XS_MASK; |
| 267 | writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup); |
| 268 | |
| 269 | srcomp_value = |
| 270 | readl((*ctrl)->control_srcomp_east_side_wkup); |
| 271 | srcomp_value &= ~OVERRIDE_XS_MASK; |
| 272 | writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup); |
| 273 | |
| 274 | clk_val = readl((*prcm)->cm_coreaon_io_srcomp_clkctrl); |
| 275 | clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK; |
| 276 | writel(clk_val, (*prcm)->cm_coreaon_io_srcomp_clkctrl); |
| 277 | |
| 278 | clk_val = readl((*prcm)->cm_wkupaon_io_srcomp_clkctrl); |
| 279 | clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK; |
| 280 | writel(clk_val, (*prcm)->cm_wkupaon_io_srcomp_clkctrl); |
| 281 | |
| 282 | for (i = 0; i < 4; i++) { |
| 283 | while (((readl((*ctrl)->control_srcomp_north_side + i*4) |
| 284 | & SRCODE_READ_XS_MASK) >> |
| 285 | SRCODE_READ_XS_SHIFT) == 0) |
| 286 | ; |
| 287 | |
| 288 | srcomp_value = |
| 289 | readl((*ctrl)->control_srcomp_north_side + i*4); |
| 290 | srcomp_value &= ~SRCODE_OVERRIDE_SEL_XS_MASK; |
| 291 | writel(srcomp_value, |
| 292 | (*ctrl)->control_srcomp_north_side + i*4); |
| 293 | } |
| 294 | |
| 295 | while (((readl((*ctrl)->control_srcomp_east_side_wkup) & |
| 296 | SRCODE_READ_XS_MASK) >> SRCODE_READ_XS_SHIFT) == 0) |
| 297 | ; |
| 298 | |
| 299 | srcomp_value = |
| 300 | readl((*ctrl)->control_srcomp_east_side_wkup); |
| 301 | srcomp_value &= ~SRCODE_OVERRIDE_SEL_XS_MASK; |
| 302 | writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup); |
| 303 | } |
| 304 | } |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 305 | #endif |
| 306 | |
Lokesh Vutla | 0f42de6 | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 307 | void config_data_eye_leveling_samples(u32 emif_base) |
| 308 | { |
SRICHARAN R | e02f5f8 | 2013-11-08 17:40:37 +0530 | [diff] [blame] | 309 | const struct ctrl_ioregs *ioregs; |
| 310 | |
| 311 | get_ioregs(&ioregs); |
| 312 | |
Lokesh Vutla | 0f42de6 | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 313 | /*EMIF_SDRAM_CONFIG_EXT-Read data eye leveling no of samples =4*/ |
| 314 | if (emif_base == EMIF1_BASE) |
SRICHARAN R | e02f5f8 | 2013-11-08 17:40:37 +0530 | [diff] [blame] | 315 | writel(ioregs->ctrl_emif_sdram_config_ext_final, |
| 316 | (*ctrl)->control_emif1_sdram_config_ext); |
Lokesh Vutla | 0f42de6 | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 317 | else if (emif_base == EMIF2_BASE) |
SRICHARAN R | e02f5f8 | 2013-11-08 17:40:37 +0530 | [diff] [blame] | 318 | writel(ioregs->ctrl_emif_sdram_config_ext_final, |
| 319 | (*ctrl)->control_emif2_sdram_config_ext); |
Lokesh Vutla | 0f42de6 | 2012-05-22 00:03:25 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Nishanth Menon | e24175a | 2015-03-09 17:12:07 -0500 | [diff] [blame] | 322 | void init_cpu_configuration(void) |
| 323 | { |
| 324 | u32 l2actlr; |
| 325 | |
| 326 | asm volatile("mrc p15, 1, %0, c15, c0, 0" : "=r"(l2actlr)); |
| 327 | /* |
| 328 | * L2ACTLR: Ensure to enable the following: |
| 329 | * 3: Disable clean/evict push to external |
| 330 | * 4: Disable WriteUnique and WriteLineUnique transactions from master |
| 331 | * 8: Disable DVM/CMO message broadcast |
| 332 | */ |
| 333 | l2actlr |= 0x118; |
| 334 | omap_smc1(OMAP5_SERVICE_L2ACTLR_SET, l2actlr); |
| 335 | } |
| 336 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 337 | void init_omap_revision(void) |
| 338 | { |
| 339 | /* |
| 340 | * For some of the ES2/ES1 boards ID_CODE is not reliable: |
| 341 | * Also, ES1 and ES2 have different ARM revisions |
| 342 | * So use ARM revision for identification |
| 343 | */ |
| 344 | unsigned int rev = cortex_rev(); |
| 345 | |
SRICHARAN R | cf85056 | 2013-02-12 01:33:41 +0000 | [diff] [blame] | 346 | switch (readl(CONTROL_ID_CODE)) { |
| 347 | case OMAP5430_CONTROL_ID_CODE_ES1_0: |
| 348 | *omap_si_rev = OMAP5430_ES1_0; |
| 349 | if (rev == MIDR_CORTEX_A15_R2P2) |
| 350 | *omap_si_rev = OMAP5430_ES2_0; |
| 351 | break; |
| 352 | case OMAP5432_CONTROL_ID_CODE_ES1_0: |
| 353 | *omap_si_rev = OMAP5432_ES1_0; |
| 354 | if (rev == MIDR_CORTEX_A15_R2P2) |
| 355 | *omap_si_rev = OMAP5432_ES2_0; |
| 356 | break; |
| 357 | case OMAP5430_CONTROL_ID_CODE_ES2_0: |
| 358 | *omap_si_rev = OMAP5430_ES2_0; |
| 359 | break; |
| 360 | case OMAP5432_CONTROL_ID_CODE_ES2_0: |
| 361 | *omap_si_rev = OMAP5432_ES2_0; |
SRICHARAN R | 602476e | 2012-03-12 02:25:39 +0000 | [diff] [blame] | 362 | break; |
Praneeth Bajjuri | 9b21ff4 | 2017-08-21 12:50:52 +0530 | [diff] [blame] | 363 | case DRA762_CONTROL_ID_CODE_ES1_0: |
| 364 | *omap_si_rev = DRA762_ES1_0; |
| 365 | break; |
Lokesh Vutla | 43c296f | 2013-02-12 21:29:03 +0000 | [diff] [blame] | 366 | case DRA752_CONTROL_ID_CODE_ES1_0: |
| 367 | *omap_si_rev = DRA752_ES1_0; |
| 368 | break; |
Nishanth Menon | 60475ff | 2014-01-14 10:54:42 -0600 | [diff] [blame] | 369 | case DRA752_CONTROL_ID_CODE_ES1_1: |
| 370 | *omap_si_rev = DRA752_ES1_1; |
| 371 | break; |
Nishanth Menon | 4de1668 | 2015-08-13 09:50:58 -0500 | [diff] [blame] | 372 | case DRA752_CONTROL_ID_CODE_ES2_0: |
| 373 | *omap_si_rev = DRA752_ES2_0; |
| 374 | break; |
Lokesh Vutla | 7572549 | 2014-05-15 11:08:38 +0530 | [diff] [blame] | 375 | case DRA722_CONTROL_ID_CODE_ES1_0: |
| 376 | *omap_si_rev = DRA722_ES1_0; |
| 377 | break; |
Ravi Babu | af9af44 | 2016-03-15 18:09:11 -0500 | [diff] [blame] | 378 | case DRA722_CONTROL_ID_CODE_ES2_0: |
| 379 | *omap_si_rev = DRA722_ES2_0; |
| 380 | break; |
Vishal Mahaveer | 42d25eb | 2017-08-26 16:51:22 -0500 | [diff] [blame] | 381 | case DRA722_CONTROL_ID_CODE_ES2_1: |
| 382 | *omap_si_rev = DRA722_ES2_1; |
| 383 | break; |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 384 | default: |
SRICHARAN R | d3901b1 | 2012-03-12 02:25:40 +0000 | [diff] [blame] | 385 | *omap_si_rev = OMAP5430_SILICON_ID_INVALID; |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 386 | } |
Nishanth Menon | e24175a | 2015-03-09 17:12:07 -0500 | [diff] [blame] | 387 | init_cpu_configuration(); |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 388 | } |
SRICHARAN R | a8f08fd | 2012-03-12 02:25:52 +0000 | [diff] [blame] | 389 | |
Lokesh Vutla | 69483e6 | 2017-12-29 11:47:51 +0530 | [diff] [blame] | 390 | void init_package_revision(void) |
| 391 | { |
| 392 | unsigned int die_id[4] = { 0 }; |
| 393 | u8 package; |
| 394 | |
| 395 | omap_die_id(die_id); |
| 396 | package = (die_id[2] >> 16) & 0x3; |
| 397 | |
| 398 | if (is_dra76x()) { |
| 399 | switch (package) { |
| 400 | case DRA762_ABZ_PACKAGE: |
| 401 | *omap_si_rev = DRA762_ABZ_ES1_0; |
| 402 | break; |
| 403 | case DRA762_ACD_PACKAGE: |
| 404 | default: |
| 405 | *omap_si_rev = DRA762_ACD_ES1_0; |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
Paul Kocialkowski | c68d569 | 2015-08-27 19:37:11 +0200 | [diff] [blame] | 411 | void omap_die_id(unsigned int *die_id) |
| 412 | { |
| 413 | die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0); |
| 414 | die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1); |
| 415 | die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2); |
| 416 | die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3); |
| 417 | } |
| 418 | |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 419 | void reset_cpu(void) |
SRICHARAN R | a8f08fd | 2012-03-12 02:25:52 +0000 | [diff] [blame] | 420 | { |
| 421 | u32 omap_rev = omap_revision(); |
| 422 | |
| 423 | /* |
| 424 | * WARM reset is not functional in case of OMAP5430 ES1.0 soc. |
| 425 | * So use cold reset in case instead. |
| 426 | */ |
| 427 | if (omap_rev == OMAP5430_ES1_0) |
Lokesh Vutla | 15c2c70 | 2013-02-17 23:33:37 +0000 | [diff] [blame] | 428 | writel(PRM_RSTCTRL_RESET << 0x1, (*prcm)->prm_rstctrl); |
SRICHARAN R | a8f08fd | 2012-03-12 02:25:52 +0000 | [diff] [blame] | 429 | else |
Lokesh Vutla | 15c2c70 | 2013-02-17 23:33:37 +0000 | [diff] [blame] | 430 | writel(PRM_RSTCTRL_RESET, (*prcm)->prm_rstctrl); |
| 431 | } |
| 432 | |
| 433 | u32 warm_reset(void) |
| 434 | { |
| 435 | return readl((*prcm)->prm_rstst) & PRM_RSTST_WARM_RESET_MASK; |
SRICHARAN R | a8f08fd | 2012-03-12 02:25:52 +0000 | [diff] [blame] | 436 | } |
Lokesh Vutla | 100c2d8 | 2013-04-17 20:49:40 +0000 | [diff] [blame] | 437 | |
| 438 | void setup_warmreset_time(void) |
| 439 | { |
| 440 | u32 rst_time, rst_val; |
| 441 | |
Tom Rini | 50e221a | 2017-05-12 22:33:17 -0400 | [diff] [blame] | 442 | /* |
| 443 | * MAX value for PRM_RSTTIME[9:0]RSTTIME1 stored is 0x3ff. |
| 444 | * 0x3ff is in the no of FUNC_32K_CLK cycles. Converting cycles |
| 445 | * into microsec and passing the value. |
| 446 | */ |
| 447 | rst_time = usec_to_32k(CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC) |
| 448 | << RSTTIME1_SHIFT; |
Lokesh Vutla | 100c2d8 | 2013-04-17 20:49:40 +0000 | [diff] [blame] | 449 | |
| 450 | if (rst_time > RSTTIME1_MASK) |
| 451 | rst_time = RSTTIME1_MASK; |
| 452 | |
| 453 | rst_val = readl((*prcm)->prm_rsttime) & ~RSTTIME1_MASK; |
| 454 | rst_val |= rst_time; |
| 455 | writel(rst_val, (*prcm)->prm_rsttime); |
| 456 | } |
Praveen Rao | 3206b8a | 2015-03-09 17:12:06 -0500 | [diff] [blame] | 457 | |
| 458 | void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr, |
| 459 | u32 cpu_rev_comb, u32 cpu_variant, |
| 460 | u32 cpu_rev) |
| 461 | { |
| 462 | omap_smc1(OMAP5_SERVICE_L2ACTLR_SET, l2auxctrl); |
| 463 | } |
Nishanth Menon | 2740b83 | 2015-07-27 16:26:06 -0500 | [diff] [blame] | 464 | |
| 465 | void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb, |
| 466 | u32 cpu_variant, u32 cpu_rev) |
| 467 | { |
Nishanth Menon | 2b244cc | 2015-07-27 16:26:07 -0500 | [diff] [blame] | 468 | |
| 469 | #ifdef CONFIG_ARM_ERRATA_801819 |
| 470 | /* |
| 471 | * DRA72x processors are uniprocessors and DONOT have |
| 472 | * ACP (Accelerator Coherency Port) hooked to ACE (AXI Coherency |
| 473 | * Extensions) Hence the erratum workaround is not applicable for |
| 474 | * DRA72x processors. |
| 475 | */ |
| 476 | if (is_dra72x()) |
| 477 | acr &= ~((0x3 << 23) | (0x3 << 25)); |
| 478 | #endif |
Nishanth Menon | 2740b83 | 2015-07-27 16:26:06 -0500 | [diff] [blame] | 479 | omap_smc1(OMAP5_SERVICE_ACR_SET, acr); |
| 480 | } |
Lokesh Vutla | d999d05 | 2016-11-23 13:25:28 +0530 | [diff] [blame] | 481 | |
| 482 | #if defined(CONFIG_PALMAS_POWER) |
Lokesh Vutla | 8352d27 | 2017-08-21 12:50:49 +0530 | [diff] [blame] | 483 | __weak void board_mmc_poweron_ldo(uint voltage) |
| 484 | { |
Lokesh Vutla | 22fa819 | 2017-08-21 12:50:50 +0530 | [diff] [blame] | 485 | palmas_mmc1_poweron_ldo(LDO1_VOLTAGE, LDO1_CTRL, voltage); |
Lokesh Vutla | 8352d27 | 2017-08-21 12:50:49 +0530 | [diff] [blame] | 486 | } |
| 487 | |
Lokesh Vutla | d999d05 | 2016-11-23 13:25:28 +0530 | [diff] [blame] | 488 | void vmmc_pbias_config(uint voltage) |
| 489 | { |
| 490 | u32 value = 0; |
Lokesh Vutla | d999d05 | 2016-11-23 13:25:28 +0530 | [diff] [blame] | 491 | |
| 492 | value = readl((*ctrl)->control_pbias); |
| 493 | value &= ~SDCARD_PWRDNZ; |
| 494 | writel(value, (*ctrl)->control_pbias); |
| 495 | udelay(10); /* wait 10 us */ |
| 496 | value &= ~SDCARD_BIAS_PWRDNZ; |
| 497 | writel(value, (*ctrl)->control_pbias); |
| 498 | |
Lokesh Vutla | 8352d27 | 2017-08-21 12:50:49 +0530 | [diff] [blame] | 499 | board_mmc_poweron_ldo(voltage); |
Lokesh Vutla | d999d05 | 2016-11-23 13:25:28 +0530 | [diff] [blame] | 500 | |
| 501 | value = readl((*ctrl)->control_pbias); |
| 502 | value |= SDCARD_BIAS_PWRDNZ; |
| 503 | writel(value, (*ctrl)->control_pbias); |
| 504 | udelay(150); /* wait 150 us */ |
| 505 | value |= SDCARD_PWRDNZ; |
| 506 | writel(value, (*ctrl)->control_pbias); |
| 507 | udelay(150); /* wait 150 us */ |
| 508 | } |
| 509 | #endif |