blob: d607ac2d516bda0cddbee933b833e48735727707 [file] [log] [blame]
Magnus Damm3fb1b6a2009-01-22 09:55:59 +00001/*
2 * SuperH Timer Support - CMT
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/init.h>
21#include <linux/bootmem.h>
22#include <linux/platform_device.h>
23#include <linux/spinlock.h>
24#include <linux/interrupt.h>
25#include <linux/ioport.h>
26#include <linux/io.h>
27#include <linux/clk.h>
28#include <linux/irq.h>
29#include <linux/err.h>
30#include <linux/clocksource.h>
31#include <linux/clockchips.h>
32#include <linux/sh_cmt.h>
33
34struct sh_cmt_priv {
35 void __iomem *mapbase;
36 struct clk *clk;
37 unsigned long width; /* 16 or 32 bit version of hardware block */
38 unsigned long overflow_bit;
39 unsigned long clear_bits;
40 struct irqaction irqaction;
41 struct platform_device *pdev;
42
43 unsigned long flags;
44 unsigned long match_value;
45 unsigned long next_match_value;
46 unsigned long max_match_value;
47 unsigned long rate;
48 spinlock_t lock;
49 struct clock_event_device ced;
Magnus Damm19bdc9d2009-04-17 05:26:31 +000050 struct clocksource cs;
Magnus Damm3fb1b6a2009-01-22 09:55:59 +000051 unsigned long total_cycles;
52};
53
54static DEFINE_SPINLOCK(sh_cmt_lock);
55
56#define CMSTR -1 /* shared register */
57#define CMCSR 0 /* channel register */
58#define CMCNT 1 /* channel register */
59#define CMCOR 2 /* channel register */
60
61static inline unsigned long sh_cmt_read(struct sh_cmt_priv *p, int reg_nr)
62{
63 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
64 void __iomem *base = p->mapbase;
65 unsigned long offs;
66
67 if (reg_nr == CMSTR) {
68 offs = 0;
69 base -= cfg->channel_offset;
70 } else
71 offs = reg_nr;
72
73 if (p->width == 16)
74 offs <<= 1;
75 else {
76 offs <<= 2;
77 if ((reg_nr == CMCNT) || (reg_nr == CMCOR))
78 return ioread32(base + offs);
79 }
80
81 return ioread16(base + offs);
82}
83
84static inline void sh_cmt_write(struct sh_cmt_priv *p, int reg_nr,
85 unsigned long value)
86{
87 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
88 void __iomem *base = p->mapbase;
89 unsigned long offs;
90
91 if (reg_nr == CMSTR) {
92 offs = 0;
93 base -= cfg->channel_offset;
94 } else
95 offs = reg_nr;
96
97 if (p->width == 16)
98 offs <<= 1;
99 else {
100 offs <<= 2;
101 if ((reg_nr == CMCNT) || (reg_nr == CMCOR)) {
102 iowrite32(value, base + offs);
103 return;
104 }
105 }
106
107 iowrite16(value, base + offs);
108}
109
110static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
111 int *has_wrapped)
112{
113 unsigned long v1, v2, v3;
Magnus Damm5b644c72009-04-28 08:17:54 +0000114 int o1, o2;
115
116 o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000117
118 /* Make sure the timer value is stable. Stolen from acpi_pm.c */
119 do {
Magnus Damm5b644c72009-04-28 08:17:54 +0000120 o2 = o1;
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000121 v1 = sh_cmt_read(p, CMCNT);
122 v2 = sh_cmt_read(p, CMCNT);
123 v3 = sh_cmt_read(p, CMCNT);
Magnus Damm5b644c72009-04-28 08:17:54 +0000124 o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;
125 } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3)
126 || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000127
Magnus Damm5b644c72009-04-28 08:17:54 +0000128 *has_wrapped = o1;
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000129 return v2;
130}
131
132
133static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
134{
135 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
136 unsigned long flags, value;
137
138 /* start stop register shared by multiple timer channels */
139 spin_lock_irqsave(&sh_cmt_lock, flags);
140 value = sh_cmt_read(p, CMSTR);
141
142 if (start)
143 value |= 1 << cfg->timer_bit;
144 else
145 value &= ~(1 << cfg->timer_bit);
146
147 sh_cmt_write(p, CMSTR, value);
148 spin_unlock_irqrestore(&sh_cmt_lock, flags);
149}
150
151static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
152{
153 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
154 int ret;
155
156 /* enable clock */
157 ret = clk_enable(p->clk);
158 if (ret) {
159 pr_err("sh_cmt: cannot enable clock \"%s\"\n", cfg->clk);
160 return ret;
161 }
162 *rate = clk_get_rate(p->clk) / 8;
163
164 /* make sure channel is disabled */
165 sh_cmt_start_stop_ch(p, 0);
166
167 /* configure channel, periodic mode and maximum timeout */
168 if (p->width == 16)
169 sh_cmt_write(p, CMCSR, 0);
170 else
171 sh_cmt_write(p, CMCSR, 0x01a4);
172
173 sh_cmt_write(p, CMCOR, 0xffffffff);
174 sh_cmt_write(p, CMCNT, 0);
175
176 /* enable channel */
177 sh_cmt_start_stop_ch(p, 1);
178 return 0;
179}
180
181static void sh_cmt_disable(struct sh_cmt_priv *p)
182{
183 /* disable channel */
184 sh_cmt_start_stop_ch(p, 0);
185
186 /* stop clock */
187 clk_disable(p->clk);
188}
189
190/* private flags */
191#define FLAG_CLOCKEVENT (1 << 0)
192#define FLAG_CLOCKSOURCE (1 << 1)
193#define FLAG_REPROGRAM (1 << 2)
194#define FLAG_SKIPEVENT (1 << 3)
195#define FLAG_IRQCONTEXT (1 << 4)
196
197static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
198 int absolute)
199{
200 unsigned long new_match;
201 unsigned long value = p->next_match_value;
202 unsigned long delay = 0;
203 unsigned long now = 0;
204 int has_wrapped;
205
206 now = sh_cmt_get_counter(p, &has_wrapped);
207 p->flags |= FLAG_REPROGRAM; /* force reprogram */
208
209 if (has_wrapped) {
210 /* we're competing with the interrupt handler.
211 * -> let the interrupt handler reprogram the timer.
212 * -> interrupt number two handles the event.
213 */
214 p->flags |= FLAG_SKIPEVENT;
215 return;
216 }
217
218 if (absolute)
219 now = 0;
220
221 do {
222 /* reprogram the timer hardware,
223 * but don't save the new match value yet.
224 */
225 new_match = now + value + delay;
226 if (new_match > p->max_match_value)
227 new_match = p->max_match_value;
228
229 sh_cmt_write(p, CMCOR, new_match);
230
231 now = sh_cmt_get_counter(p, &has_wrapped);
232 if (has_wrapped && (new_match > p->match_value)) {
233 /* we are changing to a greater match value,
234 * so this wrap must be caused by the counter
235 * matching the old value.
236 * -> first interrupt reprograms the timer.
237 * -> interrupt number two handles the event.
238 */
239 p->flags |= FLAG_SKIPEVENT;
240 break;
241 }
242
243 if (has_wrapped) {
244 /* we are changing to a smaller match value,
245 * so the wrap must be caused by the counter
246 * matching the new value.
247 * -> save programmed match value.
248 * -> let isr handle the event.
249 */
250 p->match_value = new_match;
251 break;
252 }
253
254 /* be safe: verify hardware settings */
255 if (now < new_match) {
256 /* timer value is below match value, all good.
257 * this makes sure we won't miss any match events.
258 * -> save programmed match value.
259 * -> let isr handle the event.
260 */
261 p->match_value = new_match;
262 break;
263 }
264
265 /* the counter has reached a value greater
266 * than our new match value. and since the
267 * has_wrapped flag isn't set we must have
268 * programmed a too close event.
269 * -> increase delay and retry.
270 */
271 if (delay)
272 delay <<= 1;
273 else
274 delay = 1;
275
276 if (!delay)
277 pr_warning("sh_cmt: too long delay\n");
278
279 } while (delay);
280}
281
282static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
283{
284 unsigned long flags;
285
286 if (delta > p->max_match_value)
287 pr_warning("sh_cmt: delta out of range\n");
288
289 spin_lock_irqsave(&p->lock, flags);
290 p->next_match_value = delta;
291 sh_cmt_clock_event_program_verify(p, 0);
292 spin_unlock_irqrestore(&p->lock, flags);
293}
294
295static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id)
296{
297 struct sh_cmt_priv *p = dev_id;
298
299 /* clear flags */
300 sh_cmt_write(p, CMCSR, sh_cmt_read(p, CMCSR) & p->clear_bits);
301
302 /* update clock source counter to begin with if enabled
303 * the wrap flag should be cleared by the timer specific
304 * isr before we end up here.
305 */
306 if (p->flags & FLAG_CLOCKSOURCE)
307 p->total_cycles += p->match_value;
308
309 if (!(p->flags & FLAG_REPROGRAM))
310 p->next_match_value = p->max_match_value;
311
312 p->flags |= FLAG_IRQCONTEXT;
313
314 if (p->flags & FLAG_CLOCKEVENT) {
315 if (!(p->flags & FLAG_SKIPEVENT)) {
316 if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) {
317 p->next_match_value = p->max_match_value;
318 p->flags |= FLAG_REPROGRAM;
319 }
320
321 p->ced.event_handler(&p->ced);
322 }
323 }
324
325 p->flags &= ~FLAG_SKIPEVENT;
326
327 if (p->flags & FLAG_REPROGRAM) {
328 p->flags &= ~FLAG_REPROGRAM;
329 sh_cmt_clock_event_program_verify(p, 1);
330
331 if (p->flags & FLAG_CLOCKEVENT)
332 if ((p->ced.mode == CLOCK_EVT_MODE_SHUTDOWN)
333 || (p->match_value == p->next_match_value))
334 p->flags &= ~FLAG_REPROGRAM;
335 }
336
337 p->flags &= ~FLAG_IRQCONTEXT;
338
339 return IRQ_HANDLED;
340}
341
342static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag)
343{
344 int ret = 0;
345 unsigned long flags;
346
347 spin_lock_irqsave(&p->lock, flags);
348
349 if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
350 ret = sh_cmt_enable(p, &p->rate);
351
352 if (ret)
353 goto out;
354 p->flags |= flag;
355
356 /* setup timeout if no clockevent */
357 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT)))
358 sh_cmt_set_next(p, p->max_match_value);
359 out:
360 spin_unlock_irqrestore(&p->lock, flags);
361
362 return ret;
363}
364
365static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag)
366{
367 unsigned long flags;
368 unsigned long f;
369
370 spin_lock_irqsave(&p->lock, flags);
371
372 f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE);
373 p->flags &= ~flag;
374
375 if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
376 sh_cmt_disable(p);
377
378 /* adjust the timeout to maximum if only clocksource left */
379 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE))
380 sh_cmt_set_next(p, p->max_match_value);
381
382 spin_unlock_irqrestore(&p->lock, flags);
383}
384
Magnus Damm19bdc9d2009-04-17 05:26:31 +0000385static struct sh_cmt_priv *cs_to_sh_cmt(struct clocksource *cs)
386{
387 return container_of(cs, struct sh_cmt_priv, cs);
388}
389
390static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
391{
392 struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
393 unsigned long flags, raw;
394 unsigned long value;
395 int has_wrapped;
396
397 spin_lock_irqsave(&p->lock, flags);
398 value = p->total_cycles;
399 raw = sh_cmt_get_counter(p, &has_wrapped);
400
401 if (unlikely(has_wrapped))
Magnus Damm5b644c72009-04-28 08:17:54 +0000402 raw += p->match_value;
Magnus Damm19bdc9d2009-04-17 05:26:31 +0000403 spin_unlock_irqrestore(&p->lock, flags);
404
405 return value + raw;
406}
407
408static int sh_cmt_clocksource_enable(struct clocksource *cs)
409{
410 struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
411 int ret;
412
413 p->total_cycles = 0;
414
415 ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
416 if (ret)
417 return ret;
418
419 /* TODO: calculate good shift from rate and counter bit width */
420 cs->shift = 0;
421 cs->mult = clocksource_hz2mult(p->rate, cs->shift);
422 return 0;
423}
424
425static void sh_cmt_clocksource_disable(struct clocksource *cs)
426{
427 sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
428}
429
430static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
431 char *name, unsigned long rating)
432{
433 struct clocksource *cs = &p->cs;
434
435 cs->name = name;
436 cs->rating = rating;
437 cs->read = sh_cmt_clocksource_read;
438 cs->enable = sh_cmt_clocksource_enable;
439 cs->disable = sh_cmt_clocksource_disable;
440 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
441 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
442 pr_info("sh_cmt: %s used as clock source\n", cs->name);
443 clocksource_register(cs);
444 return 0;
445}
446
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000447static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced)
448{
449 return container_of(ced, struct sh_cmt_priv, ced);
450}
451
452static void sh_cmt_clock_event_start(struct sh_cmt_priv *p, int periodic)
453{
454 struct clock_event_device *ced = &p->ced;
455
456 sh_cmt_start(p, FLAG_CLOCKEVENT);
457
458 /* TODO: calculate good shift from rate and counter bit width */
459
460 ced->shift = 32;
461 ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);
462 ced->max_delta_ns = clockevent_delta2ns(p->max_match_value, ced);
463 ced->min_delta_ns = clockevent_delta2ns(0x1f, ced);
464
465 if (periodic)
466 sh_cmt_set_next(p, (p->rate + HZ/2) / HZ);
467 else
468 sh_cmt_set_next(p, p->max_match_value);
469}
470
471static void sh_cmt_clock_event_mode(enum clock_event_mode mode,
472 struct clock_event_device *ced)
473{
474 struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
475
476 /* deal with old setting first */
477 switch (ced->mode) {
478 case CLOCK_EVT_MODE_PERIODIC:
479 case CLOCK_EVT_MODE_ONESHOT:
480 sh_cmt_stop(p, FLAG_CLOCKEVENT);
481 break;
482 default:
483 break;
484 }
485
486 switch (mode) {
487 case CLOCK_EVT_MODE_PERIODIC:
488 pr_info("sh_cmt: %s used for periodic clock events\n",
489 ced->name);
490 sh_cmt_clock_event_start(p, 1);
491 break;
492 case CLOCK_EVT_MODE_ONESHOT:
493 pr_info("sh_cmt: %s used for oneshot clock events\n",
494 ced->name);
495 sh_cmt_clock_event_start(p, 0);
496 break;
497 case CLOCK_EVT_MODE_SHUTDOWN:
498 case CLOCK_EVT_MODE_UNUSED:
499 sh_cmt_stop(p, FLAG_CLOCKEVENT);
500 break;
501 default:
502 break;
503 }
504}
505
506static int sh_cmt_clock_event_next(unsigned long delta,
507 struct clock_event_device *ced)
508{
509 struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
510
511 BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT);
512 if (likely(p->flags & FLAG_IRQCONTEXT))
513 p->next_match_value = delta;
514 else
515 sh_cmt_set_next(p, delta);
516
517 return 0;
518}
519
520static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
521 char *name, unsigned long rating)
522{
523 struct clock_event_device *ced = &p->ced;
524
525 memset(ced, 0, sizeof(*ced));
526
527 ced->name = name;
528 ced->features = CLOCK_EVT_FEAT_PERIODIC;
529 ced->features |= CLOCK_EVT_FEAT_ONESHOT;
530 ced->rating = rating;
531 ced->cpumask = cpumask_of(0);
532 ced->set_next_event = sh_cmt_clock_event_next;
533 ced->set_mode = sh_cmt_clock_event_mode;
534
535 pr_info("sh_cmt: %s used for clock events\n", ced->name);
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000536 clockevents_register_device(ced);
537}
538
539int sh_cmt_register(struct sh_cmt_priv *p, char *name,
540 unsigned long clockevent_rating,
541 unsigned long clocksource_rating)
542{
543 if (p->width == (sizeof(p->max_match_value) * 8))
544 p->max_match_value = ~0;
545 else
546 p->max_match_value = (1 << p->width) - 1;
547
548 p->match_value = p->max_match_value;
549 spin_lock_init(&p->lock);
550
551 if (clockevent_rating)
552 sh_cmt_register_clockevent(p, name, clockevent_rating);
553
Magnus Damm19bdc9d2009-04-17 05:26:31 +0000554 if (clocksource_rating)
555 sh_cmt_register_clocksource(p, name, clocksource_rating);
556
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000557 return 0;
558}
559
560static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
561{
562 struct sh_cmt_config *cfg = pdev->dev.platform_data;
563 struct resource *res;
564 int irq, ret;
565 ret = -ENXIO;
566
567 memset(p, 0, sizeof(*p));
568 p->pdev = pdev;
569
570 if (!cfg) {
571 dev_err(&p->pdev->dev, "missing platform data\n");
572 goto err0;
573 }
574
575 platform_set_drvdata(pdev, p);
576
577 res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
578 if (!res) {
579 dev_err(&p->pdev->dev, "failed to get I/O memory\n");
580 goto err0;
581 }
582
583 irq = platform_get_irq(p->pdev, 0);
584 if (irq < 0) {
585 dev_err(&p->pdev->dev, "failed to get irq\n");
586 goto err0;
587 }
588
589 /* map memory, let mapbase point to our channel */
590 p->mapbase = ioremap_nocache(res->start, resource_size(res));
591 if (p->mapbase == NULL) {
592 pr_err("sh_cmt: failed to remap I/O memory\n");
593 goto err0;
594 }
595
596 /* request irq using setup_irq() (too early for request_irq()) */
597 p->irqaction.name = cfg->name;
598 p->irqaction.handler = sh_cmt_interrupt;
599 p->irqaction.dev_id = p;
600 p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
601 p->irqaction.mask = CPU_MASK_NONE;
602 ret = setup_irq(irq, &p->irqaction);
603 if (ret) {
604 pr_err("sh_cmt: failed to request irq %d\n", irq);
605 goto err1;
606 }
607
608 /* get hold of clock */
609 p->clk = clk_get(&p->pdev->dev, cfg->clk);
610 if (IS_ERR(p->clk)) {
611 pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk);
612 ret = PTR_ERR(p->clk);
613 goto err2;
614 }
615
616 if (resource_size(res) == 6) {
617 p->width = 16;
618 p->overflow_bit = 0x80;
619 p->clear_bits = ~0xc0;
620 } else {
621 p->width = 32;
622 p->overflow_bit = 0x8000;
623 p->clear_bits = ~0xc000;
624 }
625
626 return sh_cmt_register(p, cfg->name,
627 cfg->clockevent_rating,
628 cfg->clocksource_rating);
629 err2:
Magnus Damm3093e782009-04-01 14:11:07 +0000630 remove_irq(irq, &p->irqaction);
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000631 err1:
632 iounmap(p->mapbase);
633 err0:
634 return ret;
635}
636
637static int __devinit sh_cmt_probe(struct platform_device *pdev)
638{
639 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
Magnus Damme475eed2009-04-15 10:50:04 +0000640 struct sh_cmt_config *cfg = pdev->dev.platform_data;
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000641 int ret;
642
Magnus Damme475eed2009-04-15 10:50:04 +0000643 if (p) {
644 pr_info("sh_cmt: %s kept as earlytimer\n", cfg->name);
645 return 0;
646 }
647
648 if (is_early_platform_device(pdev))
649 p = alloc_bootmem(sizeof(*p));
650 else
651 p = kmalloc(sizeof(*p), GFP_KERNEL);
652
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000653 if (p == NULL) {
654 dev_err(&pdev->dev, "failed to allocate driver data\n");
655 return -ENOMEM;
656 }
657
658 ret = sh_cmt_setup(p, pdev);
659 if (ret) {
Magnus Damme475eed2009-04-15 10:50:04 +0000660 if (is_early_platform_device(pdev))
661 free_bootmem(__pa(p), sizeof(*p));
662 else
663 kfree(p);
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000664
665 platform_set_drvdata(pdev, NULL);
666 }
667 return ret;
668}
669
670static int __devexit sh_cmt_remove(struct platform_device *pdev)
671{
672 return -EBUSY; /* cannot unregister clockevent and clocksource */
673}
674
675static struct platform_driver sh_cmt_device_driver = {
676 .probe = sh_cmt_probe,
677 .remove = __devexit_p(sh_cmt_remove),
678 .driver = {
679 .name = "sh_cmt",
680 }
681};
682
683static int __init sh_cmt_init(void)
684{
685 return platform_driver_register(&sh_cmt_device_driver);
686}
687
688static void __exit sh_cmt_exit(void)
689{
690 platform_driver_unregister(&sh_cmt_device_driver);
691}
692
Magnus Damme475eed2009-04-15 10:50:04 +0000693early_platform_init("earlytimer", &sh_cmt_device_driver);
Magnus Damm3fb1b6a2009-01-22 09:55:59 +0000694module_init(sh_cmt_init);
695module_exit(sh_cmt_exit);
696
697MODULE_AUTHOR("Magnus Damm");
698MODULE_DESCRIPTION("SuperH CMT Timer Driver");
699MODULE_LICENSE("GPL v2");