]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: at91: pit add DT support
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Fri, 14 Oct 2011 01:40:52 +0000 (09:40 +0800)
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Thu, 24 Nov 2011 19:30:18 +0000 (03:30 +0800)
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Documentation/devicetree/bindings/arm/at91.txt [new file with mode: 0644]
arch/arm/boot/dts/at91sam9g20.dtsi
arch/arm/boot/dts/at91sam9g45.dtsi
arch/arm/mach-at91/at91sam926x_time.c

diff --git a/Documentation/devicetree/bindings/arm/at91.txt b/Documentation/devicetree/bindings/arm/at91.txt
new file mode 100644 (file)
index 0000000..cdefffd
--- /dev/null
@@ -0,0 +1,7 @@
+Atmel AT91 device tree bindings.
+========================================
+
+PIT Timers required properties:
+    - compatible = "atmel,at91sam9260-pit"
+    - interrupts : The single IRQ line for the timer.
+    - reg : The register bank for the timer.
index aeef04269cf85edfb1259de7c64453b1bfb2e843..410ae6e8f53569f236fe360d58a0f4e256adeeae 100644 (file)
                                reg = <0xfffff000 0x200>;
                        };
 
+                       pit: timer@fffffd30 {
+                               compatible = "atmel,at91sam9260-pit";
+                               reg = <0xfffffd30 0xf>;
+                               interrupts = <1>;
+                       };
+
                        dbgu: serial@fffff200 {
                                compatible = "atmel,at91sam9260-usart";
                                reg = <0xfffff200 0x200>;
index db6a45202f26b44c6911c359902ad5e0504cbc25..a09b102cc3aed8244b13226fc7e3973a230853fa 100644 (file)
                                reg = <0xfffff000 0x200>;
                        };
 
+                       pit: timer@fffffd30 {
+                               compatible = "atmel,at91sam9260-pit";
+                               reg = <0xfffffd30 0xf>;
+                               interrupts = <1>;
+                       };
+
                        dma: dma-controller@ffffec00 {
                                compatible = "atmel,at91sam9g45-dma";
                                reg = <0xffffec00 0x200>;
index d89ead740a99756b51492064eb7b3922226526e2..d4b80ec0184de230294986e05d82ae2ea24b7f7d 100644 (file)
@@ -14,6 +14,8 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/clockchips.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <asm/mach/time.h>
 
@@ -133,7 +135,8 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 static struct irqaction at91sam926x_pit_irq = {
        .name           = "at91_tick",
        .flags          = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
-       .handler        = at91sam926x_pit_interrupt
+       .handler        = at91sam926x_pit_interrupt,
+       .irq            = AT91_ID_SYS,
 };
 
 static void at91sam926x_pit_reset(void)
@@ -149,6 +152,39 @@ static void at91sam926x_pit_reset(void)
        pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id timer_ids[] = {
+       { .compatible = "atmel,at91sam9260-pit" },
+};
+
+int __init of_at91sam926x_pit_init(void)
+{
+       struct device_node *np;
+       const unsigned int *intspec;
+
+       np = of_find_matching_node(NULL, timer_ids);
+       if (!np)
+               return -EINVAL;
+       pit_base_addr = of_iomap(np, 0);
+       if (!pit_base_addr)
+               return -EINVAL;
+
+       /* Get the interrupts property */
+       intspec = of_get_property(np, "interrupts", NULL);
+       BUG_ON(!intspec);
+       at91sam926x_pit_irq.irq = be32_to_cpup(intspec);
+
+       of_node_put(np);
+
+       return 0;
+}
+#else
+static int __init of_at91sam926x_pit_init(void)
+{
+       return -EINVAL;
+}
+#endif
+
 /*
  * Set up both clocksource and clockevent support.
  */
@@ -177,7 +213,7 @@ static void __init at91sam926x_pit_init(void)
        clocksource_register_hz(&pit_clk, pit_rate);
 
        /* Set up irq handler */
-       setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq);
+       setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
 
        /* Set up and register clockevents */
        pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
@@ -193,6 +229,8 @@ static void at91sam926x_pit_suspend(void)
 
 void __init at91sam926x_ioremap_pit(u32 addr)
 {
+       if (!of_at91sam926x_pit_init())
+               return;
        pit_base_addr = ioremap(addr, 16);
 
        if (!pit_base_addr)