aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc/plat-arcfpga/platform.c
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-01-18 04:42:20 -0500
committerVineet Gupta <vgupta@synopsys.com>2013-02-15 12:45:55 -0500
commitee36d1722112f33725ec1a7fc02f6c46e630fd27 (patch)
tree280390c8cb2a375a01a68d5e9724cbf740685052 /arch/arc/plat-arcfpga/platform.c
parentc121c5063c0674fad6811f0b0d86ec3bc6eecbbd (diff)
ARC: [plat-arcfpga] Static platform device for CONFIG_SERIAL_ARC
N.B. This is old style of hardcoding platform device specific info in code and it's instantiation thererof using platform_add_devices(). Subsequent patches replace this with DeviceTree based runtime probe. This patch has been retained just as an example of "don't-do-this" for newer kernel ports. Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Cc: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arc/plat-arcfpga/platform.c')
-rw-r--r--arch/arc/plat-arcfpga/platform.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c
index 7b5dcab5becb..5388b31e2ead 100644
--- a/arch/arc/plat-arcfpga/platform.c
+++ b/arch/arc/plat-arcfpga/platform.c
@@ -10,7 +10,102 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/device.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/console.h>
16#include <asm/setup.h>
17#include <asm/irq.h>
18#include <asm/clk.h>
19#include <plat/memmap.h>
20
21/*----------------------- Platform Devices -----------------------------*/
22
23#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE)
24
25static unsigned long arc_uart_info[] = {
26 CONFIG_ARC_SERIAL_BAUD, /* uart->baud */
27 -1, /* uart->port.uartclk */
28 -1, /* uart->is_emulated (runtime @running_on_hw) */
29 0
30};
31
32#define ARC_UART_DEV(n) \
33 \
34static struct resource arc_uart##n##_res[] = { \
35 { \
36 .start = UART##n##_BASE, \
37 .end = UART##n##_BASE + 0xFF, \
38 .flags = IORESOURCE_MEM, \
39 }, \
40 { \
41 .start = UART##n##_IRQ, \
42 .end = UART##n##_IRQ, \
43 .flags = IORESOURCE_IRQ, \
44 }, \
45}; \
46 \
47static struct platform_device arc_uart##n##_dev = { \
48 .name = "arc-uart", \
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
57ARC_UART_DEV(0);
58#if CONFIG_SERIAL_ARC_NR_PORTS > 1
59ARC_UART_DEV(1);
60#endif
61
62static struct platform_device *fpga_early_devs[] __initdata = {
63#if defined(CONFIG_SERIAL_ARC_CONSOLE)
64 &arc_uart0_dev,
65#endif
66};
67
68static void arc_fpga_serial_init(void)
69{
70 arc_uart_info[1] = arc_get_core_freq();
71
72 /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */
73 arc_uart_info[2] = !running_on_hw;
74
75 early_platform_add_devices(fpga_early_devs,
76 ARRAY_SIZE(fpga_early_devs));
77
78 /*
79 * ARC console driver registers itself as an early platform driver
80 * of class "earlyprintk".
81 * Install it here, followed by probe of devices.
82 * The installation here doesn't require earlyprintk in command line
83 * To do so however, replace the lines below with
84 * parse_early_param();
85 * early_platform_driver_probe("earlyprintk", 1, 1);
86 * ^^
87 */
88 early_platform_driver_register_all("earlyprintk");
89 early_platform_driver_probe("earlyprintk", 1, 0);
90
91 /*
92 * This is to make sure that arc uart would be preferred console
93 * despite one/more of following:
94 * -command line lacked "console=ttyARC0" or
95 * -CONFIG_VT_CONSOLE was enabled (for no reason whatsoever)
96 * Note that this needs to be done after above early console is reg,
97 * otherwise the early console never gets a chance to run.
98 */
99 add_preferred_console("ttyARC", 0, "115200");
100}
101
102#else
103
104static void arc_fpga_serial_init(void)
105{
106}
107
108#endif /* CONFIG_SERIAL_ARC */
14 109
15/* 110/*
16 * Early Platform Initialization called from setup_arch() 111 * Early Platform Initialization called from setup_arch()
@@ -18,12 +113,25 @@
18void __init arc_platform_early_init(void) 113void __init arc_platform_early_init(void)
19{ 114{
20 pr_info("[plat-arcfpga]: registering early dev resources\n"); 115 pr_info("[plat-arcfpga]: registering early dev resources\n");
116
117 arc_fpga_serial_init();
21} 118}
22 119
120static struct platform_device *fpga_devs[] __initdata = {
121#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE)
122 &arc_uart0_dev,
123#if CONFIG_SERIAL_ARC_NR_PORTS > 1
124 &arc_uart1_dev,
125#endif
126#endif
127};
128
23int __init fpga_plat_init(void) 129int __init fpga_plat_init(void)
24{ 130{
25 pr_info("[plat-arcfpga]: registering device resources\n"); 131 pr_info("[plat-arcfpga]: registering device resources\n");
26 132
133 platform_add_devices(fpga_devs, ARRAY_SIZE(fpga_devs));
134
27 return 0; 135 return 0;
28} 136}
29arch_initcall(fpga_plat_init); 137arch_initcall(fpga_plat_init);