aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc/plat-arcfpga/platform.c
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-01-18 04:42:21 -0500
committerVineet Gupta <vgupta@synopsys.com>2013-02-15 12:45:57 -0500
commitabe11ddea1d759f9995a9a4636c28c9b40856ca8 (patch)
tree53085d131ecbe7a810f9feadcba571f49a2e9465 /arch/arc/plat-arcfpga/platform.c
parent450dd430bf45ab212a91acfb9bed2528d17f30cd (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>
Diffstat (limited to 'arch/arc/plat-arcfpga/platform.c')
-rw-r--r--arch/arc/plat-arcfpga/platform.c97
1 files changed, 46 insertions, 51 deletions
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
25static unsigned long arc_uart_info[] = { 24static 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/*
34static 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, \ 36static 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,
47static 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
57ARC_UART_DEV(0); 49static struct platform_device arc_uart0_dev = {
58#if CONFIG_SERIAL_ARC_NR_PORTS > 1 50 .name = "arc-uart",
59ARC_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
62static struct platform_device *fpga_early_devs[] __initdata = { 59static 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
68static void arc_fpga_serial_init(void) 64static 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
104static 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
120static struct platform_device *fpga_devs[] __initdata = { 112static 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
129int __init fpga_plat_init(void) 119int __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}