Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Samsung Electronics |
| 3 | * Minkyu Kang <mk7.kang@samsung.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/clock.h> |
| 11 | #include <asm/arch/clk.h> |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 12 | #include <asm/arch/periph.h> |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 13 | |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 14 | #define PLL_DIV_1024 1024 |
| 15 | #define PLL_DIV_65535 65535 |
| 16 | #define PLL_DIV_65536 65536 |
| 17 | |
Padmavathi Venna | 37feb7b | 2013-03-28 04:32:21 +0000 | [diff] [blame] | 18 | /* * |
| 19 | * This structure is to store the src bit, div bit and prediv bit |
| 20 | * positions of the peripheral clocks of the src and div registers |
| 21 | */ |
| 22 | struct clk_bit_info { |
| 23 | int8_t src_bit; |
| 24 | int8_t div_bit; |
| 25 | int8_t prediv_bit; |
| 26 | }; |
| 27 | |
| 28 | /* src_bit div_bit prediv_bit */ |
Minkyu Kang | 30e472f | 2014-01-29 17:03:58 +0900 | [diff] [blame] | 29 | static struct clk_bit_info clk_bit_info[] = { |
Padmavathi Venna | 37feb7b | 2013-03-28 04:32:21 +0000 | [diff] [blame] | 30 | {0, 0, -1}, |
| 31 | {4, 4, -1}, |
| 32 | {8, 8, -1}, |
| 33 | {12, 12, -1}, |
| 34 | {0, 0, 8}, |
| 35 | {4, 16, 24}, |
| 36 | {8, 0, 8}, |
| 37 | {12, 16, 24}, |
| 38 | {-1, -1, -1}, |
| 39 | {16, 0, 8}, |
| 40 | {20, 16, 24}, |
| 41 | {24, 0, 8}, |
| 42 | {0, 0, 4}, |
| 43 | {4, 12, 16}, |
| 44 | {-1, -1, -1}, |
| 45 | {-1, -1, -1}, |
| 46 | {-1, 24, 0}, |
| 47 | {-1, 24, 0}, |
| 48 | {-1, 24, 0}, |
| 49 | {-1, 24, 0}, |
| 50 | {-1, 24, 0}, |
| 51 | {-1, 24, 0}, |
| 52 | {-1, 24, 0}, |
| 53 | {-1, 24, 0}, |
| 54 | {24, 0, -1}, |
| 55 | {24, 0, -1}, |
| 56 | {24, 0, -1}, |
| 57 | {24, 0, -1}, |
| 58 | {24, 0, -1}, |
| 59 | }; |
| 60 | |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 61 | /* Epll Clock division values to achive different frequency output */ |
| 62 | static struct set_epll_con_val exynos5_epll_div[] = { |
| 63 | { 192000000, 0, 48, 3, 1, 0 }, |
| 64 | { 180000000, 0, 45, 3, 1, 0 }, |
| 65 | { 73728000, 1, 73, 3, 3, 47710 }, |
| 66 | { 67737600, 1, 90, 4, 3, 20762 }, |
| 67 | { 49152000, 0, 49, 3, 3, 9961 }, |
| 68 | { 45158400, 0, 45, 3, 3, 10381 }, |
| 69 | { 180633600, 0, 45, 3, 1, 10381 } |
| 70 | }; |
| 71 | |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 72 | /* exynos: return pll clock frequency */ |
| 73 | static int exynos_get_pll_clk(int pllreg, unsigned int r, unsigned int k) |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 74 | { |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 75 | unsigned long m, p, s = 0, mask, fout; |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 76 | unsigned int div; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 77 | unsigned int freq; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 78 | /* |
| 79 | * APLL_CON: MIDV [25:16] |
| 80 | * MPLL_CON: MIDV [25:16] |
| 81 | * EPLL_CON: MIDV [24:16] |
| 82 | * VPLL_CON: MIDV [24:16] |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 83 | * BPLL_CON: MIDV [25:16]: Exynos5 |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 84 | */ |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 85 | if (pllreg == APLL || pllreg == MPLL || pllreg == BPLL) |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 86 | mask = 0x3ff; |
| 87 | else |
| 88 | mask = 0x1ff; |
| 89 | |
| 90 | m = (r >> 16) & mask; |
| 91 | |
| 92 | /* PDIV [13:8] */ |
| 93 | p = (r >> 8) & 0x3f; |
| 94 | /* SDIV [2:0] */ |
| 95 | s = r & 0x7; |
| 96 | |
Chander Kashyap | 6a870e1 | 2012-02-05 23:01:45 +0000 | [diff] [blame] | 97 | freq = CONFIG_SYS_CLK_FREQ; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 98 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 99 | if (pllreg == EPLL || pllreg == RPLL) { |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 100 | k = k & 0xffff; |
| 101 | /* FOUT = (MDIV + K / 65536) * FIN / (PDIV * 2^SDIV) */ |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 102 | fout = (m + k / PLL_DIV_65536) * (freq / (p * (1 << s))); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 103 | } else if (pllreg == VPLL) { |
| 104 | k = k & 0xfff; |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * Exynos4210 |
| 108 | * FOUT = (MDIV + K / 1024) * FIN / (PDIV * 2^SDIV) |
| 109 | * |
| 110 | * Exynos4412 |
| 111 | * FOUT = (MDIV + K / 65535) * FIN / (PDIV * 2^SDIV) |
| 112 | * |
| 113 | * Exynos5250 |
| 114 | * FOUT = (MDIV + K / 65536) * FIN / (PDIV * 2^SDIV) |
| 115 | */ |
| 116 | if (proid_is_exynos4210()) |
| 117 | div = PLL_DIV_1024; |
| 118 | else if (proid_is_exynos4412()) |
| 119 | div = PLL_DIV_65535; |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 120 | else if (proid_is_exynos5250() || proid_is_exynos5420()) |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 121 | div = PLL_DIV_65536; |
| 122 | else |
| 123 | return 0; |
| 124 | |
| 125 | fout = (m + k / div) * (freq / (p * (1 << s))); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 126 | } else { |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 127 | /* |
Łukasz Majewski | 326c459 | 2013-07-12 19:08:25 +0200 | [diff] [blame] | 128 | * Exynos4412 / Exynos5250 |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 129 | * FOUT = MDIV * FIN / (PDIV * 2^SDIV) |
| 130 | * |
Łukasz Majewski | 326c459 | 2013-07-12 19:08:25 +0200 | [diff] [blame] | 131 | * Exynos4210 |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 132 | * FOUT = MDIV * FIN / (PDIV * 2^(SDIV-1)) |
| 133 | */ |
| 134 | if (proid_is_exynos4210()) |
Minkyu Kang | 368588e | 2013-07-05 19:08:33 +0900 | [diff] [blame] | 135 | fout = m * (freq / (p * (1 << (s - 1)))); |
Łukasz Majewski | 326c459 | 2013-07-12 19:08:25 +0200 | [diff] [blame] | 136 | else |
| 137 | fout = m * (freq / (p * (1 << s))); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 138 | } |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 139 | return fout; |
| 140 | } |
| 141 | |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 142 | /* exynos4: return pll clock frequency */ |
| 143 | static unsigned long exynos4_get_pll_clk(int pllreg) |
| 144 | { |
| 145 | struct exynos4_clock *clk = |
| 146 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 147 | unsigned long r, k = 0; |
| 148 | |
| 149 | switch (pllreg) { |
| 150 | case APLL: |
| 151 | r = readl(&clk->apll_con0); |
| 152 | break; |
| 153 | case MPLL: |
| 154 | r = readl(&clk->mpll_con0); |
| 155 | break; |
| 156 | case EPLL: |
| 157 | r = readl(&clk->epll_con0); |
| 158 | k = readl(&clk->epll_con1); |
| 159 | break; |
| 160 | case VPLL: |
| 161 | r = readl(&clk->vpll_con0); |
| 162 | k = readl(&clk->vpll_con1); |
| 163 | break; |
| 164 | default: |
| 165 | printf("Unsupported PLL (%d)\n", pllreg); |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | return exynos_get_pll_clk(pllreg, r, k); |
| 170 | } |
| 171 | |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 172 | /* exynos4x12: return pll clock frequency */ |
| 173 | static unsigned long exynos4x12_get_pll_clk(int pllreg) |
| 174 | { |
| 175 | struct exynos4x12_clock *clk = |
| 176 | (struct exynos4x12_clock *)samsung_get_base_clock(); |
| 177 | unsigned long r, k = 0; |
| 178 | |
| 179 | switch (pllreg) { |
| 180 | case APLL: |
| 181 | r = readl(&clk->apll_con0); |
| 182 | break; |
| 183 | case MPLL: |
| 184 | r = readl(&clk->mpll_con0); |
| 185 | break; |
| 186 | case EPLL: |
| 187 | r = readl(&clk->epll_con0); |
| 188 | k = readl(&clk->epll_con1); |
| 189 | break; |
| 190 | case VPLL: |
| 191 | r = readl(&clk->vpll_con0); |
| 192 | k = readl(&clk->vpll_con1); |
| 193 | break; |
| 194 | default: |
| 195 | printf("Unsupported PLL (%d)\n", pllreg); |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | return exynos_get_pll_clk(pllreg, r, k); |
| 200 | } |
| 201 | |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 202 | /* exynos5: return pll clock frequency */ |
| 203 | static unsigned long exynos5_get_pll_clk(int pllreg) |
| 204 | { |
| 205 | struct exynos5_clock *clk = |
| 206 | (struct exynos5_clock *)samsung_get_base_clock(); |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 207 | unsigned long r, k = 0, fout; |
| 208 | unsigned int pll_div2_sel, fout_sel; |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 209 | |
| 210 | switch (pllreg) { |
| 211 | case APLL: |
| 212 | r = readl(&clk->apll_con0); |
| 213 | break; |
| 214 | case MPLL: |
| 215 | r = readl(&clk->mpll_con0); |
| 216 | break; |
| 217 | case EPLL: |
| 218 | r = readl(&clk->epll_con0); |
| 219 | k = readl(&clk->epll_con1); |
| 220 | break; |
| 221 | case VPLL: |
| 222 | r = readl(&clk->vpll_con0); |
| 223 | k = readl(&clk->vpll_con1); |
| 224 | break; |
Rajeshwari Shinde | 8411286 | 2012-07-03 20:02:58 +0000 | [diff] [blame] | 225 | case BPLL: |
| 226 | r = readl(&clk->bpll_con0); |
| 227 | break; |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 228 | default: |
| 229 | printf("Unsupported PLL (%d)\n", pllreg); |
| 230 | return 0; |
| 231 | } |
| 232 | |
Minkyu Kang | 1a055aa | 2012-10-15 01:58:00 +0000 | [diff] [blame] | 233 | fout = exynos_get_pll_clk(pllreg, r, k); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 234 | |
Rajeshwari Shinde | 8411286 | 2012-07-03 20:02:58 +0000 | [diff] [blame] | 235 | /* According to the user manual, in EVT1 MPLL and BPLL always gives |
Rajeshwari Shinde | 7b9afce | 2012-07-03 20:02:57 +0000 | [diff] [blame] | 236 | * 1.6GHz clock, so divide by 2 to get 800MHz MPLL clock.*/ |
Rajeshwari Shinde | 8411286 | 2012-07-03 20:02:58 +0000 | [diff] [blame] | 237 | if (pllreg == MPLL || pllreg == BPLL) { |
Rajeshwari Shinde | 7b9afce | 2012-07-03 20:02:57 +0000 | [diff] [blame] | 238 | pll_div2_sel = readl(&clk->pll_div2_sel); |
Rajeshwari Shinde | 8411286 | 2012-07-03 20:02:58 +0000 | [diff] [blame] | 239 | |
| 240 | switch (pllreg) { |
| 241 | case MPLL: |
| 242 | fout_sel = (pll_div2_sel >> MPLL_FOUT_SEL_SHIFT) |
| 243 | & MPLL_FOUT_SEL_MASK; |
| 244 | break; |
| 245 | case BPLL: |
| 246 | fout_sel = (pll_div2_sel >> BPLL_FOUT_SEL_SHIFT) |
| 247 | & BPLL_FOUT_SEL_MASK; |
| 248 | break; |
Jaehoon Chung | 0fc779c | 2012-07-09 21:20:34 +0000 | [diff] [blame] | 249 | default: |
| 250 | fout_sel = -1; |
| 251 | break; |
Rajeshwari Shinde | 8411286 | 2012-07-03 20:02:58 +0000 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | if (fout_sel == 0) |
Rajeshwari Shinde | 7b9afce | 2012-07-03 20:02:57 +0000 | [diff] [blame] | 255 | fout /= 2; |
| 256 | } |
| 257 | |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 258 | return fout; |
| 259 | } |
| 260 | |
Padmavathi Venna | 37feb7b | 2013-03-28 04:32:21 +0000 | [diff] [blame] | 261 | static unsigned long exynos5_get_periph_rate(int peripheral) |
| 262 | { |
| 263 | struct clk_bit_info *bit_info = &clk_bit_info[peripheral]; |
| 264 | unsigned long sclk, sub_clk; |
| 265 | unsigned int src, div, sub_div; |
| 266 | struct exynos5_clock *clk = |
| 267 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 268 | |
| 269 | switch (peripheral) { |
| 270 | case PERIPH_ID_UART0: |
| 271 | case PERIPH_ID_UART1: |
| 272 | case PERIPH_ID_UART2: |
| 273 | case PERIPH_ID_UART3: |
| 274 | src = readl(&clk->src_peric0); |
| 275 | div = readl(&clk->div_peric0); |
| 276 | break; |
| 277 | case PERIPH_ID_PWM0: |
| 278 | case PERIPH_ID_PWM1: |
| 279 | case PERIPH_ID_PWM2: |
| 280 | case PERIPH_ID_PWM3: |
| 281 | case PERIPH_ID_PWM4: |
| 282 | src = readl(&clk->src_peric0); |
| 283 | div = readl(&clk->div_peric3); |
| 284 | break; |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 285 | case PERIPH_ID_I2S0: |
| 286 | src = readl(&clk->src_mau); |
| 287 | div = readl(&clk->div_mau); |
Padmavathi Venna | 37feb7b | 2013-03-28 04:32:21 +0000 | [diff] [blame] | 288 | case PERIPH_ID_SPI0: |
| 289 | case PERIPH_ID_SPI1: |
| 290 | src = readl(&clk->src_peric1); |
| 291 | div = readl(&clk->div_peric1); |
| 292 | break; |
| 293 | case PERIPH_ID_SPI2: |
| 294 | src = readl(&clk->src_peric1); |
| 295 | div = readl(&clk->div_peric2); |
| 296 | break; |
| 297 | case PERIPH_ID_SPI3: |
| 298 | case PERIPH_ID_SPI4: |
| 299 | src = readl(&clk->sclk_src_isp); |
| 300 | div = readl(&clk->sclk_div_isp); |
| 301 | break; |
| 302 | case PERIPH_ID_SDMMC0: |
| 303 | case PERIPH_ID_SDMMC1: |
| 304 | case PERIPH_ID_SDMMC2: |
| 305 | case PERIPH_ID_SDMMC3: |
| 306 | src = readl(&clk->src_fsys); |
| 307 | div = readl(&clk->div_fsys1); |
| 308 | break; |
| 309 | case PERIPH_ID_I2C0: |
| 310 | case PERIPH_ID_I2C1: |
| 311 | case PERIPH_ID_I2C2: |
| 312 | case PERIPH_ID_I2C3: |
| 313 | case PERIPH_ID_I2C4: |
| 314 | case PERIPH_ID_I2C5: |
| 315 | case PERIPH_ID_I2C6: |
| 316 | case PERIPH_ID_I2C7: |
| 317 | sclk = exynos5_get_pll_clk(MPLL); |
| 318 | sub_div = ((readl(&clk->div_top1) >> bit_info->div_bit) |
| 319 | & 0x7) + 1; |
| 320 | div = ((readl(&clk->div_top0) >> bit_info->prediv_bit) |
| 321 | & 0x7) + 1; |
| 322 | return (sclk / sub_div) / div; |
| 323 | default: |
| 324 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 325 | return -1; |
| 326 | }; |
| 327 | |
| 328 | src = (src >> bit_info->src_bit) & 0xf; |
| 329 | |
| 330 | switch (src) { |
| 331 | case EXYNOS_SRC_MPLL: |
| 332 | sclk = exynos5_get_pll_clk(MPLL); |
| 333 | break; |
| 334 | case EXYNOS_SRC_EPLL: |
| 335 | sclk = exynos5_get_pll_clk(EPLL); |
| 336 | break; |
| 337 | case EXYNOS_SRC_VPLL: |
| 338 | sclk = exynos5_get_pll_clk(VPLL); |
| 339 | break; |
| 340 | default: |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | /* Ratio clock division for this peripheral */ |
| 345 | sub_div = (div >> bit_info->div_bit) & 0xf; |
| 346 | sub_clk = sclk / (sub_div + 1); |
| 347 | |
| 348 | /* Pre-ratio clock division for SDMMC0 and 2 */ |
| 349 | if (peripheral == PERIPH_ID_SDMMC0 || peripheral == PERIPH_ID_SDMMC2) { |
| 350 | div = (div >> bit_info->prediv_bit) & 0xff; |
| 351 | return sub_clk / (div + 1); |
| 352 | } |
| 353 | |
| 354 | return sub_clk; |
| 355 | } |
| 356 | |
| 357 | unsigned long clock_get_periph_rate(int peripheral) |
| 358 | { |
| 359 | if (cpu_is_exynos5()) |
| 360 | return exynos5_get_periph_rate(peripheral); |
| 361 | else |
| 362 | return 0; |
| 363 | } |
| 364 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 365 | /* exynos5420: return pll clock frequency */ |
| 366 | static unsigned long exynos5420_get_pll_clk(int pllreg) |
| 367 | { |
| 368 | struct exynos5420_clock *clk = |
| 369 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 370 | unsigned long r, k = 0; |
| 371 | |
| 372 | switch (pllreg) { |
| 373 | case APLL: |
| 374 | r = readl(&clk->apll_con0); |
| 375 | break; |
| 376 | case MPLL: |
| 377 | r = readl(&clk->mpll_con0); |
| 378 | break; |
| 379 | case EPLL: |
| 380 | r = readl(&clk->epll_con0); |
| 381 | k = readl(&clk->epll_con1); |
| 382 | break; |
| 383 | case VPLL: |
| 384 | r = readl(&clk->vpll_con0); |
| 385 | k = readl(&clk->vpll_con1); |
| 386 | break; |
| 387 | case BPLL: |
| 388 | r = readl(&clk->bpll_con0); |
| 389 | break; |
| 390 | case RPLL: |
| 391 | r = readl(&clk->rpll_con0); |
| 392 | k = readl(&clk->rpll_con1); |
| 393 | break; |
| 394 | default: |
| 395 | printf("Unsupported PLL (%d)\n", pllreg); |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | return exynos_get_pll_clk(pllreg, r, k); |
| 400 | } |
| 401 | |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 402 | /* exynos4: return ARM clock frequency */ |
| 403 | static unsigned long exynos4_get_arm_clk(void) |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 404 | { |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 405 | struct exynos4_clock *clk = |
| 406 | (struct exynos4_clock *)samsung_get_base_clock(); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 407 | unsigned long div; |
Chander Kashyap | 3c7721f | 2011-12-18 22:56:44 +0000 | [diff] [blame] | 408 | unsigned long armclk; |
| 409 | unsigned int core_ratio; |
| 410 | unsigned int core2_ratio; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 411 | |
| 412 | div = readl(&clk->div_cpu0); |
| 413 | |
Chander Kashyap | 3c7721f | 2011-12-18 22:56:44 +0000 | [diff] [blame] | 414 | /* CORE_RATIO: [2:0], CORE2_RATIO: [30:28] */ |
| 415 | core_ratio = (div >> 0) & 0x7; |
| 416 | core2_ratio = (div >> 28) & 0x7; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 417 | |
Chander Kashyap | 3c7721f | 2011-12-18 22:56:44 +0000 | [diff] [blame] | 418 | armclk = get_pll_clk(APLL) / (core_ratio + 1); |
| 419 | armclk /= (core2_ratio + 1); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 420 | |
Chander Kashyap | 3c7721f | 2011-12-18 22:56:44 +0000 | [diff] [blame] | 421 | return armclk; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 422 | } |
| 423 | |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 424 | /* exynos4x12: return ARM clock frequency */ |
| 425 | static unsigned long exynos4x12_get_arm_clk(void) |
| 426 | { |
| 427 | struct exynos4x12_clock *clk = |
| 428 | (struct exynos4x12_clock *)samsung_get_base_clock(); |
| 429 | unsigned long div; |
| 430 | unsigned long armclk; |
| 431 | unsigned int core_ratio; |
| 432 | unsigned int core2_ratio; |
| 433 | |
| 434 | div = readl(&clk->div_cpu0); |
| 435 | |
| 436 | /* CORE_RATIO: [2:0], CORE2_RATIO: [30:28] */ |
| 437 | core_ratio = (div >> 0) & 0x7; |
| 438 | core2_ratio = (div >> 28) & 0x7; |
| 439 | |
| 440 | armclk = get_pll_clk(APLL) / (core_ratio + 1); |
| 441 | armclk /= (core2_ratio + 1); |
| 442 | |
| 443 | return armclk; |
| 444 | } |
| 445 | |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 446 | /* exynos5: return ARM clock frequency */ |
| 447 | static unsigned long exynos5_get_arm_clk(void) |
| 448 | { |
| 449 | struct exynos5_clock *clk = |
| 450 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 451 | unsigned long div; |
| 452 | unsigned long armclk; |
| 453 | unsigned int arm_ratio; |
| 454 | unsigned int arm2_ratio; |
| 455 | |
| 456 | div = readl(&clk->div_cpu0); |
| 457 | |
| 458 | /* ARM_RATIO: [2:0], ARM2_RATIO: [30:28] */ |
| 459 | arm_ratio = (div >> 0) & 0x7; |
| 460 | arm2_ratio = (div >> 28) & 0x7; |
| 461 | |
| 462 | armclk = get_pll_clk(APLL) / (arm_ratio + 1); |
| 463 | armclk /= (arm2_ratio + 1); |
| 464 | |
| 465 | return armclk; |
| 466 | } |
| 467 | |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 468 | /* exynos4: return pwm clock frequency */ |
| 469 | static unsigned long exynos4_get_pwm_clk(void) |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 470 | { |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 471 | struct exynos4_clock *clk = |
| 472 | (struct exynos4_clock *)samsung_get_base_clock(); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 473 | unsigned long pclk, sclk; |
| 474 | unsigned int sel; |
| 475 | unsigned int ratio; |
| 476 | |
Minkyu Kang | 69b2824 | 2011-05-18 16:57:55 +0900 | [diff] [blame] | 477 | if (s5p_get_cpu_rev() == 0) { |
| 478 | /* |
| 479 | * CLK_SRC_PERIL0 |
| 480 | * PWM_SEL [27:24] |
| 481 | */ |
| 482 | sel = readl(&clk->src_peril0); |
| 483 | sel = (sel >> 24) & 0xf; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 484 | |
Minkyu Kang | 69b2824 | 2011-05-18 16:57:55 +0900 | [diff] [blame] | 485 | if (sel == 0x6) |
| 486 | sclk = get_pll_clk(MPLL); |
| 487 | else if (sel == 0x7) |
| 488 | sclk = get_pll_clk(EPLL); |
| 489 | else if (sel == 0x8) |
| 490 | sclk = get_pll_clk(VPLL); |
| 491 | else |
| 492 | return 0; |
| 493 | |
| 494 | /* |
| 495 | * CLK_DIV_PERIL3 |
| 496 | * PWM_RATIO [3:0] |
| 497 | */ |
| 498 | ratio = readl(&clk->div_peril3); |
| 499 | ratio = ratio & 0xf; |
| 500 | } else if (s5p_get_cpu_rev() == 1) { |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 501 | sclk = get_pll_clk(MPLL); |
Minkyu Kang | 69b2824 | 2011-05-18 16:57:55 +0900 | [diff] [blame] | 502 | ratio = 8; |
| 503 | } else |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 504 | return 0; |
| 505 | |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 506 | pclk = sclk / (ratio + 1); |
| 507 | |
| 508 | return pclk; |
| 509 | } |
| 510 | |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 511 | /* exynos4x12: return pwm clock frequency */ |
| 512 | static unsigned long exynos4x12_get_pwm_clk(void) |
| 513 | { |
| 514 | unsigned long pclk, sclk; |
| 515 | unsigned int ratio; |
| 516 | |
| 517 | sclk = get_pll_clk(MPLL); |
| 518 | ratio = 8; |
| 519 | |
| 520 | pclk = sclk / (ratio + 1); |
| 521 | |
| 522 | return pclk; |
| 523 | } |
| 524 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 525 | /* exynos5420: return pwm clock frequency */ |
| 526 | static unsigned long exynos5420_get_pwm_clk(void) |
| 527 | { |
| 528 | struct exynos5420_clock *clk = |
| 529 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 530 | unsigned long pclk, sclk; |
| 531 | unsigned int ratio; |
| 532 | |
| 533 | /* |
| 534 | * CLK_DIV_PERIC0 |
| 535 | * PWM_RATIO [31:28] |
| 536 | */ |
| 537 | ratio = readl(&clk->div_peric0); |
| 538 | ratio = (ratio >> 28) & 0xf; |
| 539 | sclk = get_pll_clk(MPLL); |
| 540 | |
| 541 | pclk = sclk / (ratio + 1); |
| 542 | |
| 543 | return pclk; |
| 544 | } |
| 545 | |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 546 | /* exynos4: return uart clock frequency */ |
| 547 | static unsigned long exynos4_get_uart_clk(int dev_index) |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 548 | { |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 549 | struct exynos4_clock *clk = |
| 550 | (struct exynos4_clock *)samsung_get_base_clock(); |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 551 | unsigned long uclk, sclk; |
| 552 | unsigned int sel; |
| 553 | unsigned int ratio; |
| 554 | |
| 555 | /* |
| 556 | * CLK_SRC_PERIL0 |
| 557 | * UART0_SEL [3:0] |
| 558 | * UART1_SEL [7:4] |
| 559 | * UART2_SEL [8:11] |
| 560 | * UART3_SEL [12:15] |
| 561 | * UART4_SEL [16:19] |
| 562 | * UART5_SEL [23:20] |
| 563 | */ |
| 564 | sel = readl(&clk->src_peril0); |
| 565 | sel = (sel >> (dev_index << 2)) & 0xf; |
| 566 | |
| 567 | if (sel == 0x6) |
| 568 | sclk = get_pll_clk(MPLL); |
| 569 | else if (sel == 0x7) |
| 570 | sclk = get_pll_clk(EPLL); |
| 571 | else if (sel == 0x8) |
| 572 | sclk = get_pll_clk(VPLL); |
| 573 | else |
| 574 | return 0; |
| 575 | |
| 576 | /* |
| 577 | * CLK_DIV_PERIL0 |
| 578 | * UART0_RATIO [3:0] |
| 579 | * UART1_RATIO [7:4] |
| 580 | * UART2_RATIO [8:11] |
| 581 | * UART3_RATIO [12:15] |
| 582 | * UART4_RATIO [16:19] |
| 583 | * UART5_RATIO [23:20] |
| 584 | */ |
| 585 | ratio = readl(&clk->div_peril0); |
| 586 | ratio = (ratio >> (dev_index << 2)) & 0xf; |
| 587 | |
| 588 | uclk = sclk / (ratio + 1); |
| 589 | |
| 590 | return uclk; |
| 591 | } |
| 592 | |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 593 | /* exynos4x12: return uart clock frequency */ |
| 594 | static unsigned long exynos4x12_get_uart_clk(int dev_index) |
| 595 | { |
| 596 | struct exynos4x12_clock *clk = |
| 597 | (struct exynos4x12_clock *)samsung_get_base_clock(); |
| 598 | unsigned long uclk, sclk; |
| 599 | unsigned int sel; |
| 600 | unsigned int ratio; |
| 601 | |
| 602 | /* |
| 603 | * CLK_SRC_PERIL0 |
| 604 | * UART0_SEL [3:0] |
| 605 | * UART1_SEL [7:4] |
| 606 | * UART2_SEL [8:11] |
| 607 | * UART3_SEL [12:15] |
| 608 | * UART4_SEL [16:19] |
| 609 | */ |
| 610 | sel = readl(&clk->src_peril0); |
| 611 | sel = (sel >> (dev_index << 2)) & 0xf; |
| 612 | |
| 613 | if (sel == 0x6) |
| 614 | sclk = get_pll_clk(MPLL); |
| 615 | else if (sel == 0x7) |
| 616 | sclk = get_pll_clk(EPLL); |
| 617 | else if (sel == 0x8) |
| 618 | sclk = get_pll_clk(VPLL); |
| 619 | else |
| 620 | return 0; |
| 621 | |
| 622 | /* |
| 623 | * CLK_DIV_PERIL0 |
| 624 | * UART0_RATIO [3:0] |
| 625 | * UART1_RATIO [7:4] |
| 626 | * UART2_RATIO [8:11] |
| 627 | * UART3_RATIO [12:15] |
| 628 | * UART4_RATIO [16:19] |
| 629 | */ |
| 630 | ratio = readl(&clk->div_peril0); |
| 631 | ratio = (ratio >> (dev_index << 2)) & 0xf; |
| 632 | |
| 633 | uclk = sclk / (ratio + 1); |
| 634 | |
| 635 | return uclk; |
| 636 | } |
| 637 | |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 638 | /* exynos5: return uart clock frequency */ |
| 639 | static unsigned long exynos5_get_uart_clk(int dev_index) |
| 640 | { |
| 641 | struct exynos5_clock *clk = |
| 642 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 643 | unsigned long uclk, sclk; |
| 644 | unsigned int sel; |
| 645 | unsigned int ratio; |
| 646 | |
| 647 | /* |
| 648 | * CLK_SRC_PERIC0 |
| 649 | * UART0_SEL [3:0] |
| 650 | * UART1_SEL [7:4] |
| 651 | * UART2_SEL [8:11] |
| 652 | * UART3_SEL [12:15] |
| 653 | * UART4_SEL [16:19] |
| 654 | * UART5_SEL [23:20] |
| 655 | */ |
| 656 | sel = readl(&clk->src_peric0); |
| 657 | sel = (sel >> (dev_index << 2)) & 0xf; |
| 658 | |
| 659 | if (sel == 0x6) |
| 660 | sclk = get_pll_clk(MPLL); |
| 661 | else if (sel == 0x7) |
| 662 | sclk = get_pll_clk(EPLL); |
| 663 | else if (sel == 0x8) |
| 664 | sclk = get_pll_clk(VPLL); |
| 665 | else |
| 666 | return 0; |
| 667 | |
| 668 | /* |
| 669 | * CLK_DIV_PERIC0 |
| 670 | * UART0_RATIO [3:0] |
| 671 | * UART1_RATIO [7:4] |
| 672 | * UART2_RATIO [8:11] |
| 673 | * UART3_RATIO [12:15] |
| 674 | * UART4_RATIO [16:19] |
| 675 | * UART5_RATIO [23:20] |
| 676 | */ |
| 677 | ratio = readl(&clk->div_peric0); |
| 678 | ratio = (ratio >> (dev_index << 2)) & 0xf; |
| 679 | |
| 680 | uclk = sclk / (ratio + 1); |
| 681 | |
| 682 | return uclk; |
| 683 | } |
| 684 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 685 | /* exynos5420: return uart clock frequency */ |
| 686 | static unsigned long exynos5420_get_uart_clk(int dev_index) |
| 687 | { |
| 688 | struct exynos5420_clock *clk = |
| 689 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 690 | unsigned long uclk, sclk; |
| 691 | unsigned int sel; |
| 692 | unsigned int ratio; |
| 693 | |
| 694 | /* |
| 695 | * CLK_SRC_PERIC0 |
| 696 | * UART0_SEL [6:4] |
| 697 | * UART1_SEL [10:8] |
| 698 | * UART2_SEL [14:12] |
| 699 | * UART3_SEL [18:16] |
| 700 | * generalised calculation as follows |
| 701 | * sel = (sel >> ((dev_index * 4) + 4)) & mask; |
| 702 | */ |
| 703 | sel = readl(&clk->src_peric0); |
| 704 | sel = (sel >> ((dev_index * 4) + 4)) & 0x7; |
| 705 | |
| 706 | if (sel == 0x3) |
| 707 | sclk = get_pll_clk(MPLL); |
| 708 | else if (sel == 0x6) |
| 709 | sclk = get_pll_clk(EPLL); |
| 710 | else if (sel == 0x7) |
| 711 | sclk = get_pll_clk(RPLL); |
| 712 | else |
| 713 | return 0; |
| 714 | |
| 715 | /* |
| 716 | * CLK_DIV_PERIC0 |
| 717 | * UART0_RATIO [11:8] |
| 718 | * UART1_RATIO [15:12] |
| 719 | * UART2_RATIO [19:16] |
| 720 | * UART3_RATIO [23:20] |
| 721 | * generalised calculation as follows |
| 722 | * ratio = (ratio >> ((dev_index * 4) + 8)) & mask; |
| 723 | */ |
| 724 | ratio = readl(&clk->div_peric0); |
| 725 | ratio = (ratio >> ((dev_index * 4) + 8)) & 0xf; |
| 726 | |
| 727 | uclk = sclk / (ratio + 1); |
| 728 | |
| 729 | return uclk; |
| 730 | } |
| 731 | |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 732 | static unsigned long exynos4_get_mmc_clk(int dev_index) |
| 733 | { |
| 734 | struct exynos4_clock *clk = |
| 735 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 736 | unsigned long uclk, sclk; |
| 737 | unsigned int sel, ratio, pre_ratio; |
Amar | e1df628 | 2013-04-27 11:42:56 +0530 | [diff] [blame] | 738 | int shift = 0; |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 739 | |
| 740 | sel = readl(&clk->src_fsys); |
| 741 | sel = (sel >> (dev_index << 2)) & 0xf; |
| 742 | |
| 743 | if (sel == 0x6) |
| 744 | sclk = get_pll_clk(MPLL); |
| 745 | else if (sel == 0x7) |
| 746 | sclk = get_pll_clk(EPLL); |
| 747 | else if (sel == 0x8) |
| 748 | sclk = get_pll_clk(VPLL); |
| 749 | else |
| 750 | return 0; |
| 751 | |
| 752 | switch (dev_index) { |
| 753 | case 0: |
| 754 | case 1: |
| 755 | ratio = readl(&clk->div_fsys1); |
| 756 | pre_ratio = readl(&clk->div_fsys1); |
| 757 | break; |
| 758 | case 2: |
| 759 | case 3: |
| 760 | ratio = readl(&clk->div_fsys2); |
| 761 | pre_ratio = readl(&clk->div_fsys2); |
| 762 | break; |
| 763 | case 4: |
| 764 | ratio = readl(&clk->div_fsys3); |
| 765 | pre_ratio = readl(&clk->div_fsys3); |
| 766 | break; |
| 767 | default: |
| 768 | return 0; |
| 769 | } |
| 770 | |
| 771 | if (dev_index == 1 || dev_index == 3) |
| 772 | shift = 16; |
| 773 | |
| 774 | ratio = (ratio >> shift) & 0xf; |
| 775 | pre_ratio = (pre_ratio >> (shift + 8)) & 0xff; |
| 776 | uclk = (sclk / (ratio + 1)) / (pre_ratio + 1); |
| 777 | |
| 778 | return uclk; |
| 779 | } |
| 780 | |
| 781 | static unsigned long exynos5_get_mmc_clk(int dev_index) |
| 782 | { |
| 783 | struct exynos5_clock *clk = |
| 784 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 785 | unsigned long uclk, sclk; |
| 786 | unsigned int sel, ratio, pre_ratio; |
Amar | e1df628 | 2013-04-27 11:42:56 +0530 | [diff] [blame] | 787 | int shift = 0; |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 788 | |
| 789 | sel = readl(&clk->src_fsys); |
| 790 | sel = (sel >> (dev_index << 2)) & 0xf; |
| 791 | |
| 792 | if (sel == 0x6) |
| 793 | sclk = get_pll_clk(MPLL); |
| 794 | else if (sel == 0x7) |
| 795 | sclk = get_pll_clk(EPLL); |
| 796 | else if (sel == 0x8) |
| 797 | sclk = get_pll_clk(VPLL); |
| 798 | else |
| 799 | return 0; |
| 800 | |
| 801 | switch (dev_index) { |
| 802 | case 0: |
| 803 | case 1: |
| 804 | ratio = readl(&clk->div_fsys1); |
| 805 | pre_ratio = readl(&clk->div_fsys1); |
| 806 | break; |
| 807 | case 2: |
| 808 | case 3: |
| 809 | ratio = readl(&clk->div_fsys2); |
| 810 | pre_ratio = readl(&clk->div_fsys2); |
| 811 | break; |
| 812 | default: |
| 813 | return 0; |
| 814 | } |
| 815 | |
| 816 | if (dev_index == 1 || dev_index == 3) |
| 817 | shift = 16; |
| 818 | |
| 819 | ratio = (ratio >> shift) & 0xf; |
| 820 | pre_ratio = (pre_ratio >> (shift + 8)) & 0xff; |
| 821 | uclk = (sclk / (ratio + 1)) / (pre_ratio + 1); |
| 822 | |
| 823 | return uclk; |
| 824 | } |
| 825 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 826 | static unsigned long exynos5420_get_mmc_clk(int dev_index) |
| 827 | { |
| 828 | struct exynos5420_clock *clk = |
| 829 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 830 | unsigned long uclk, sclk; |
| 831 | unsigned int sel, ratio; |
| 832 | |
| 833 | /* |
| 834 | * CLK_SRC_FSYS |
| 835 | * MMC0_SEL [10:8] |
| 836 | * MMC1_SEL [14:12] |
| 837 | * MMC2_SEL [18:16] |
| 838 | * generalised calculation as follows |
| 839 | * sel = (sel >> ((dev_index * 4) + 8)) & mask |
| 840 | */ |
| 841 | sel = readl(&clk->src_fsys); |
| 842 | sel = (sel >> ((dev_index * 4) + 8)) & 0x7; |
| 843 | |
| 844 | if (sel == 0x3) |
| 845 | sclk = get_pll_clk(MPLL); |
| 846 | else if (sel == 0x6) |
| 847 | sclk = get_pll_clk(EPLL); |
| 848 | else |
| 849 | return 0; |
| 850 | |
| 851 | /* |
| 852 | * CLK_DIV_FSYS1 |
| 853 | * MMC0_RATIO [9:0] |
| 854 | * MMC1_RATIO [19:10] |
| 855 | * MMC2_RATIO [29:20] |
| 856 | * generalised calculation as follows |
| 857 | * ratio = (ratio >> (dev_index * 10)) & mask |
| 858 | */ |
| 859 | ratio = readl(&clk->div_fsys1); |
| 860 | ratio = (ratio >> (dev_index * 10)) & 0x3ff; |
| 861 | |
| 862 | uclk = (sclk / (ratio + 1)); |
| 863 | |
| 864 | return uclk; |
| 865 | } |
| 866 | |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 867 | /* exynos4: set the mmc clock */ |
| 868 | static void exynos4_set_mmc_clk(int dev_index, unsigned int div) |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 869 | { |
Chander Kashyap | 4131a77 | 2011-12-06 23:34:12 +0000 | [diff] [blame] | 870 | struct exynos4_clock *clk = |
| 871 | (struct exynos4_clock *)samsung_get_base_clock(); |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 872 | unsigned int addr; |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 873 | |
| 874 | /* |
| 875 | * CLK_DIV_FSYS1 |
| 876 | * MMC0_PRE_RATIO [15:8], MMC1_PRE_RATIO [31:24] |
| 877 | * CLK_DIV_FSYS2 |
| 878 | * MMC2_PRE_RATIO [15:8], MMC3_PRE_RATIO [31:24] |
Jaehoon Chung | 29fe8c5 | 2012-12-27 22:30:33 +0000 | [diff] [blame] | 879 | * CLK_DIV_FSYS3 |
| 880 | * MMC4_PRE_RATIO [15:8] |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 881 | */ |
| 882 | if (dev_index < 2) { |
| 883 | addr = (unsigned int)&clk->div_fsys1; |
Jaehoon Chung | 29fe8c5 | 2012-12-27 22:30:33 +0000 | [diff] [blame] | 884 | } else if (dev_index == 4) { |
| 885 | addr = (unsigned int)&clk->div_fsys3; |
| 886 | dev_index -= 4; |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 887 | } else { |
| 888 | addr = (unsigned int)&clk->div_fsys2; |
| 889 | dev_index -= 2; |
| 890 | } |
| 891 | |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 892 | clrsetbits_le32(addr, 0xff << ((dev_index << 4) + 8), |
| 893 | (div & 0xff) << ((dev_index << 4) + 8)); |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 894 | } |
| 895 | |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 896 | /* exynos5: set the mmc clock */ |
| 897 | static void exynos5_set_mmc_clk(int dev_index, unsigned int div) |
| 898 | { |
| 899 | struct exynos5_clock *clk = |
| 900 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 901 | unsigned int addr; |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 902 | |
| 903 | /* |
| 904 | * CLK_DIV_FSYS1 |
| 905 | * MMC0_PRE_RATIO [15:8], MMC1_PRE_RATIO [31:24] |
| 906 | * CLK_DIV_FSYS2 |
| 907 | * MMC2_PRE_RATIO [15:8], MMC3_PRE_RATIO [31:24] |
| 908 | */ |
| 909 | if (dev_index < 2) { |
| 910 | addr = (unsigned int)&clk->div_fsys1; |
| 911 | } else { |
| 912 | addr = (unsigned int)&clk->div_fsys2; |
| 913 | dev_index -= 2; |
| 914 | } |
| 915 | |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 916 | clrsetbits_le32(addr, 0xff << ((dev_index << 4) + 8), |
| 917 | (div & 0xff) << ((dev_index << 4) + 8)); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 918 | } |
| 919 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 920 | /* exynos5: set the mmc clock */ |
| 921 | static void exynos5420_set_mmc_clk(int dev_index, unsigned int div) |
| 922 | { |
| 923 | struct exynos5420_clock *clk = |
| 924 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 925 | unsigned int addr; |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 926 | unsigned int shift; |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 927 | |
| 928 | /* |
| 929 | * CLK_DIV_FSYS1 |
| 930 | * MMC0_RATIO [9:0] |
| 931 | * MMC1_RATIO [19:10] |
| 932 | * MMC2_RATIO [29:20] |
| 933 | */ |
| 934 | addr = (unsigned int)&clk->div_fsys1; |
| 935 | shift = dev_index * 10; |
| 936 | |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 937 | clrsetbits_le32(addr, 0x3ff << shift, (div & 0x3ff) << shift); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 938 | } |
| 939 | |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 940 | /* get_lcd_clk: return lcd clock frequency */ |
| 941 | static unsigned long exynos4_get_lcd_clk(void) |
| 942 | { |
| 943 | struct exynos4_clock *clk = |
| 944 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 945 | unsigned long pclk, sclk; |
| 946 | unsigned int sel; |
| 947 | unsigned int ratio; |
| 948 | |
| 949 | /* |
| 950 | * CLK_SRC_LCD0 |
| 951 | * FIMD0_SEL [3:0] |
| 952 | */ |
| 953 | sel = readl(&clk->src_lcd0); |
| 954 | sel = sel & 0xf; |
| 955 | |
| 956 | /* |
| 957 | * 0x6: SCLK_MPLL |
| 958 | * 0x7: SCLK_EPLL |
| 959 | * 0x8: SCLK_VPLL |
| 960 | */ |
| 961 | if (sel == 0x6) |
| 962 | sclk = get_pll_clk(MPLL); |
| 963 | else if (sel == 0x7) |
| 964 | sclk = get_pll_clk(EPLL); |
| 965 | else if (sel == 0x8) |
| 966 | sclk = get_pll_clk(VPLL); |
| 967 | else |
| 968 | return 0; |
| 969 | |
| 970 | /* |
| 971 | * CLK_DIV_LCD0 |
| 972 | * FIMD0_RATIO [3:0] |
| 973 | */ |
| 974 | ratio = readl(&clk->div_lcd0); |
| 975 | ratio = ratio & 0xf; |
| 976 | |
| 977 | pclk = sclk / (ratio + 1); |
| 978 | |
| 979 | return pclk; |
| 980 | } |
| 981 | |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 982 | /* get_lcd_clk: return lcd clock frequency */ |
| 983 | static unsigned long exynos5_get_lcd_clk(void) |
| 984 | { |
| 985 | struct exynos5_clock *clk = |
| 986 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 987 | unsigned long pclk, sclk; |
| 988 | unsigned int sel; |
| 989 | unsigned int ratio; |
| 990 | |
| 991 | /* |
| 992 | * CLK_SRC_LCD0 |
| 993 | * FIMD0_SEL [3:0] |
| 994 | */ |
| 995 | sel = readl(&clk->src_disp1_0); |
| 996 | sel = sel & 0xf; |
| 997 | |
| 998 | /* |
| 999 | * 0x6: SCLK_MPLL |
| 1000 | * 0x7: SCLK_EPLL |
| 1001 | * 0x8: SCLK_VPLL |
| 1002 | */ |
| 1003 | if (sel == 0x6) |
| 1004 | sclk = get_pll_clk(MPLL); |
| 1005 | else if (sel == 0x7) |
| 1006 | sclk = get_pll_clk(EPLL); |
| 1007 | else if (sel == 0x8) |
| 1008 | sclk = get_pll_clk(VPLL); |
| 1009 | else |
| 1010 | return 0; |
| 1011 | |
| 1012 | /* |
| 1013 | * CLK_DIV_LCD0 |
| 1014 | * FIMD0_RATIO [3:0] |
| 1015 | */ |
| 1016 | ratio = readl(&clk->div_disp1_0); |
| 1017 | ratio = ratio & 0xf; |
| 1018 | |
| 1019 | pclk = sclk / (ratio + 1); |
| 1020 | |
| 1021 | return pclk; |
| 1022 | } |
| 1023 | |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1024 | void exynos4_set_lcd_clk(void) |
| 1025 | { |
| 1026 | struct exynos4_clock *clk = |
| 1027 | (struct exynos4_clock *)samsung_get_base_clock(); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1028 | |
| 1029 | /* |
| 1030 | * CLK_GATE_BLOCK |
| 1031 | * CLK_CAM [0] |
| 1032 | * CLK_TV [1] |
| 1033 | * CLK_MFC [2] |
| 1034 | * CLK_G3D [3] |
| 1035 | * CLK_LCD0 [4] |
| 1036 | * CLK_LCD1 [5] |
| 1037 | * CLK_GPS [7] |
| 1038 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1039 | setbits_le32(&clk->gate_block, 1 << 4); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1040 | |
| 1041 | /* |
| 1042 | * CLK_SRC_LCD0 |
| 1043 | * FIMD0_SEL [3:0] |
| 1044 | * MDNIE0_SEL [7:4] |
| 1045 | * MDNIE_PWM0_SEL [8:11] |
| 1046 | * MIPI0_SEL [12:15] |
| 1047 | * set lcd0 src clock 0x6: SCLK_MPLL |
| 1048 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1049 | clrsetbits_le32(&clk->src_lcd0, 0xf, 0x6); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1050 | |
| 1051 | /* |
| 1052 | * CLK_GATE_IP_LCD0 |
| 1053 | * CLK_FIMD0 [0] |
| 1054 | * CLK_MIE0 [1] |
| 1055 | * CLK_MDNIE0 [2] |
| 1056 | * CLK_DSIM0 [3] |
| 1057 | * CLK_SMMUFIMD0 [4] |
| 1058 | * CLK_PPMULCD0 [5] |
| 1059 | * Gating all clocks for FIMD0 |
| 1060 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1061 | setbits_le32(&clk->gate_ip_lcd0, 1 << 0); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1062 | |
| 1063 | /* |
| 1064 | * CLK_DIV_LCD0 |
| 1065 | * FIMD0_RATIO [3:0] |
| 1066 | * MDNIE0_RATIO [7:4] |
| 1067 | * MDNIE_PWM0_RATIO [11:8] |
| 1068 | * MDNIE_PWM_PRE_RATIO [15:12] |
| 1069 | * MIPI0_RATIO [19:16] |
| 1070 | * MIPI0_PRE_RATIO [23:20] |
| 1071 | * set fimd ratio |
| 1072 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1073 | clrsetbits_le32(&clk->div_lcd0, 0xf, 0x1); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1074 | } |
| 1075 | |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1076 | void exynos5_set_lcd_clk(void) |
| 1077 | { |
| 1078 | struct exynos5_clock *clk = |
| 1079 | (struct exynos5_clock *)samsung_get_base_clock(); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1080 | |
| 1081 | /* |
| 1082 | * CLK_GATE_BLOCK |
| 1083 | * CLK_CAM [0] |
| 1084 | * CLK_TV [1] |
| 1085 | * CLK_MFC [2] |
| 1086 | * CLK_G3D [3] |
| 1087 | * CLK_LCD0 [4] |
| 1088 | * CLK_LCD1 [5] |
| 1089 | * CLK_GPS [7] |
| 1090 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1091 | setbits_le32(&clk->gate_block, 1 << 4); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1092 | |
| 1093 | /* |
| 1094 | * CLK_SRC_LCD0 |
| 1095 | * FIMD0_SEL [3:0] |
| 1096 | * MDNIE0_SEL [7:4] |
| 1097 | * MDNIE_PWM0_SEL [8:11] |
| 1098 | * MIPI0_SEL [12:15] |
| 1099 | * set lcd0 src clock 0x6: SCLK_MPLL |
| 1100 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1101 | clrsetbits_le32(&clk->src_disp1_0, 0xf, 0x6); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1102 | |
| 1103 | /* |
| 1104 | * CLK_GATE_IP_LCD0 |
| 1105 | * CLK_FIMD0 [0] |
| 1106 | * CLK_MIE0 [1] |
| 1107 | * CLK_MDNIE0 [2] |
| 1108 | * CLK_DSIM0 [3] |
| 1109 | * CLK_SMMUFIMD0 [4] |
| 1110 | * CLK_PPMULCD0 [5] |
| 1111 | * Gating all clocks for FIMD0 |
| 1112 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1113 | setbits_le32(&clk->gate_ip_disp1, 1 << 0); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1114 | |
| 1115 | /* |
| 1116 | * CLK_DIV_LCD0 |
| 1117 | * FIMD0_RATIO [3:0] |
| 1118 | * MDNIE0_RATIO [7:4] |
| 1119 | * MDNIE_PWM0_RATIO [11:8] |
| 1120 | * MDNIE_PWM_PRE_RATIO [15:12] |
| 1121 | * MIPI0_RATIO [19:16] |
| 1122 | * MIPI0_PRE_RATIO [23:20] |
| 1123 | * set fimd ratio |
| 1124 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1125 | clrsetbits_le32(&clk->div_disp1_0, 0xf, 0x0); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1128 | void exynos4_set_mipi_clk(void) |
| 1129 | { |
| 1130 | struct exynos4_clock *clk = |
| 1131 | (struct exynos4_clock *)samsung_get_base_clock(); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1132 | |
| 1133 | /* |
| 1134 | * CLK_SRC_LCD0 |
| 1135 | * FIMD0_SEL [3:0] |
| 1136 | * MDNIE0_SEL [7:4] |
| 1137 | * MDNIE_PWM0_SEL [8:11] |
| 1138 | * MIPI0_SEL [12:15] |
| 1139 | * set mipi0 src clock 0x6: SCLK_MPLL |
| 1140 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1141 | clrsetbits_le32(&clk->src_lcd0, 0xf << 12, 0x6 << 12); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1142 | |
| 1143 | /* |
| 1144 | * CLK_SRC_MASK_LCD0 |
| 1145 | * FIMD0_MASK [0] |
| 1146 | * MDNIE0_MASK [4] |
| 1147 | * MDNIE_PWM0_MASK [8] |
| 1148 | * MIPI0_MASK [12] |
| 1149 | * set src mask mipi0 0x1: Unmask |
| 1150 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1151 | setbits_le32(&clk->src_mask_lcd0, 0x1 << 12); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1152 | |
| 1153 | /* |
| 1154 | * CLK_GATE_IP_LCD0 |
| 1155 | * CLK_FIMD0 [0] |
| 1156 | * CLK_MIE0 [1] |
| 1157 | * CLK_MDNIE0 [2] |
| 1158 | * CLK_DSIM0 [3] |
| 1159 | * CLK_SMMUFIMD0 [4] |
| 1160 | * CLK_PPMULCD0 [5] |
| 1161 | * Gating all clocks for MIPI0 |
| 1162 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1163 | setbits_le32(&clk->gate_ip_lcd0, 1 << 3); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1164 | |
| 1165 | /* |
| 1166 | * CLK_DIV_LCD0 |
| 1167 | * FIMD0_RATIO [3:0] |
| 1168 | * MDNIE0_RATIO [7:4] |
| 1169 | * MDNIE_PWM0_RATIO [11:8] |
| 1170 | * MDNIE_PWM_PRE_RATIO [15:12] |
| 1171 | * MIPI0_RATIO [19:16] |
| 1172 | * MIPI0_PRE_RATIO [23:20] |
| 1173 | * set mipi ratio |
| 1174 | */ |
Inha Song | 4e55853 | 2014-02-06 14:20:12 +0900 | [diff] [blame] | 1175 | clrsetbits_le32(&clk->div_lcd0, 0xf << 16, 0x1 << 16); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1176 | } |
| 1177 | |
Rajeshwari Shinde | 1c9412a | 2012-07-23 21:23:48 +0000 | [diff] [blame] | 1178 | /* |
| 1179 | * I2C |
| 1180 | * |
| 1181 | * exynos5: obtaining the I2C clock |
| 1182 | */ |
| 1183 | static unsigned long exynos5_get_i2c_clk(void) |
| 1184 | { |
| 1185 | struct exynos5_clock *clk = |
| 1186 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 1187 | unsigned long aclk_66, aclk_66_pre, sclk; |
| 1188 | unsigned int ratio; |
| 1189 | |
| 1190 | sclk = get_pll_clk(MPLL); |
| 1191 | |
| 1192 | ratio = (readl(&clk->div_top1)) >> 24; |
| 1193 | ratio &= 0x7; |
| 1194 | aclk_66_pre = sclk / (ratio + 1); |
| 1195 | ratio = readl(&clk->div_top0); |
| 1196 | ratio &= 0x7; |
| 1197 | aclk_66 = aclk_66_pre / (ratio + 1); |
| 1198 | return aclk_66; |
| 1199 | } |
| 1200 | |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1201 | int exynos5_set_epll_clk(unsigned long rate) |
| 1202 | { |
| 1203 | unsigned int epll_con, epll_con_k; |
| 1204 | unsigned int i; |
| 1205 | unsigned int lockcnt; |
| 1206 | unsigned int start; |
| 1207 | struct exynos5_clock *clk = |
| 1208 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 1209 | |
| 1210 | epll_con = readl(&clk->epll_con0); |
| 1211 | epll_con &= ~((EPLL_CON0_LOCK_DET_EN_MASK << |
| 1212 | EPLL_CON0_LOCK_DET_EN_SHIFT) | |
| 1213 | EPLL_CON0_MDIV_MASK << EPLL_CON0_MDIV_SHIFT | |
| 1214 | EPLL_CON0_PDIV_MASK << EPLL_CON0_PDIV_SHIFT | |
| 1215 | EPLL_CON0_SDIV_MASK << EPLL_CON0_SDIV_SHIFT); |
| 1216 | |
| 1217 | for (i = 0; i < ARRAY_SIZE(exynos5_epll_div); i++) { |
| 1218 | if (exynos5_epll_div[i].freq_out == rate) |
| 1219 | break; |
| 1220 | } |
| 1221 | |
| 1222 | if (i == ARRAY_SIZE(exynos5_epll_div)) |
| 1223 | return -1; |
| 1224 | |
| 1225 | epll_con_k = exynos5_epll_div[i].k_dsm << 0; |
| 1226 | epll_con |= exynos5_epll_div[i].en_lock_det << |
| 1227 | EPLL_CON0_LOCK_DET_EN_SHIFT; |
| 1228 | epll_con |= exynos5_epll_div[i].m_div << EPLL_CON0_MDIV_SHIFT; |
| 1229 | epll_con |= exynos5_epll_div[i].p_div << EPLL_CON0_PDIV_SHIFT; |
| 1230 | epll_con |= exynos5_epll_div[i].s_div << EPLL_CON0_SDIV_SHIFT; |
| 1231 | |
| 1232 | /* |
| 1233 | * Required period ( in cycles) to genarate a stable clock output. |
| 1234 | * The maximum clock time can be up to 3000 * PDIV cycles of PLLs |
| 1235 | * frequency input (as per spec) |
| 1236 | */ |
| 1237 | lockcnt = 3000 * exynos5_epll_div[i].p_div; |
| 1238 | |
| 1239 | writel(lockcnt, &clk->epll_lock); |
| 1240 | writel(epll_con, &clk->epll_con0); |
| 1241 | writel(epll_con_k, &clk->epll_con1); |
| 1242 | |
| 1243 | start = get_timer(0); |
| 1244 | |
| 1245 | while (!(readl(&clk->epll_con0) & |
| 1246 | (0x1 << EXYNOS5_EPLLCON0_LOCKED_SHIFT))) { |
| 1247 | if (get_timer(start) > TIMEOUT_EPLL_LOCK) { |
| 1248 | debug("%s: Timeout waiting for EPLL lock\n", __func__); |
| 1249 | return -1; |
| 1250 | } |
| 1251 | } |
| 1252 | return 0; |
| 1253 | } |
| 1254 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1255 | int exynos5_set_i2s_clk_source(unsigned int i2s_id) |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1256 | { |
| 1257 | struct exynos5_clock *clk = |
| 1258 | (struct exynos5_clock *)samsung_get_base_clock(); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1259 | unsigned int *audio_ass = (unsigned int *)samsung_get_base_audio_ass(); |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1260 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1261 | if (i2s_id == 0) { |
| 1262 | setbits_le32(&clk->src_top2, CLK_SRC_MOUT_EPLL); |
| 1263 | clrsetbits_le32(&clk->src_mau, AUDIO0_SEL_MASK, |
| 1264 | (CLK_SRC_SCLK_EPLL)); |
| 1265 | setbits_le32(audio_ass, AUDIO_CLKMUX_ASS); |
| 1266 | } else if (i2s_id == 1) { |
| 1267 | clrsetbits_le32(&clk->src_peric1, AUDIO1_SEL_MASK, |
| 1268 | (CLK_SRC_SCLK_EPLL)); |
| 1269 | } else { |
| 1270 | return -1; |
| 1271 | } |
| 1272 | return 0; |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | int exynos5_set_i2s_clk_prescaler(unsigned int src_frq, |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1276 | unsigned int dst_frq, |
| 1277 | unsigned int i2s_id) |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1278 | { |
| 1279 | struct exynos5_clock *clk = |
| 1280 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 1281 | unsigned int div; |
| 1282 | |
| 1283 | if ((dst_frq == 0) || (src_frq == 0)) { |
| 1284 | debug("%s: Invalid requency input for prescaler\n", __func__); |
| 1285 | debug("src frq = %d des frq = %d ", src_frq, dst_frq); |
| 1286 | return -1; |
| 1287 | } |
| 1288 | |
| 1289 | div = (src_frq / dst_frq); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1290 | if (i2s_id == 0) { |
| 1291 | if (div > AUDIO_0_RATIO_MASK) { |
| 1292 | debug("%s: Frequency ratio is out of range\n", |
| 1293 | __func__); |
| 1294 | debug("src frq = %d des frq = %d ", src_frq, dst_frq); |
| 1295 | return -1; |
| 1296 | } |
| 1297 | clrsetbits_le32(&clk->div_mau, AUDIO_0_RATIO_MASK, |
| 1298 | (div & AUDIO_0_RATIO_MASK)); |
| 1299 | } else if(i2s_id == 1) { |
| 1300 | if (div > AUDIO_1_RATIO_MASK) { |
| 1301 | debug("%s: Frequency ratio is out of range\n", |
| 1302 | __func__); |
| 1303 | debug("src frq = %d des frq = %d ", src_frq, dst_frq); |
| 1304 | return -1; |
| 1305 | } |
| 1306 | clrsetbits_le32(&clk->div_peric4, AUDIO_1_RATIO_MASK, |
| 1307 | (div & AUDIO_1_RATIO_MASK)); |
| 1308 | } else { |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1309 | return -1; |
| 1310 | } |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1311 | return 0; |
| 1312 | } |
| 1313 | |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 1314 | /** |
| 1315 | * Linearly searches for the most accurate main and fine stage clock scalars |
| 1316 | * (divisors) for a specified target frequency and scalar bit sizes by checking |
| 1317 | * all multiples of main_scalar_bits values. Will always return scalars up to or |
| 1318 | * slower than target. |
| 1319 | * |
| 1320 | * @param main_scalar_bits Number of main scalar bits, must be > 0 and < 32 |
| 1321 | * @param fine_scalar_bits Number of fine scalar bits, must be > 0 and < 32 |
| 1322 | * @param input_freq Clock frequency to be scaled in Hz |
| 1323 | * @param target_freq Desired clock frequency in Hz |
| 1324 | * @param best_fine_scalar Pointer to store the fine stage divisor |
| 1325 | * |
| 1326 | * @return best_main_scalar Main scalar for desired frequency or -1 if none |
| 1327 | * found |
| 1328 | */ |
| 1329 | static int clock_calc_best_scalar(unsigned int main_scaler_bits, |
| 1330 | unsigned int fine_scalar_bits, unsigned int input_rate, |
| 1331 | unsigned int target_rate, unsigned int *best_fine_scalar) |
| 1332 | { |
| 1333 | int i; |
| 1334 | int best_main_scalar = -1; |
| 1335 | unsigned int best_error = target_rate; |
| 1336 | const unsigned int cap = (1 << fine_scalar_bits) - 1; |
| 1337 | const unsigned int loops = 1 << main_scaler_bits; |
| 1338 | |
| 1339 | debug("Input Rate is %u, Target is %u, Cap is %u\n", input_rate, |
| 1340 | target_rate, cap); |
| 1341 | |
| 1342 | assert(best_fine_scalar != NULL); |
| 1343 | assert(main_scaler_bits <= fine_scalar_bits); |
| 1344 | |
| 1345 | *best_fine_scalar = 1; |
| 1346 | |
| 1347 | if (input_rate == 0 || target_rate == 0) |
| 1348 | return -1; |
| 1349 | |
| 1350 | if (target_rate >= input_rate) |
| 1351 | return 1; |
| 1352 | |
| 1353 | for (i = 1; i <= loops; i++) { |
| 1354 | const unsigned int effective_div = max(min(input_rate / i / |
| 1355 | target_rate, cap), 1); |
| 1356 | const unsigned int effective_rate = input_rate / i / |
| 1357 | effective_div; |
| 1358 | const int error = target_rate - effective_rate; |
| 1359 | |
| 1360 | debug("%d|effdiv:%u, effrate:%u, error:%d\n", i, effective_div, |
| 1361 | effective_rate, error); |
| 1362 | |
| 1363 | if (error >= 0 && error <= best_error) { |
| 1364 | best_error = error; |
| 1365 | best_main_scalar = i; |
| 1366 | *best_fine_scalar = effective_div; |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | return best_main_scalar; |
| 1371 | } |
| 1372 | |
| 1373 | static int exynos5_set_spi_clk(enum periph_id periph_id, |
| 1374 | unsigned int rate) |
| 1375 | { |
| 1376 | struct exynos5_clock *clk = |
| 1377 | (struct exynos5_clock *)samsung_get_base_clock(); |
| 1378 | int main; |
| 1379 | unsigned int fine; |
| 1380 | unsigned shift, pre_shift; |
| 1381 | unsigned mask = 0xff; |
| 1382 | u32 *reg; |
| 1383 | |
| 1384 | main = clock_calc_best_scalar(4, 8, 400000000, rate, &fine); |
| 1385 | if (main < 0) { |
| 1386 | debug("%s: Cannot set clock rate for periph %d", |
| 1387 | __func__, periph_id); |
| 1388 | return -1; |
| 1389 | } |
| 1390 | main = main - 1; |
| 1391 | fine = fine - 1; |
| 1392 | |
| 1393 | switch (periph_id) { |
| 1394 | case PERIPH_ID_SPI0: |
| 1395 | reg = &clk->div_peric1; |
| 1396 | shift = 0; |
| 1397 | pre_shift = 8; |
| 1398 | break; |
| 1399 | case PERIPH_ID_SPI1: |
| 1400 | reg = &clk->div_peric1; |
| 1401 | shift = 16; |
| 1402 | pre_shift = 24; |
| 1403 | break; |
| 1404 | case PERIPH_ID_SPI2: |
| 1405 | reg = &clk->div_peric2; |
| 1406 | shift = 0; |
| 1407 | pre_shift = 8; |
| 1408 | break; |
| 1409 | case PERIPH_ID_SPI3: |
| 1410 | reg = &clk->sclk_div_isp; |
| 1411 | shift = 0; |
| 1412 | pre_shift = 4; |
| 1413 | break; |
| 1414 | case PERIPH_ID_SPI4: |
| 1415 | reg = &clk->sclk_div_isp; |
| 1416 | shift = 12; |
| 1417 | pre_shift = 16; |
| 1418 | break; |
| 1419 | default: |
| 1420 | debug("%s: Unsupported peripheral ID %d\n", __func__, |
| 1421 | periph_id); |
| 1422 | return -1; |
| 1423 | } |
| 1424 | clrsetbits_le32(reg, mask << shift, (main & mask) << shift); |
| 1425 | clrsetbits_le32(reg, mask << pre_shift, (fine & mask) << pre_shift); |
| 1426 | |
| 1427 | return 0; |
| 1428 | } |
| 1429 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1430 | static int exynos5420_set_spi_clk(enum periph_id periph_id, |
| 1431 | unsigned int rate) |
| 1432 | { |
| 1433 | struct exynos5420_clock *clk = |
| 1434 | (struct exynos5420_clock *)samsung_get_base_clock(); |
| 1435 | int main; |
| 1436 | unsigned int fine; |
| 1437 | unsigned shift, pre_shift; |
| 1438 | unsigned div_mask = 0xf, pre_div_mask = 0xff; |
| 1439 | u32 *reg; |
| 1440 | u32 *pre_reg; |
| 1441 | |
| 1442 | main = clock_calc_best_scalar(4, 8, 400000000, rate, &fine); |
| 1443 | if (main < 0) { |
| 1444 | debug("%s: Cannot set clock rate for periph %d", |
| 1445 | __func__, periph_id); |
| 1446 | return -1; |
| 1447 | } |
| 1448 | main = main - 1; |
| 1449 | fine = fine - 1; |
| 1450 | |
| 1451 | switch (periph_id) { |
| 1452 | case PERIPH_ID_SPI0: |
| 1453 | reg = &clk->div_peric1; |
| 1454 | shift = 20; |
| 1455 | pre_reg = &clk->div_peric4; |
| 1456 | pre_shift = 8; |
| 1457 | break; |
| 1458 | case PERIPH_ID_SPI1: |
| 1459 | reg = &clk->div_peric1; |
| 1460 | shift = 24; |
| 1461 | pre_reg = &clk->div_peric4; |
| 1462 | pre_shift = 16; |
| 1463 | break; |
| 1464 | case PERIPH_ID_SPI2: |
| 1465 | reg = &clk->div_peric1; |
| 1466 | shift = 28; |
| 1467 | pre_reg = &clk->div_peric4; |
| 1468 | pre_shift = 24; |
| 1469 | break; |
| 1470 | case PERIPH_ID_SPI3: |
| 1471 | reg = &clk->div_isp1; |
| 1472 | shift = 16; |
| 1473 | pre_reg = &clk->div_isp1; |
| 1474 | pre_shift = 0; |
| 1475 | break; |
| 1476 | case PERIPH_ID_SPI4: |
| 1477 | reg = &clk->div_isp1; |
| 1478 | shift = 20; |
| 1479 | pre_reg = &clk->div_isp1; |
| 1480 | pre_shift = 8; |
| 1481 | break; |
| 1482 | default: |
| 1483 | debug("%s: Unsupported peripheral ID %d\n", __func__, |
| 1484 | periph_id); |
| 1485 | return -1; |
| 1486 | } |
| 1487 | |
| 1488 | clrsetbits_le32(reg, div_mask << shift, (main & div_mask) << shift); |
| 1489 | clrsetbits_le32(pre_reg, pre_div_mask << pre_shift, |
| 1490 | (fine & pre_div_mask) << pre_shift); |
| 1491 | |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
Piotr Wilczek | 01d589f | 2012-11-20 02:19:02 +0000 | [diff] [blame] | 1495 | static unsigned long exynos4_get_i2c_clk(void) |
| 1496 | { |
| 1497 | struct exynos4_clock *clk = |
| 1498 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 1499 | unsigned long sclk, aclk_100; |
| 1500 | unsigned int ratio; |
| 1501 | |
| 1502 | sclk = get_pll_clk(APLL); |
| 1503 | |
| 1504 | ratio = (readl(&clk->div_top)) >> 4; |
| 1505 | ratio &= 0xf; |
| 1506 | aclk_100 = sclk / (ratio + 1); |
| 1507 | return aclk_100; |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1508 | } |
| 1509 | |
| 1510 | unsigned long get_pll_clk(int pllreg) |
| 1511 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1512 | if (cpu_is_exynos5()) { |
| 1513 | if (proid_is_exynos5420()) |
| 1514 | return exynos5420_get_pll_clk(pllreg); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1515 | return exynos5_get_pll_clk(pllreg); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1516 | } else { |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1517 | if (proid_is_exynos4412()) |
| 1518 | return exynos4x12_get_pll_clk(pllreg); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1519 | return exynos4_get_pll_clk(pllreg); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1520 | } |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | unsigned long get_arm_clk(void) |
| 1524 | { |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1525 | if (cpu_is_exynos5()) |
| 1526 | return exynos5_get_arm_clk(); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1527 | else { |
| 1528 | if (proid_is_exynos4412()) |
| 1529 | return exynos4x12_get_arm_clk(); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1530 | return exynos4_get_arm_clk(); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1531 | } |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1532 | } |
| 1533 | |
Rajeshwari Shinde | 1c9412a | 2012-07-23 21:23:48 +0000 | [diff] [blame] | 1534 | unsigned long get_i2c_clk(void) |
| 1535 | { |
| 1536 | if (cpu_is_exynos5()) { |
| 1537 | return exynos5_get_i2c_clk(); |
Piotr Wilczek | 01d589f | 2012-11-20 02:19:02 +0000 | [diff] [blame] | 1538 | } else if (cpu_is_exynos4()) { |
| 1539 | return exynos4_get_i2c_clk(); |
Rajeshwari Shinde | 1c9412a | 2012-07-23 21:23:48 +0000 | [diff] [blame] | 1540 | } else { |
| 1541 | debug("I2C clock is not set for this CPU\n"); |
| 1542 | return 0; |
| 1543 | } |
| 1544 | } |
| 1545 | |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1546 | unsigned long get_pwm_clk(void) |
| 1547 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1548 | if (cpu_is_exynos5()) { |
| 1549 | if (proid_is_exynos5420()) |
| 1550 | return exynos5420_get_pwm_clk(); |
Padmavathi Venna | bb71416 | 2013-03-28 04:32:23 +0000 | [diff] [blame] | 1551 | return clock_get_periph_rate(PERIPH_ID_PWM0); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1552 | } else { |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1553 | if (proid_is_exynos4412()) |
| 1554 | return exynos4x12_get_pwm_clk(); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1555 | return exynos4_get_pwm_clk(); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1556 | } |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1557 | } |
| 1558 | |
| 1559 | unsigned long get_uart_clk(int dev_index) |
| 1560 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1561 | if (cpu_is_exynos5()) { |
| 1562 | if (proid_is_exynos5420()) |
| 1563 | return exynos5420_get_uart_clk(dev_index); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1564 | return exynos5_get_uart_clk(dev_index); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1565 | } else { |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1566 | if (proid_is_exynos4412()) |
| 1567 | return exynos4x12_get_uart_clk(dev_index); |
Chander Kashyap | 34076a0 | 2012-02-05 23:01:46 +0000 | [diff] [blame] | 1568 | return exynos4_get_uart_clk(dev_index); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1569 | } |
Minkyu Kang | b1b2468 | 2011-01-24 15:22:23 +0900 | [diff] [blame] | 1570 | } |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 1571 | |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 1572 | unsigned long get_mmc_clk(int dev_index) |
| 1573 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1574 | if (cpu_is_exynos5()) { |
| 1575 | if (proid_is_exynos5420()) |
| 1576 | return exynos5420_get_mmc_clk(dev_index); |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 1577 | return exynos5_get_mmc_clk(dev_index); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1578 | } else { |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 1579 | return exynos4_get_mmc_clk(dev_index); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1580 | } |
Jaehoon Chung | 8788e06 | 2012-12-27 22:30:32 +0000 | [diff] [blame] | 1581 | } |
| 1582 | |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 1583 | void set_mmc_clk(int dev_index, unsigned int div) |
| 1584 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1585 | if (cpu_is_exynos5()) { |
| 1586 | if (proid_is_exynos5420()) |
| 1587 | exynos5420_set_mmc_clk(dev_index, div); |
| 1588 | else |
| 1589 | exynos5_set_mmc_clk(dev_index, div); |
| 1590 | } else { |
Beomho Seo | 99660cc | 2014-05-16 13:59:47 +0900 | [diff] [blame^] | 1591 | exynos4_set_mmc_clk(dev_index, div); |
Chander Kashyap | 400ab16 | 2012-10-07 01:43:17 +0000 | [diff] [blame] | 1592 | } |
Jaehoon Chung | 9a77221 | 2011-05-17 21:19:17 +0000 | [diff] [blame] | 1593 | } |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1594 | |
| 1595 | unsigned long get_lcd_clk(void) |
| 1596 | { |
| 1597 | if (cpu_is_exynos4()) |
| 1598 | return exynos4_get_lcd_clk(); |
| 1599 | else |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1600 | return exynos5_get_lcd_clk(); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1601 | } |
| 1602 | |
| 1603 | void set_lcd_clk(void) |
| 1604 | { |
| 1605 | if (cpu_is_exynos4()) |
| 1606 | exynos4_set_lcd_clk(); |
Donghwa Lee | 3c9d453 | 2012-07-02 01:15:49 +0000 | [diff] [blame] | 1607 | else |
| 1608 | exynos5_set_lcd_clk(); |
Donghwa Lee | 77ba191 | 2012-04-05 19:36:12 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | void set_mipi_clk(void) |
| 1612 | { |
| 1613 | if (cpu_is_exynos4()) |
| 1614 | exynos4_set_mipi_clk(); |
| 1615 | } |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1616 | |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 1617 | int set_spi_clk(int periph_id, unsigned int rate) |
| 1618 | { |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1619 | if (cpu_is_exynos5()) { |
| 1620 | if (proid_is_exynos5420()) |
| 1621 | return exynos5420_set_spi_clk(periph_id, rate); |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 1622 | return exynos5_set_spi_clk(periph_id, rate); |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1623 | } else { |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 1624 | return 0; |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 1625 | } |
Hatim RV | e6365b6 | 2012-11-02 01:15:34 +0000 | [diff] [blame] | 1626 | } |
| 1627 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1628 | int set_i2s_clk_prescaler(unsigned int src_frq, unsigned int dst_frq, |
| 1629 | unsigned int i2s_id) |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1630 | { |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1631 | if (cpu_is_exynos5()) |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1632 | return exynos5_set_i2s_clk_prescaler(src_frq, dst_frq, i2s_id); |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1633 | else |
| 1634 | return 0; |
| 1635 | } |
| 1636 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1637 | int set_i2s_clk_source(unsigned int i2s_id) |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1638 | { |
| 1639 | if (cpu_is_exynos5()) |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 1640 | return exynos5_set_i2s_clk_source(i2s_id); |
| 1641 | else |
| 1642 | return 0; |
Rajeshwari Shinde | 392a73a | 2012-10-25 19:49:29 +0000 | [diff] [blame] | 1643 | } |
| 1644 | |
| 1645 | int set_epll_clk(unsigned long rate) |
| 1646 | { |
| 1647 | if (cpu_is_exynos5()) |
| 1648 | return exynos5_set_epll_clk(rate); |
| 1649 | else |
| 1650 | return 0; |
| 1651 | } |