diff options
Diffstat (limited to 'arch/arm/plat-s3c24xx/clock.c')
-rw-r--r-- | arch/arm/plat-s3c24xx/clock.c | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c index a005ddbd9ef3..bf2633bd3996 100644 --- a/arch/arm/plat-s3c24xx/clock.c +++ b/arch/arm/plat-s3c24xx/clock.c | |||
@@ -283,178 +283,7 @@ struct clk clk_usb_bus = { | |||
283 | .parent = &clk_upll, | 283 | .parent = &clk_upll, |
284 | }; | 284 | }; |
285 | 285 | ||
286 | /* clocks that could be registered by external code */ | ||
287 | 286 | ||
288 | static int s3c24xx_dclk_enable(struct clk *clk, int enable) | ||
289 | { | ||
290 | unsigned long dclkcon = __raw_readl(S3C24XX_DCLKCON); | ||
291 | |||
292 | if (enable) | ||
293 | dclkcon |= clk->ctrlbit; | ||
294 | else | ||
295 | dclkcon &= ~clk->ctrlbit; | ||
296 | |||
297 | __raw_writel(dclkcon, S3C24XX_DCLKCON); | ||
298 | |||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent) | ||
303 | { | ||
304 | unsigned long dclkcon; | ||
305 | unsigned int uclk; | ||
306 | |||
307 | if (parent == &clk_upll) | ||
308 | uclk = 1; | ||
309 | else if (parent == &clk_p) | ||
310 | uclk = 0; | ||
311 | else | ||
312 | return -EINVAL; | ||
313 | |||
314 | clk->parent = parent; | ||
315 | |||
316 | dclkcon = __raw_readl(S3C24XX_DCLKCON); | ||
317 | |||
318 | if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) { | ||
319 | if (uclk) | ||
320 | dclkcon |= S3C2410_DCLKCON_DCLK0_UCLK; | ||
321 | else | ||
322 | dclkcon &= ~S3C2410_DCLKCON_DCLK0_UCLK; | ||
323 | } else { | ||
324 | if (uclk) | ||
325 | dclkcon |= S3C2410_DCLKCON_DCLK1_UCLK; | ||
326 | else | ||
327 | dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK; | ||
328 | } | ||
329 | |||
330 | __raw_writel(dclkcon, S3C24XX_DCLKCON); | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static unsigned long s3c24xx_calc_div(struct clk *clk, unsigned long rate) | ||
336 | { | ||
337 | unsigned long div; | ||
338 | |||
339 | if ((rate == 0) || !clk->parent) | ||
340 | return 0; | ||
341 | |||
342 | div = clk_get_rate(clk->parent) / rate; | ||
343 | if (div < 2) | ||
344 | div = 2; | ||
345 | else if (div > 16) | ||
346 | div = 16; | ||
347 | |||
348 | return div; | ||
349 | } | ||
350 | |||
351 | static unsigned long s3c24xx_round_dclk_rate(struct clk *clk, | ||
352 | unsigned long rate) | ||
353 | { | ||
354 | unsigned long div = s3c24xx_calc_div(clk, rate); | ||
355 | |||
356 | if (div == 0) | ||
357 | return 0; | ||
358 | |||
359 | return clk_get_rate(clk->parent) / div; | ||
360 | } | ||
361 | |||
362 | static int s3c24xx_set_dclk_rate(struct clk *clk, unsigned long rate) | ||
363 | { | ||
364 | unsigned long mask, data, div = s3c24xx_calc_div(clk, rate); | ||
365 | |||
366 | if (div == 0) | ||
367 | return -EINVAL; | ||
368 | |||
369 | if (clk == &s3c24xx_dclk0) { | ||
370 | mask = S3C2410_DCLKCON_DCLK0_DIV_MASK | | ||
371 | S3C2410_DCLKCON_DCLK0_CMP_MASK; | ||
372 | data = S3C2410_DCLKCON_DCLK0_DIV(div) | | ||
373 | S3C2410_DCLKCON_DCLK0_CMP((div + 1) / 2); | ||
374 | } else if (clk == &s3c24xx_dclk1) { | ||
375 | mask = S3C2410_DCLKCON_DCLK1_DIV_MASK | | ||
376 | S3C2410_DCLKCON_DCLK1_CMP_MASK; | ||
377 | data = S3C2410_DCLKCON_DCLK1_DIV(div) | | ||
378 | S3C2410_DCLKCON_DCLK1_CMP((div + 1) / 2); | ||
379 | } else | ||
380 | return -EINVAL; | ||
381 | |||
382 | clk->rate = clk_get_rate(clk->parent) / div; | ||
383 | __raw_writel(((__raw_readl(S3C24XX_DCLKCON) & ~mask) | data), | ||
384 | S3C24XX_DCLKCON); | ||
385 | return clk->rate; | ||
386 | } | ||
387 | |||
388 | static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent) | ||
389 | { | ||
390 | unsigned long mask; | ||
391 | unsigned long source; | ||
392 | |||
393 | /* calculate the MISCCR setting for the clock */ | ||
394 | |||
395 | if (parent == &clk_xtal) | ||
396 | source = S3C2410_MISCCR_CLK0_MPLL; | ||
397 | else if (parent == &clk_upll) | ||
398 | source = S3C2410_MISCCR_CLK0_UPLL; | ||
399 | else if (parent == &clk_f) | ||
400 | source = S3C2410_MISCCR_CLK0_FCLK; | ||
401 | else if (parent == &clk_h) | ||
402 | source = S3C2410_MISCCR_CLK0_HCLK; | ||
403 | else if (parent == &clk_p) | ||
404 | source = S3C2410_MISCCR_CLK0_PCLK; | ||
405 | else if (clk == &s3c24xx_clkout0 && parent == &s3c24xx_dclk0) | ||
406 | source = S3C2410_MISCCR_CLK0_DCLK0; | ||
407 | else if (clk == &s3c24xx_clkout1 && parent == &s3c24xx_dclk1) | ||
408 | source = S3C2410_MISCCR_CLK0_DCLK0; | ||
409 | else | ||
410 | return -EINVAL; | ||
411 | |||
412 | clk->parent = parent; | ||
413 | |||
414 | if (clk == &s3c24xx_clkout0) | ||
415 | mask = S3C2410_MISCCR_CLK0_MASK; | ||
416 | else { | ||
417 | source <<= 4; | ||
418 | mask = S3C2410_MISCCR_CLK1_MASK; | ||
419 | } | ||
420 | |||
421 | s3c2410_modify_misccr(mask, source); | ||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | /* external clock definitions */ | ||
426 | |||
427 | struct clk s3c24xx_dclk0 = { | ||
428 | .name = "dclk0", | ||
429 | .id = -1, | ||
430 | .ctrlbit = S3C2410_DCLKCON_DCLK0EN, | ||
431 | .enable = s3c24xx_dclk_enable, | ||
432 | .set_parent = s3c24xx_dclk_setparent, | ||
433 | .set_rate = s3c24xx_set_dclk_rate, | ||
434 | .round_rate = s3c24xx_round_dclk_rate, | ||
435 | }; | ||
436 | |||
437 | struct clk s3c24xx_dclk1 = { | ||
438 | .name = "dclk1", | ||
439 | .id = -1, | ||
440 | .ctrlbit = S3C2410_DCLKCON_DCLK1EN, | ||
441 | .enable = s3c24xx_dclk_enable, | ||
442 | .set_parent = s3c24xx_dclk_setparent, | ||
443 | .set_rate = s3c24xx_set_dclk_rate, | ||
444 | .round_rate = s3c24xx_round_dclk_rate, | ||
445 | }; | ||
446 | |||
447 | struct clk s3c24xx_clkout0 = { | ||
448 | .name = "clkout0", | ||
449 | .id = -1, | ||
450 | .set_parent = s3c24xx_clkout_setparent, | ||
451 | }; | ||
452 | |||
453 | struct clk s3c24xx_clkout1 = { | ||
454 | .name = "clkout1", | ||
455 | .id = -1, | ||
456 | .set_parent = s3c24xx_clkout_setparent, | ||
457 | }; | ||
458 | 287 | ||
459 | struct clk s3c24xx_uclk = { | 288 | struct clk s3c24xx_uclk = { |
460 | .name = "uclk", | 289 | .name = "uclk", |