diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:21 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:45:57 -0500 |
commit | abe11ddea1d759f9995a9a4636c28c9b40856ca8 (patch) | |
tree | 53085d131ecbe7a810f9feadcba571f49a2e9465 | |
parent | 450dd430bf45ab212a91acfb9bed2528d17f30cd (diff) |
ARC: [plat-arcfpga]: Enabling DeviceTree for Angel4 board
* arc-uart platform device now populated dynamically, using
of_platform_populate() - applies to any other device whatsoever.
* uart in turn requires incore arc-intc to be also present in DT
* A irq-domain needs to be instantiated for IRQ requests by DT probed
device (e.g. arc-uart)
TODO: switch over to linear irq domain once all devs have been
transitioned to DT
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | Documentation/devicetree/bindings/arc/interrupts.txt | 24 | ||||
-rw-r--r-- | arch/arc/boot/dts/Makefile | 2 | ||||
-rw-r--r-- | arch/arc/boot/dts/angel4.dts | 55 | ||||
-rw-r--r-- | arch/arc/boot/dts/skeleton.dtsi | 12 | ||||
-rw-r--r-- | arch/arc/kernel/irq.c | 38 | ||||
-rw-r--r-- | arch/arc/plat-arcfpga/platform.c | 97 |
6 files changed, 170 insertions, 58 deletions
diff --git a/Documentation/devicetree/bindings/arc/interrupts.txt b/Documentation/devicetree/bindings/arc/interrupts.txt new file mode 100644 index 000000000000..9a5d562435ea --- /dev/null +++ b/Documentation/devicetree/bindings/arc/interrupts.txt | |||
@@ -0,0 +1,24 @@ | |||
1 | * ARC700 incore Interrupt Controller | ||
2 | |||
3 | The core interrupt controller provides 32 prioritised interrupts (2 levels) | ||
4 | to ARC700 core. | ||
5 | |||
6 | Properties: | ||
7 | |||
8 | - compatible: "snps,arc700-intc" | ||
9 | - interrupt-controller: This is an interrupt controller. | ||
10 | - #interrupt-cells: Must be <1>. | ||
11 | |||
12 | Single Cell "interrupts" property of a device specifies the IRQ number | ||
13 | between 0 to 31 | ||
14 | |||
15 | intc accessed via the special ARC AUX register interface, hence "reg" property | ||
16 | is not specified. | ||
17 | |||
18 | Example: | ||
19 | |||
20 | intc: interrupt-controller { | ||
21 | compatible = "snps,arc700-intc"; | ||
22 | interrupt-controller; | ||
23 | #interrupt-cells = <1>; | ||
24 | }; | ||
diff --git a/arch/arc/boot/dts/Makefile b/arch/arc/boot/dts/Makefile index 17dc7b8b05fa..5776835d583f 100644 --- a/arch/arc/boot/dts/Makefile +++ b/arch/arc/boot/dts/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # Built-in dtb | 1 | # Built-in dtb |
2 | builtindtb-y := skeleton | 2 | builtindtb-y := angel4 |
3 | 3 | ||
4 | ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),"") | 4 | ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),"") |
5 | builtindtb-y := $(patsubst "%",%,$(CONFIG_ARC_BUILTIN_DTB_NAME)) | 5 | builtindtb-y := $(patsubst "%",%,$(CONFIG_ARC_BUILTIN_DTB_NAME)) |
diff --git a/arch/arc/boot/dts/angel4.dts b/arch/arc/boot/dts/angel4.dts new file mode 100644 index 000000000000..4c188d5bc10c --- /dev/null +++ b/arch/arc/boot/dts/angel4.dts | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | /dts-v1/; | ||
9 | |||
10 | /include/ "skeleton.dtsi" | ||
11 | |||
12 | / { | ||
13 | compatible = "snps,arc-angel4"; | ||
14 | clock-frequency = <80000000>; /* 80 MHZ */ | ||
15 | #address-cells = <1>; | ||
16 | #size-cells = <1>; | ||
17 | interrupt-parent = <&intc>; | ||
18 | |||
19 | chosen { | ||
20 | bootargs = "console=ttyARC0,115200n8"; | ||
21 | }; | ||
22 | |||
23 | aliases { | ||
24 | serial0 = &arcuart0; | ||
25 | }; | ||
26 | |||
27 | memory { | ||
28 | device_type = "memory"; | ||
29 | reg = <0x00000000 0x10000000>; /* 256M */ | ||
30 | }; | ||
31 | |||
32 | fpga { | ||
33 | compatible = "simple-bus"; | ||
34 | #address-cells = <1>; | ||
35 | #size-cells = <1>; | ||
36 | |||
37 | /* child and parent address space 1:1 mapped */ | ||
38 | ranges; | ||
39 | |||
40 | intc: interrupt-controller { | ||
41 | compatible = "snps,arc700-intc"; | ||
42 | interrupt-controller; | ||
43 | #interrupt-cells = <1>; | ||
44 | }; | ||
45 | |||
46 | arcuart0: serial@c0fc1000 { | ||
47 | compatible = "snps,arc-uart"; | ||
48 | reg = <0xc0fc1000 0x100>; | ||
49 | interrupts = <5>; | ||
50 | clock-frequency = <80000000>; | ||
51 | baud = <115200>; | ||
52 | status = "okay"; | ||
53 | }; | ||
54 | }; | ||
55 | }; | ||
diff --git a/arch/arc/boot/dts/skeleton.dtsi b/arch/arc/boot/dts/skeleton.dtsi index eb8b77367352..a870bdd5e404 100644 --- a/arch/arc/boot/dts/skeleton.dtsi +++ b/arch/arc/boot/dts/skeleton.dtsi | |||
@@ -18,6 +18,18 @@ | |||
18 | #size-cells = <1>; | 18 | #size-cells = <1>; |
19 | chosen { }; | 19 | chosen { }; |
20 | aliases { }; | 20 | aliases { }; |
21 | |||
22 | cpus { | ||
23 | #address-cells = <1>; | ||
24 | #size-cells = <0>; | ||
25 | |||
26 | cpu@0 { | ||
27 | device_type = "cpu"; | ||
28 | compatible = "snps,arc770d"; | ||
29 | reg = <0>; | ||
30 | }; | ||
31 | }; | ||
32 | |||
21 | memory { | 33 | memory { |
22 | device_type = "memory"; | 34 | device_type = "memory"; |
23 | reg = <0x00000000 0x10000000>; /* 256M */ | 35 | reg = <0x00000000 0x10000000>; /* 256M */ |
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c index 2f399eb88f9d..3c18e66386c7 100644 --- a/arch/arc/kernel/irq.c +++ b/arch/arc/kernel/irq.c | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/of.h> | ||
13 | #include <linux/irqdomain.h> | ||
12 | #include <asm/sections.h> | 14 | #include <asm/sections.h> |
13 | #include <asm/irq.h> | 15 | #include <asm/irq.h> |
14 | 16 | ||
@@ -59,16 +61,40 @@ static struct irq_chip onchip_intc = { | |||
59 | .irq_unmask = arc_unmask_irq, | 61 | .irq_unmask = arc_unmask_irq, |
60 | }; | 62 | }; |
61 | 63 | ||
64 | static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq, | ||
65 | irq_hw_number_t hw) | ||
66 | { | ||
67 | if (irq == TIMER0_IRQ) | ||
68 | irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq); | ||
69 | else | ||
70 | irq_set_chip_and_handler(irq, &onchip_intc, handle_level_irq); | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static const struct irq_domain_ops arc_intc_domain_ops = { | ||
76 | .xlate = irq_domain_xlate_onecell, | ||
77 | .map = arc_intc_domain_map, | ||
78 | }; | ||
79 | |||
80 | static struct irq_domain *root_domain; | ||
81 | |||
62 | void __init init_onchip_IRQ(void) | 82 | void __init init_onchip_IRQ(void) |
63 | { | 83 | { |
64 | int i; | 84 | struct device_node *intc = NULL; |
85 | |||
86 | intc = of_find_compatible_node(NULL, NULL, "snps,arc700-intc"); | ||
87 | if(!intc) | ||
88 | panic("DeviceTree Missing incore intc\n"); | ||
89 | |||
90 | root_domain = irq_domain_add_legacy(intc, NR_IRQS, 0, 0, | ||
91 | &arc_intc_domain_ops, NULL); | ||
65 | 92 | ||
66 | for (i = 0; i < NR_IRQS; i++) | 93 | if (!root_domain) |
67 | irq_set_chip_and_handler(i, &onchip_intc, handle_level_irq); | 94 | panic("root irq domain not avail\n"); |
68 | 95 | ||
69 | #ifdef CONFIG_SMP | 96 | /* with this we don't need to export root_domain */ |
70 | irq_set_chip_and_handler(TIMER0_IRQ, &onchip_intc, handle_percpu_irq); | 97 | irq_set_default_host(root_domain); |
71 | #endif | ||
72 | } | 98 | } |
73 | 99 | ||
74 | /* | 100 | /* |
diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 5388b31e2ead..33bcac8bd6b8 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/device.h> | 13 | #include <linux/device.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/console.h> | 15 | #include <linux/console.h> |
16 | #include <linux/of_platform.h> | ||
16 | #include <asm/setup.h> | 17 | #include <asm/setup.h> |
17 | #include <asm/irq.h> | 18 | #include <asm/irq.h> |
18 | #include <asm/clk.h> | 19 | #include <asm/clk.h> |
@@ -20,58 +21,56 @@ | |||
20 | 21 | ||
21 | /*----------------------- Platform Devices -----------------------------*/ | 22 | /*----------------------- Platform Devices -----------------------------*/ |
22 | 23 | ||
23 | #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) | ||
24 | |||
25 | static unsigned long arc_uart_info[] = { | 24 | static unsigned long arc_uart_info[] = { |
26 | CONFIG_ARC_SERIAL_BAUD, /* uart->baud */ | 25 | 0, /* uart->is_emulated (runtime @running_on_hw) */ |
27 | -1, /* uart->port.uartclk */ | 26 | 0, /* uart->port.uartclk */ |
28 | -1, /* uart->is_emulated (runtime @running_on_hw) */ | 27 | 0, /* uart->baud */ |
29 | 0 | 28 | 0 |
30 | }; | 29 | }; |
31 | 30 | ||
32 | #define ARC_UART_DEV(n) \ | 31 | #if defined(CONFIG_SERIAL_ARC_CONSOLE) |
33 | \ | 32 | /* |
34 | static struct resource arc_uart##n##_res[] = { \ | 33 | * static platform data - but only for early serial |
35 | { \ | 34 | * TBD: derive this from a special DT node |
36 | .start = UART##n##_BASE, \ | 35 | */ |
37 | .end = UART##n##_BASE + 0xFF, \ | 36 | static struct resource arc_uart0_res[] = { |
38 | .flags = IORESOURCE_MEM, \ | 37 | { |
39 | }, \ | 38 | .start = UART0_BASE, |
40 | { \ | 39 | .end = UART0_BASE + 0xFF, |
41 | .start = UART##n##_IRQ, \ | 40 | .flags = IORESOURCE_MEM, |
42 | .end = UART##n##_IRQ, \ | 41 | }, |
43 | .flags = IORESOURCE_IRQ, \ | 42 | { |
44 | }, \ | 43 | .start = UART0_IRQ, |
45 | }; \ | 44 | .end = UART0_IRQ, |
46 | \ | 45 | .flags = IORESOURCE_IRQ, |
47 | static struct platform_device arc_uart##n##_dev = { \ | 46 | }, |
48 | .name = "arc-uart", \ | 47 | }; |
49 | .id = n, \ | ||
50 | .num_resources = ARRAY_SIZE(arc_uart##n##_res), \ | ||
51 | .resource = arc_uart##n##_res, \ | ||
52 | .dev = { \ | ||
53 | .platform_data = &arc_uart_info, \ | ||
54 | }, \ | ||
55 | } | ||
56 | 48 | ||
57 | ARC_UART_DEV(0); | 49 | static struct platform_device arc_uart0_dev = { |
58 | #if CONFIG_SERIAL_ARC_NR_PORTS > 1 | 50 | .name = "arc-uart", |
59 | ARC_UART_DEV(1); | 51 | .id = 0, |
60 | #endif | 52 | .num_resources = ARRAY_SIZE(arc_uart0_res), |
53 | .resource = arc_uart0_res, | ||
54 | .dev = { | ||
55 | .platform_data = &arc_uart_info, | ||
56 | }, | ||
57 | }; | ||
61 | 58 | ||
62 | static struct platform_device *fpga_early_devs[] __initdata = { | 59 | static struct platform_device *fpga_early_devs[] __initdata = { |
63 | #if defined(CONFIG_SERIAL_ARC_CONSOLE) | ||
64 | &arc_uart0_dev, | 60 | &arc_uart0_dev, |
65 | #endif | ||
66 | }; | 61 | }; |
62 | #endif | ||
67 | 63 | ||
68 | static void arc_fpga_serial_init(void) | 64 | static void arc_fpga_serial_init(void) |
69 | { | 65 | { |
66 | /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */ | ||
67 | arc_uart_info[0] = !running_on_hw; | ||
68 | |||
70 | arc_uart_info[1] = arc_get_core_freq(); | 69 | arc_uart_info[1] = arc_get_core_freq(); |
71 | 70 | ||
72 | /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */ | 71 | arc_uart_info[2] = CONFIG_ARC_SERIAL_BAUD; |
73 | arc_uart_info[2] = !running_on_hw; | ||
74 | 72 | ||
73 | #if defined(CONFIG_SERIAL_ARC_CONSOLE) | ||
75 | early_platform_add_devices(fpga_early_devs, | 74 | early_platform_add_devices(fpga_early_devs, |
76 | ARRAY_SIZE(fpga_early_devs)); | 75 | ARRAY_SIZE(fpga_early_devs)); |
77 | 76 | ||
@@ -97,16 +96,9 @@ static void arc_fpga_serial_init(void) | |||
97 | * otherwise the early console never gets a chance to run. | 96 | * otherwise the early console never gets a chance to run. |
98 | */ | 97 | */ |
99 | add_preferred_console("ttyARC", 0, "115200"); | 98 | add_preferred_console("ttyARC", 0, "115200"); |
99 | #endif | ||
100 | } | 100 | } |
101 | 101 | ||
102 | #else | ||
103 | |||
104 | static void arc_fpga_serial_init(void) | ||
105 | { | ||
106 | } | ||
107 | |||
108 | #endif /* CONFIG_SERIAL_ARC */ | ||
109 | |||
110 | /* | 102 | /* |
111 | * Early Platform Initialization called from setup_arch() | 103 | * Early Platform Initialization called from setup_arch() |
112 | */ | 104 | */ |
@@ -117,20 +109,23 @@ void __init arc_platform_early_init(void) | |||
117 | arc_fpga_serial_init(); | 109 | arc_fpga_serial_init(); |
118 | } | 110 | } |
119 | 111 | ||
120 | static struct platform_device *fpga_devs[] __initdata = { | 112 | static struct of_dev_auxdata plat_auxdata_lookup[] __initdata = { |
121 | #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) | 113 | #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) |
122 | &arc_uart0_dev, | 114 | OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info), |
123 | #if CONFIG_SERIAL_ARC_NR_PORTS > 1 | ||
124 | &arc_uart1_dev, | ||
125 | #endif | ||
126 | #endif | 115 | #endif |
116 | {} | ||
127 | }; | 117 | }; |
128 | 118 | ||
129 | int __init fpga_plat_init(void) | 119 | int __init fpga_plat_init(void) |
130 | { | 120 | { |
131 | pr_info("[plat-arcfpga]: registering device resources\n"); | 121 | pr_info("[plat-arcfpga]: registering device resources\n"); |
132 | 122 | ||
133 | platform_add_devices(fpga_devs, ARRAY_SIZE(fpga_devs)); | 123 | /* |
124 | * Traverses flattened DeviceTree - registering platform devices | ||
125 | * complete with their resources | ||
126 | */ | ||
127 | of_platform_populate(NULL, of_default_bus_match_table, | ||
128 | plat_auxdata_lookup, NULL); | ||
134 | 129 | ||
135 | return 0; | 130 | return 0; |
136 | } | 131 | } |