aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJon Hunter <jon-hunter@ti.com>2012-06-05 13:34:59 -0400
committerTony Lindgren <tony@atomide.com>2012-06-14 05:39:47 -0400
commit2b2d35230099613365ad6000f4d71086130b9e71 (patch)
tree6ac2f7db9822cb94949f6822ff327139d7c4f155 /arch
parentbca4580845cbffb455d77783fc7e58a94b3904e0 (diff)
ARM: OMAP2+: Move dmtimer clock set function to dmtimer driver
OMAP1 uses an architecture specific function for setting the dmtimer clock source, where as the OMAP2+ devices use the clock framework. Eventually OMAP1 device should also use the clock framework and hence we should not any architecture specific functions. For now move the OMAP2+ function for configuring the clock source into the dmtimer driver. Therefore, we do no longer need to specify an architecture specific function for setting the clock source for OMAP2+ devices. This will simplify device tree migration of the dmtimers for OMAP2+ devices. From now on, only OMAP1 devices should specify an architecture specific function for setting the clock source via the platform data set_dmtimer_src() function pointer. Signed-off-by: Jon Hunter <jon-hunter@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/timer.c55
-rw-r--r--arch/arm/plat-omap/dmtimer.c46
-rw-r--r--arch/arm/plat-omap/include/plat/dmtimer.h1
3 files changed, 46 insertions, 56 deletions
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 0e17a0d9690b..8fe75a81e12d 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -390,59 +390,6 @@ OMAP_SYS_TIMER(4)
390#endif 390#endif
391 391
392/** 392/**
393 * omap2_dm_timer_set_src - change the timer input clock source
394 * @pdev: timer platform device pointer
395 * @source: array index of parent clock source
396 */
397static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
398{
399 int ret;
400 struct clk *fclk, *parent;
401 char *parent_name = NULL;
402
403 fclk = clk_get(&pdev->dev, "fck");
404 if (IS_ERR_OR_NULL(fclk)) {
405 dev_err(&pdev->dev, "%s: %d: clk_get() FAILED\n",
406 __func__, __LINE__);
407 return -EINVAL;
408 }
409
410 switch (source) {
411 case OMAP_TIMER_SRC_SYS_CLK:
412 parent_name = "sys_ck";
413 break;
414
415 case OMAP_TIMER_SRC_32_KHZ:
416 parent_name = "32k_ck";
417 break;
418
419 case OMAP_TIMER_SRC_EXT_CLK:
420 parent_name = "alt_ck";
421 break;
422 }
423
424 parent = clk_get(&pdev->dev, parent_name);
425 if (IS_ERR_OR_NULL(parent)) {
426 dev_err(&pdev->dev, "%s: %d: clk_get() %s FAILED\n",
427 __func__, __LINE__, parent_name);
428 clk_put(fclk);
429 return -EINVAL;
430 }
431
432 ret = clk_set_parent(fclk, parent);
433 if (IS_ERR_VALUE(ret)) {
434 dev_err(&pdev->dev, "%s: clk_set_parent() to %s FAILED\n",
435 __func__, parent_name);
436 ret = -EINVAL;
437 }
438
439 clk_put(parent);
440 clk_put(fclk);
441
442 return ret;
443}
444
445/**
446 * omap_timer_init - build and register timer device with an 393 * omap_timer_init - build and register timer device with an
447 * associated timer hwmod 394 * associated timer hwmod
448 * @oh: timer hwmod pointer to be used to build timer device 395 * @oh: timer hwmod pointer to be used to build timer device
@@ -489,8 +436,6 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
489 */ 436 */
490 sscanf(oh->name, "timer%2d", &id); 437 sscanf(oh->name, "timer%2d", &id);
491 438
492 pdata->set_timer_src = omap2_dm_timer_set_src;
493
494 if (timer_dev_attr) 439 if (timer_dev_attr)
495 pdata->timer_capability = timer_dev_attr->timer_capability; 440 pdata->timer_capability = timer_dev_attr->timer_capability;
496 441
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 6510e5e7b7e3..6a7088972c55 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -397,6 +397,8 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
397int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) 397int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
398{ 398{
399 int ret; 399 int ret;
400 char *parent_name = NULL;
401 struct clk *fclk, *parent;
400 struct dmtimer_platform_data *pdata; 402 struct dmtimer_platform_data *pdata;
401 403
402 if (unlikely(!timer)) 404 if (unlikely(!timer))
@@ -407,7 +409,49 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
407 if (source < 0 || source >= 3) 409 if (source < 0 || source >= 3)
408 return -EINVAL; 410 return -EINVAL;
409 411
410 ret = pdata->set_timer_src(timer->pdev, source); 412 /*
413 * FIXME: Used for OMAP1 devices only because they do not currently
414 * use the clock framework to set the parent clock. To be removed
415 * once OMAP1 migrated to using clock framework for dmtimers
416 */
417 if (pdata->set_timer_src)
418 return pdata->set_timer_src(timer->pdev, source);
419
420 fclk = clk_get(&timer->pdev->dev, "fck");
421 if (IS_ERR_OR_NULL(fclk)) {
422 pr_err("%s: fck not found\n", __func__);
423 return -EINVAL;
424 }
425
426 switch (source) {
427 case OMAP_TIMER_SRC_SYS_CLK:
428 parent_name = "sys_ck";
429 break;
430
431 case OMAP_TIMER_SRC_32_KHZ:
432 parent_name = "32k_ck";
433 break;
434
435 case OMAP_TIMER_SRC_EXT_CLK:
436 parent_name = "alt_ck";
437 break;
438 }
439
440 parent = clk_get(&timer->pdev->dev, parent_name);
441 if (IS_ERR_OR_NULL(parent)) {
442 pr_err("%s: %s not found\n", __func__, parent_name);
443 ret = -EINVAL;
444 goto out;
445 }
446
447 ret = clk_set_parent(fclk, parent);
448 if (IS_ERR_VALUE(ret))
449 pr_err("%s: failed to set %s as parent\n", __func__,
450 parent_name);
451
452 clk_put(parent);
453out:
454 clk_put(fclk);
411 455
412 return ret; 456 return ret;
413} 457}
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index c039e84bca7e..19e7fa577bd0 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -90,6 +90,7 @@ struct timer_regs {
90}; 90};
91 91
92struct dmtimer_platform_data { 92struct dmtimer_platform_data {
93 /* set_timer_src - Only used for OMAP1 devices */
93 int (*set_timer_src)(struct platform_device *pdev, int source); 94 int (*set_timer_src)(struct platform_device *pdev, int source);
94 u32 timer_capability; 95 u32 timer_capability;
95}; 96};