Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: AT91: Add DT support to AT91RM9200 System Timer

Based on AT91 PIT DT patch from Jean-Christophe PLAGNIOL-VILLARD.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

authored by

Joachim Eastwood and committed by
Jean-Christophe PLAGNIOL-VILLARD
454c46df 35ed3c7a

+67 -2
+6
Documentation/devicetree/bindings/arm/atmel-at91.txt
··· 7 7 - interrupts: Should contain interrupt for the PIT which is the IRQ line 8 8 shared across all System Controller members. 9 9 10 + System Timer (ST) required properties: 11 + - compatible: Should be "atmel,at91rm9200-st" 12 + - reg: Should contain registers location and length 13 + - interrupts: Should contain interrupt for the ST which is the IRQ line 14 + shared across all System Controller members. 15 + 10 16 TC/TCLIB Timer required properties: 11 17 - compatible: Should be "atmel,<chip>-pit". 12 18 <chip> can be "at91rm9200" or "at91sam9x5"
+61 -2
arch/arm/mach-at91/at91rm9200_time.c
··· 24 24 #include <linux/irq.h> 25 25 #include <linux/clockchips.h> 26 26 #include <linux/export.h> 27 + #include <linux/of.h> 28 + #include <linux/of_address.h> 29 + #include <linux/of_irq.h> 27 30 28 31 #include <asm/mach/time.h> 29 32 ··· 94 91 static struct irqaction at91rm9200_timer_irq = { 95 92 .name = "at91_tick", 96 93 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 97 - .handler = at91rm9200_timer_interrupt 94 + .handler = at91rm9200_timer_interrupt, 95 + .irq = NR_IRQS_LEGACY + AT91_ID_SYS, 98 96 }; 99 97 100 98 static cycle_t read_clk32k(struct clocksource *cs) ··· 183 179 void __iomem *at91_st_base; 184 180 EXPORT_SYMBOL_GPL(at91_st_base); 185 181 182 + #ifdef CONFIG_OF 183 + static struct of_device_id at91rm9200_st_timer_ids[] = { 184 + { .compatible = "atmel,at91rm9200-st" }, 185 + { /* sentinel */ } 186 + }; 187 + 188 + static int __init of_at91rm9200_st_init(void) 189 + { 190 + struct device_node *np; 191 + int ret; 192 + 193 + np = of_find_matching_node(NULL, at91rm9200_st_timer_ids); 194 + if (!np) 195 + goto err; 196 + 197 + at91_st_base = of_iomap(np, 0); 198 + if (!at91_st_base) 199 + goto node_err; 200 + 201 + /* Get the interrupts property */ 202 + ret = irq_of_parse_and_map(np, 0); 203 + if (!ret) 204 + goto ioremap_err; 205 + at91rm9200_timer_irq.irq = ret; 206 + 207 + of_node_put(np); 208 + 209 + return 0; 210 + 211 + ioremap_err: 212 + iounmap(at91_st_base); 213 + node_err: 214 + of_node_put(np); 215 + err: 216 + return -EINVAL; 217 + } 218 + #else 219 + static int __init of_at91rm9200_st_init(void) 220 + { 221 + return -EINVAL; 222 + } 223 + #endif 224 + 186 225 void __init at91rm9200_ioremap_st(u32 addr) 187 226 { 227 + #ifdef CONFIG_OF 228 + struct device_node *np; 229 + 230 + np = of_find_matching_node(NULL, at91rm9200_st_timer_ids); 231 + if (np) { 232 + of_node_put(np); 233 + return; 234 + } 235 + #endif 188 236 at91_st_base = ioremap(addr, 256); 189 237 if (!at91_st_base) 190 238 panic("Impossible to ioremap ST\n"); ··· 247 191 */ 248 192 void __init at91rm9200_timer_init(void) 249 193 { 194 + /* For device tree enabled device: initialize here */ 195 + of_at91rm9200_st_init(); 196 + 250 197 /* Disable all timer interrupts, and clear any pending ones */ 251 198 at91_st_write(AT91_ST_IDR, 252 199 AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS); 253 200 at91_st_read(AT91_ST_SR); 254 201 255 202 /* Make IRQs happen for the system timer */ 256 - setup_irq(NR_IRQS_LEGACY + AT91_ID_SYS, &at91rm9200_timer_irq); 203 + setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq); 257 204 258 205 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used 259 206 * directly for the clocksource and all clockevents, after adjusting