From ebd3cad74cf06ba5f0a033918dce03150d33308d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Wed, 4 Dec 2013 11:29:37 +0800 Subject: [PATCH] ARM: rockchip: fiq-debugger: better support device tree --- arch/arm/boot/dts/rk3188-tb.dts | 7 ++-- arch/arm/boot/dts/rk3188.dtsi | 9 ++-- arch/arm/mach-rockchip/rk_fiq_debugger.c | 52 +++++++++++++----------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/arch/arm/boot/dts/rk3188-tb.dts b/arch/arm/boot/dts/rk3188-tb.dts index 6659ed1d4c05..705fecb77ef2 100644 --- a/arch/arm/boot/dts/rk3188-tb.dts +++ b/arch/arm/boot/dts/rk3188-tb.dts @@ -9,11 +9,12 @@ }; chosen { - + bootargs = ""; }; - ttyFIQ0 { - id = <2>; + fiq-debugger { + serial-id = <2>; + status = "okay"; }; }; diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi index 96c0b297fe59..4b16e0f0c69c 100755 --- a/arch/arm/boot/dts/rk3188.dtsi +++ b/arch/arm/boot/dts/rk3188.dtsi @@ -417,10 +417,11 @@ 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"; }; }; diff --git a/arch/arm/mach-rockchip/rk_fiq_debugger.c b/arch/arm/mach-rockchip/rk_fiq_debugger.c index 7e8c9251ad90..99397cd5dca6 100644 --- a/arch/arm/mach-rockchip/rk_fiq_debugger.c +++ b/arch/arm/mach-rockchip/rk_fiq_debugger.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -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; } -- 2.34.1