aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
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:20 -0400
commitfe68eb802ef8bf034735f37cb561ab814fb3b0d6 (patch)
tree356310622afae96696047d2ecc68f76a1ff725f0 /drivers/clocksource
parentde693461bf9624ec12808f8c5524510364cc2a43 (diff)
clocksource: sh_tmu: Add index to struct sh_tmu_channel
Use the index as the timer start/stop bit and when printing messages to identify the channel. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/sh_tmu.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index a464ed868a68..e30430439bb1 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -39,6 +39,7 @@ struct sh_tmu_device;
39 39
40struct sh_tmu_channel { 40struct sh_tmu_channel {
41 struct sh_tmu_device *tmu; 41 struct sh_tmu_device *tmu;
42 unsigned int index;
42 43
43 void __iomem *base; 44 void __iomem *base;
44 int irq; 45 int irq;
@@ -102,7 +103,6 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr,
102 103
103static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) 104static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
104{ 105{
105 struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data;
106 unsigned long flags, value; 106 unsigned long flags, value;
107 107
108 /* start stop register shared by multiple timer channels */ 108 /* start stop register shared by multiple timer channels */
@@ -110,9 +110,9 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
110 value = sh_tmu_read(ch, TSTR); 110 value = sh_tmu_read(ch, TSTR);
111 111
112 if (start) 112 if (start)
113 value |= 1 << cfg->timer_bit; 113 value |= 1 << ch->index;
114 else 114 else
115 value &= ~(1 << cfg->timer_bit); 115 value &= ~(1 << ch->index);
116 116
117 sh_tmu_write(ch, TSTR, value); 117 sh_tmu_write(ch, TSTR, value);
118 raw_spin_unlock_irqrestore(&sh_tmu_lock, flags); 118 raw_spin_unlock_irqrestore(&sh_tmu_lock, flags);
@@ -125,7 +125,8 @@ static int __sh_tmu_enable(struct sh_tmu_channel *ch)
125 /* enable clock */ 125 /* enable clock */
126 ret = clk_enable(ch->tmu->clk); 126 ret = clk_enable(ch->tmu->clk);
127 if (ret) { 127 if (ret) {
128 dev_err(&ch->tmu->pdev->dev, "cannot enable clock\n"); 128 dev_err(&ch->tmu->pdev->dev, "ch%u: cannot enable clock\n",
129 ch->index);
129 return ret; 130 return ret;
130 } 131 }
131 132
@@ -303,7 +304,8 @@ static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch,
303 cs->mask = CLOCKSOURCE_MASK(32); 304 cs->mask = CLOCKSOURCE_MASK(32);
304 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; 305 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
305 306
306 dev_info(&ch->tmu->pdev->dev, "used as clock source\n"); 307 dev_info(&ch->tmu->pdev->dev, "ch%u: used as clock source\n",
308 ch->index);
307 309
308 /* Register with dummy 1 Hz value, gets updated in ->enable() */ 310 /* Register with dummy 1 Hz value, gets updated in ->enable() */
309 clocksource_register_hz(cs, 1); 311 clocksource_register_hz(cs, 1);
@@ -349,12 +351,12 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode,
349 switch (mode) { 351 switch (mode) {
350 case CLOCK_EVT_MODE_PERIODIC: 352 case CLOCK_EVT_MODE_PERIODIC:
351 dev_info(&ch->tmu->pdev->dev, 353 dev_info(&ch->tmu->pdev->dev,
352 "used for periodic clock events\n"); 354 "ch%u: used for periodic clock events\n", ch->index);
353 sh_tmu_clock_event_start(ch, 1); 355 sh_tmu_clock_event_start(ch, 1);
354 break; 356 break;
355 case CLOCK_EVT_MODE_ONESHOT: 357 case CLOCK_EVT_MODE_ONESHOT:
356 dev_info(&ch->tmu->pdev->dev, 358 dev_info(&ch->tmu->pdev->dev,
357 "used for oneshot clock events\n"); 359 "ch%u: used for oneshot clock events\n", ch->index);
358 sh_tmu_clock_event_start(ch, 0); 360 sh_tmu_clock_event_start(ch, 0);
359 break; 361 break;
360 case CLOCK_EVT_MODE_UNUSED: 362 case CLOCK_EVT_MODE_UNUSED:
@@ -407,7 +409,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch,
407 ced->suspend = sh_tmu_clock_event_suspend; 409 ced->suspend = sh_tmu_clock_event_suspend;
408 ced->resume = sh_tmu_clock_event_resume; 410 ced->resume = sh_tmu_clock_event_resume;
409 411
410 dev_info(&ch->tmu->pdev->dev, "used for clock events\n"); 412 dev_info(&ch->tmu->pdev->dev, "ch%u: used for clock events\n",
413 ch->index);
411 414
412 clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); 415 clockevents_config_and_register(ced, 1, 0x300, 0xffffffff);
413 416
@@ -415,8 +418,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch,
415 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, 418 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
416 dev_name(&ch->tmu->pdev->dev), ch); 419 dev_name(&ch->tmu->pdev->dev), ch);
417 if (ret) { 420 if (ret) {
418 dev_err(&ch->tmu->pdev->dev, "failed to request irq %d\n", 421 dev_err(&ch->tmu->pdev->dev, "ch%u: failed to request irq %d\n",
419 ch->irq); 422 ch->index, ch->irq);
420 return; 423 return;
421 } 424 }
422} 425}
@@ -441,9 +444,19 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch,
441 memset(ch, 0, sizeof(*ch)); 444 memset(ch, 0, sizeof(*ch));
442 ch->tmu = tmu; 445 ch->tmu = tmu;
443 446
447 /*
448 * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps channel
449 * registers blocks at base + 2 + 12 * index, while all other variants
450 * map them at base + 4 + 12 * index. We can compute the index by just
451 * dividing by 12, the 2 bytes or 4 bytes offset being hidden by the
452 * integer division.
453 */
454 ch->index = cfg->channel_offset / 12;
455
444 ch->irq = platform_get_irq(tmu->pdev, 0); 456 ch->irq = platform_get_irq(tmu->pdev, 0);
445 if (ch->irq < 0) { 457 if (ch->irq < 0) {
446 dev_err(&tmu->pdev->dev, "failed to get irq\n"); 458 dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n",
459 ch->index);
447 return ch->irq; 460 return ch->irq;
448 } 461 }
449 462