blob: d06559123835eb654d55e3ba4a72d53ed40e9ebb [file] [log] [blame]
Andrew Lunn28a2b452011-05-15 13:32:41 +02001/*
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}
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200172
173/*****************************************************************************
174 * SoC RTC
175 ****************************************************************************/
176static struct resource orion_rtc_resource[2];
177
178void __init orion_rtc_init(unsigned long mapbase,
179 unsigned long irq)
180{
181 orion_rtc_resource[0].start = mapbase;
182 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
183 orion_rtc_resource[0].flags = IORESOURCE_MEM;
184 orion_rtc_resource[1].start = irq;
185 orion_rtc_resource[1].end = irq;
186 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
187
188 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
189}