ARM: rockchip: fiq-debugger: better support device tree
author黄涛 <huangtao@rock-chips.com>
Wed, 4 Dec 2013 03:29:37 +0000 (11:29 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 4 Dec 2013 03:29:37 +0000 (11:29 +0800)
arch/arm/boot/dts/rk3188-tb.dts
arch/arm/boot/dts/rk3188.dtsi
arch/arm/mach-rockchip/rk_fiq_debugger.c

index 6659ed1d4c0535db41db598e704c3fc7d3495293..705fecb77ef20dcec9ce79b2439822f8f4306870 100644 (file)
@@ -9,11 +9,12 @@
        };
 
        chosen {
-
+               bootargs = "";
        };
 
-       ttyFIQ0 {
-               id = <2>;
+       fiq-debugger {
+               serial-id = <2>;
+               status = "okay";
        };
 };
 
index 96c0b297fe5958a8bf3152aad6889cd1b34cd8bb..4b16e0f0c69c175f34b49dad818ffb971a0b737a 100755 (executable)
                status = "disabled";
        };
 
-       ttyFIQ0 {
-               id = <2>;
-               signal_irq = <112>;
-               wake_irq = <0>;
+       fiq-debugger {
+               compatible = "rockchip,fiq-debugger";
+               serial-id = <2>;
+               signal-irq = <112>;
+               wake-irq = <0>;
                status = "disabled";
        };
 };
index 7e8c9251ad90b42e164d6101f6f272525fd1c676..99397cd5dca62c56df8794116e654118b69703ac 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/interrupt.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
@@ -287,53 +288,58 @@ out2:
        kfree(t);
 }
 
+static const struct of_device_id ids[] __initconst = {
+       { .compatible = "rockchip,fiq-debugger" },
+       {}
+};
+
 static int __init rk_fiq_debugger_init(void) {
 
        void __iomem *base;
-       u32 out_values[6] = {0};
-       struct device_node *from = NULL;
-       unsigned int i = 0, id = 0, serial_id = 0, ok = 0;
-       u32 irq = 32, signal_irq = 0, wake_irq = 0;
-       
-       from = of_find_node_by_name(from, "ttyFIQ0");
-       
-       if(!from) {
-               printk("ttyFIQ0 is missing in device tree!\n");
+       struct device_node *np;
+       unsigned int i, id, serial_id, ok = 0;
+       u32 irq, signal_irq = 0, wake_irq = 0;
+
+       np = of_find_matching_node(NULL, ids);
+
+       if (!np) {
+               printk("fiq-debugger is missing in device tree!\n");
                return -ENODEV;
        }
                
-       if(of_property_read_u32(from, "id", &id)) {
+       if (of_property_read_u32(np, "serial-id", &serial_id)) {
                return -EINVAL; 
        }
 
-       if(of_property_read_u32(from, "signal_irq", &signal_irq)) {
+       if (of_property_read_u32(np, "signal-irq", &signal_irq)) {
                signal_irq = -1;
        }
 
-       if(of_property_read_u32(from, "wake_irq", &wake_irq)) {
+       if (of_property_read_u32(np, "wake-irq", &wake_irq)) {
                wake_irq = -1;
        }
        
-       from = NULL;
-       for(i = 0; i < 5; i++) {
-               from = of_find_node_by_name(from, "serial");
-               if(from && !of_property_read_u32(from, "id", &serial_id)) {
-                       if(id == serial_id) {
+       np = NULL;
+       for (i = 0; i < 5; i++) {
+               np = of_find_node_by_name(np, "serial");
+               if (np && !of_property_read_u32(np, "id", &id)) {
+                       if (id == serial_id) {
                                ok = 1;
                                break;
                        }
                }
        }
-       
-       if(ok != 1)
+       if (!ok)
                return -EINVAL;
 
-       if(of_property_read_u32_array(from, "interrupts", out_values, 3))
+       irq = irq_of_parse_and_map(np, 0);
+       if (!irq)
                return -EINVAL;
-       irq += *(out_values + 1);
-       base = of_iomap(from, 0);
-       if(base)
+
+       base = of_iomap(np, 0);
+       if (base)
                rk_serial_debug_init(base, irq, signal_irq, wake_irq);
+
        return 0;
 }