Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Clock initialization for OMAP4 |
| 4 | * |
| 5 | * (C) Copyright 2010 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Aneesh V <aneesh@ti.com> |
| 9 | * |
| 10 | * Based on previous work by: |
| 11 | * Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 12 | * Rajendra Nayak <rnayak@ti.com> |
| 13 | * |
| 14 | * See file CREDITS for list of people who contributed to this |
| 15 | * project. |
| 16 | * |
| 17 | * This program is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU General Public License as |
| 19 | * published by the Free Software Foundation; either version 2 of |
| 20 | * the License, or (at your option) any later version. |
| 21 | * |
| 22 | * This program is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | * GNU General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU General Public License |
| 28 | * along with this program; if not, write to the Free Software |
| 29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 30 | * MA 02111-1307 USA |
| 31 | */ |
| 32 | #include <common.h> |
| 33 | #include <asm/omap_common.h> |
| 34 | #include <asm/gpio.h> |
| 35 | #include <asm/arch/clocks.h> |
| 36 | #include <asm/arch/sys_proto.h> |
| 37 | #include <asm/utils.h> |
| 38 | #include <asm/omap_gpio.h> |
| 39 | |
| 40 | #ifndef CONFIG_SPL_BUILD |
| 41 | /* |
| 42 | * printing to console doesn't work unless |
| 43 | * this code is executed from SPL |
| 44 | */ |
| 45 | #define printf(fmt, args...) |
| 46 | #define puts(s) |
Robert P. J. Day | 3037e52 | 2012-11-13 08:12:08 +0000 | [diff] [blame] | 47 | #endif /* !CONFIG_SPL_BUILD */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 48 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 49 | const u32 sys_clk_array[8] = { |
| 50 | 12000000, /* 12 MHz */ |
| 51 | 13000000, /* 13 MHz */ |
| 52 | 16800000, /* 16.8 MHz */ |
| 53 | 19200000, /* 19.2 MHz */ |
| 54 | 26000000, /* 26 MHz */ |
| 55 | 27000000, /* 27 MHz */ |
| 56 | 38400000, /* 38.4 MHz */ |
| 57 | }; |
| 58 | |
| 59 | /* |
| 60 | * The M & N values in the following tables are created using the |
| 61 | * following tool: |
| 62 | * tools/omap/clocks_get_m_n.c |
| 63 | * Please use this tool for creating the table for any new frequency. |
| 64 | */ |
| 65 | |
Aneesh V | 4684fde | 2012-02-06 05:07:43 +0000 | [diff] [blame] | 66 | /* dpll locked at 1400 MHz MPU clk at 700 MHz(OPP100) - DCC OFF */ |
| 67 | static const struct dpll_params mpu_dpll_params_1400mhz[NUM_SYS_CLKS] = { |
| 68 | {175, 2, 1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 69 | {700, 12, 1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 70 | {125, 2, 1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 71 | {401, 10, 1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 72 | {350, 12, 1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 73 | {700, 26, 1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 74 | {638, 34, 1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | /* dpll locked at 1584 MHz - MPU clk at 792 MHz(OPP Turbo 4430) */ |
| 78 | static const struct dpll_params mpu_dpll_params_1600mhz[NUM_SYS_CLKS] = { |
| 79 | {200, 2, 1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 80 | {800, 12, 1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 81 | {619, 12, 1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 82 | {125, 2, 1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 83 | {400, 12, 1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 84 | {800, 26, 1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 85 | {125, 5, 1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 86 | }; |
| 87 | |
| 88 | /* dpll locked at 1200 MHz - MPU clk at 600 MHz */ |
| 89 | static const struct dpll_params mpu_dpll_params_1200mhz[NUM_SYS_CLKS] = { |
| 90 | {50, 0, 1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 91 | {600, 12, 1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 92 | {250, 6, 1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 93 | {125, 3, 1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 94 | {300, 12, 1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 95 | {200, 8, 1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 96 | {125, 7, 1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 97 | }; |
| 98 | |
| 99 | static const struct dpll_params core_dpll_params_1600mhz[NUM_SYS_CLKS] = { |
| 100 | {200, 2, 1, 5, 8, 4, 6, 5}, /* 12 MHz */ |
| 101 | {800, 12, 1, 5, 8, 4, 6, 5}, /* 13 MHz */ |
| 102 | {619, 12, 1, 5, 8, 4, 6, 5}, /* 16.8 MHz */ |
| 103 | {125, 2, 1, 5, 8, 4, 6, 5}, /* 19.2 MHz */ |
| 104 | {400, 12, 1, 5, 8, 4, 6, 5}, /* 26 MHz */ |
| 105 | {800, 26, 1, 5, 8, 4, 6, 5}, /* 27 MHz */ |
| 106 | {125, 5, 1, 5, 8, 4, 6, 5} /* 38.4 MHz */ |
| 107 | }; |
| 108 | |
| 109 | static const struct dpll_params core_dpll_params_es1_1524mhz[NUM_SYS_CLKS] = { |
| 110 | {127, 1, 1, 5, 8, 4, 6, 5}, /* 12 MHz */ |
| 111 | {762, 12, 1, 5, 8, 4, 6, 5}, /* 13 MHz */ |
| 112 | {635, 13, 1, 5, 8, 4, 6, 5}, /* 16.8 MHz */ |
| 113 | {635, 15, 1, 5, 8, 4, 6, 5}, /* 19.2 MHz */ |
| 114 | {381, 12, 1, 5, 8, 4, 6, 5}, /* 26 MHz */ |
| 115 | {254, 8, 1, 5, 8, 4, 6, 5}, /* 27 MHz */ |
| 116 | {496, 24, 1, 5, 8, 4, 6, 5} /* 38.4 MHz */ |
| 117 | }; |
| 118 | |
| 119 | static const struct dpll_params |
| 120 | core_dpll_params_es2_1600mhz_ddr200mhz[NUM_SYS_CLKS] = { |
| 121 | {200, 2, 2, 5, 8, 4, 6, 5}, /* 12 MHz */ |
| 122 | {800, 12, 2, 5, 8, 4, 6, 5}, /* 13 MHz */ |
| 123 | {619, 12, 2, 5, 8, 4, 6, 5}, /* 16.8 MHz */ |
| 124 | {125, 2, 2, 5, 8, 4, 6, 5}, /* 19.2 MHz */ |
| 125 | {400, 12, 2, 5, 8, 4, 6, 5}, /* 26 MHz */ |
| 126 | {800, 26, 2, 5, 8, 4, 6, 5}, /* 27 MHz */ |
| 127 | {125, 5, 2, 5, 8, 4, 6, 5} /* 38.4 MHz */ |
| 128 | }; |
| 129 | |
| 130 | static const struct dpll_params per_dpll_params_1536mhz[NUM_SYS_CLKS] = { |
| 131 | {64, 0, 8, 6, 12, 9, 4, 5}, /* 12 MHz */ |
| 132 | {768, 12, 8, 6, 12, 9, 4, 5}, /* 13 MHz */ |
| 133 | {320, 6, 8, 6, 12, 9, 4, 5}, /* 16.8 MHz */ |
| 134 | {40, 0, 8, 6, 12, 9, 4, 5}, /* 19.2 MHz */ |
| 135 | {384, 12, 8, 6, 12, 9, 4, 5}, /* 26 MHz */ |
| 136 | {256, 8, 8, 6, 12, 9, 4, 5}, /* 27 MHz */ |
| 137 | {20, 0, 8, 6, 12, 9, 4, 5} /* 38.4 MHz */ |
| 138 | }; |
| 139 | |
| 140 | static const struct dpll_params iva_dpll_params_1862mhz[NUM_SYS_CLKS] = { |
| 141 | {931, 11, -1, -1, 4, 7, -1, -1}, /* 12 MHz */ |
| 142 | {931, 12, -1, -1, 4, 7, -1, -1}, /* 13 MHz */ |
| 143 | {665, 11, -1, -1, 4, 7, -1, -1}, /* 16.8 MHz */ |
| 144 | {727, 14, -1, -1, 4, 7, -1, -1}, /* 19.2 MHz */ |
| 145 | {931, 25, -1, -1, 4, 7, -1, -1}, /* 26 MHz */ |
| 146 | {931, 26, -1, -1, 4, 7, -1, -1}, /* 27 MHz */ |
Sebastien Jan | 530bfd1 | 2012-06-13 05:16:40 +0000 | [diff] [blame] | 147 | {291, 11, -1, -1, 4, 7, -1, -1} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | /* ABE M & N values with sys_clk as source */ |
| 151 | static const struct dpll_params |
| 152 | abe_dpll_params_sysclk_196608khz[NUM_SYS_CLKS] = { |
| 153 | {49, 5, 1, 1, -1, -1, -1, -1}, /* 12 MHz */ |
| 154 | {68, 8, 1, 1, -1, -1, -1, -1}, /* 13 MHz */ |
| 155 | {35, 5, 1, 1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 156 | {46, 8, 1, 1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 157 | {34, 8, 1, 1, -1, -1, -1, -1}, /* 26 MHz */ |
| 158 | {29, 7, 1, 1, -1, -1, -1, -1}, /* 27 MHz */ |
| 159 | {64, 24, 1, 1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 160 | }; |
| 161 | |
| 162 | /* ABE M & N values with 32K clock as source */ |
| 163 | static const struct dpll_params abe_dpll_params_32k_196608khz = { |
| 164 | 750, 0, 1, 1, -1, -1, -1, -1 |
| 165 | }; |
| 166 | |
| 167 | static const struct dpll_params usb_dpll_params_1920mhz[NUM_SYS_CLKS] = { |
| 168 | {80, 0, 2, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 169 | {960, 12, 2, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 170 | {400, 6, 2, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 171 | {50, 0, 2, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 172 | {480, 12, 2, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 173 | {320, 8, 2, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 174 | {25, 0, 2, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 175 | }; |
| 176 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 177 | void setup_post_dividers(u32 const base, const struct dpll_params *params) |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 178 | { |
| 179 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 180 | |
| 181 | /* Setup post-dividers */ |
| 182 | if (params->m2 >= 0) |
| 183 | writel(params->m2, &dpll_regs->cm_div_m2_dpll); |
| 184 | if (params->m3 >= 0) |
| 185 | writel(params->m3, &dpll_regs->cm_div_m3_dpll); |
| 186 | if (params->m4 >= 0) |
| 187 | writel(params->m4, &dpll_regs->cm_div_m4_dpll); |
| 188 | if (params->m5 >= 0) |
| 189 | writel(params->m5, &dpll_regs->cm_div_m5_dpll); |
| 190 | if (params->m6 >= 0) |
| 191 | writel(params->m6, &dpll_regs->cm_div_m6_dpll); |
| 192 | if (params->m7 >= 0) |
| 193 | writel(params->m7, &dpll_regs->cm_div_m7_dpll); |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * Lock MPU dpll |
| 198 | * |
| 199 | * Resulting MPU frequencies: |
| 200 | * 4430 ES1.0 : 600 MHz |
| 201 | * 4430 ES2.x : 792 MHz (OPP Turbo) |
| 202 | * 4460 : 920 MHz (OPP Turbo) - DCC disabled |
| 203 | */ |
| 204 | const struct dpll_params *get_mpu_dpll_params(void) |
| 205 | { |
| 206 | u32 omap_rev, sysclk_ind; |
| 207 | |
| 208 | omap_rev = omap_revision(); |
| 209 | sysclk_ind = get_sys_clk_index(); |
| 210 | |
| 211 | if (omap_rev == OMAP4430_ES1_0) |
| 212 | return &mpu_dpll_params_1200mhz[sysclk_ind]; |
| 213 | else if (omap_rev < OMAP4460_ES1_0) |
| 214 | return &mpu_dpll_params_1600mhz[sysclk_ind]; |
| 215 | else |
Aneesh V | 4684fde | 2012-02-06 05:07:43 +0000 | [diff] [blame] | 216 | return &mpu_dpll_params_1400mhz[sysclk_ind]; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | const struct dpll_params *get_core_dpll_params(void) |
| 220 | { |
| 221 | u32 sysclk_ind = get_sys_clk_index(); |
| 222 | |
| 223 | switch (omap_revision()) { |
| 224 | case OMAP4430_ES1_0: |
| 225 | return &core_dpll_params_es1_1524mhz[sysclk_ind]; |
| 226 | case OMAP4430_ES2_0: |
| 227 | case OMAP4430_SILICON_ID_INVALID: |
| 228 | /* safest */ |
| 229 | return &core_dpll_params_es2_1600mhz_ddr200mhz[sysclk_ind]; |
| 230 | default: |
| 231 | return &core_dpll_params_1600mhz[sysclk_ind]; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | |
| 236 | const struct dpll_params *get_per_dpll_params(void) |
| 237 | { |
| 238 | u32 sysclk_ind = get_sys_clk_index(); |
| 239 | return &per_dpll_params_1536mhz[sysclk_ind]; |
| 240 | } |
| 241 | |
| 242 | const struct dpll_params *get_iva_dpll_params(void) |
| 243 | { |
| 244 | u32 sysclk_ind = get_sys_clk_index(); |
| 245 | return &iva_dpll_params_1862mhz[sysclk_ind]; |
| 246 | } |
| 247 | |
| 248 | const struct dpll_params *get_usb_dpll_params(void) |
| 249 | { |
| 250 | u32 sysclk_ind = get_sys_clk_index(); |
| 251 | return &usb_dpll_params_1920mhz[sysclk_ind]; |
| 252 | } |
| 253 | |
| 254 | const struct dpll_params *get_abe_dpll_params(void) |
| 255 | { |
| 256 | #ifdef CONFIG_SYS_OMAP_ABE_SYSCK |
| 257 | u32 sysclk_ind = get_sys_clk_index(); |
| 258 | return &abe_dpll_params_sysclk_196608khz[sysclk_ind]; |
| 259 | #else |
| 260 | return &abe_dpll_params_32k_196608khz; |
| 261 | #endif |
| 262 | } |
| 263 | |
| 264 | /* |
| 265 | * Setup the voltages for vdd_mpu, vdd_core, and vdd_iva |
| 266 | * We set the maximum voltages allowed here because Smart-Reflex is not |
| 267 | * enabled in bootloader. Voltage initialization in the kernel will set |
| 268 | * these to the nominal values after enabling Smart-Reflex |
| 269 | */ |
| 270 | void scale_vcores(void) |
| 271 | { |
| 272 | u32 volt, omap_rev; |
| 273 | |
Nishanth Menon | 41d7ab1 | 2012-03-01 14:17:37 +0000 | [diff] [blame] | 274 | omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 275 | |
| 276 | omap_rev = omap_revision(); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 277 | |
| 278 | /* |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 279 | * Scale Voltage rails: |
| 280 | * 1. VDD_CORE |
| 281 | * 3. VDD_MPU |
| 282 | * 3. VDD_IVA |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 283 | */ |
| 284 | if (omap_rev < OMAP4460_ES1_0) { |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 285 | /* |
| 286 | * OMAP4430: |
| 287 | * VDD_CORE = TWL6030 VCORE3 |
| 288 | * VDD_MPU = TWL6030 VCORE1 |
| 289 | * VDD_IVA = TWL6030 VCORE2 |
| 290 | */ |
| 291 | volt = 1200; |
| 292 | do_scale_vcore(SMPS_REG_ADDR_VCORE3, volt); |
| 293 | |
| 294 | /* |
| 295 | * note on VDD_MPU: |
| 296 | * Setting a high voltage for Nitro mode as smart reflex is not |
| 297 | * enabled. We use the maximum possible value in the AVS range |
| 298 | * because the next higher voltage in the discrete range |
| 299 | * (code >= 0b111010) is way too high. |
| 300 | */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 301 | volt = 1325; |
| 302 | do_scale_vcore(SMPS_REG_ADDR_VCORE1, volt); |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 303 | volt = 1200; |
| 304 | do_scale_vcore(SMPS_REG_ADDR_VCORE2, volt); |
| 305 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 306 | } else { |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 307 | /* |
| 308 | * OMAP4460: |
| 309 | * VDD_CORE = TWL6030 VCORE1 |
| 310 | * VDD_MPU = TPS62361 |
| 311 | * VDD_IVA = TWL6030 VCORE2 |
| 312 | */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 313 | volt = 1200; |
| 314 | do_scale_vcore(SMPS_REG_ADDR_VCORE1, volt); |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 315 | /* TPS62361 */ |
| 316 | volt = 1203; |
| 317 | do_scale_tps62361(TPS62361_VSEL0_GPIO, |
| 318 | TPS62361_REG_ADDR_SET1, volt); |
| 319 | /* VCORE 2 - supplies vdd_iva */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 320 | volt = 1200; |
Nishanth Menon | 5a1bfc8 | 2012-03-01 14:17:39 +0000 | [diff] [blame] | 321 | do_scale_vcore(SMPS_REG_ADDR_VCORE2, volt); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 325 | u32 get_offset_code(u32 offset) |
| 326 | { |
| 327 | u32 offset_code, step = 12660; /* 12.66 mV represented in uV */ |
| 328 | |
| 329 | if (omap_revision() == OMAP4430_ES1_0) |
| 330 | offset -= PHOENIX_SMPS_BASE_VOLT_STD_MODE_UV; |
| 331 | else |
| 332 | offset -= PHOENIX_SMPS_BASE_VOLT_STD_MODE_WITH_OFFSET_UV; |
| 333 | |
| 334 | offset_code = (offset + step - 1) / step; |
| 335 | |
| 336 | /* The code starts at 1 not 0 */ |
| 337 | return ++offset_code; |
| 338 | } |
| 339 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 340 | /* |
| 341 | * Enable essential clock domains, modules and |
| 342 | * do some additional special settings needed |
| 343 | */ |
| 344 | void enable_basic_clocks(void) |
| 345 | { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 346 | u32 const clk_domains_essential[] = { |
| 347 | (*prcm)->cm_l4per_clkstctrl, |
| 348 | (*prcm)->cm_l3init_clkstctrl, |
| 349 | (*prcm)->cm_memif_clkstctrl, |
| 350 | (*prcm)->cm_l4cfg_clkstctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 351 | 0 |
| 352 | }; |
| 353 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 354 | u32 const clk_modules_hw_auto_essential[] = { |
| 355 | (*prcm)->cm_l3_2_gpmc_clkctrl, |
| 356 | (*prcm)->cm_memif_emif_1_clkctrl, |
| 357 | (*prcm)->cm_memif_emif_2_clkctrl, |
| 358 | (*prcm)->cm_l4cfg_l4_cfg_clkctrl, |
| 359 | (*prcm)->cm_wkup_gpio1_clkctrl, |
| 360 | (*prcm)->cm_l4per_gpio2_clkctrl, |
| 361 | (*prcm)->cm_l4per_gpio3_clkctrl, |
| 362 | (*prcm)->cm_l4per_gpio4_clkctrl, |
| 363 | (*prcm)->cm_l4per_gpio5_clkctrl, |
| 364 | (*prcm)->cm_l4per_gpio6_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 365 | 0 |
| 366 | }; |
| 367 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 368 | u32 const clk_modules_explicit_en_essential[] = { |
| 369 | (*prcm)->cm_wkup_gptimer1_clkctrl, |
| 370 | (*prcm)->cm_l3init_hsmmc1_clkctrl, |
| 371 | (*prcm)->cm_l3init_hsmmc2_clkctrl, |
| 372 | (*prcm)->cm_l4per_gptimer2_clkctrl, |
| 373 | (*prcm)->cm_wkup_wdtimer2_clkctrl, |
| 374 | (*prcm)->cm_l4per_uart3_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 375 | 0 |
| 376 | }; |
| 377 | |
| 378 | /* Enable optional additional functional clock for GPIO4 */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 379 | setbits_le32((*prcm)->cm_l4per_gpio4_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 380 | GPIO4_CLKCTRL_OPTFCLKEN_MASK); |
| 381 | |
| 382 | /* Enable 96 MHz clock for MMC1 & MMC2 */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 383 | setbits_le32((*prcm)->cm_l3init_hsmmc1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 384 | HSMMC_CLKCTRL_CLKSEL_MASK); |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 385 | setbits_le32((*prcm)->cm_l3init_hsmmc2_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 386 | HSMMC_CLKCTRL_CLKSEL_MASK); |
| 387 | |
| 388 | /* Select 32KHz clock as the source of GPTIMER1 */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 389 | setbits_le32((*prcm)->cm_wkup_gptimer1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 390 | GPTIMER1_CLKCTRL_CLKSEL_MASK); |
| 391 | |
| 392 | /* Enable optional 48M functional clock for USB PHY */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 393 | setbits_le32((*prcm)->cm_l3init_usbphy_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 394 | USBPHY_CLKCTRL_OPTFCLKEN_PHY_48M_MASK); |
| 395 | |
| 396 | do_enable_clocks(clk_domains_essential, |
| 397 | clk_modules_hw_auto_essential, |
| 398 | clk_modules_explicit_en_essential, |
| 399 | 1); |
| 400 | } |
| 401 | |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 402 | void enable_basic_uboot_clocks(void) |
| 403 | { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 404 | u32 const clk_domains_essential[] = { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 405 | 0 |
| 406 | }; |
| 407 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 408 | u32 const clk_modules_hw_auto_essential[] = { |
| 409 | (*prcm)->cm_l3init_hsusbotg_clkctrl, |
| 410 | (*prcm)->cm_l3init_usbphy_clkctrl, |
| 411 | (*prcm)->cm_l3init_usbphy_clkctrl, |
| 412 | (*prcm)->cm_clksel_usb_60mhz, |
| 413 | (*prcm)->cm_l3init_hsusbtll_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 414 | 0 |
| 415 | }; |
| 416 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 417 | u32 const clk_modules_explicit_en_essential[] = { |
| 418 | (*prcm)->cm_l4per_mcspi1_clkctrl, |
| 419 | (*prcm)->cm_l4per_i2c1_clkctrl, |
| 420 | (*prcm)->cm_l4per_i2c2_clkctrl, |
| 421 | (*prcm)->cm_l4per_i2c3_clkctrl, |
| 422 | (*prcm)->cm_l4per_i2c4_clkctrl, |
| 423 | (*prcm)->cm_l3init_hsusbhost_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 424 | 0 |
| 425 | }; |
| 426 | |
| 427 | do_enable_clocks(clk_domains_essential, |
| 428 | clk_modules_hw_auto_essential, |
| 429 | clk_modules_explicit_en_essential, |
| 430 | 1); |
| 431 | } |
| 432 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 433 | /* |
| 434 | * Enable non-essential clock domains, modules and |
| 435 | * do some additional special settings needed |
| 436 | */ |
| 437 | void enable_non_essential_clocks(void) |
| 438 | { |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 439 | u32 const clk_domains_non_essential[] = { |
| 440 | (*prcm)->cm_mpu_m3_clkstctrl, |
| 441 | (*prcm)->cm_ivahd_clkstctrl, |
| 442 | (*prcm)->cm_dsp_clkstctrl, |
| 443 | (*prcm)->cm_dss_clkstctrl, |
| 444 | (*prcm)->cm_sgx_clkstctrl, |
| 445 | (*prcm)->cm1_abe_clkstctrl, |
| 446 | (*prcm)->cm_c2c_clkstctrl, |
| 447 | (*prcm)->cm_cam_clkstctrl, |
| 448 | (*prcm)->cm_dss_clkstctrl, |
| 449 | (*prcm)->cm_sdma_clkstctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 450 | 0 |
| 451 | }; |
| 452 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 453 | u32 const clk_modules_hw_auto_non_essential[] = { |
| 454 | (*prcm)->cm_l3instr_l3_3_clkctrl, |
| 455 | (*prcm)->cm_l3instr_l3_instr_clkctrl, |
| 456 | (*prcm)->cm_l3instr_intrconn_wp1_clkctrl, |
| 457 | (*prcm)->cm_l3init_hsi_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 458 | 0 |
| 459 | }; |
| 460 | |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 461 | u32 const clk_modules_explicit_en_non_essential[] = { |
| 462 | (*prcm)->cm1_abe_aess_clkctrl, |
| 463 | (*prcm)->cm1_abe_pdm_clkctrl, |
| 464 | (*prcm)->cm1_abe_dmic_clkctrl, |
| 465 | (*prcm)->cm1_abe_mcasp_clkctrl, |
| 466 | (*prcm)->cm1_abe_mcbsp1_clkctrl, |
| 467 | (*prcm)->cm1_abe_mcbsp2_clkctrl, |
| 468 | (*prcm)->cm1_abe_mcbsp3_clkctrl, |
| 469 | (*prcm)->cm1_abe_slimbus_clkctrl, |
| 470 | (*prcm)->cm1_abe_timer5_clkctrl, |
| 471 | (*prcm)->cm1_abe_timer6_clkctrl, |
| 472 | (*prcm)->cm1_abe_timer7_clkctrl, |
| 473 | (*prcm)->cm1_abe_timer8_clkctrl, |
| 474 | (*prcm)->cm1_abe_wdt3_clkctrl, |
| 475 | (*prcm)->cm_l4per_gptimer9_clkctrl, |
| 476 | (*prcm)->cm_l4per_gptimer10_clkctrl, |
| 477 | (*prcm)->cm_l4per_gptimer11_clkctrl, |
| 478 | (*prcm)->cm_l4per_gptimer3_clkctrl, |
| 479 | (*prcm)->cm_l4per_gptimer4_clkctrl, |
| 480 | (*prcm)->cm_l4per_hdq1w_clkctrl, |
| 481 | (*prcm)->cm_l4per_mcbsp4_clkctrl, |
| 482 | (*prcm)->cm_l4per_mcspi2_clkctrl, |
| 483 | (*prcm)->cm_l4per_mcspi3_clkctrl, |
| 484 | (*prcm)->cm_l4per_mcspi4_clkctrl, |
| 485 | (*prcm)->cm_l4per_mmcsd3_clkctrl, |
| 486 | (*prcm)->cm_l4per_mmcsd4_clkctrl, |
| 487 | (*prcm)->cm_l4per_mmcsd5_clkctrl, |
| 488 | (*prcm)->cm_l4per_uart1_clkctrl, |
| 489 | (*prcm)->cm_l4per_uart2_clkctrl, |
| 490 | (*prcm)->cm_l4per_uart4_clkctrl, |
| 491 | (*prcm)->cm_wkup_keyboard_clkctrl, |
| 492 | (*prcm)->cm_wkup_wdtimer2_clkctrl, |
| 493 | (*prcm)->cm_cam_iss_clkctrl, |
| 494 | (*prcm)->cm_cam_fdif_clkctrl, |
| 495 | (*prcm)->cm_dss_dss_clkctrl, |
| 496 | (*prcm)->cm_sgx_sgx_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 497 | 0 |
| 498 | }; |
| 499 | |
| 500 | /* Enable optional functional clock for ISS */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 501 | setbits_le32((*prcm)->cm_cam_iss_clkctrl, ISS_CLKCTRL_OPTFCLKEN_MASK); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 502 | |
| 503 | /* Enable all optional functional clocks of DSS */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 504 | setbits_le32((*prcm)->cm_dss_dss_clkctrl, DSS_CLKCTRL_OPTFCLKEN_MASK); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 505 | |
| 506 | do_enable_clocks(clk_domains_non_essential, |
| 507 | clk_modules_hw_auto_non_essential, |
| 508 | clk_modules_explicit_en_non_essential, |
| 509 | 0); |
| 510 | |
| 511 | /* Put camera module in no sleep mode */ |
SRICHARAN R | fb6aa1f | 2013-02-04 04:22:00 +0000 | [diff] [blame^] | 512 | clrsetbits_le32((*prcm)->cm_cam_clkstctrl, |
| 513 | MODULE_CLKCTRL_MODULEMODE_MASK, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 514 | CD_CLKCTRL_CLKTRCTRL_NO_SLEEP << |
| 515 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 516 | } |