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:19 -0400
commitde693461bf9624ec12808f8c5524510364cc2a43 (patch)
treea70316a3c82329956d7e591bb23ba8a91a7953cd
parent84876d0505b15a2907696566a80a365993feab44 (diff)
clocksource: sh_tmu: Add memory base to sh_tmu_channel structure
The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
-rw-r--r--drivers/clocksource/sh_tmu.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 2c64e3f93f16..a464ed868a68 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -40,6 +40,7 @@ struct sh_tmu_device;
40struct sh_tmu_channel { 40struct sh_tmu_channel {
41 struct sh_tmu_device *tmu; 41 struct sh_tmu_device *tmu;
42 42
43 void __iomem *base;
43 int irq; 44 int irq;
44 45
45 unsigned long rate; 46 unsigned long rate;
@@ -68,39 +69,35 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock);
68 69
69static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) 70static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr)
70{ 71{
71 struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data;
72 void __iomem *base = ch->tmu->mapbase;
73 unsigned long offs; 72 unsigned long offs;
74 73
75 if (reg_nr == TSTR) 74 if (reg_nr == TSTR)
76 return ioread8(base - cfg->channel_offset); 75 return ioread8(ch->tmu->mapbase);
77 76
78 offs = reg_nr << 2; 77 offs = reg_nr << 2;
79 78
80 if (reg_nr == TCR) 79 if (reg_nr == TCR)
81 return ioread16(base + offs); 80 return ioread16(ch->base + offs);
82 else 81 else
83 return ioread32(base + offs); 82 return ioread32(ch->base + offs);
84} 83}
85 84
86static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, 85static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr,
87 unsigned long value) 86 unsigned long value)
88{ 87{
89 struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data;
90 void __iomem *base = ch->tmu->mapbase;
91 unsigned long offs; 88 unsigned long offs;
92 89
93 if (reg_nr == TSTR) { 90 if (reg_nr == TSTR) {
94 iowrite8(value, base - cfg->channel_offset); 91 iowrite8(value, ch->tmu->mapbase);
95 return; 92 return;
96 } 93 }
97 94
98 offs = reg_nr << 2; 95 offs = reg_nr << 2;
99 96
100 if (reg_nr == TCR) 97 if (reg_nr == TCR)
101 iowrite16(value, base + offs); 98 iowrite16(value, ch->base + offs);
102 else 99 else
103 iowrite32(value, base + offs); 100 iowrite32(value, ch->base + offs);
104} 101}
105 102
106static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) 103static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
@@ -481,13 +478,18 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
481 goto err0; 478 goto err0;
482 } 479 }
483 480
484 /* map memory, let mapbase point to our channel */ 481 /*
485 tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); 482 * Map memory, let channel.base point to our channel and mapbase to the
486 if (tmu->mapbase == NULL) { 483 * start/stop shared register.
484 */
485 tmu->channel.base = ioremap_nocache(res->start, resource_size(res));
486 if (tmu->channel.base == NULL) {
487 dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); 487 dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n");
488 goto err0; 488 goto err0;
489 } 489 }
490 490
491 tmu->mapbase = tmu->channel.base - cfg->channel_offset;
492
491 /* get hold of clock */ 493 /* get hold of clock */
492 tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); 494 tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck");
493 if (IS_ERR(tmu->clk)) { 495 if (IS_ERR(tmu->clk)) {
@@ -511,7 +513,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
511 err2: 513 err2:
512 clk_put(tmu->clk); 514 clk_put(tmu->clk);
513 err1: 515 err1:
514 iounmap(tmu->mapbase); 516 iounmap(tmu->channel.base);
515 err0: 517 err0:
516 return ret; 518 return ret;
517} 519}