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