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