Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s5pv310/clock.c |
| 2 | * |
| 3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com/ |
| 5 | * |
| 6 | * S5PV310 - Clock support |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/err.h> |
| 15 | #include <linux/io.h> |
| 16 | |
| 17 | #include <plat/cpu-freq.h> |
| 18 | #include <plat/clock.h> |
| 19 | #include <plat/cpu.h> |
| 20 | #include <plat/pll.h> |
| 21 | #include <plat/s5p-clock.h> |
| 22 | #include <plat/clock-clksrc.h> |
| 23 | |
| 24 | #include <mach/map.h> |
| 25 | #include <mach/regs-clock.h> |
| 26 | |
| 27 | static struct clk clk_sclk_hdmi27m = { |
| 28 | .name = "sclk_hdmi27m", |
| 29 | .id = -1, |
| 30 | .rate = 27000000, |
| 31 | }; |
| 32 | |
Jongpill Lee | b99380e | 2010-08-18 22:16:45 +0900 | [diff] [blame^] | 33 | static struct clk clk_sclk_hdmiphy = { |
| 34 | .name = "sclk_hdmiphy", |
| 35 | .id = -1, |
| 36 | }; |
| 37 | |
| 38 | static struct clk clk_sclk_usbphy0 = { |
| 39 | .name = "sclk_usbphy0", |
| 40 | .id = -1, |
| 41 | .rate = 27000000, |
| 42 | }; |
| 43 | |
| 44 | static struct clk clk_sclk_usbphy1 = { |
| 45 | .name = "sclk_usbphy1", |
| 46 | .id = -1, |
| 47 | }; |
| 48 | |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 49 | static int s5pv310_clksrc_mask_peril0_ctrl(struct clk *clk, int enable) |
| 50 | { |
| 51 | return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable); |
| 52 | } |
| 53 | |
Jongpill Lee | 5a847b4 | 2010-08-27 16:50:47 +0900 | [diff] [blame] | 54 | static int s5pv310_clk_ip_peril_ctrl(struct clk *clk, int enable) |
| 55 | { |
| 56 | return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable); |
| 57 | } |
| 58 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 59 | /* Core list of CMU_CPU side */ |
| 60 | |
| 61 | static struct clksrc_clk clk_mout_apll = { |
| 62 | .clk = { |
| 63 | .name = "mout_apll", |
| 64 | .id = -1, |
| 65 | }, |
| 66 | .sources = &clk_src_apll, |
| 67 | .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 0, .size = 1 }, |
Jongpill Lee | 3ff3102 | 2010-08-18 22:20:31 +0900 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static struct clksrc_clk clk_sclk_apll = { |
| 71 | .clk = { |
| 72 | .name = "sclk_apll", |
| 73 | .id = -1, |
| 74 | .parent = &clk_mout_apll.clk, |
| 75 | }, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 76 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 24, .size = 3 }, |
| 77 | }; |
| 78 | |
| 79 | static struct clksrc_clk clk_mout_epll = { |
| 80 | .clk = { |
| 81 | .name = "mout_epll", |
| 82 | .id = -1, |
| 83 | }, |
| 84 | .sources = &clk_src_epll, |
| 85 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 4, .size = 1 }, |
| 86 | }; |
| 87 | |
| 88 | static struct clksrc_clk clk_mout_mpll = { |
| 89 | .clk = { |
| 90 | .name = "mout_mpll", |
| 91 | .id = -1, |
| 92 | }, |
| 93 | .sources = &clk_src_mpll, |
| 94 | .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 8, .size = 1 }, |
| 95 | }; |
| 96 | |
| 97 | static struct clk *clkset_moutcore_list[] = { |
Jongpill Lee | 3ff3102 | 2010-08-18 22:20:31 +0900 | [diff] [blame] | 98 | [0] = &clk_sclk_apll.clk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 99 | [1] = &clk_mout_mpll.clk, |
| 100 | }; |
| 101 | |
| 102 | static struct clksrc_sources clkset_moutcore = { |
| 103 | .sources = clkset_moutcore_list, |
| 104 | .nr_sources = ARRAY_SIZE(clkset_moutcore_list), |
| 105 | }; |
| 106 | |
| 107 | static struct clksrc_clk clk_moutcore = { |
| 108 | .clk = { |
| 109 | .name = "moutcore", |
| 110 | .id = -1, |
| 111 | }, |
| 112 | .sources = &clkset_moutcore, |
| 113 | .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 16, .size = 1 }, |
| 114 | }; |
| 115 | |
| 116 | static struct clksrc_clk clk_coreclk = { |
| 117 | .clk = { |
| 118 | .name = "core_clk", |
| 119 | .id = -1, |
| 120 | .parent = &clk_moutcore.clk, |
| 121 | }, |
| 122 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 0, .size = 3 }, |
| 123 | }; |
| 124 | |
| 125 | static struct clksrc_clk clk_armclk = { |
| 126 | .clk = { |
| 127 | .name = "armclk", |
| 128 | .id = -1, |
| 129 | .parent = &clk_coreclk.clk, |
| 130 | }, |
| 131 | }; |
| 132 | |
| 133 | static struct clksrc_clk clk_aclk_corem0 = { |
| 134 | .clk = { |
| 135 | .name = "aclk_corem0", |
| 136 | .id = -1, |
| 137 | .parent = &clk_coreclk.clk, |
| 138 | }, |
| 139 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 }, |
| 140 | }; |
| 141 | |
| 142 | static struct clksrc_clk clk_aclk_cores = { |
| 143 | .clk = { |
| 144 | .name = "aclk_cores", |
| 145 | .id = -1, |
| 146 | .parent = &clk_coreclk.clk, |
| 147 | }, |
| 148 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 }, |
| 149 | }; |
| 150 | |
| 151 | static struct clksrc_clk clk_aclk_corem1 = { |
| 152 | .clk = { |
| 153 | .name = "aclk_corem1", |
| 154 | .id = -1, |
| 155 | .parent = &clk_coreclk.clk, |
| 156 | }, |
| 157 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 8, .size = 3 }, |
| 158 | }; |
| 159 | |
| 160 | static struct clksrc_clk clk_periphclk = { |
| 161 | .clk = { |
| 162 | .name = "periphclk", |
| 163 | .id = -1, |
| 164 | .parent = &clk_coreclk.clk, |
| 165 | }, |
| 166 | .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 }, |
| 167 | }; |
| 168 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 169 | /* Core list of CMU_CORE side */ |
| 170 | |
| 171 | static struct clk *clkset_corebus_list[] = { |
| 172 | [0] = &clk_mout_mpll.clk, |
Jongpill Lee | 3ff3102 | 2010-08-18 22:20:31 +0900 | [diff] [blame] | 173 | [1] = &clk_sclk_apll.clk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | static struct clksrc_sources clkset_mout_corebus = { |
| 177 | .sources = clkset_corebus_list, |
| 178 | .nr_sources = ARRAY_SIZE(clkset_corebus_list), |
| 179 | }; |
| 180 | |
| 181 | static struct clksrc_clk clk_mout_corebus = { |
| 182 | .clk = { |
| 183 | .name = "mout_corebus", |
| 184 | .id = -1, |
| 185 | }, |
| 186 | .sources = &clkset_mout_corebus, |
| 187 | .reg_src = { .reg = S5P_CLKSRC_CORE, .shift = 4, .size = 1 }, |
| 188 | }; |
| 189 | |
| 190 | static struct clksrc_clk clk_sclk_dmc = { |
| 191 | .clk = { |
| 192 | .name = "sclk_dmc", |
| 193 | .id = -1, |
| 194 | .parent = &clk_mout_corebus.clk, |
| 195 | }, |
| 196 | .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 12, .size = 3 }, |
| 197 | }; |
| 198 | |
| 199 | static struct clksrc_clk clk_aclk_cored = { |
| 200 | .clk = { |
| 201 | .name = "aclk_cored", |
| 202 | .id = -1, |
| 203 | .parent = &clk_sclk_dmc.clk, |
| 204 | }, |
| 205 | .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 16, .size = 3 }, |
| 206 | }; |
| 207 | |
| 208 | static struct clksrc_clk clk_aclk_corep = { |
| 209 | .clk = { |
| 210 | .name = "aclk_corep", |
| 211 | .id = -1, |
| 212 | .parent = &clk_aclk_cored.clk, |
| 213 | }, |
| 214 | .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 20, .size = 3 }, |
| 215 | }; |
| 216 | |
| 217 | static struct clksrc_clk clk_aclk_acp = { |
| 218 | .clk = { |
| 219 | .name = "aclk_acp", |
| 220 | .id = -1, |
| 221 | .parent = &clk_mout_corebus.clk, |
| 222 | }, |
| 223 | .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 0, .size = 3 }, |
| 224 | }; |
| 225 | |
| 226 | static struct clksrc_clk clk_pclk_acp = { |
| 227 | .clk = { |
| 228 | .name = "pclk_acp", |
| 229 | .id = -1, |
| 230 | .parent = &clk_aclk_acp.clk, |
| 231 | }, |
| 232 | .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 4, .size = 3 }, |
| 233 | }; |
| 234 | |
| 235 | /* Core list of CMU_TOP side */ |
| 236 | |
| 237 | static struct clk *clkset_aclk_top_list[] = { |
| 238 | [0] = &clk_mout_mpll.clk, |
Jongpill Lee | 3ff3102 | 2010-08-18 22:20:31 +0900 | [diff] [blame] | 239 | [1] = &clk_sclk_apll.clk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 240 | }; |
| 241 | |
Kukjin Kim | 9e23552 | 2010-08-18 22:06:02 +0900 | [diff] [blame] | 242 | static struct clksrc_sources clkset_aclk = { |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 243 | .sources = clkset_aclk_top_list, |
| 244 | .nr_sources = ARRAY_SIZE(clkset_aclk_top_list), |
| 245 | }; |
| 246 | |
| 247 | static struct clksrc_clk clk_aclk_200 = { |
| 248 | .clk = { |
| 249 | .name = "aclk_200", |
| 250 | .id = -1, |
| 251 | }, |
Kukjin Kim | 9e23552 | 2010-08-18 22:06:02 +0900 | [diff] [blame] | 252 | .sources = &clkset_aclk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 253 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 }, |
| 254 | .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 }, |
| 255 | }; |
| 256 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 257 | static struct clksrc_clk clk_aclk_100 = { |
| 258 | .clk = { |
| 259 | .name = "aclk_100", |
| 260 | .id = -1, |
| 261 | }, |
Kukjin Kim | 9e23552 | 2010-08-18 22:06:02 +0900 | [diff] [blame] | 262 | .sources = &clkset_aclk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 263 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 }, |
| 264 | .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 }, |
| 265 | }; |
| 266 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 267 | static struct clksrc_clk clk_aclk_160 = { |
| 268 | .clk = { |
| 269 | .name = "aclk_160", |
| 270 | .id = -1, |
| 271 | }, |
Kukjin Kim | 9e23552 | 2010-08-18 22:06:02 +0900 | [diff] [blame] | 272 | .sources = &clkset_aclk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 273 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 }, |
| 274 | .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 }, |
| 275 | }; |
| 276 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 277 | static struct clksrc_clk clk_aclk_133 = { |
| 278 | .clk = { |
| 279 | .name = "aclk_133", |
| 280 | .id = -1, |
| 281 | }, |
Kukjin Kim | 9e23552 | 2010-08-18 22:06:02 +0900 | [diff] [blame] | 282 | .sources = &clkset_aclk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 283 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 }, |
| 284 | .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 }, |
| 285 | }; |
| 286 | |
| 287 | static struct clk *clkset_vpllsrc_list[] = { |
| 288 | [0] = &clk_fin_vpll, |
| 289 | [1] = &clk_sclk_hdmi27m, |
| 290 | }; |
| 291 | |
| 292 | static struct clksrc_sources clkset_vpllsrc = { |
| 293 | .sources = clkset_vpllsrc_list, |
| 294 | .nr_sources = ARRAY_SIZE(clkset_vpllsrc_list), |
| 295 | }; |
| 296 | |
| 297 | static struct clksrc_clk clk_vpllsrc = { |
| 298 | .clk = { |
| 299 | .name = "vpll_src", |
| 300 | .id = -1, |
| 301 | }, |
| 302 | .sources = &clkset_vpllsrc, |
| 303 | .reg_src = { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 }, |
| 304 | }; |
| 305 | |
| 306 | static struct clk *clkset_sclk_vpll_list[] = { |
| 307 | [0] = &clk_vpllsrc.clk, |
| 308 | [1] = &clk_fout_vpll, |
| 309 | }; |
| 310 | |
| 311 | static struct clksrc_sources clkset_sclk_vpll = { |
| 312 | .sources = clkset_sclk_vpll_list, |
| 313 | .nr_sources = ARRAY_SIZE(clkset_sclk_vpll_list), |
| 314 | }; |
| 315 | |
| 316 | static struct clksrc_clk clk_sclk_vpll = { |
| 317 | .clk = { |
| 318 | .name = "sclk_vpll", |
| 319 | .id = -1, |
| 320 | }, |
| 321 | .sources = &clkset_sclk_vpll, |
| 322 | .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 8, .size = 1 }, |
| 323 | }; |
| 324 | |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 325 | static struct clk init_clocks_disable[] = { |
| 326 | { |
| 327 | .name = "timers", |
| 328 | .id = -1, |
| 329 | .parent = &clk_aclk_100.clk, |
| 330 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 331 | .ctrlbit = (1<<24), |
| 332 | } |
| 333 | }; |
| 334 | |
| 335 | static struct clk init_clocks[] = { |
Jongpill Lee | 5a847b4 | 2010-08-27 16:50:47 +0900 | [diff] [blame] | 336 | { |
| 337 | .name = "uart", |
| 338 | .id = 0, |
| 339 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 340 | .ctrlbit = (1 << 0), |
| 341 | }, { |
| 342 | .name = "uart", |
| 343 | .id = 1, |
| 344 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 345 | .ctrlbit = (1 << 1), |
| 346 | }, { |
| 347 | .name = "uart", |
| 348 | .id = 2, |
| 349 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 350 | .ctrlbit = (1 << 2), |
| 351 | }, { |
| 352 | .name = "uart", |
| 353 | .id = 3, |
| 354 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 355 | .ctrlbit = (1 << 3), |
| 356 | }, { |
| 357 | .name = "uart", |
| 358 | .id = 4, |
| 359 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 360 | .ctrlbit = (1 << 4), |
| 361 | }, { |
| 362 | .name = "uart", |
| 363 | .id = 5, |
| 364 | .enable = s5pv310_clk_ip_peril_ctrl, |
| 365 | .ctrlbit = (1 << 5), |
| 366 | } |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 367 | }; |
| 368 | |
| 369 | static struct clk *clkset_group_list[] = { |
| 370 | [0] = &clk_ext_xtal_mux, |
| 371 | [1] = &clk_xusbxti, |
| 372 | [2] = &clk_sclk_hdmi27m, |
Jongpill Lee | b99380e | 2010-08-18 22:16:45 +0900 | [diff] [blame^] | 373 | [3] = &clk_sclk_usbphy0, |
| 374 | [4] = &clk_sclk_usbphy1, |
| 375 | [5] = &clk_sclk_hdmiphy, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 376 | [6] = &clk_mout_mpll.clk, |
| 377 | [7] = &clk_mout_epll.clk, |
| 378 | [8] = &clk_sclk_vpll.clk, |
| 379 | }; |
| 380 | |
| 381 | static struct clksrc_sources clkset_group = { |
| 382 | .sources = clkset_group_list, |
| 383 | .nr_sources = ARRAY_SIZE(clkset_group_list), |
| 384 | }; |
| 385 | |
| 386 | static struct clksrc_clk clksrcs[] = { |
| 387 | { |
| 388 | .clk = { |
| 389 | .name = "uclk1", |
| 390 | .id = 0, |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 391 | .enable = s5pv310_clksrc_mask_peril0_ctrl, |
Jongpill Lee | 5a847b4 | 2010-08-27 16:50:47 +0900 | [diff] [blame] | 392 | .ctrlbit = (1 << 0), |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 393 | }, |
| 394 | .sources = &clkset_group, |
| 395 | .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 0, .size = 4 }, |
| 396 | .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 0, .size = 4 }, |
| 397 | }, { |
| 398 | .clk = { |
| 399 | .name = "uclk1", |
| 400 | .id = 1, |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 401 | .enable = s5pv310_clksrc_mask_peril0_ctrl, |
| 402 | .ctrlbit = (1 << 4), |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 403 | }, |
| 404 | .sources = &clkset_group, |
| 405 | .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 4, .size = 4 }, |
| 406 | .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 4, .size = 4 }, |
| 407 | }, { |
| 408 | .clk = { |
| 409 | .name = "uclk1", |
| 410 | .id = 2, |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 411 | .enable = s5pv310_clksrc_mask_peril0_ctrl, |
| 412 | .ctrlbit = (1 << 8), |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 413 | }, |
| 414 | .sources = &clkset_group, |
| 415 | .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 8, .size = 4 }, |
| 416 | .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 8, .size = 4 }, |
| 417 | }, { |
| 418 | .clk = { |
| 419 | .name = "uclk1", |
| 420 | .id = 3, |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 421 | .enable = s5pv310_clksrc_mask_peril0_ctrl, |
| 422 | .ctrlbit = (1 << 12), |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 423 | }, |
| 424 | .sources = &clkset_group, |
| 425 | .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 12, .size = 4 }, |
| 426 | .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 12, .size = 4 }, |
| 427 | }, { |
| 428 | .clk = { |
| 429 | .name = "sclk_pwm", |
| 430 | .id = -1, |
Jongpill Lee | 3297c2e | 2010-08-27 17:53:26 +0900 | [diff] [blame] | 431 | .enable = s5pv310_clksrc_mask_peril0_ctrl, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 432 | .ctrlbit = (1 << 24), |
| 433 | }, |
| 434 | .sources = &clkset_group, |
| 435 | .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 }, |
| 436 | .reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 }, |
| 437 | }, |
| 438 | }; |
| 439 | |
| 440 | /* Clock initialization code */ |
| 441 | static struct clksrc_clk *sysclks[] = { |
| 442 | &clk_mout_apll, |
Jongpill Lee | 3ff3102 | 2010-08-18 22:20:31 +0900 | [diff] [blame] | 443 | &clk_sclk_apll, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 444 | &clk_mout_epll, |
| 445 | &clk_mout_mpll, |
| 446 | &clk_moutcore, |
| 447 | &clk_coreclk, |
| 448 | &clk_armclk, |
| 449 | &clk_aclk_corem0, |
| 450 | &clk_aclk_cores, |
| 451 | &clk_aclk_corem1, |
| 452 | &clk_periphclk, |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 453 | &clk_mout_corebus, |
| 454 | &clk_sclk_dmc, |
| 455 | &clk_aclk_cored, |
| 456 | &clk_aclk_corep, |
| 457 | &clk_aclk_acp, |
| 458 | &clk_pclk_acp, |
| 459 | &clk_vpllsrc, |
| 460 | &clk_sclk_vpll, |
| 461 | &clk_aclk_200, |
| 462 | &clk_aclk_100, |
| 463 | &clk_aclk_160, |
| 464 | &clk_aclk_133, |
| 465 | }; |
| 466 | |
| 467 | void __init_or_cpufreq s5pv310_setup_clocks(void) |
| 468 | { |
| 469 | struct clk *xtal_clk; |
| 470 | unsigned long apll; |
| 471 | unsigned long mpll; |
| 472 | unsigned long epll; |
| 473 | unsigned long vpll; |
| 474 | unsigned long vpllsrc; |
| 475 | unsigned long xtal; |
| 476 | unsigned long armclk; |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 477 | unsigned long sclk_dmc; |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 478 | unsigned int ptr; |
| 479 | |
| 480 | printk(KERN_DEBUG "%s: registering clocks\n", __func__); |
| 481 | |
| 482 | xtal_clk = clk_get(NULL, "xtal"); |
| 483 | BUG_ON(IS_ERR(xtal_clk)); |
| 484 | |
| 485 | xtal = clk_get_rate(xtal_clk); |
| 486 | clk_put(xtal_clk); |
| 487 | |
| 488 | printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal); |
| 489 | |
| 490 | apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON0), pll_4508); |
| 491 | mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON0), pll_4508); |
| 492 | epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON0), |
Jongpill Lee | 4d235f79 | 2010-08-18 22:13:49 +0900 | [diff] [blame] | 493 | __raw_readl(S5P_EPLL_CON1), pll_4600); |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 494 | |
| 495 | vpllsrc = clk_get_rate(&clk_vpllsrc.clk); |
| 496 | vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(S5P_VPLL_CON0), |
Jongpill Lee | 4d235f79 | 2010-08-18 22:13:49 +0900 | [diff] [blame] | 497 | __raw_readl(S5P_VPLL_CON1), pll_4650); |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 498 | |
| 499 | clk_fout_apll.rate = apll; |
| 500 | clk_fout_mpll.rate = mpll; |
| 501 | clk_fout_epll.rate = epll; |
| 502 | clk_fout_vpll.rate = vpll; |
| 503 | |
| 504 | printk(KERN_INFO "S5PV310: PLL settings, A=%ld, M=%ld, E=%ld V=%ld", |
| 505 | apll, mpll, epll, vpll); |
| 506 | |
| 507 | armclk = clk_get_rate(&clk_armclk.clk); |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 508 | sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk); |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 509 | |
Kukjin Kim | a6aa7a5 | 2010-08-18 22:03:19 +0900 | [diff] [blame] | 510 | printk(KERN_INFO "S5PV310: ARMCLK=%ld, DMC=%ld\n", armclk, sclk_dmc); |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 511 | |
| 512 | clk_f.rate = armclk; |
| 513 | clk_h.rate = sclk_dmc; |
Changhwan Youn | c8bef14 | 2010-07-27 17:52:39 +0900 | [diff] [blame] | 514 | |
| 515 | for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) |
| 516 | s3c_set_clksrc(&clksrcs[ptr], true); |
| 517 | } |
| 518 | |
| 519 | static struct clk *clks[] __initdata = { |
| 520 | /* Nothing here yet */ |
| 521 | }; |
| 522 | |
| 523 | void __init s5pv310_register_clocks(void) |
| 524 | { |
| 525 | struct clk *clkp; |
| 526 | int ret; |
| 527 | int ptr; |
| 528 | |
| 529 | ret = s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); |
| 530 | if (ret > 0) |
| 531 | printk(KERN_ERR "Failed to register %u clocks\n", ret); |
| 532 | |
| 533 | for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++) |
| 534 | s3c_register_clksrc(sysclks[ptr], 1); |
| 535 | |
| 536 | s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs)); |
| 537 | s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks)); |
| 538 | |
| 539 | clkp = init_clocks_disable; |
| 540 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) { |
| 541 | ret = s3c24xx_register_clock(clkp); |
| 542 | if (ret < 0) { |
| 543 | printk(KERN_ERR "Failed to register clock %s (%d)\n", |
| 544 | clkp->name, ret); |
| 545 | } |
| 546 | (clkp->enable)(clkp, 0); |
| 547 | } |
| 548 | |
| 549 | s3c_pwmclk_init(); |
| 550 | } |