aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/jmr3927
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2007-10-24 12:34:09 -0400
committerRalf Baechle <ralf@linux-mips.org>2007-10-29 15:35:35 -0400
commit229f773ef4ee852ad7bfbe8e1238a2c35b2baa6f (patch)
tree44d9dd3f2be845140024883db13ab879b4ce1f2e /arch/mips/jmr3927
parent22df3f53e33d55335e1ef43d4e6ead54b379b3a2 (diff)
[MIPS] txx9tmr clockevent/clocksource driver
Convert jmr3927_clock_event_device to more generic txx9tmr_clock_event_device which supports one-shot mode. The txx9tmr_clock_event_device can be used for TX49 too if the cp0 timer interrupt was not available. Convert jmr3927_hpt_read to txx9_clocksource driver which does not depends jiffies anymore. The txx9_clocksource itself can be used for TX49, but normally TX49 uses higher precision clocksource_mips. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/jmr3927')
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c83
1 files changed, 7 insertions, 76 deletions
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index edb9e59248ec..06e01c8f4e3a 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -27,17 +27,13 @@
27 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) 27 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
28 */ 28 */
29 29
30#include <linux/clockchips.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/kdev_t.h> 32#include <linux/kdev_t.h>
34#include <linux/types.h> 33#include <linux/types.h>
35#include <linux/sched.h>
36#include <linux/pci.h> 34#include <linux/pci.h>
37#include <linux/ide.h> 35#include <linux/ide.h>
38#include <linux/irq.h>
39#include <linux/ioport.h> 36#include <linux/ioport.h>
40#include <linux/param.h> /* for HZ */
41#include <linux/delay.h> 37#include <linux/delay.h>
42#include <linux/pm.h> 38#include <linux/pm.h>
43#include <linux/platform_device.h> 39#include <linux/platform_device.h>
@@ -48,17 +44,13 @@
48#endif 44#endif
49 45
50#include <asm/addrspace.h> 46#include <asm/addrspace.h>
51#include <asm/time.h> 47#include <asm/txx9tmr.h>
52#include <asm/reboot.h> 48#include <asm/reboot.h>
53#include <asm/jmr3927/jmr3927.h> 49#include <asm/jmr3927/jmr3927.h>
54#include <asm/mipsregs.h> 50#include <asm/mipsregs.h>
55 51
56extern void puts(const char *cp); 52extern void puts(const char *cp);
57 53
58/* Tick Timer divider */
59#define JMR3927_TIMER_CCD 0 /* 1/2 */
60#define JMR3927_TIMER_CLK (JMR3927_IMCLK / (2 << JMR3927_TIMER_CCD))
61
62/* don't enable - see errata */ 54/* don't enable - see errata */
63static int jmr3927_ccfg_toeon; 55static int jmr3927_ccfg_toeon;
64 56
@@ -93,66 +85,12 @@ static void jmr3927_machine_power_off(void)
93 while (1); 85 while (1);
94} 86}
95 87
96static cycle_t jmr3927_hpt_read(void)
97{
98 /* We assume this function is called xtime_lock held. */
99 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
100}
101
102static void jmr3927_set_mode(enum clock_event_mode mode,
103 struct clock_event_device *evt)
104{
105 /* Nothing to do here */
106}
107
108struct clock_event_device jmr3927_clock_event_device = {
109 .name = "MIPS",
110 .features = CLOCK_EVT_FEAT_PERIODIC,
111 .shift = 32,
112 .rating = 300,
113 .cpumask = CPU_MASK_CPU0,
114 .irq = JMR3927_IRQ_TICK,
115 .set_mode = jmr3927_set_mode,
116};
117
118static irqreturn_t jmr3927_timer_interrupt(int irq, void *dev_id)
119{
120 struct clock_event_device *cd = &jmr3927_clock_event_device;
121
122 jmr3927_tmrptr->tisr = 0; /* ack interrupt */
123
124 cd->event_handler(cd);
125
126 return IRQ_HANDLED;
127}
128
129static struct irqaction jmr3927_timer_irqaction = {
130 .handler = jmr3927_timer_interrupt,
131 .flags = IRQF_DISABLED | IRQF_PERCPU,
132 .name = "jmr3927-timer",
133};
134
135void __init plat_time_init(void) 88void __init plat_time_init(void)
136{ 89{
137 struct clock_event_device *cd; 90 txx9_clockevent_init(TX3927_TMR_REG(0),
138 91 TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0),
139 clocksource_mips.read = jmr3927_hpt_read; 92 JMR3927_IMCLK);
140 mips_hpt_frequency = JMR3927_TIMER_CLK; 93 txx9_clocksource_init(TX3927_TMR_REG(1), JMR3927_IMCLK);
141
142 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ;
143 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE;
144 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD;
145 jmr3927_tmrptr->tcr =
146 TXx927_TMTCR_TCE | TXx927_TMTCR_CCDE | TXx927_TMTCR_TMODE_ITVL;
147
148 cd = &jmr3927_clock_event_device;
149 /* Calculate the min / max delta */
150 cd->mult = div_sc((unsigned long) JMR3927_IMCLK, NSEC_PER_SEC, 32);
151 cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd);
152 cd->min_delta_ns = clockevent_delta2ns(0x300, cd);
153 clockevents_register_device(cd);
154
155 setup_irq(JMR3927_IRQ_TICK, &jmr3927_timer_irqaction);
156} 94}
157 95
158#define DO_WRITE_THROUGH 96#define DO_WRITE_THROUGH
@@ -317,15 +255,8 @@ static void __init tx3927_setup(void)
317 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg); 255 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg);
318 256
319 /* TMR */ 257 /* TMR */
320 /* disable all timers */ 258 for (i = 0; i < TX3927_NR_TMR; i++)
321 for (i = 0; i < TX3927_NR_TMR; i++) { 259 txx9_tmr_init(TX3927_TMR_REG(i));
322 tx3927_tmrptr(i)->tcr = TXx927_TMTCR_CRE;
323 tx3927_tmrptr(i)->tisr = 0;
324 tx3927_tmrptr(i)->cpra = 0xffffffff;
325 tx3927_tmrptr(i)->itmr = 0;
326 tx3927_tmrptr(i)->ccdr = 0;
327 tx3927_tmrptr(i)->pgmr = 0;
328 }
329 260
330 /* DMA */ 261 /* DMA */
331 tx3927_dmaptr->mcr = 0; 262 tx3927_dmaptr->mcr = 0;