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 | { |
Lokesh Vutla | 4acda71 | 2012-05-22 00:03:27 +0000 | [diff] [blame^] | 263 | u32 volt_core, volt_mpu, volt_mm; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 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 */ |
Lokesh Vutla | 4acda71 | 2012-05-22 00:03:27 +0000 | [diff] [blame^] | 268 | if (omap_revision() != OMAP5432_ES1_0) { |
| 269 | volt_core = VDD_CORE; |
| 270 | volt_mpu = VDD_MPU; |
| 271 | volt_mm = VDD_MM; |
| 272 | } else { |
| 273 | volt_core = VDD_CORE_5432; |
| 274 | volt_mpu = VDD_MPU_5432; |
| 275 | volt_mm = VDD_MM_5432; |
| 276 | } |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 277 | |
Lokesh Vutla | 4acda71 | 2012-05-22 00:03:27 +0000 | [diff] [blame^] | 278 | do_scale_vcore(SMPS_REG_ADDR_8_CORE, volt_core); |
| 279 | do_scale_vcore(SMPS_REG_ADDR_12_MPU, volt_mpu); |
| 280 | do_scale_vcore(SMPS_REG_ADDR_45_IVA, volt_mm); |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 281 | |
Lokesh Vutla | 4acda71 | 2012-05-22 00:03:27 +0000 | [diff] [blame^] | 282 | if (omap_revision() == OMAP5432_ES1_0) { |
| 283 | /* Configure LDO SRAM "magic" bits */ |
| 284 | writel(2, &prcm->prm_sldo_core_setup); |
| 285 | writel(2, &prcm->prm_sldo_mpu_setup); |
| 286 | writel(2, &prcm->prm_sldo_mm_setup); |
| 287 | } |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | u32 get_offset_code(u32 volt_offset) |
| 291 | { |
| 292 | u32 offset_code, step = 10000; /* 10 mV represented in uV */ |
| 293 | |
| 294 | volt_offset -= PALMAS_SMPS_BASE_VOLT_UV; |
| 295 | |
| 296 | offset_code = (volt_offset + step - 1) / step; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 297 | |
SRICHARAN R | 698a1f2 | 2012-03-12 02:25:38 +0000 | [diff] [blame] | 298 | /* |
| 299 | * Offset codes 1-6 all give the base voltage in Palmas |
| 300 | * Offset code 0 switches OFF the SMPS |
| 301 | */ |
| 302 | return offset_code + 6; |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* |
| 306 | * Enable essential clock domains, modules and |
| 307 | * do some additional special settings needed |
| 308 | */ |
| 309 | void enable_basic_clocks(void) |
| 310 | { |
| 311 | u32 *const clk_domains_essential[] = { |
| 312 | &prcm->cm_l4per_clkstctrl, |
| 313 | &prcm->cm_l3init_clkstctrl, |
| 314 | &prcm->cm_memif_clkstctrl, |
| 315 | &prcm->cm_l4cfg_clkstctrl, |
| 316 | 0 |
| 317 | }; |
| 318 | |
| 319 | u32 *const clk_modules_hw_auto_essential[] = { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 320 | &prcm->cm_memif_emif_1_clkctrl, |
| 321 | &prcm->cm_memif_emif_2_clkctrl, |
| 322 | &prcm->cm_l4cfg_l4_cfg_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 323 | &prcm->cm_wkup_gpio1_clkctrl, |
| 324 | &prcm->cm_l4per_gpio2_clkctrl, |
| 325 | &prcm->cm_l4per_gpio3_clkctrl, |
| 326 | &prcm->cm_l4per_gpio4_clkctrl, |
| 327 | &prcm->cm_l4per_gpio5_clkctrl, |
| 328 | &prcm->cm_l4per_gpio6_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 329 | 0 |
| 330 | }; |
| 331 | |
| 332 | u32 *const clk_modules_explicit_en_essential[] = { |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 333 | &prcm->cm_wkup_gptimer1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 334 | &prcm->cm_l3init_hsmmc1_clkctrl, |
| 335 | &prcm->cm_l3init_hsmmc2_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 336 | &prcm->cm_l4per_gptimer2_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 337 | &prcm->cm_wkup_wdtimer2_clkctrl, |
| 338 | &prcm->cm_l4per_uart3_clkctrl, |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 339 | &prcm->cm_l4per_i2c1_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 340 | 0 |
| 341 | }; |
| 342 | |
| 343 | /* Enable optional additional functional clock for GPIO4 */ |
| 344 | setbits_le32(&prcm->cm_l4per_gpio4_clkctrl, |
| 345 | GPIO4_CLKCTRL_OPTFCLKEN_MASK); |
| 346 | |
| 347 | /* Enable 96 MHz clock for MMC1 & MMC2 */ |
| 348 | setbits_le32(&prcm->cm_l3init_hsmmc1_clkctrl, |
| 349 | HSMMC_CLKCTRL_CLKSEL_MASK); |
| 350 | setbits_le32(&prcm->cm_l3init_hsmmc2_clkctrl, |
| 351 | HSMMC_CLKCTRL_CLKSEL_MASK); |
| 352 | |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 353 | /* Set the correct clock dividers for mmc */ |
| 354 | setbits_le32(&prcm->cm_l3init_hsmmc1_clkctrl, |
| 355 | HSMMC_CLKCTRL_CLKSEL_DIV_MASK); |
| 356 | setbits_le32(&prcm->cm_l3init_hsmmc2_clkctrl, |
| 357 | HSMMC_CLKCTRL_CLKSEL_DIV_MASK); |
| 358 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 359 | /* Select 32KHz clock as the source of GPTIMER1 */ |
| 360 | setbits_le32(&prcm->cm_wkup_gptimer1_clkctrl, |
| 361 | GPTIMER1_CLKCTRL_CLKSEL_MASK); |
| 362 | |
| 363 | do_enable_clocks(clk_domains_essential, |
| 364 | clk_modules_hw_auto_essential, |
| 365 | clk_modules_explicit_en_essential, |
| 366 | 1); |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 367 | |
| 368 | /* Select 384Mhz for GPU as its the POR for ES1.0 */ |
| 369 | setbits_le32(&prcm->cm_sgx_sgx_clkctrl, |
| 370 | CLKSEL_GPU_HYD_GCLK_MASK); |
| 371 | setbits_le32(&prcm->cm_sgx_sgx_clkctrl, |
| 372 | CLKSEL_GPU_CORE_GCLK_MASK); |
| 373 | |
| 374 | /* Enable SCRM OPT clocks for PER and CORE dpll */ |
| 375 | setbits_le32(&prcm->cm_wkupaon_scrm_clkctrl, |
| 376 | OPTFCLKEN_SCRM_PER_MASK); |
| 377 | setbits_le32(&prcm->cm_wkupaon_scrm_clkctrl, |
| 378 | OPTFCLKEN_SCRM_CORE_MASK); |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 379 | } |
| 380 | |
Sricharan | 308fe92 | 2011-11-15 09:50:03 -0500 | [diff] [blame] | 381 | void enable_basic_uboot_clocks(void) |
| 382 | { |
| 383 | u32 *const clk_domains_essential[] = { |
| 384 | 0 |
| 385 | }; |
| 386 | |
| 387 | u32 *const clk_modules_hw_auto_essential[] = { |
| 388 | 0 |
| 389 | }; |
| 390 | |
| 391 | u32 *const clk_modules_explicit_en_essential[] = { |
| 392 | &prcm->cm_l4per_mcspi1_clkctrl, |
| 393 | &prcm->cm_l4per_i2c2_clkctrl, |
| 394 | &prcm->cm_l4per_i2c3_clkctrl, |
| 395 | &prcm->cm_l4per_i2c4_clkctrl, |
| 396 | 0 |
| 397 | }; |
| 398 | |
| 399 | do_enable_clocks(clk_domains_essential, |
| 400 | clk_modules_hw_auto_essential, |
| 401 | clk_modules_explicit_en_essential, |
| 402 | 1); |
| 403 | } |
| 404 | |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 405 | /* |
| 406 | * Enable non-essential clock domains, modules and |
| 407 | * do some additional special settings needed |
| 408 | */ |
| 409 | void enable_non_essential_clocks(void) |
| 410 | { |
| 411 | u32 *const clk_domains_non_essential[] = { |
| 412 | &prcm->cm_mpu_m3_clkstctrl, |
| 413 | &prcm->cm_ivahd_clkstctrl, |
| 414 | &prcm->cm_dsp_clkstctrl, |
| 415 | &prcm->cm_dss_clkstctrl, |
| 416 | &prcm->cm_sgx_clkstctrl, |
| 417 | &prcm->cm1_abe_clkstctrl, |
| 418 | &prcm->cm_c2c_clkstctrl, |
| 419 | &prcm->cm_cam_clkstctrl, |
| 420 | &prcm->cm_dss_clkstctrl, |
| 421 | &prcm->cm_sdma_clkstctrl, |
| 422 | 0 |
| 423 | }; |
| 424 | |
| 425 | u32 *const clk_modules_hw_auto_non_essential[] = { |
| 426 | &prcm->cm_mpu_m3_mpu_m3_clkctrl, |
| 427 | &prcm->cm_ivahd_ivahd_clkctrl, |
| 428 | &prcm->cm_ivahd_sl2_clkctrl, |
| 429 | &prcm->cm_dsp_dsp_clkctrl, |
| 430 | &prcm->cm_l3_2_gpmc_clkctrl, |
| 431 | &prcm->cm_l3instr_l3_3_clkctrl, |
| 432 | &prcm->cm_l3instr_l3_instr_clkctrl, |
| 433 | &prcm->cm_l3instr_intrconn_wp1_clkctrl, |
| 434 | &prcm->cm_l3init_hsi_clkctrl, |
| 435 | &prcm->cm_l3init_hsusbtll_clkctrl, |
SRICHARAN R | b1ee0bc | 2012-03-12 02:25:34 +0000 | [diff] [blame] | 436 | &prcm->cm_l4per_hdq1w_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 437 | 0 |
| 438 | }; |
| 439 | |
| 440 | u32 *const clk_modules_explicit_en_non_essential[] = { |
| 441 | &prcm->cm1_abe_aess_clkctrl, |
| 442 | &prcm->cm1_abe_pdm_clkctrl, |
| 443 | &prcm->cm1_abe_dmic_clkctrl, |
| 444 | &prcm->cm1_abe_mcasp_clkctrl, |
| 445 | &prcm->cm1_abe_mcbsp1_clkctrl, |
| 446 | &prcm->cm1_abe_mcbsp2_clkctrl, |
| 447 | &prcm->cm1_abe_mcbsp3_clkctrl, |
| 448 | &prcm->cm1_abe_slimbus_clkctrl, |
| 449 | &prcm->cm1_abe_timer5_clkctrl, |
| 450 | &prcm->cm1_abe_timer6_clkctrl, |
| 451 | &prcm->cm1_abe_timer7_clkctrl, |
| 452 | &prcm->cm1_abe_timer8_clkctrl, |
| 453 | &prcm->cm1_abe_wdt3_clkctrl, |
| 454 | &prcm->cm_l4per_gptimer9_clkctrl, |
| 455 | &prcm->cm_l4per_gptimer10_clkctrl, |
| 456 | &prcm->cm_l4per_gptimer11_clkctrl, |
| 457 | &prcm->cm_l4per_gptimer3_clkctrl, |
| 458 | &prcm->cm_l4per_gptimer4_clkctrl, |
Sricharan | 9784f1f | 2011-11-15 09:49:58 -0500 | [diff] [blame] | 459 | &prcm->cm_l4per_mcspi2_clkctrl, |
| 460 | &prcm->cm_l4per_mcspi3_clkctrl, |
| 461 | &prcm->cm_l4per_mcspi4_clkctrl, |
| 462 | &prcm->cm_l4per_mmcsd3_clkctrl, |
| 463 | &prcm->cm_l4per_mmcsd4_clkctrl, |
| 464 | &prcm->cm_l4per_mmcsd5_clkctrl, |
| 465 | &prcm->cm_l4per_uart1_clkctrl, |
| 466 | &prcm->cm_l4per_uart2_clkctrl, |
| 467 | &prcm->cm_l4per_uart4_clkctrl, |
| 468 | &prcm->cm_wkup_keyboard_clkctrl, |
| 469 | &prcm->cm_wkup_wdtimer2_clkctrl, |
| 470 | &prcm->cm_cam_iss_clkctrl, |
| 471 | &prcm->cm_cam_fdif_clkctrl, |
| 472 | &prcm->cm_dss_dss_clkctrl, |
| 473 | &prcm->cm_sgx_sgx_clkctrl, |
| 474 | &prcm->cm_l3init_hsusbhost_clkctrl, |
| 475 | &prcm->cm_l3init_fsusb_clkctrl, |
| 476 | 0 |
| 477 | }; |
| 478 | |
| 479 | /* Enable optional functional clock for ISS */ |
| 480 | setbits_le32(&prcm->cm_cam_iss_clkctrl, ISS_CLKCTRL_OPTFCLKEN_MASK); |
| 481 | |
| 482 | /* Enable all optional functional clocks of DSS */ |
| 483 | setbits_le32(&prcm->cm_dss_dss_clkctrl, DSS_CLKCTRL_OPTFCLKEN_MASK); |
| 484 | |
| 485 | do_enable_clocks(clk_domains_non_essential, |
| 486 | clk_modules_hw_auto_non_essential, |
| 487 | clk_modules_explicit_en_non_essential, |
| 488 | 0); |
| 489 | |
| 490 | /* Put camera module in no sleep mode */ |
| 491 | clrsetbits_le32(&prcm->cm_cam_clkstctrl, MODULE_CLKCTRL_MODULEMODE_MASK, |
| 492 | CD_CLKCTRL_CLKTRCTRL_NO_SLEEP << |
| 493 | MODULE_CLKCTRL_MODULEMODE_SHIFT); |
| 494 | } |