Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Clock initialization for OMAP5 |
| 4 | * |
| 5 | * (C) Copyright 2010 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Aneesh V <aneesh@ti.com> |
| 9 | * Sricharan R <r.sricharan@ti.com> |
| 10 | * |
| 11 | * Based on previous work by: |
| 12 | * Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 13 | * Rajendra Nayak <rnayak@ti.com> |
| 14 | * |
| 15 | * See file CREDITS for list of people who contributed to this |
| 16 | * project. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU General Public License as |
| 20 | * published by the Free Software Foundation; either version 2 of |
| 21 | * the License, or (at your option) any later version. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program; if not, write to the Free Software |
| 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 31 | * MA 02111-1307 USA |
| 32 | */ |
| 33 | #include <common.h> |
| 34 | #include <asm/omap_common.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 | struct omap5_prcm_regs *const prcm = (struct omap5_prcm_regs *)0x4A004100; |
| 50 | |
| 51 | const u32 sys_clk_array[8] = { |
| 52 | 12000000, /* 12 MHz */ |
| 53 | 0, /* NA */ |
| 54 | 16800000, /* 16.8 MHz */ |
| 55 | 19200000, /* 19.2 MHz */ |
| 56 | 26000000, /* 26 MHz */ |
| 57 | 0, /* NA */ |
| 58 | 38400000, /* 38.4 MHz */ |
| 59 | }; |
| 60 | |
| 61 | static const struct dpll_params mpu_dpll_params_1_5ghz[NUM_SYS_CLKS] = { |
| 62 | {125, 0, 1, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 63 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 64 | {625, 6, 1, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 65 | {625, 7, 1, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 66 | {750, 12, 1, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 67 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 68 | {625, 15, 1, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 69 | }; |
| 70 | |
| 71 | static const struct dpll_params mpu_dpll_params_2ghz[NUM_SYS_CLKS] = { |
| 72 | {500, 2, 1, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 73 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 74 | {2024, 16, 1, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 75 | {625, 5, 1, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 76 | {1000, 12, 1, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 77 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 78 | {625, 11, 1, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 79 | }; |
| 80 | |
| 81 | static const struct dpll_params mpu_dpll_params_1100mhz[NUM_SYS_CLKS] = { |
| 82 | {275, 2, 1, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 83 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 84 | {1375, 20, 1, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 85 | {1375, 23, 1, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 86 | {550, 12, 1, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 87 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 88 | {1375, 47, 1, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 89 | }; |
| 90 | |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 91 | static const struct dpll_params mpu_dpll_params_800mhz[NUM_SYS_CLKS] = { |
| 92 | {200, 2, 1, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 93 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 94 | {1000, 20, 1, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 95 | {375, 8, 1, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 96 | {400, 12, 1, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 97 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 98 | {375, 17, 1, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 99 | }; |
| 100 | |
| 101 | static const struct dpll_params mpu_dpll_params_400mhz[NUM_SYS_CLKS] = { |
| 102 | {200, 2, 2, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 103 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 104 | {1000, 20, 2, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 105 | {375, 8, 2, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 106 | {400, 12, 2, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 107 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 108 | {375, 17, 2, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 109 | }; |
| 110 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 111 | static const struct dpll_params mpu_dpll_params_550mhz[NUM_SYS_CLKS] = { |
| 112 | {275, 2, 2, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 113 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 114 | {1375, 20, 2, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 115 | {1375, 23, 2, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 116 | {550, 12, 2, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 117 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 118 | {1375, 47, 2, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
| 119 | }; |
| 120 | |
| 121 | static const struct dpll_params |
| 122 | core_dpll_params_2128mhz_ddr532[NUM_SYS_CLKS] = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 123 | {266, 2, 2, 5, 8, 4, 62, 5, 5, 7}, /* 12 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 124 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 125 | {570, 8, 2, 5, 8, 4, 62, 5, 5, 7}, /* 16.8 MHz */ |
| 126 | {665, 11, 2, 5, 8, 4, 62, 5, 5, 7}, /* 19.2 MHz */ |
| 127 | {532, 12, 2, 5, 8, 4, 62, 5, 5, 7}, /* 26 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 128 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 129 | {665, 23, 2, 5, 8, 4, 62, 5, 5, 7} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | static const struct dpll_params |
| 133 | core_dpll_params_2128mhz_ddr266[NUM_SYS_CLKS] = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 134 | {266, 2, 4, 5, 8, 8, 62, 10, 10, 14}, /* 12 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 135 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 136 | {570, 8, 4, 5, 8, 8, 62, 10, 10, 14}, /* 16.8 MHz */ |
| 137 | {665, 11, 4, 5, 8, 8, 62, 10, 10, 14}, /* 19.2 MHz */ |
| 138 | {532, 12, 4, 8, 8, 8, 62, 10, 10, 14}, /* 26 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 139 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 140 | {665, 23, 4, 8, 8, 8, 62, 10, 10, 14} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | static const struct dpll_params per_dpll_params_768mhz[NUM_SYS_CLKS] = { |
| 144 | {32, 0, 4, 3, 6, 4, -1, 2, -1, -1}, /* 12 MHz */ |
| 145 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 146 | {160, 6, 4, 3, 6, 4, -1, 2, -1, -1}, /* 16.8 MHz */ |
| 147 | {20, 0, 4, 3, 6, 4, -1, 2, -1, -1}, /* 19.2 MHz */ |
| 148 | {192, 12, 4, 3, 6, 4, -1, 2, -1, -1}, /* 26 MHz */ |
| 149 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 150 | {10, 0, 4, 3, 6, 4, -1, 2, -1, -1} /* 38.4 MHz */ |
| 151 | }; |
| 152 | |
| 153 | static const struct dpll_params iva_dpll_params_2330mhz[NUM_SYS_CLKS] = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 154 | {1165, 11, -1, -1, 5, 6, -1, -1, -1, -1}, /* 12 MHz */ |
| 155 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 156 | {2011, 28, -1, -1, 5, 6, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 157 | {1881, 30, -1, -1, 5, 6, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 158 | {1165, 25, -1, -1, 5, 6, -1, -1, -1, -1}, /* 26 MHz */ |
| 159 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 160 | {1972, 64, -1, -1, 5, 6, -1, -1, -1, -1} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | /* ABE M & N values with sys_clk as source */ |
| 164 | static const struct dpll_params |
| 165 | abe_dpll_params_sysclk_196608khz[NUM_SYS_CLKS] = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 166 | {49, 5, 1, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 167 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 168 | {35, 5, 1, 1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 169 | {46, 8, 1, 1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 170 | {34, 8, 1, 1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 171 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 172 | {64, 24, 1, 1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | /* ABE M & N values with 32K clock as source */ |
| 176 | static const struct dpll_params abe_dpll_params_32k_196608khz = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 177 | 750, 0, 1, 1, -1, -1, -1, -1, -1, -1 |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | static const struct dpll_params usb_dpll_params_1920mhz[NUM_SYS_CLKS] = { |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 181 | {400, 4, 2, -1, -1, -1, -1, -1, -1, -1}, /* 12 MHz */ |
| 182 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */ |
| 183 | {400, 6, 2, -1, -1, -1, -1, -1, -1, -1}, /* 16.8 MHz */ |
| 184 | {400, 7, 2, -1, -1, -1, -1, -1, -1, -1}, /* 19.2 MHz */ |
| 185 | {480, 12, 2, -1, -1, -1, -1, -1, -1, -1}, /* 26 MHz */ |
| 186 | {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */ |
| 187 | {400, 15, 2, -1, -1, -1, -1, -1, -1, -1} /* 38.4 MHz */ |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | void setup_post_dividers(u32 *const base, const struct dpll_params *params) |
| 191 | { |
| 192 | struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; |
| 193 | |
| 194 | /* Setup post-dividers */ |
| 195 | if (params->m2 >= 0) |
| 196 | writel(params->m2, &dpll_regs->cm_div_m2_dpll); |
| 197 | if (params->m3 >= 0) |
| 198 | writel(params->m3, &dpll_regs->cm_div_m3_dpll); |
| 199 | if (params->h11 >= 0) |
| 200 | writel(params->h11, &dpll_regs->cm_div_h11_dpll); |
| 201 | if (params->h12 >= 0) |
| 202 | writel(params->h12, &dpll_regs->cm_div_h12_dpll); |
| 203 | if (params->h13 >= 0) |
| 204 | writel(params->h13, &dpll_regs->cm_div_h13_dpll); |
| 205 | if (params->h14 >= 0) |
| 206 | writel(params->h14, &dpll_regs->cm_div_h14_dpll); |
| 207 | if (params->h22 >= 0) |
| 208 | writel(params->h22, &dpll_regs->cm_div_h22_dpll); |
| 209 | if (params->h23 >= 0) |
| 210 | writel(params->h23, &dpll_regs->cm_div_h23_dpll); |
| 211 | } |
| 212 | |
| 213 | const struct dpll_params *get_mpu_dpll_params(void) |
| 214 | { |
| 215 | u32 sysclk_ind = get_sys_clk_index(); |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 216 | return &mpu_dpll_params_800mhz[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 | /* Configuring the DDR to be at 532mhz */ |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 224 | return &core_dpll_params_2128mhz_ddr532[sysclk_ind]; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | const struct dpll_params *get_per_dpll_params(void) |
| 228 | { |
| 229 | u32 sysclk_ind = get_sys_clk_index(); |
| 230 | return &per_dpll_params_768mhz[sysclk_ind]; |
| 231 | } |
| 232 | |
| 233 | const struct dpll_params *get_iva_dpll_params(void) |
| 234 | { |
| 235 | u32 sysclk_ind = get_sys_clk_index(); |
| 236 | return &iva_dpll_params_2330mhz[sysclk_ind]; |
| 237 | } |
| 238 | |
| 239 | const struct dpll_params *get_usb_dpll_params(void) |
| 240 | { |
| 241 | u32 sysclk_ind = get_sys_clk_index(); |
| 242 | return &usb_dpll_params_1920mhz[sysclk_ind]; |
| 243 | } |
| 244 | |
| 245 | const struct dpll_params *get_abe_dpll_params(void) |
| 246 | { |
| 247 | #ifdef CONFIG_SYS_OMAP_ABE_SYSCK |
| 248 | u32 sysclk_ind = get_sys_clk_index(); |
| 249 | return &abe_dpll_params_sysclk_196608khz[sysclk_ind]; |
| 250 | #else |
| 251 | return &abe_dpll_params_32k_196608khz; |
| 252 | #endif |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * Setup the voltages for vdd_mpu, vdd_core, and vdd_iva |
| 257 | * We set the maximum voltages allowed here because Smart-Reflex is not |
| 258 | * enabled in bootloader. Voltage initialization in the kernel will set |
| 259 | * these to the nominal values after enabling Smart-Reflex |
| 260 | */ |
| 261 | void scale_vcores(void) |
| 262 | { |
| 263 | u32 volt; |
| 264 | |
Nishanth Menon | 41d7ab1 | 2012-03-01 14:17:37 +0000 | [diff] [blame] | 265 | omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 266 | |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 267 | /* Palmas settings */ |
| 268 | volt = VDD_CORE; |
| 269 | do_scale_vcore(SMPS_REG_ADDR_8_CORE, volt); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 270 | |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 271 | volt = VDD_MPU; |
| 272 | do_scale_vcore(SMPS_REG_ADDR_12_MPU, volt); |
| 273 | |
| 274 | volt = VDD_MM; |
| 275 | do_scale_vcore(SMPS_REG_ADDR_45_IVA, volt); |
| 276 | |
| 277 | } |
| 278 | |
| 279 | u32 get_offset_code(u32 volt_offset) |
| 280 | { |
| 281 | u32 offset_code, step = 10000; /* 10 mV represented in uV */ |
| 282 | |
| 283 | volt_offset -= PALMAS_SMPS_BASE_VOLT_UV; |
| 284 | |
| 285 | offset_code = (volt_offset + step - 1) / step; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 286 | |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 287 | /* |
| 288 | * Offset codes 1-6 all give the base voltage in Palmas |
| 289 | * Offset code 0 switches OFF the SMPS |
| 290 | */ |
| 291 | return offset_code + 6; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /* |
| 295 | * Enable essential clock domains, modules and |
| 296 | * do some additional special settings needed |
| 297 | */ |
| 298 | void enable_basic_clocks(void) |
| 299 | { |
| 300 | u32 *const clk_domains_essential[] = { |
| 301 | &prcm->cm_l4per_clkstctrl, |
| 302 | &prcm->cm_l3init_clkstctrl, |
| 303 | &prcm->cm_memif_clkstctrl, |
| 304 | &prcm->cm_l4cfg_clkstctrl, |
| 305 | 0 |
| 306 | }; |
| 307 | |
| 308 | u32 *const clk_modules_hw_auto_essential[] = { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 309 | &prcm->cm_memif_emif_1_clkctrl, |
| 310 | &prcm->cm_memif_emif_2_clkctrl, |
| 311 | &prcm->cm_l4cfg_l4_cfg_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 312 | &prcm->cm_wkup_gpio1_clkctrl, |
| 313 | &prcm->cm_l4per_gpio2_clkctrl, |
| 314 | &prcm->cm_l4per_gpio3_clkctrl, |
| 315 | &prcm->cm_l4per_gpio4_clkctrl, |
| 316 | &prcm->cm_l4per_gpio5_clkctrl, |
| 317 | &prcm->cm_l4per_gpio6_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 318 | 0 |
| 319 | }; |
| 320 | |
| 321 | u32 *const clk_modules_explicit_en_essential[] = { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 322 | &prcm->cm_wkup_gptimer1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 323 | &prcm->cm_l3init_hsmmc1_clkctrl, |
| 324 | &prcm->cm_l3init_hsmmc2_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 325 | &prcm->cm_l4per_gptimer2_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 326 | &prcm->cm_wkup_wdtimer2_clkctrl, |
| 327 | &prcm->cm_l4per_uart3_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 328 | &prcm->cm_l4per_i2c1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 329 | 0 |
| 330 | }; |
| 331 | |
| 332 | /* Enable optional additional functional clock for GPIO4 */ |
| 333 | setbits_le32(&prcm->cm_l4per_gpio4_clkctrl, |
| 334 | GPIO4_CLKCTRL_OPTFCLKEN_MASK); |
| 335 | |
| 336 | /* Enable 96 MHz clock for MMC1 & MMC2 */ |
| 337 | setbits_le32(&prcm->cm_l3init_hsmmc1_clkctrl, |
| 338 | HSMMC_CLKCTRL_CLKSEL_MASK); |
| 339 | setbits_le32(&prcm->cm_l3init_hsmmc2_clkctrl, |
| 340 | HSMMC_CLKCTRL_CLKSEL_MASK); |
| 341 | |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 342 | /* Set the correct clock dividers for mmc */ |
| 343 | setbits_le32(&prcm->cm_l3init_hsmmc1_clkctrl, |
| 344 | HSMMC_CLKCTRL_CLKSEL_DIV_MASK); |
| 345 | setbits_le32(&prcm->cm_l3init_hsmmc2_clkctrl, |
| 346 | HSMMC_CLKCTRL_CLKSEL_DIV_MASK); |
| 347 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 348 | /* Select 32KHz clock as the source of GPTIMER1 */ |
| 349 | setbits_le32(&prcm->cm_wkup_gptimer1_clkctrl, |
| 350 | GPTIMER1_CLKCTRL_CLKSEL_MASK); |
| 351 | |
| 352 | do_enable_clocks(clk_domains_essential, |
| 353 | clk_modules_hw_auto_essential, |
| 354 | clk_modules_explicit_en_essential, |
| 355 | 1); |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 356 | |
| 357 | /* Select 384Mhz for GPU as its the POR for ES1.0 */ |
| 358 | setbits_le32(&prcm->cm_sgx_sgx_clkctrl, |
| 359 | CLKSEL_GPU_HYD_GCLK_MASK); |
| 360 | setbits_le32(&prcm->cm_sgx_sgx_clkctrl, |
| 361 | CLKSEL_GPU_CORE_GCLK_MASK); |
| 362 | |
| 363 | /* Enable SCRM OPT clocks for PER and CORE dpll */ |
| 364 | setbits_le32(&prcm->cm_wkupaon_scrm_clkctrl, |
| 365 | OPTFCLKEN_SCRM_PER_MASK); |
| 366 | setbits_le32(&prcm->cm_wkupaon_scrm_clkctrl, |
| 367 | OPTFCLKEN_SCRM_CORE_MASK); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 368 | } |
| 369 | |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 370 | void enable_basic_uboot_clocks(void) |
| 371 | { |
| 372 | u32 *const clk_domains_essential[] = { |
| 373 | 0 |
| 374 | }; |
| 375 | |
| 376 | u32 *const clk_modules_hw_auto_essential[] = { |
| 377 | 0 |
| 378 | }; |
| 379 | |
| 380 | u32 *const clk_modules_explicit_en_essential[] = { |
| 381 | &prcm->cm_l4per_mcspi1_clkctrl, |
| 382 | &prcm->cm_l4per_i2c2_clkctrl, |
| 383 | &prcm->cm_l4per_i2c3_clkctrl, |
| 384 | &prcm->cm_l4per_i2c4_clkctrl, |
| 385 | 0 |
| 386 | }; |
| 387 | |
| 388 | do_enable_clocks(clk_domains_essential, |
| 389 | clk_modules_hw_auto_essential, |
| 390 | clk_modules_explicit_en_essential, |
| 391 | 1); |
| 392 | } |
| 393 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 394 | /* |
| 395 | * Enable non-essential clock domains, modules and |
| 396 | * do some additional special settings needed |
| 397 | */ |
| 398 | void enable_non_essential_clocks(void) |
| 399 | { |
| 400 | u32 *const clk_domains_non_essential[] = { |
| 401 | &prcm->cm_mpu_m3_clkstctrl, |
| 402 | &prcm->cm_ivahd_clkstctrl, |
| 403 | &prcm->cm_dsp_clkstctrl, |
| 404 | &prcm->cm_dss_clkstctrl, |
| 405 | &prcm->cm_sgx_clkstctrl, |
| 406 | &prcm->cm1_abe_clkstctrl, |
| 407 | &prcm->cm_c2c_clkstctrl, |
| 408 | &prcm->cm_cam_clkstctrl, |
| 409 | &prcm->cm_dss_clkstctrl, |
| 410 | &prcm->cm_sdma_clkstctrl, |
| 411 | 0 |
| 412 | }; |
| 413 | |
| 414 | u32 *const clk_modules_hw_auto_non_essential[] = { |
| 415 | &prcm->cm_mpu_m3_mpu_m3_clkctrl, |
| 416 | &prcm->cm_ivahd_ivahd_clkctrl, |
| 417 | &prcm->cm_ivahd_sl2_clkctrl, |
| 418 | &prcm->cm_dsp_dsp_clkctrl, |
| 419 | &prcm->cm_l3_2_gpmc_clkctrl, |
| 420 | &prcm->cm_l3instr_l3_3_clkctrl, |
| 421 | &prcm->cm_l3instr_l3_instr_clkctrl, |
| 422 | &prcm->cm_l3instr_intrconn_wp1_clkctrl, |
| 423 | &prcm->cm_l3init_hsi_clkctrl, |
| 424 | &prcm->cm_l3init_hsusbtll_clkctrl, |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 425 | &prcm->cm_l4per_hdq1w_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 426 | 0 |
| 427 | }; |
| 428 | |
| 429 | u32 *const clk_modules_explicit_en_non_essential[] = { |
| 430 | &prcm->cm1_abe_aess_clkctrl, |
| 431 | &prcm->cm1_abe_pdm_clkctrl, |
| 432 | &prcm->cm1_abe_dmic_clkctrl, |
| 433 | &prcm->cm1_abe_mcasp_clkctrl, |
| 434 | &prcm->cm1_abe_mcbsp1_clkctrl, |
| 435 | &prcm->cm1_abe_mcbsp2_clkctrl, |
| 436 | &prcm->cm1_abe_mcbsp3_clkctrl, |
| 437 | &prcm->cm1_abe_slimbus_clkctrl, |
| 438 | &prcm->cm1_abe_timer5_clkctrl, |
| 439 | &prcm->cm1_abe_timer6_clkctrl, |
| 440 | &prcm->cm1_abe_timer7_clkctrl, |
| 441 | &prcm->cm1_abe_timer8_clkctrl, |
| 442 | &prcm->cm1_abe_wdt3_clkctrl, |
| 443 | &prcm->cm_l4per_gptimer9_clkctrl, |
| 444 | &prcm->cm_l4per_gptimer10_clkctrl, |
| 445 | &prcm->cm_l4per_gptimer11_clkctrl, |
| 446 | &prcm->cm_l4per_gptimer3_clkctrl, |
| 447 | &prcm->cm_l4per_gptimer4_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 448 | &prcm->cm_l4per_mcspi2_clkctrl, |
| 449 | &prcm->cm_l4per_mcspi3_clkctrl, |
| 450 | &prcm->cm_l4per_mcspi4_clkctrl, |
| 451 | &prcm->cm_l4per_mmcsd3_clkctrl, |
| 452 | &prcm->cm_l4per_mmcsd4_clkctrl, |
| 453 | &prcm->cm_l4per_mmcsd5_clkctrl, |
| 454 | &prcm->cm_l4per_uart1_clkctrl, |
| 455 | &prcm->cm_l4per_uart2_clkctrl, |
| 456 | &prcm->cm_l4per_uart4_clkctrl, |
| 457 | &prcm->cm_wkup_keyboard_clkctrl, |
| 458 | &prcm->cm_wkup_wdtimer2_clkctrl, |
| 459 | &prcm->cm_cam_iss_clkctrl, |
| 460 | &prcm->cm_cam_fdif_clkctrl, |
| 461 | &prcm->cm_dss_dss_clkctrl, |
| 462 | &prcm->cm_sgx_sgx_clkctrl, |
| 463 | &prcm->cm_l3init_hsusbhost_clkctrl, |
| 464 | &prcm->cm_l3init_fsusb_clkctrl, |
| 465 | 0 |
| 466 | }; |
| 467 | |
| 468 | /* Enable optional functional clock for ISS */ |
| 469 | setbits_le32(&prcm->cm_cam_iss_clkctrl, ISS_CLKCTRL_OPTFCLKEN_MASK); |
| 470 | |
| 471 | /* Enable all optional functional clocks of DSS */ |
| 472 | setbits_le32(&prcm->cm_dss_dss_clkctrl, DSS_CLKCTRL_OPTFCLKEN_MASK); |
| 473 | |
| 474 | do_enable_clocks(clk_domains_non_essential, |
| 475 | clk_modules_hw_auto_non_essential, |
| 476 | clk_modules_explicit_en_non_essential, |
| 477 | 0); |
| 478 | |
| 479 | /* Put camera module in no sleep mode */ |
| 480 | clrsetbits_le32(&prcm->cm_cam_clkstctrl, MODULE_CLKCTRL_MODULEMODE_MASK, |
| 481 | CD_CLKCTRL_CLKTRCTRL_NO_SLEEP << |
| 482 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 483 | } |