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