aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-orion
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2011-05-15 07:32:41 -0400
committerNicolas Pitre <nico@fluxnic.net>2011-05-16 14:46:17 -0400
commit28a2b45054f2e3f3671e36a6e9efc82756afa31a (patch)
treeb33726c3de55636902cc033124eb3dd6ba6fe1d1 /arch/arm/plat-orion
parent5c60255149eece2a36ec9f5c99817b85f96fe8ec (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/Makefile2
-rw-r--r--arch/arm/plat-orion/common.c171
-rw-r--r--arch/arm/plat-orion/include/plat/common.h33
3 files changed, 205 insertions, 1 deletions
diff --git a/arch/arm/plat-orion/Makefile b/arch/arm/plat-orion/Makefile
index 56021a72e10..0f048c58b4c 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
5obj-y := irq.o pcie.o time.o 5obj-y := irq.o pcie.o time.o common.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
new file mode 100644
index 00000000000..4eac532ae8a
--- /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.*/
19static 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 ****************************************************************************/
42static 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 ****************************************************************************/
64static 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
73static struct resource orion_uart0_resources[2];
74
75static struct platform_device orion_uart0 = {
76 .name = "serial8250",
77 .id = PLAT8250_DEV_PLATFORM,
78};
79
80void __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 ****************************************************************************/
92static 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
101static struct resource orion_uart1_resources[2];
102
103static struct platform_device orion_uart1 = {
104 .name = "serial8250",
105 .id = PLAT8250_DEV_PLATFORM1,
106};
107
108void __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 ****************************************************************************/
120static 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
129static struct resource orion_uart2_resources[2];
130
131static struct platform_device orion_uart2 = {
132 .name = "serial8250",
133 .id = PLAT8250_DEV_PLATFORM2,
134};
135
136void __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 ****************************************************************************/
148static 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
157static struct resource orion_uart3_resources[2];
158
159static struct platform_device orion_uart3 = {
160 .name = "serial8250",
161 .id = 3,
162};
163
164void __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 00000000000..92ff9916a1d
--- /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
14void __init orion_uart0_init(unsigned int membase,
15 resource_size_t mapbase,
16 unsigned int irq,
17 unsigned int uartclk);
18
19void __init orion_uart1_init(unsigned int membase,
20 resource_size_t mapbase,
21 unsigned int irq,
22 unsigned int uartclk);
23
24void __init orion_uart2_init(unsigned int membase,
25 resource_size_t mapbase,
26 unsigned int irq,
27 unsigned int uartclk);
28
29void __init orion_uart3_init(unsigned int membase,
30 resource_size_t mapbase,
31 unsigned int irq,
32 unsigned int uartclk);
33#endif