diff options
author | Andrew Lunn <andrew@lunn.ch> | 2011-05-15 07:32:41 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2011-05-16 14:46:17 -0400 |
commit | 28a2b45054f2e3f3671e36a6e9efc82756afa31a (patch) | |
tree | b33726c3de55636902cc033124eb3dd6ba6fe1d1 /arch/arm/plat-orion | |
parent | 5c60255149eece2a36ec9f5c99817b85f96fe8ec (diff) |
ARM: orion: Consolidate the creation of the uart platform data.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Diffstat (limited to 'arch/arm/plat-orion')
-rw-r--r-- | arch/arm/plat-orion/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-orion/common.c | 171 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/common.h | 33 |
3 files changed, 205 insertions, 1 deletions
diff --git a/arch/arm/plat-orion/Makefile b/arch/arm/plat-orion/Makefile index 56021a72e10c..0f048c58b4c9 100644 --- a/arch/arm/plat-orion/Makefile +++ b/arch/arm/plat-orion/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := irq.o pcie.o time.o | 5 | obj-y := irq.o pcie.o time.o common.o |
6 | obj-m := | 6 | obj-m := |
7 | obj-n := | 7 | obj-n := |
8 | obj- := | 8 | obj- := |
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c new file mode 100644 index 000000000000..4eac532ae8ae --- /dev/null +++ b/arch/arm/plat-orion/common.c | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/common.c | ||
3 | * | ||
4 | * Marvell Orion SoC common setup code used by multiple mach-/common.c | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/serial_8250.h> | ||
15 | |||
16 | /* Fill in the resources structure and link it into the platform | ||
17 | device structure. There is always a memory region, and nearly | ||
18 | always an interrupt.*/ | ||
19 | static void fill_resources(struct platform_device *device, | ||
20 | struct resource *resources, | ||
21 | resource_size_t mapbase, | ||
22 | resource_size_t size, | ||
23 | unsigned int irq) | ||
24 | { | ||
25 | device->resource = resources; | ||
26 | device->num_resources = 1; | ||
27 | resources[0].flags = IORESOURCE_MEM; | ||
28 | resources[0].start = mapbase; | ||
29 | resources[0].end = mapbase + size; | ||
30 | |||
31 | if (irq != NO_IRQ) { | ||
32 | device->num_resources++; | ||
33 | resources[1].flags = IORESOURCE_IRQ; | ||
34 | resources[1].start = irq; | ||
35 | resources[1].end = irq; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /***************************************************************************** | ||
40 | * UART | ||
41 | ****************************************************************************/ | ||
42 | static void __init uart_complete( | ||
43 | struct platform_device *orion_uart, | ||
44 | struct plat_serial8250_port *data, | ||
45 | struct resource *resources, | ||
46 | unsigned int membase, | ||
47 | resource_size_t mapbase, | ||
48 | unsigned int irq, | ||
49 | unsigned int uartclk) | ||
50 | { | ||
51 | data->mapbase = mapbase; | ||
52 | data->membase = (void __iomem *)membase; | ||
53 | data->irq = irq; | ||
54 | data->uartclk = uartclk; | ||
55 | orion_uart->dev.platform_data = data; | ||
56 | |||
57 | fill_resources(orion_uart, resources, mapbase, 0xff, irq); | ||
58 | platform_device_register(orion_uart); | ||
59 | } | ||
60 | |||
61 | /***************************************************************************** | ||
62 | * UART0 | ||
63 | ****************************************************************************/ | ||
64 | static struct plat_serial8250_port orion_uart0_data[] = { | ||
65 | { | ||
66 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
67 | .iotype = UPIO_MEM, | ||
68 | .regshift = 2, | ||
69 | }, { | ||
70 | }, | ||
71 | }; | ||
72 | |||
73 | static struct resource orion_uart0_resources[2]; | ||
74 | |||
75 | static struct platform_device orion_uart0 = { | ||
76 | .name = "serial8250", | ||
77 | .id = PLAT8250_DEV_PLATFORM, | ||
78 | }; | ||
79 | |||
80 | void __init orion_uart0_init(unsigned int membase, | ||
81 | resource_size_t mapbase, | ||
82 | unsigned int irq, | ||
83 | unsigned int uartclk) | ||
84 | { | ||
85 | uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources, | ||
86 | membase, mapbase, irq, uartclk); | ||
87 | } | ||
88 | |||
89 | /***************************************************************************** | ||
90 | * UART1 | ||
91 | ****************************************************************************/ | ||
92 | static struct plat_serial8250_port orion_uart1_data[] = { | ||
93 | { | ||
94 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
95 | .iotype = UPIO_MEM, | ||
96 | .regshift = 2, | ||
97 | }, { | ||
98 | }, | ||
99 | }; | ||
100 | |||
101 | static struct resource orion_uart1_resources[2]; | ||
102 | |||
103 | static struct platform_device orion_uart1 = { | ||
104 | .name = "serial8250", | ||
105 | .id = PLAT8250_DEV_PLATFORM1, | ||
106 | }; | ||
107 | |||
108 | void __init orion_uart1_init(unsigned int membase, | ||
109 | resource_size_t mapbase, | ||
110 | unsigned int irq, | ||
111 | unsigned int uartclk) | ||
112 | { | ||
113 | uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources, | ||
114 | membase, mapbase, irq, uartclk); | ||
115 | } | ||
116 | |||
117 | /***************************************************************************** | ||
118 | * UART2 | ||
119 | ****************************************************************************/ | ||
120 | static struct plat_serial8250_port orion_uart2_data[] = { | ||
121 | { | ||
122 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
123 | .iotype = UPIO_MEM, | ||
124 | .regshift = 2, | ||
125 | }, { | ||
126 | }, | ||
127 | }; | ||
128 | |||
129 | static struct resource orion_uart2_resources[2]; | ||
130 | |||
131 | static struct platform_device orion_uart2 = { | ||
132 | .name = "serial8250", | ||
133 | .id = PLAT8250_DEV_PLATFORM2, | ||
134 | }; | ||
135 | |||
136 | void __init orion_uart2_init(unsigned int membase, | ||
137 | resource_size_t mapbase, | ||
138 | unsigned int irq, | ||
139 | unsigned int uartclk) | ||
140 | { | ||
141 | uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources, | ||
142 | membase, mapbase, irq, uartclk); | ||
143 | } | ||
144 | |||
145 | /***************************************************************************** | ||
146 | * UART3 | ||
147 | ****************************************************************************/ | ||
148 | static struct plat_serial8250_port orion_uart3_data[] = { | ||
149 | { | ||
150 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
151 | .iotype = UPIO_MEM, | ||
152 | .regshift = 2, | ||
153 | }, { | ||
154 | }, | ||
155 | }; | ||
156 | |||
157 | static struct resource orion_uart3_resources[2]; | ||
158 | |||
159 | static struct platform_device orion_uart3 = { | ||
160 | .name = "serial8250", | ||
161 | .id = 3, | ||
162 | }; | ||
163 | |||
164 | void __init orion_uart3_init(unsigned int membase, | ||
165 | resource_size_t mapbase, | ||
166 | unsigned int irq, | ||
167 | unsigned int uartclk) | ||
168 | { | ||
169 | uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources, | ||
170 | membase, mapbase, irq, uartclk); | ||
171 | } | ||
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h new file mode 100644 index 000000000000..92ff9916a1d0 --- /dev/null +++ b/arch/arm/plat-orion/include/plat/common.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/include/plat/common.h | ||
3 | * | ||
4 | * Marvell Orion SoC common setup code used by different mach-/common.c | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __PLAT_COMMON_H | ||
12 | |||
13 | |||
14 | void __init orion_uart0_init(unsigned int membase, | ||
15 | resource_size_t mapbase, | ||
16 | unsigned int irq, | ||
17 | unsigned int uartclk); | ||
18 | |||
19 | void __init orion_uart1_init(unsigned int membase, | ||
20 | resource_size_t mapbase, | ||
21 | unsigned int irq, | ||
22 | unsigned int uartclk); | ||
23 | |||
24 | void __init orion_uart2_init(unsigned int membase, | ||
25 | resource_size_t mapbase, | ||
26 | unsigned int irq, | ||
27 | unsigned int uartclk); | ||
28 | |||
29 | void __init orion_uart3_init(unsigned int membase, | ||
30 | resource_size_t mapbase, | ||
31 | unsigned int irq, | ||
32 | unsigned int uartclk); | ||
33 | #endif | ||