aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2014-01-27 16:04:17 -0500
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2014-04-16 06:03:21 -0400
commita5de49f436e2bc498c1d13f6f8a9afaf19cb5f95 (patch)
treec65d02c25839094dc81dc418d70a98669a0f27ce
parent3b77a83eeabb885c5fff02756eba50f446a2d83c (diff)
clocksource: sh_tmu: Allocate channels dynamically
This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
-rw-r--r--drivers/clocksource/sh_tmu.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 26a9f7dadfbc..55b7a37f0c9b 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -58,7 +58,8 @@ struct sh_tmu_device {
58 void __iomem *mapbase; 58 void __iomem *mapbase;
59 struct clk *clk; 59 struct clk *clk;
60 60
61 struct sh_tmu_channel channel; 61 struct sh_tmu_channel *channels;
62 unsigned int num_channels;
62}; 63};
63 64
64static DEFINE_RAW_SPINLOCK(sh_tmu_lock); 65static DEFINE_RAW_SPINLOCK(sh_tmu_lock);
@@ -469,6 +470,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
469{ 470{
470 struct sh_timer_config *cfg = pdev->dev.platform_data; 471 struct sh_timer_config *cfg = pdev->dev.platform_data;
471 struct resource *res; 472 struct resource *res;
473 void __iomem *base;
472 int ret; 474 int ret;
473 ret = -ENXIO; 475 ret = -ENXIO;
474 476
@@ -488,16 +490,16 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
488 } 490 }
489 491
490 /* 492 /*
491 * Map memory, let channel.base point to our channel and mapbase to the 493 * Map memory, let base point to our channel and mapbase to the
492 * start/stop shared register. 494 * start/stop shared register.
493 */ 495 */
494 tmu->channel.base = ioremap_nocache(res->start, resource_size(res)); 496 base = ioremap_nocache(res->start, resource_size(res));
495 if (tmu->channel.base == NULL) { 497 if (base == NULL) {
496 dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); 498 dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n");
497 goto err0; 499 goto err0;
498 } 500 }
499 501
500 tmu->mapbase = tmu->channel.base - cfg->channel_offset; 502 tmu->mapbase = base - cfg->channel_offset;
501 503
502 /* get hold of clock */ 504 /* get hold of clock */
503 tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); 505 tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck");
@@ -511,18 +513,29 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
511 if (ret < 0) 513 if (ret < 0)
512 goto err2; 514 goto err2;
513 515
514 ret = sh_tmu_channel_setup(&tmu->channel, tmu); 516 tmu->channels = kzalloc(sizeof(*tmu->channels), GFP_KERNEL);
517 if (tmu->channels == NULL) {
518 ret = -ENOMEM;
519 goto err3;
520 }
521
522 tmu->num_channels = 1;
523
524 tmu->channels[0].base = base;
525
526 ret = sh_tmu_channel_setup(&tmu->channels[0], tmu);
515 if (ret < 0) 527 if (ret < 0)
516 goto err3; 528 goto err3;
517 529
518 return 0; 530 return 0;
519 531
520 err3: 532 err3:
533 kfree(tmu->channels);
521 clk_unprepare(tmu->clk); 534 clk_unprepare(tmu->clk);
522 err2: 535 err2:
523 clk_put(tmu->clk); 536 clk_put(tmu->clk);
524 err1: 537 err1:
525 iounmap(tmu->channel.base); 538 iounmap(base);
526 err0: 539 err0:
527 return ret; 540 return ret;
528} 541}