diff options
Diffstat (limited to 'arch/arm/mach-at91/at91sam926x_time.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam926x_time.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c index 358412f1f5f8..3a4bc2e1a65e 100644 --- a/arch/arm/mach-at91/at91sam926x_time.c +++ b/arch/arm/mach-at91/at91sam926x_time.c | |||
@@ -104,12 +104,38 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev) | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | static void at91sam926x_pit_suspend(struct clock_event_device *cedev) | ||
108 | { | ||
109 | /* Disable timer */ | ||
110 | pit_write(AT91_PIT_MR, 0); | ||
111 | } | ||
112 | |||
113 | static void at91sam926x_pit_reset(void) | ||
114 | { | ||
115 | /* Disable timer and irqs */ | ||
116 | pit_write(AT91_PIT_MR, 0); | ||
117 | |||
118 | /* Clear any pending interrupts, wait for PIT to stop counting */ | ||
119 | while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0) | ||
120 | cpu_relax(); | ||
121 | |||
122 | /* Start PIT but don't enable IRQ */ | ||
123 | pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); | ||
124 | } | ||
125 | |||
126 | static void at91sam926x_pit_resume(struct clock_event_device *cedev) | ||
127 | { | ||
128 | at91sam926x_pit_reset(); | ||
129 | } | ||
130 | |||
107 | static struct clock_event_device pit_clkevt = { | 131 | static struct clock_event_device pit_clkevt = { |
108 | .name = "pit", | 132 | .name = "pit", |
109 | .features = CLOCK_EVT_FEAT_PERIODIC, | 133 | .features = CLOCK_EVT_FEAT_PERIODIC, |
110 | .shift = 32, | 134 | .shift = 32, |
111 | .rating = 100, | 135 | .rating = 100, |
112 | .set_mode = pit_clkevt_mode, | 136 | .set_mode = pit_clkevt_mode, |
137 | .suspend = at91sam926x_pit_suspend, | ||
138 | .resume = at91sam926x_pit_resume, | ||
113 | }; | 139 | }; |
114 | 140 | ||
115 | 141 | ||
@@ -150,19 +176,6 @@ static struct irqaction at91sam926x_pit_irq = { | |||
150 | .irq = NR_IRQS_LEGACY + AT91_ID_SYS, | 176 | .irq = NR_IRQS_LEGACY + AT91_ID_SYS, |
151 | }; | 177 | }; |
152 | 178 | ||
153 | static void at91sam926x_pit_reset(void) | ||
154 | { | ||
155 | /* Disable timer and irqs */ | ||
156 | pit_write(AT91_PIT_MR, 0); | ||
157 | |||
158 | /* Clear any pending interrupts, wait for PIT to stop counting */ | ||
159 | while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0) | ||
160 | cpu_relax(); | ||
161 | |||
162 | /* Start PIT but don't enable IRQ */ | ||
163 | pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); | ||
164 | } | ||
165 | |||
166 | #ifdef CONFIG_OF | 179 | #ifdef CONFIG_OF |
167 | static struct of_device_id pit_timer_ids[] = { | 180 | static struct of_device_id pit_timer_ids[] = { |
168 | { .compatible = "atmel,at91sam9260-pit" }, | 181 | { .compatible = "atmel,at91sam9260-pit" }, |
@@ -211,7 +224,7 @@ static int __init of_at91sam926x_pit_init(void) | |||
211 | /* | 224 | /* |
212 | * Set up both clocksource and clockevent support. | 225 | * Set up both clocksource and clockevent support. |
213 | */ | 226 | */ |
214 | static void __init at91sam926x_pit_init(void) | 227 | void __init at91sam926x_pit_init(void) |
215 | { | 228 | { |
216 | unsigned long pit_rate; | 229 | unsigned long pit_rate; |
217 | unsigned bits; | 230 | unsigned bits; |
@@ -250,12 +263,6 @@ static void __init at91sam926x_pit_init(void) | |||
250 | clockevents_register_device(&pit_clkevt); | 263 | clockevents_register_device(&pit_clkevt); |
251 | } | 264 | } |
252 | 265 | ||
253 | static void at91sam926x_pit_suspend(void) | ||
254 | { | ||
255 | /* Disable timer */ | ||
256 | pit_write(AT91_PIT_MR, 0); | ||
257 | } | ||
258 | |||
259 | void __init at91sam926x_ioremap_pit(u32 addr) | 266 | void __init at91sam926x_ioremap_pit(u32 addr) |
260 | { | 267 | { |
261 | #if defined(CONFIG_OF) | 268 | #if defined(CONFIG_OF) |
@@ -272,9 +279,3 @@ void __init at91sam926x_ioremap_pit(u32 addr) | |||
272 | if (!pit_base_addr) | 279 | if (!pit_base_addr) |
273 | panic("Impossible to ioremap PIT\n"); | 280 | panic("Impossible to ioremap PIT\n"); |
274 | } | 281 | } |
275 | |||
276 | struct sys_timer at91sam926x_timer = { | ||
277 | .init = at91sam926x_pit_init, | ||
278 | .suspend = at91sam926x_pit_suspend, | ||
279 | .resume = at91sam926x_pit_reset, | ||
280 | }; | ||