ceph: fix rare potential cap leak
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-loki / common.c
blobe41e909cf8f413db3506c927957ca68e26293510
1 /*
2 * arch/arm/mach-loki/common.c
4 * Core functions for Marvell Loki (88RC8480) SoCs
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 */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/mv643xx_eth.h>
17 #include <asm/page.h>
18 #include <asm/timex.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <mach/bridge-regs.h>
22 #include <mach/loki.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
25 #include "common.h"
27 /*****************************************************************************
28 * I/O Address Mapping
29 ****************************************************************************/
30 static struct map_desc loki_io_desc[] __initdata = {
32 .virtual = LOKI_REGS_VIRT_BASE,
33 .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
34 .length = LOKI_REGS_SIZE,
35 .type = MT_DEVICE,
39 void __init loki_map_io(void)
41 iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
45 /*****************************************************************************
46 * GE0
47 ****************************************************************************/
48 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
49 .t_clk = LOKI_TCLK,
50 .dram = &loki_mbus_dram_info,
53 static struct resource loki_ge0_shared_resources[] = {
55 .name = "ge0 base",
56 .start = GE0_PHYS_BASE + 0x2000,
57 .end = GE0_PHYS_BASE + 0x3fff,
58 .flags = IORESOURCE_MEM,
62 static struct platform_device loki_ge0_shared = {
63 .name = MV643XX_ETH_SHARED_NAME,
64 .id = 0,
65 .dev = {
66 .platform_data = &loki_ge0_shared_data,
68 .num_resources = 1,
69 .resource = loki_ge0_shared_resources,
72 static struct resource loki_ge0_resources[] = {
74 .name = "ge0 irq",
75 .start = IRQ_LOKI_GBE_A_INT,
76 .end = IRQ_LOKI_GBE_A_INT,
77 .flags = IORESOURCE_IRQ,
81 static struct platform_device loki_ge0 = {
82 .name = MV643XX_ETH_NAME,
83 .id = 0,
84 .num_resources = 1,
85 .resource = loki_ge0_resources,
86 .dev = {
87 .coherent_dma_mask = 0xffffffff,
91 void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
93 eth_data->shared = &loki_ge0_shared;
94 loki_ge0.dev.platform_data = eth_data;
96 writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
97 platform_device_register(&loki_ge0_shared);
98 platform_device_register(&loki_ge0);
102 /*****************************************************************************
103 * GE1
104 ****************************************************************************/
105 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
106 .t_clk = LOKI_TCLK,
107 .dram = &loki_mbus_dram_info,
110 static struct resource loki_ge1_shared_resources[] = {
112 .name = "ge1 base",
113 .start = GE1_PHYS_BASE + 0x2000,
114 .end = GE1_PHYS_BASE + 0x3fff,
115 .flags = IORESOURCE_MEM,
119 static struct platform_device loki_ge1_shared = {
120 .name = MV643XX_ETH_SHARED_NAME,
121 .id = 1,
122 .dev = {
123 .platform_data = &loki_ge1_shared_data,
125 .num_resources = 1,
126 .resource = loki_ge1_shared_resources,
129 static struct resource loki_ge1_resources[] = {
131 .name = "ge1 irq",
132 .start = IRQ_LOKI_GBE_B_INT,
133 .end = IRQ_LOKI_GBE_B_INT,
134 .flags = IORESOURCE_IRQ,
138 static struct platform_device loki_ge1 = {
139 .name = MV643XX_ETH_NAME,
140 .id = 1,
141 .num_resources = 1,
142 .resource = loki_ge1_resources,
143 .dev = {
144 .coherent_dma_mask = 0xffffffff,
148 void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
150 eth_data->shared = &loki_ge1_shared;
151 loki_ge1.dev.platform_data = eth_data;
153 writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
154 platform_device_register(&loki_ge1_shared);
155 platform_device_register(&loki_ge1);
159 /*****************************************************************************
160 * SAS/SATA
161 ****************************************************************************/
162 static struct resource loki_sas_resources[] = {
164 .name = "mvsas0 mem",
165 .start = SAS0_PHYS_BASE,
166 .end = SAS0_PHYS_BASE + 0x01ff,
167 .flags = IORESOURCE_MEM,
168 }, {
169 .name = "mvsas0 irq",
170 .start = IRQ_LOKI_SAS_A,
171 .end = IRQ_LOKI_SAS_A,
172 .flags = IORESOURCE_IRQ,
173 }, {
174 .name = "mvsas1 mem",
175 .start = SAS1_PHYS_BASE,
176 .end = SAS1_PHYS_BASE + 0x01ff,
177 .flags = IORESOURCE_MEM,
178 }, {
179 .name = "mvsas1 irq",
180 .start = IRQ_LOKI_SAS_B,
181 .end = IRQ_LOKI_SAS_B,
182 .flags = IORESOURCE_IRQ,
186 static struct platform_device loki_sas = {
187 .name = "mvsas",
188 .id = 0,
189 .dev = {
190 .coherent_dma_mask = 0xffffffff,
192 .num_resources = ARRAY_SIZE(loki_sas_resources),
193 .resource = loki_sas_resources,
196 void __init loki_sas_init(void)
198 writel(0x8300f707, DDR_REG(0x1424));
199 platform_device_register(&loki_sas);
203 /*****************************************************************************
204 * UART0
205 ****************************************************************************/
206 static struct plat_serial8250_port loki_uart0_data[] = {
208 .mapbase = UART0_PHYS_BASE,
209 .membase = (char *)UART0_VIRT_BASE,
210 .irq = IRQ_LOKI_UART0,
211 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
212 .iotype = UPIO_MEM,
213 .regshift = 2,
214 .uartclk = LOKI_TCLK,
215 }, {
219 static struct resource loki_uart0_resources[] = {
221 .start = UART0_PHYS_BASE,
222 .end = UART0_PHYS_BASE + 0xff,
223 .flags = IORESOURCE_MEM,
224 }, {
225 .start = IRQ_LOKI_UART0,
226 .end = IRQ_LOKI_UART0,
227 .flags = IORESOURCE_IRQ,
231 static struct platform_device loki_uart0 = {
232 .name = "serial8250",
233 .id = 0,
234 .dev = {
235 .platform_data = loki_uart0_data,
237 .resource = loki_uart0_resources,
238 .num_resources = ARRAY_SIZE(loki_uart0_resources),
241 void __init loki_uart0_init(void)
243 platform_device_register(&loki_uart0);
247 /*****************************************************************************
248 * UART1
249 ****************************************************************************/
250 static struct plat_serial8250_port loki_uart1_data[] = {
252 .mapbase = UART1_PHYS_BASE,
253 .membase = (char *)UART1_VIRT_BASE,
254 .irq = IRQ_LOKI_UART1,
255 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
256 .iotype = UPIO_MEM,
257 .regshift = 2,
258 .uartclk = LOKI_TCLK,
259 }, {
263 static struct resource loki_uart1_resources[] = {
265 .start = UART1_PHYS_BASE,
266 .end = UART1_PHYS_BASE + 0xff,
267 .flags = IORESOURCE_MEM,
268 }, {
269 .start = IRQ_LOKI_UART1,
270 .end = IRQ_LOKI_UART1,
271 .flags = IORESOURCE_IRQ,
275 static struct platform_device loki_uart1 = {
276 .name = "serial8250",
277 .id = 1,
278 .dev = {
279 .platform_data = loki_uart1_data,
281 .resource = loki_uart1_resources,
282 .num_resources = ARRAY_SIZE(loki_uart1_resources),
285 void __init loki_uart1_init(void)
287 platform_device_register(&loki_uart1);
291 /*****************************************************************************
292 * Time handling
293 ****************************************************************************/
294 void __init loki_init_early(void)
296 orion_time_set_base(TIMER_VIRT_BASE);
299 static void loki_timer_init(void)
301 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
302 IRQ_LOKI_BRIDGE, LOKI_TCLK);
305 struct sys_timer loki_timer = {
306 .init = loki_timer_init,
310 /*****************************************************************************
311 * General
312 ****************************************************************************/
313 void __init loki_init(void)
315 printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
317 loki_setup_cpu_mbus();