Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * Clock initialization for OMAP4 |
| 5 | * |
| 6 | * (C) Copyright 2010 |
| 7 | * Texas Instruments, <www.ti.com> |
| 8 | * |
| 9 | * Aneesh V <aneesh@ti.com> |
| 10 | * |
| 11 | * Based on previous work by: |
| 12 | * Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 13 | * Rajendra Nayak <rnayak@ti.com> |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 14 | */ |
| 15 | #include <common.h> |
Lokesh Vutla | 3685297 | 2013-05-30 03:19:29 +0000 | [diff] [blame] | 16 | #include <i2c.h> |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 17 | #include <asm/omap_common.h> |
Sanjeev Premi | 0c2c8ac | 2011-09-08 10:48:39 -0400 | [diff] [blame] | 18 | #include <asm/gpio.h> |
Lokesh Vutla | 61c517f | 2013-05-30 02:54:32 +0000 | [diff] [blame] | 19 | #include <asm/arch/clock.h> |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 20 | #include <asm/arch/sys_proto.h> |
| 21 | #include <asm/utils.h> |
Aneesh V | 0fa1d1b | 2011-07-21 09:29:32 -0400 | [diff] [blame] | 22 | #include <asm/omap_gpio.h> |
Lokesh Vutla | fef54c3 | 2013-02-04 04:21:59 +0000 | [diff] [blame] | 23 | #include <asm/emif.h> |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 24 | |
| 25 | #ifndef CONFIG_SPL_BUILD |
| 26 | /* |
| 27 | * printing to console doesn't work unless |
| 28 | * this code is executed from SPL |
| 29 | */ |
| 30 | #define printf(fmt, args...) |
| 31 | #define puts(s) |
| 32 | #endif |
| 33 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 34 | const u32 sys_clk_array[8] = { |
| 35 | 12000000, /* 12 MHz */ |
Lokesh Vutla | 1652326 | 2013-05-30 03:19:38 +0000 | [diff] [blame] | 36 | 20000000, /* 20 MHz */ |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 37 | 16800000, /* 16.8 MHz */ |
| 38 | 19200000, /* 19.2 MHz */ |
| 39 | 26000000, /* 26 MHz */ |
| 40 | 27000000, /* 27 MHz */ |
| 41 | 38400000, /* 38.4 MHz */ |
| 42 | }; |
| 43 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 44 | static inline u32 __get_sys_clk_index(void) |
| 45 | { |
Lokesh Vutla | 5e70e29 | 2013-02-12 21:29:05 +0000 | [diff] [blame] | 46 | s8 ind; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 47 | /* |
| 48 | * For ES1 the ROM code calibration of sys clock is not reliable |
| 49 | * due to hw issue. So, use hard-coded value. If this value is not |
| 50 | * correct for any board over-ride this function in board file |
| 51 | * From ES2.0 onwards you will get this information from |
| 52 | * CM_SYS_CLKSEL |
| 53 | */ |
| 54 | if (omap_revision() == OMAP4430_ES1_0) |
| 55 | ind = OMAP_SYS_CLK_IND_38_4_MHZ; |
| 56 | else { |
| 57 | /* SYS_CLKSEL - 1 to match the dpll param array indices */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 58 | ind = (readl((*prcm)->cm_sys_clksel) & |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 59 | CM_SYS_CLKSEL_SYS_CLKSEL_MASK) - 1; |
| 60 | } |
| 61 | return ind; |
| 62 | } |
| 63 | |
| 64 | u32 get_sys_clk_index(void) |
| 65 | __attribute__ ((weak, alias("__get_sys_clk_index"))); |
| 66 | |
| 67 | u32 get_sys_clk_freq(void) |
| 68 | { |
| 69 | u8 index = get_sys_clk_index(); |
| 70 | return sys_clk_array[index]; |
| 71 | } |
| 72 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 73 | void setup_post_dividers(u32 const base, const struct dpll_params *params) |
| 74 | { |
| 75 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 76 | |
| 77 | /* Setup post-dividers */ |
| 78 | if (params->m2 >= 0) |
| 79 | writel(params->m2, &dpll_regs->cm_div_m2_dpll); |
| 80 | if (params->m3 >= 0) |
| 81 | writel(params->m3, &dpll_regs->cm_div_m3_dpll); |
| 82 | if (params->m4_h11 >= 0) |
| 83 | writel(params->m4_h11, &dpll_regs->cm_div_m4_h11_dpll); |
| 84 | if (params->m5_h12 >= 0) |
| 85 | writel(params->m5_h12, &dpll_regs->cm_div_m5_h12_dpll); |
| 86 | if (params->m6_h13 >= 0) |
| 87 | writel(params->m6_h13, &dpll_regs->cm_div_m6_h13_dpll); |
| 88 | if (params->m7_h14 >= 0) |
| 89 | writel(params->m7_h14, &dpll_regs->cm_div_m7_h14_dpll); |
SRICHARAN R | a04ed14 | 2013-02-12 01:33:43 +0000 | [diff] [blame] | 90 | if (params->h21 >= 0) |
| 91 | writel(params->h21, &dpll_regs->cm_div_h21_dpll); |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 92 | if (params->h22 >= 0) |
| 93 | writel(params->h22, &dpll_regs->cm_div_h22_dpll); |
| 94 | if (params->h23 >= 0) |
| 95 | writel(params->h23, &dpll_regs->cm_div_h23_dpll); |
SRICHARAN R | a04ed14 | 2013-02-12 01:33:43 +0000 | [diff] [blame] | 96 | if (params->h24 >= 0) |
| 97 | writel(params->h24, &dpll_regs->cm_div_h24_dpll); |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 98 | } |
| 99 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 100 | static inline void do_bypass_dpll(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 101 | { |
| 102 | struct dpll_regs *dpll_regs = (struct dpll_regs *)base; |
| 103 | |
| 104 | clrsetbits_le32(&dpll_regs->cm_clkmode_dpll, |
| 105 | CM_CLKMODE_DPLL_DPLL_EN_MASK, |
| 106 | DPLL_EN_FAST_RELOCK_BYPASS << |
| 107 | CM_CLKMODE_DPLL_EN_SHIFT); |
| 108 | } |
| 109 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 110 | static inline void wait_for_bypass(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 111 | { |
| 112 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 113 | |
| 114 | if (!wait_on_value(ST_DPLL_CLK_MASK, 0, &dpll_regs->cm_idlest_dpll, |
| 115 | LDELAY)) { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 116 | printf("Bypassing DPLL failed %x\n", base); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 120 | static inline void do_lock_dpll(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 121 | { |
| 122 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 123 | |
| 124 | clrsetbits_le32(&dpll_regs->cm_clkmode_dpll, |
| 125 | CM_CLKMODE_DPLL_DPLL_EN_MASK, |
| 126 | DPLL_EN_LOCK << CM_CLKMODE_DPLL_EN_SHIFT); |
| 127 | } |
| 128 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 129 | static inline void wait_for_lock(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 130 | { |
| 131 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 132 | |
| 133 | if (!wait_on_value(ST_DPLL_CLK_MASK, ST_DPLL_CLK_MASK, |
| 134 | &dpll_regs->cm_idlest_dpll, LDELAY)) { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 135 | printf("DPLL locking failed for %x\n", base); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 136 | hang(); |
| 137 | } |
| 138 | } |
| 139 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 140 | inline u32 check_for_lock(u32 const base) |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 141 | { |
| 142 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 143 | u32 lock = readl(&dpll_regs->cm_idlest_dpll) & ST_DPLL_CLK_MASK; |
| 144 | |
| 145 | return lock; |
| 146 | } |
| 147 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 148 | const struct dpll_params *get_mpu_dpll_params(struct dplls const *dpll_data) |
| 149 | { |
| 150 | u32 sysclk_ind = get_sys_clk_index(); |
| 151 | return &dpll_data->mpu[sysclk_ind]; |
| 152 | } |
| 153 | |
| 154 | const struct dpll_params *get_core_dpll_params(struct dplls const *dpll_data) |
| 155 | { |
| 156 | u32 sysclk_ind = get_sys_clk_index(); |
| 157 | return &dpll_data->core[sysclk_ind]; |
| 158 | } |
| 159 | |
| 160 | const struct dpll_params *get_per_dpll_params(struct dplls const *dpll_data) |
| 161 | { |
| 162 | u32 sysclk_ind = get_sys_clk_index(); |
| 163 | return &dpll_data->per[sysclk_ind]; |
| 164 | } |
| 165 | |
| 166 | const struct dpll_params *get_iva_dpll_params(struct dplls const *dpll_data) |
| 167 | { |
| 168 | u32 sysclk_ind = get_sys_clk_index(); |
| 169 | return &dpll_data->iva[sysclk_ind]; |
| 170 | } |
| 171 | |
| 172 | const struct dpll_params *get_usb_dpll_params(struct dplls const *dpll_data) |
| 173 | { |
| 174 | u32 sysclk_ind = get_sys_clk_index(); |
| 175 | return &dpll_data->usb[sysclk_ind]; |
| 176 | } |
| 177 | |
| 178 | const struct dpll_params *get_abe_dpll_params(struct dplls const *dpll_data) |
| 179 | { |
| 180 | #ifdef CONFIG_SYS_OMAP_ABE_SYSCK |
| 181 | u32 sysclk_ind = get_sys_clk_index(); |
| 182 | return &dpll_data->abe[sysclk_ind]; |
| 183 | #else |
| 184 | return dpll_data->abe; |
| 185 | #endif |
| 186 | } |
| 187 | |
Lokesh Vutla | 5e70e29 | 2013-02-12 21:29:05 +0000 | [diff] [blame] | 188 | static const struct dpll_params *get_ddr_dpll_params |
| 189 | (struct dplls const *dpll_data) |
| 190 | { |
| 191 | u32 sysclk_ind = get_sys_clk_index(); |
| 192 | |
| 193 | if (!dpll_data->ddr) |
| 194 | return NULL; |
| 195 | return &dpll_data->ddr[sysclk_ind]; |
| 196 | } |
| 197 | |
Lokesh Vutla | adc52df | 2013-07-08 16:04:39 +0530 | [diff] [blame] | 198 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 199 | static const struct dpll_params *get_gmac_dpll_params |
| 200 | (struct dplls const *dpll_data) |
| 201 | { |
| 202 | u32 sysclk_ind = get_sys_clk_index(); |
| 203 | |
| 204 | if (!dpll_data->gmac) |
| 205 | return NULL; |
| 206 | return &dpll_data->gmac[sysclk_ind]; |
| 207 | } |
| 208 | #endif |
| 209 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 210 | static void do_setup_dpll(u32 const base, const struct dpll_params *params, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 211 | u8 lock, char *dpll) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 212 | { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 213 | u32 temp, M, N; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 214 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 215 | |
Lokesh Vutla | 5e70e29 | 2013-02-12 21:29:05 +0000 | [diff] [blame] | 216 | if (!params) |
| 217 | return; |
| 218 | |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 219 | temp = readl(&dpll_regs->cm_clksel_dpll); |
| 220 | |
| 221 | if (check_for_lock(base)) { |
| 222 | /* |
| 223 | * The Dpll has already been locked by rom code using CH. |
| 224 | * Check if M,N are matching with Ideal nominal opp values. |
| 225 | * If matches, skip the rest otherwise relock. |
| 226 | */ |
| 227 | M = (temp & CM_CLKSEL_DPLL_M_MASK) >> CM_CLKSEL_DPLL_M_SHIFT; |
| 228 | N = (temp & CM_CLKSEL_DPLL_N_MASK) >> CM_CLKSEL_DPLL_N_SHIFT; |
| 229 | if ((M != (params->m)) || (N != (params->n))) { |
| 230 | debug("\n %s Dpll locked, but not for ideal M = %d," |
| 231 | "N = %d values, current values are M = %d," |
| 232 | "N= %d" , dpll, params->m, params->n, |
| 233 | M, N); |
| 234 | } else { |
| 235 | /* Dpll locked with ideal values for nominal opps. */ |
| 236 | debug("\n %s Dpll already locked with ideal" |
| 237 | "nominal opp values", dpll); |
Lokesh Vutla | 9bd0f9a | 2016-05-23 13:31:19 +0530 | [diff] [blame] | 238 | |
| 239 | bypass_dpll(base); |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 240 | goto setup_post_dividers; |
| 241 | } |
| 242 | } |
| 243 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 244 | bypass_dpll(base); |
| 245 | |
| 246 | /* Set M & N */ |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 247 | temp &= ~CM_CLKSEL_DPLL_M_MASK; |
| 248 | temp |= (params->m << CM_CLKSEL_DPLL_M_SHIFT) & CM_CLKSEL_DPLL_M_MASK; |
| 249 | |
| 250 | temp &= ~CM_CLKSEL_DPLL_N_MASK; |
| 251 | temp |= (params->n << CM_CLKSEL_DPLL_N_SHIFT) & CM_CLKSEL_DPLL_N_MASK; |
| 252 | |
| 253 | writel(temp, &dpll_regs->cm_clksel_dpll); |
| 254 | |
Lokesh Vutla | 9bd0f9a | 2016-05-23 13:31:19 +0530 | [diff] [blame] | 255 | setup_post_dividers: |
| 256 | setup_post_dividers(base, params); |
| 257 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 258 | /* Lock */ |
| 259 | if (lock) |
| 260 | do_lock_dpll(base); |
| 261 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 262 | /* Wait till the DPLL locks */ |
| 263 | if (lock) |
| 264 | wait_for_lock(base); |
| 265 | } |
| 266 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 267 | u32 omap_ddr_clk(void) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 268 | { |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 269 | u32 ddr_clk, sys_clk_khz, omap_rev, divider; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 270 | const struct dpll_params *core_dpll_params; |
| 271 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 272 | omap_rev = omap_revision(); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 273 | sys_clk_khz = get_sys_clk_freq() / 1000; |
| 274 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 275 | core_dpll_params = get_core_dpll_params(*dplls_data); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 276 | |
| 277 | debug("sys_clk %d\n ", sys_clk_khz * 1000); |
| 278 | |
| 279 | /* Find Core DPLL locked frequency first */ |
| 280 | ddr_clk = sys_clk_khz * 2 * core_dpll_params->m / |
| 281 | (core_dpll_params->n + 1); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 282 | |
| 283 | if (omap_rev < OMAP5430_ES1_0) { |
| 284 | /* |
| 285 | * DDR frequency is PHY_ROOT_CLK/2 |
| 286 | * PHY_ROOT_CLK = Fdpll/2/M2 |
| 287 | */ |
| 288 | divider = 4; |
| 289 | } else { |
| 290 | /* |
| 291 | * DDR frequency is PHY_ROOT_CLK |
| 292 | * PHY_ROOT_CLK = Fdpll/2/M2 |
| 293 | */ |
| 294 | divider = 2; |
| 295 | } |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 296 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 297 | ddr_clk = ddr_clk / divider / core_dpll_params->m2; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 298 | ddr_clk *= 1000; /* convert to Hz */ |
| 299 | debug("ddr_clk %d\n ", ddr_clk); |
| 300 | |
| 301 | return ddr_clk; |
| 302 | } |
| 303 | |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 304 | /* |
| 305 | * Lock MPU dpll |
| 306 | * |
| 307 | * Resulting MPU frequencies: |
| 308 | * 4430 ES1.0 : 600 MHz |
| 309 | * 4430 ES2.x : 792 MHz (OPP Turbo) |
| 310 | * 4460 : 920 MHz (OPP Turbo) - DCC disabled |
| 311 | */ |
| 312 | void configure_mpu_dpll(void) |
| 313 | { |
| 314 | const struct dpll_params *params; |
| 315 | struct dpll_regs *mpu_dpll_regs; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 316 | u32 omap_rev; |
| 317 | omap_rev = omap_revision(); |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 318 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 319 | /* |
| 320 | * DCC and clock divider settings for 4460. |
| 321 | * DCC is required, if more than a certain frequency is required. |
| 322 | * For, 4460 > 1GHZ. |
| 323 | * 5430 > 1.4GHZ. |
| 324 | */ |
| 325 | if ((omap_rev >= OMAP4460_ES1_0) && (omap_rev < OMAP5430_ES1_0)) { |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 326 | mpu_dpll_regs = |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 327 | (struct dpll_regs *)((*prcm)->cm_clkmode_dpll_mpu); |
| 328 | bypass_dpll((*prcm)->cm_clkmode_dpll_mpu); |
| 329 | clrbits_le32((*prcm)->cm_mpu_mpu_clkctrl, |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 330 | MPU_CLKCTRL_CLKSEL_EMIF_DIV_MODE_MASK); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 331 | setbits_le32((*prcm)->cm_mpu_mpu_clkctrl, |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 332 | MPU_CLKCTRL_CLKSEL_ABE_DIV_MODE_MASK); |
| 333 | clrbits_le32(&mpu_dpll_regs->cm_clksel_dpll, |
| 334 | CM_CLKSEL_DCC_EN_MASK); |
| 335 | } |
| 336 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 337 | params = get_mpu_dpll_params(*dplls_data); |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 338 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 339 | do_setup_dpll((*prcm)->cm_clkmode_dpll_mpu, params, DPLL_LOCK, "mpu"); |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 340 | debug("MPU DPLL locked\n"); |
| 341 | } |
| 342 | |
Paul Kocialkowski | ec3ec83 | 2016-02-27 19:19:01 +0100 | [diff] [blame] | 343 | #if defined(CONFIG_USB_EHCI_OMAP) || defined(CONFIG_USB_XHCI_OMAP) || \ |
| 344 | defined(CONFIG_USB_MUSB_OMAP2PLUS) |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 345 | static void setup_usb_dpll(void) |
| 346 | { |
| 347 | const struct dpll_params *params; |
| 348 | u32 sys_clk_khz, sd_div, num, den; |
| 349 | |
| 350 | sys_clk_khz = get_sys_clk_freq() / 1000; |
| 351 | /* |
| 352 | * USB: |
| 353 | * USB dpll is J-type. Need to set DPLL_SD_DIV for jitter correction |
| 354 | * DPLL_SD_DIV = CEILING ([DPLL_MULT/(DPLL_DIV+1)]* CLKINP / 250) |
| 355 | * - where CLKINP is sys_clk in MHz |
| 356 | * Use CLKINP in KHz and adjust the denominator accordingly so |
| 357 | * that we have enough accuracy and at the same time no overflow |
| 358 | */ |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 359 | params = get_usb_dpll_params(*dplls_data); |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 360 | num = params->m * sys_clk_khz; |
| 361 | den = (params->n + 1) * 250 * 1000; |
| 362 | num += den - 1; |
| 363 | sd_div = num / den; |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 364 | clrsetbits_le32((*prcm)->cm_clksel_dpll_usb, |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 365 | CM_CLKSEL_DPLL_DPLL_SD_DIV_MASK, |
| 366 | sd_div << CM_CLKSEL_DPLL_DPLL_SD_DIV_SHIFT); |
| 367 | |
| 368 | /* Now setup the dpll with the regular function */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 369 | do_setup_dpll((*prcm)->cm_clkmode_dpll_usb, params, DPLL_LOCK, "usb"); |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 370 | } |
| 371 | #endif |
| 372 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 373 | static void setup_dplls(void) |
| 374 | { |
Anatolij Gustschin | 20f2351 | 2011-12-03 06:46:14 +0000 | [diff] [blame] | 375 | u32 temp; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 376 | const struct dpll_params *params; |
Tom Rini | be8d635 | 2015-06-05 15:51:11 +0530 | [diff] [blame] | 377 | struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 378 | |
Anatolij Gustschin | 20f2351 | 2011-12-03 06:46:14 +0000 | [diff] [blame] | 379 | debug("setup_dplls\n"); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 380 | |
| 381 | /* CORE dpll */ |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 382 | params = get_core_dpll_params(*dplls_data); /* default - safest */ |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 383 | /* |
| 384 | * Do not lock the core DPLL now. Just set it up. |
| 385 | * Core DPLL will be locked after setting up EMIF |
| 386 | * using the FREQ_UPDATE method(freq_update_core()) |
| 387 | */ |
Tom Rini | be8d635 | 2015-06-05 15:51:11 +0530 | [diff] [blame] | 388 | if (emif_sdram_type(readl(&emif->emif_sdram_config)) == |
| 389 | EMIF_SDRAM_TYPE_LPDDR2) |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 390 | do_setup_dpll((*prcm)->cm_clkmode_dpll_core, params, |
Lokesh Vutla | cdfc4ea | 2012-05-22 00:03:26 +0000 | [diff] [blame] | 391 | DPLL_NO_LOCK, "core"); |
| 392 | else |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 393 | do_setup_dpll((*prcm)->cm_clkmode_dpll_core, params, |
Lokesh Vutla | cdfc4ea | 2012-05-22 00:03:26 +0000 | [diff] [blame] | 394 | DPLL_LOCK, "core"); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 395 | /* Set the ratios for CORE_CLK, L3_CLK, L4_CLK */ |
| 396 | temp = (CLKSEL_CORE_X2_DIV_1 << CLKSEL_CORE_SHIFT) | |
| 397 | (CLKSEL_L3_CORE_DIV_2 << CLKSEL_L3_SHIFT) | |
| 398 | (CLKSEL_L4_L3_DIV_2 << CLKSEL_L4_SHIFT); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 399 | writel(temp, (*prcm)->cm_clksel_core); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 400 | debug("Core DPLL configured\n"); |
| 401 | |
| 402 | /* lock PER dpll */ |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 403 | params = get_per_dpll_params(*dplls_data); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 404 | do_setup_dpll((*prcm)->cm_clkmode_dpll_per, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 405 | params, DPLL_LOCK, "per"); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 406 | debug("PER DPLL locked\n"); |
| 407 | |
| 408 | /* MPU dpll */ |
Aneesh V | a47a79f | 2011-07-21 09:29:36 -0400 | [diff] [blame] | 409 | configure_mpu_dpll(); |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 410 | |
Paul Kocialkowski | ec3ec83 | 2016-02-27 19:19:01 +0100 | [diff] [blame] | 411 | #if defined(CONFIG_USB_EHCI_OMAP) || defined(CONFIG_USB_XHCI_OMAP) || \ |
| 412 | defined(CONFIG_USB_MUSB_OMAP2PLUS) |
Govindraj.R | ad4426b | 2012-02-06 03:55:36 +0000 | [diff] [blame] | 413 | setup_usb_dpll(); |
| 414 | #endif |
Lokesh Vutla | 5e70e29 | 2013-02-12 21:29:05 +0000 | [diff] [blame] | 415 | params = get_ddr_dpll_params(*dplls_data); |
| 416 | do_setup_dpll((*prcm)->cm_clkmode_dpll_ddrphy, |
| 417 | params, DPLL_LOCK, "ddr"); |
Lokesh Vutla | adc52df | 2013-07-08 16:04:39 +0530 | [diff] [blame] | 418 | |
| 419 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 420 | params = get_gmac_dpll_params(*dplls_data); |
| 421 | do_setup_dpll((*prcm)->cm_clkmode_dpll_gmac, params, |
| 422 | DPLL_LOCK, "gmac"); |
| 423 | #endif |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 424 | } |
| 425 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 426 | u32 get_offset_code(u32 volt_offset, struct pmic_data *pmic) |
Aneesh V | 0fa1d1b | 2011-07-21 09:29:32 -0400 | [diff] [blame] | 427 | { |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 428 | u32 offset_code; |
Aneesh V | 0fa1d1b | 2011-07-21 09:29:32 -0400 | [diff] [blame] | 429 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 430 | volt_offset -= pmic->base_offset; |
Aneesh V | 0fa1d1b | 2011-07-21 09:29:32 -0400 | [diff] [blame] | 431 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 432 | offset_code = (volt_offset + pmic->step - 1) / pmic->step; |
Nishanth Menon | a0f45c1 | 2012-03-01 14:17:38 +0000 | [diff] [blame] | 433 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 434 | /* |
| 435 | * Offset codes 1-6 all give the base voltage in Palmas |
| 436 | * Offset code 0 switches OFF the SMPS |
| 437 | */ |
| 438 | return offset_code + pmic->start_code; |
Aneesh V | 0fa1d1b | 2011-07-21 09:29:32 -0400 | [diff] [blame] | 439 | } |
| 440 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 441 | void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 442 | { |
Nishanth Menon | 41d7ab1 | 2012-03-01 14:17:37 +0000 | [diff] [blame] | 443 | u32 offset_code; |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 444 | u32 offset = volt_mv; |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 445 | int ret = 0; |
| 446 | |
Lokesh Vutla | 3685297 | 2013-05-30 03:19:29 +0000 | [diff] [blame] | 447 | if (!volt_mv) |
| 448 | return; |
| 449 | |
Lokesh Vutla | ae49f6d | 2013-05-30 02:54:33 +0000 | [diff] [blame] | 450 | pmic->pmic_bus_init(); |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 451 | /* See if we can first get the GPIO if needed */ |
| 452 | if (pmic->gpio_en) |
| 453 | ret = gpio_request(pmic->gpio, "PMIC_GPIO"); |
| 454 | |
| 455 | if (ret < 0) { |
| 456 | printf("%s: gpio %d request failed %d\n", __func__, |
| 457 | pmic->gpio, ret); |
| 458 | return; |
| 459 | } |
| 460 | |
| 461 | /* Pull the GPIO low to select SET0 register, while we program SET1 */ |
| 462 | if (pmic->gpio_en) |
| 463 | gpio_direction_output(pmic->gpio, 0); |
Lokesh Vutla | 266b23a | 2016-08-17 16:25:35 +0530 | [diff] [blame] | 464 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 465 | /* convert to uV for better accuracy in the calculations */ |
| 466 | offset *= 1000; |
| 467 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 468 | offset_code = get_offset_code(offset, pmic); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 469 | |
| 470 | debug("do_scale_vcore: volt - %d offset_code - 0x%x\n", volt_mv, |
| 471 | offset_code); |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 472 | |
Lokesh Vutla | ae49f6d | 2013-05-30 02:54:33 +0000 | [diff] [blame] | 473 | if (pmic->pmic_write(pmic->i2c_slave_addr, vcore_reg, offset_code)) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 474 | printf("Scaling voltage failed for 0x%x\n", vcore_reg); |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 475 | if (pmic->gpio_en) |
| 476 | gpio_direction_output(pmic->gpio, 1); |
| 477 | } |
| 478 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 479 | int __weak get_voltrail_opp(int rail_offset) |
| 480 | { |
| 481 | /* |
| 482 | * By default return OPP_NOM for all voltage rails. |
| 483 | */ |
| 484 | return OPP_NOM; |
| 485 | } |
| 486 | |
| 487 | static u32 optimize_vcore_voltage(struct volts const *v, int opp) |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 488 | { |
| 489 | u32 val; |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 490 | |
| 491 | if (!v->value[opp]) |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 492 | return 0; |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 493 | if (!v->efuse.reg[opp]) |
| 494 | return v->value[opp]; |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 495 | |
| 496 | switch (v->efuse.reg_bits) { |
| 497 | case 16: |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 498 | val = readw(v->efuse.reg[opp]); |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 499 | break; |
| 500 | case 32: |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 501 | val = readl(v->efuse.reg[opp]); |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 502 | break; |
| 503 | default: |
| 504 | printf("Error: efuse 0x%08x bits=%d unknown\n", |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 505 | v->efuse.reg[opp], v->efuse.reg_bits); |
| 506 | return v->value[opp]; |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | if (!val) { |
| 510 | printf("Error: efuse 0x%08x bits=%d val=0, using %d\n", |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 511 | v->efuse.reg[opp], v->efuse.reg_bits, v->value[opp]); |
| 512 | return v->value[opp]; |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | debug("%s:efuse 0x%08x bits=%d Vnom=%d, using efuse value %d\n", |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 516 | __func__, v->efuse.reg[opp], v->efuse.reg_bits, v->value[opp], |
| 517 | val); |
Nishanth Menon | 93cdb28 | 2013-05-30 03:19:31 +0000 | [diff] [blame] | 518 | return val; |
| 519 | } |
| 520 | |
Lokesh Vutla | 3de40ac | 2015-06-04 16:42:36 +0530 | [diff] [blame] | 521 | #ifdef CONFIG_IODELAY_RECALIBRATION |
| 522 | void __weak recalibrate_iodelay(void) |
| 523 | { |
| 524 | } |
| 525 | #endif |
| 526 | |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 527 | /* |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 528 | * Setup the voltages for the main SoC core power domains. |
| 529 | * We start with the maximum voltages allowed here, as set in the corresponding |
| 530 | * vcores_data struct, and then scale (usually down) to the fused values that |
| 531 | * are retrieved from the SoC. The scaling happens only if the efuse.reg fields |
| 532 | * are initialised. |
| 533 | * Rail grouping is supported for the DRA7xx SoCs only, therefore the code is |
| 534 | * compiled conditionally. Note that the new code writes the scaled (or zeroed) |
| 535 | * values back to the vcores_data struct for eventual reuse. Zero values mean |
| 536 | * that the corresponding rails are not controlled separately, and are not sent |
| 537 | * to the PMIC. |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 538 | */ |
| 539 | void scale_vcores(struct vcores_data const *vcores) |
| 540 | { |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 541 | int i, opp, j, ol; |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 542 | struct volts *pv = (struct volts *)vcores; |
| 543 | struct volts *px; |
| 544 | |
| 545 | for (i=0; i<(sizeof(struct vcores_data)/sizeof(struct volts)); i++) { |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 546 | opp = get_voltrail_opp(i); |
| 547 | debug("%d -> ", pv->value[opp]); |
| 548 | |
| 549 | if (pv->value[opp]) { |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 550 | /* Handle non-empty members only */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 551 | pv->value[opp] = optimize_vcore_voltage(pv, opp); |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 552 | px = (struct volts *)vcores; |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 553 | j = 0; |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 554 | while (px < pv) { |
| 555 | /* |
| 556 | * Scan already handled non-empty members to see |
| 557 | * if we have a group and find the max voltage, |
| 558 | * which is set to the first occurance of the |
| 559 | * particular SMPS; the other group voltages are |
| 560 | * zeroed. |
| 561 | */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 562 | ol = get_voltrail_opp(j); |
| 563 | if (px->value[ol] && |
| 564 | (pv->pmic->i2c_slave_addr == |
| 565 | px->pmic->i2c_slave_addr) && |
| 566 | (pv->addr == px->addr)) { |
| 567 | /* Same PMIC, same SMPS */ |
| 568 | if (pv->value[opp] > px->value[ol]) |
| 569 | px->value[ol] = pv->value[opp]; |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 570 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 571 | pv->value[opp] = 0; |
| 572 | } |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 573 | px++; |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 574 | j++; |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 575 | } |
| 576 | } |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 577 | debug("%d\n", pv->value[opp]); |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 578 | pv++; |
| 579 | } |
| 580 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 581 | opp = get_voltrail_opp(VOLT_CORE); |
| 582 | debug("cor: %d\n", vcores->core.value[opp]); |
| 583 | do_scale_vcore(vcores->core.addr, vcores->core.value[opp], |
| 584 | vcores->core.pmic); |
Lokesh Vutla | 3de40ac | 2015-06-04 16:42:36 +0530 | [diff] [blame] | 585 | /* |
| 586 | * IO delay recalibration should be done immediately after |
| 587 | * adjusting AVS voltages for VDD_CORE_L. |
| 588 | * Respective boards should call __recalibrate_iodelay() |
| 589 | * with proper mux, virtual and manual mode configurations. |
| 590 | */ |
| 591 | #ifdef CONFIG_IODELAY_RECALIBRATION |
| 592 | recalibrate_iodelay(); |
| 593 | #endif |
| 594 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 595 | opp = get_voltrail_opp(VOLT_MPU); |
| 596 | debug("mpu: %d\n", vcores->mpu.value[opp]); |
| 597 | do_scale_vcore(vcores->mpu.addr, vcores->mpu.value[opp], |
| 598 | vcores->mpu.pmic); |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 599 | /* Configure MPU ABB LDO after scale */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 600 | abb_setup(vcores->mpu.efuse.reg[opp], |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 601 | (*ctrl)->control_wkup_ldovbb_mpu_voltage_ctrl, |
| 602 | (*prcm)->prm_abbldo_mpu_setup, |
| 603 | (*prcm)->prm_abbldo_mpu_ctrl, |
| 604 | (*prcm)->prm_irqstatus_mpu_2, |
Nishanth Menon | 1eb62b4 | 2016-04-21 14:34:23 -0500 | [diff] [blame] | 605 | vcores->mpu.abb_tx_done_mask, |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 606 | OMAP_ABB_FAST_OPP); |
| 607 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 608 | opp = get_voltrail_opp(VOLT_MM); |
| 609 | debug("mm: %d\n", vcores->mm.value[opp]); |
| 610 | do_scale_vcore(vcores->mm.addr, vcores->mm.value[opp], |
| 611 | vcores->mm.pmic); |
Lokesh Vutla | 42eae24 | 2016-08-17 16:25:36 +0530 | [diff] [blame] | 612 | /* Configure MM ABB LDO after scale */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 613 | abb_setup(vcores->mm.efuse.reg[opp], |
Lokesh Vutla | 42eae24 | 2016-08-17 16:25:36 +0530 | [diff] [blame] | 614 | (*ctrl)->control_wkup_ldovbb_mm_voltage_ctrl, |
| 615 | (*prcm)->prm_abbldo_mm_setup, |
| 616 | (*prcm)->prm_abbldo_mm_ctrl, |
| 617 | (*prcm)->prm_irqstatus_mpu, |
| 618 | vcores->mm.abb_tx_done_mask, |
| 619 | OMAP_ABB_FAST_OPP); |
Lubomir Popov | 21f3406 | 2014-12-19 17:34:31 +0200 | [diff] [blame] | 620 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 621 | opp = get_voltrail_opp(VOLT_GPU); |
| 622 | debug("gpu: %d\n", vcores->gpu.value[opp]); |
| 623 | do_scale_vcore(vcores->gpu.addr, vcores->gpu.value[opp], |
| 624 | vcores->gpu.pmic); |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 625 | /* Configure GPU ABB LDO after scale */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 626 | abb_setup(vcores->gpu.efuse.reg[opp], |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 627 | (*ctrl)->control_wkup_ldovbb_gpu_voltage_ctrl, |
| 628 | (*prcm)->prm_abbldo_gpu_setup, |
| 629 | (*prcm)->prm_abbldo_gpu_ctrl, |
| 630 | (*prcm)->prm_irqstatus_mpu, |
| 631 | vcores->gpu.abb_tx_done_mask, |
| 632 | OMAP_ABB_FAST_OPP); |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 633 | |
| 634 | opp = get_voltrail_opp(VOLT_EVE); |
| 635 | debug("eve: %d\n", vcores->eve.value[opp]); |
| 636 | do_scale_vcore(vcores->eve.addr, vcores->eve.value[opp], |
| 637 | vcores->eve.pmic); |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 638 | /* Configure EVE ABB LDO after scale */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 639 | abb_setup(vcores->eve.efuse.reg[opp], |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 640 | (*ctrl)->control_wkup_ldovbb_eve_voltage_ctrl, |
| 641 | (*prcm)->prm_abbldo_eve_setup, |
| 642 | (*prcm)->prm_abbldo_eve_ctrl, |
| 643 | (*prcm)->prm_irqstatus_mpu, |
| 644 | vcores->eve.abb_tx_done_mask, |
| 645 | OMAP_ABB_FAST_OPP); |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 646 | |
| 647 | opp = get_voltrail_opp(VOLT_IVA); |
| 648 | debug("iva: %d\n", vcores->iva.value[opp]); |
| 649 | do_scale_vcore(vcores->iva.addr, vcores->iva.value[opp], |
| 650 | vcores->iva.pmic); |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 651 | /* Configure IVA ABB LDO after scale */ |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 652 | abb_setup(vcores->iva.efuse.reg[opp], |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 653 | (*ctrl)->control_wkup_ldovbb_iva_voltage_ctrl, |
| 654 | (*prcm)->prm_abbldo_iva_setup, |
| 655 | (*prcm)->prm_abbldo_iva_ctrl, |
| 656 | (*prcm)->prm_irqstatus_mpu, |
| 657 | vcores->iva.abb_tx_done_mask, |
| 658 | OMAP_ABB_FAST_OPP); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 659 | } |
| 660 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 661 | static inline void enable_clock_domain(u32 const clkctrl_reg, u32 enable_mode) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 662 | { |
| 663 | clrsetbits_le32(clkctrl_reg, CD_CLKCTRL_CLKTRCTRL_MASK, |
| 664 | enable_mode << CD_CLKCTRL_CLKTRCTRL_SHIFT); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 665 | debug("Enable clock domain - %x\n", clkctrl_reg); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 666 | } |
| 667 | |
Kishon Vijay Abraham I | 920f156f | 2015-08-17 13:29:51 +0530 | [diff] [blame] | 668 | static inline void disable_clock_domain(u32 const clkctrl_reg) |
| 669 | { |
| 670 | clrsetbits_le32(clkctrl_reg, CD_CLKCTRL_CLKTRCTRL_MASK, |
| 671 | CD_CLKCTRL_CLKTRCTRL_SW_SLEEP << |
| 672 | CD_CLKCTRL_CLKTRCTRL_SHIFT); |
| 673 | debug("Disable clock domain - %x\n", clkctrl_reg); |
| 674 | } |
| 675 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 676 | static inline void wait_for_clk_enable(u32 clkctrl_addr) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 677 | { |
| 678 | u32 clkctrl, idlest = MODULE_CLKCTRL_IDLEST_DISABLED; |
| 679 | u32 bound = LDELAY; |
| 680 | |
| 681 | while ((idlest == MODULE_CLKCTRL_IDLEST_DISABLED) || |
| 682 | (idlest == MODULE_CLKCTRL_IDLEST_TRANSITIONING)) { |
| 683 | |
| 684 | clkctrl = readl(clkctrl_addr); |
| 685 | idlest = (clkctrl & MODULE_CLKCTRL_IDLEST_MASK) >> |
| 686 | MODULE_CLKCTRL_IDLEST_SHIFT; |
| 687 | if (--bound == 0) { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 688 | printf("Clock enable failed for 0x%x idlest 0x%x\n", |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 689 | clkctrl_addr, clkctrl); |
| 690 | return; |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 695 | static inline void enable_clock_module(u32 const clkctrl_addr, u32 enable_mode, |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 696 | u32 wait_for_enable) |
| 697 | { |
| 698 | clrsetbits_le32(clkctrl_addr, MODULE_CLKCTRL_MODULEMODE_MASK, |
| 699 | enable_mode << MODULE_CLKCTRL_MODULEMODE_SHIFT); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 700 | debug("Enable clock module - %x\n", clkctrl_addr); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 701 | if (wait_for_enable) |
| 702 | wait_for_clk_enable(clkctrl_addr); |
| 703 | } |
| 704 | |
Kishon Vijay Abraham I | 920f156f | 2015-08-17 13:29:51 +0530 | [diff] [blame] | 705 | static inline void wait_for_clk_disable(u32 clkctrl_addr) |
| 706 | { |
| 707 | u32 clkctrl, idlest = MODULE_CLKCTRL_IDLEST_FULLY_FUNCTIONAL; |
| 708 | u32 bound = LDELAY; |
| 709 | |
| 710 | while ((idlest != MODULE_CLKCTRL_IDLEST_DISABLED)) { |
| 711 | clkctrl = readl(clkctrl_addr); |
| 712 | idlest = (clkctrl & MODULE_CLKCTRL_IDLEST_MASK) >> |
| 713 | MODULE_CLKCTRL_IDLEST_SHIFT; |
| 714 | if (--bound == 0) { |
| 715 | printf("Clock disable failed for 0x%x idlest 0x%x\n", |
| 716 | clkctrl_addr, clkctrl); |
| 717 | return; |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | static inline void disable_clock_module(u32 const clkctrl_addr, |
| 723 | u32 wait_for_disable) |
| 724 | { |
| 725 | clrsetbits_le32(clkctrl_addr, MODULE_CLKCTRL_MODULEMODE_MASK, |
| 726 | MODULE_CLKCTRL_MODULEMODE_SW_DISABLE << |
| 727 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 728 | debug("Disable clock module - %x\n", clkctrl_addr); |
| 729 | if (wait_for_disable) |
| 730 | wait_for_clk_disable(clkctrl_addr); |
| 731 | } |
| 732 | |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 733 | void freq_update_core(void) |
| 734 | { |
| 735 | u32 freq_config1 = 0; |
| 736 | const struct dpll_params *core_dpll_params; |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame] | 737 | u32 omap_rev = omap_revision(); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 738 | |
SRICHARAN R | 1a79cab | 2013-02-04 04:22:01 +0000 | [diff] [blame] | 739 | core_dpll_params = get_core_dpll_params(*dplls_data); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 740 | /* Put EMIF clock domain in sw wakeup mode */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 741 | enable_clock_domain((*prcm)->cm_memif_clkstctrl, |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 742 | CD_CLKCTRL_CLKTRCTRL_SW_WKUP); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 743 | wait_for_clk_enable((*prcm)->cm_memif_emif_1_clkctrl); |
| 744 | wait_for_clk_enable((*prcm)->cm_memif_emif_2_clkctrl); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 745 | |
| 746 | freq_config1 = SHADOW_FREQ_CONFIG1_FREQ_UPDATE_MASK | |
| 747 | SHADOW_FREQ_CONFIG1_DLL_RESET_MASK; |
| 748 | |
| 749 | freq_config1 |= (DPLL_EN_LOCK << SHADOW_FREQ_CONFIG1_DPLL_EN_SHIFT) & |
| 750 | SHADOW_FREQ_CONFIG1_DPLL_EN_MASK; |
| 751 | |
| 752 | freq_config1 |= (core_dpll_params->m2 << |
| 753 | SHADOW_FREQ_CONFIG1_M2_DIV_SHIFT) & |
| 754 | SHADOW_FREQ_CONFIG1_M2_DIV_MASK; |
| 755 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 756 | writel(freq_config1, (*prcm)->cm_shadow_freq_config1); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 757 | if (!wait_on_value(SHADOW_FREQ_CONFIG1_FREQ_UPDATE_MASK, 0, |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 758 | (u32 *) (*prcm)->cm_shadow_freq_config1, LDELAY)) { |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 759 | puts("FREQ UPDATE procedure failed!!"); |
| 760 | hang(); |
| 761 | } |
| 762 | |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame] | 763 | /* |
| 764 | * Putting EMIF in HW_AUTO is seen to be causing issues with |
Lubomir Popov | a01f0b0 | 2013-04-04 05:51:45 +0000 | [diff] [blame] | 765 | * EMIF clocks and the master DLL. Keep EMIF in SW_WKUP |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame] | 766 | * in OMAP5430 ES1.0 silicon |
| 767 | */ |
| 768 | if (omap_rev != OMAP5430_ES1_0) { |
| 769 | /* Put EMIF clock domain back in hw auto mode */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 770 | enable_clock_domain((*prcm)->cm_memif_clkstctrl, |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame] | 771 | CD_CLKCTRL_CLKTRCTRL_HW_AUTO); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 772 | wait_for_clk_enable((*prcm)->cm_memif_emif_1_clkctrl); |
| 773 | wait_for_clk_enable((*prcm)->cm_memif_emif_2_clkctrl); |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame] | 774 | } |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 775 | } |
| 776 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 777 | void bypass_dpll(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 778 | { |
| 779 | do_bypass_dpll(base); |
| 780 | wait_for_bypass(base); |
| 781 | } |
| 782 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 783 | void lock_dpll(u32 const base) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 784 | { |
| 785 | do_lock_dpll(base); |
| 786 | wait_for_lock(base); |
| 787 | } |
| 788 | |
Kipisz, Steven | ebe86dc | 2016-02-24 12:30:52 -0600 | [diff] [blame] | 789 | static void setup_clocks_for_console(void) |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 790 | { |
| 791 | /* Do not add any spl_debug prints in this function */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 792 | clrsetbits_le32((*prcm)->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 793 | CD_CLKCTRL_CLKTRCTRL_SW_WKUP << |
| 794 | CD_CLKCTRL_CLKTRCTRL_SHIFT); |
| 795 | |
| 796 | /* Enable all UARTs - console will be on one of them */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 797 | clrsetbits_le32((*prcm)->cm_l4per_uart1_clkctrl, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 798 | MODULE_CLKCTRL_MODULEMODE_MASK, |
| 799 | MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN << |
| 800 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 801 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 802 | clrsetbits_le32((*prcm)->cm_l4per_uart2_clkctrl, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 803 | MODULE_CLKCTRL_MODULEMODE_MASK, |
| 804 | MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN << |
| 805 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 806 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 807 | clrsetbits_le32((*prcm)->cm_l4per_uart3_clkctrl, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 808 | MODULE_CLKCTRL_MODULEMODE_MASK, |
| 809 | MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN << |
| 810 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 811 | |
Lubomir Popov | a01f0b0 | 2013-04-04 05:51:45 +0000 | [diff] [blame] | 812 | clrsetbits_le32((*prcm)->cm_l4per_uart4_clkctrl, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 813 | MODULE_CLKCTRL_MODULEMODE_MASK, |
| 814 | MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN << |
| 815 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 816 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 817 | clrsetbits_le32((*prcm)->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK, |
Aneesh V | b8e60b9 | 2011-07-21 09:10:21 -0400 | [diff] [blame] | 818 | CD_CLKCTRL_CLKTRCTRL_HW_AUTO << |
| 819 | CD_CLKCTRL_CLKTRCTRL_SHIFT); |
| 820 | } |
| 821 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame] | 822 | void do_enable_clocks(u32 const *clk_domains, |
| 823 | u32 const *clk_modules_hw_auto, |
| 824 | u32 const *clk_modules_explicit_en, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 825 | u8 wait_for_enable) |
| 826 | { |
| 827 | u32 i, max = 100; |
| 828 | |
| 829 | /* Put the clock domains in SW_WKUP mode */ |
Lukasz Majewski | 9e3491b | 2017-03-27 10:15:27 +0200 | [diff] [blame] | 830 | for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++) { |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 831 | enable_clock_domain(clk_domains[i], |
| 832 | CD_CLKCTRL_CLKTRCTRL_SW_WKUP); |
| 833 | } |
| 834 | |
| 835 | /* Clock modules that need to be put in HW_AUTO */ |
Lukasz Majewski | 9e3491b | 2017-03-27 10:15:27 +0200 | [diff] [blame] | 836 | for (i = 0; (i < max) && clk_modules_hw_auto && |
| 837 | clk_modules_hw_auto[i]; i++) { |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 838 | enable_clock_module(clk_modules_hw_auto[i], |
| 839 | MODULE_CLKCTRL_MODULEMODE_HW_AUTO, |
| 840 | wait_for_enable); |
| 841 | }; |
| 842 | |
| 843 | /* Clock modules that need to be put in SW_EXPLICIT_EN mode */ |
Lukasz Majewski | 9e3491b | 2017-03-27 10:15:27 +0200 | [diff] [blame] | 844 | for (i = 0; (i < max) && clk_modules_explicit_en && |
| 845 | clk_modules_explicit_en[i]; i++) { |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 846 | enable_clock_module(clk_modules_explicit_en[i], |
| 847 | MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN, |
| 848 | wait_for_enable); |
| 849 | }; |
| 850 | |
| 851 | /* Put the clock domains in HW_AUTO mode now */ |
Lukasz Majewski | 9e3491b | 2017-03-27 10:15:27 +0200 | [diff] [blame] | 852 | for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++) { |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 853 | enable_clock_domain(clk_domains[i], |
| 854 | CD_CLKCTRL_CLKTRCTRL_HW_AUTO); |
| 855 | } |
| 856 | } |
| 857 | |
Kishon Vijay Abraham I | 920f156f | 2015-08-17 13:29:51 +0530 | [diff] [blame] | 858 | void do_disable_clocks(u32 const *clk_domains, |
| 859 | u32 const *clk_modules_disable, |
| 860 | u8 wait_for_disable) |
| 861 | { |
| 862 | u32 i, max = 100; |
| 863 | |
| 864 | |
| 865 | /* Clock modules that need to be put in SW_DISABLE */ |
| 866 | for (i = 0; (i < max) && clk_modules_disable[i]; i++) |
| 867 | disable_clock_module(clk_modules_disable[i], |
| 868 | wait_for_disable); |
| 869 | |
| 870 | /* Put the clock domains in SW_SLEEP mode */ |
| 871 | for (i = 0; (i < max) && clk_domains[i]; i++) |
| 872 | disable_clock_domain(clk_domains[i]); |
| 873 | } |
| 874 | |
Kipisz, Steven | ebe86dc | 2016-02-24 12:30:52 -0600 | [diff] [blame] | 875 | /** |
| 876 | * setup_early_clocks() - Setup early clocks needed for SoC |
| 877 | * |
| 878 | * Setup clocks for console, SPL basic initialization clocks and initialize |
| 879 | * the timer. This is invoked prior prcm_init. |
| 880 | */ |
| 881 | void setup_early_clocks(void) |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 882 | { |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 883 | switch (omap_hw_init_context()) { |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 884 | case OMAP_INIT_CONTEXT_SPL: |
| 885 | case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR: |
| 886 | case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH: |
Kipisz, Steven | ebe86dc | 2016-02-24 12:30:52 -0600 | [diff] [blame] | 887 | setup_clocks_for_console(); |
Aneesh V | 9a39088 | 2011-07-21 09:29:29 -0400 | [diff] [blame] | 888 | enable_basic_clocks(); |
Lokesh Vutla | d9c839a | 2013-05-30 03:19:30 +0000 | [diff] [blame] | 889 | timer_init(); |
Kipisz, Steven | ebe86dc | 2016-02-24 12:30:52 -0600 | [diff] [blame] | 890 | /* Fall through */ |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | void prcm_init(void) |
| 895 | { |
| 896 | switch (omap_hw_init_context()) { |
| 897 | case OMAP_INIT_CONTEXT_SPL: |
| 898 | case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR: |
| 899 | case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH: |
SRICHARAN R | 00d328c | 2013-02-04 04:22:02 +0000 | [diff] [blame] | 900 | scale_vcores(*omap_vcores); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 901 | setup_dplls(); |
Lokesh Vutla | 100c2d8 | 2013-04-17 20:49:40 +0000 | [diff] [blame] | 902 | setup_warmreset_time(); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 903 | break; |
| 904 | default: |
| 905 | break; |
| 906 | } |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 907 | |
| 908 | if (OMAP_INIT_CONTEXT_SPL != omap_hw_init_context()) |
| 909 | enable_basic_uboot_clocks(); |
Aneesh V | 0d2628b | 2011-07-21 09:10:07 -0400 | [diff] [blame] | 910 | } |
Lokesh Vutla | 3685297 | 2013-05-30 03:19:29 +0000 | [diff] [blame] | 911 | |
| 912 | void gpi2c_init(void) |
| 913 | { |
| 914 | static int gpi2c = 1; |
| 915 | |
| 916 | if (gpi2c) { |
Heiko Schocher | f53f2b8 | 2013-10-22 11:03:18 +0200 | [diff] [blame] | 917 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, |
| 918 | CONFIG_SYS_OMAP24_I2C_SLAVE); |
Lokesh Vutla | 3685297 | 2013-05-30 03:19:29 +0000 | [diff] [blame] | 919 | gpi2c = 0; |
| 920 | } |
| 921 | } |