ACPICA: Add support for zero-length buffer-to-string conversions
[linux-2.6/mini2440.git] / arch / arm / mach-kirkwood / common.c
blob189f16f3619d19692bcbe75c876045dc4bd36042
1 /*
2 * arch/arm/mach-kirkwood/common.c
4 * Core functions for Marvell Kirkwood 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 <linux/ata_platform.h>
18 #include <linux/spi/orion_spi.h>
19 #include <asm/page.h>
20 #include <asm/timex.h>
21 #include <asm/mach/map.h>
22 #include <asm/mach/time.h>
23 #include <mach/kirkwood.h>
24 #include <plat/cache-feroceon-l2.h>
25 #include <plat/ehci-orion.h>
26 #include <plat/mv_xor.h>
27 #include <plat/orion_nand.h>
28 #include <plat/time.h>
29 #include "common.h"
31 /*****************************************************************************
32 * I/O Address Mapping
33 ****************************************************************************/
34 static struct map_desc kirkwood_io_desc[] __initdata = {
36 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
37 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
38 .length = KIRKWOOD_PCIE_IO_SIZE,
39 .type = MT_DEVICE,
40 }, {
41 .virtual = KIRKWOOD_REGS_VIRT_BASE,
42 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
43 .length = KIRKWOOD_REGS_SIZE,
44 .type = MT_DEVICE,
48 void __init kirkwood_map_io(void)
50 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
54 /*****************************************************************************
55 * EHCI
56 ****************************************************************************/
57 static struct orion_ehci_data kirkwood_ehci_data = {
58 .dram = &kirkwood_mbus_dram_info,
61 static u64 ehci_dmamask = 0xffffffffUL;
64 /*****************************************************************************
65 * EHCI0
66 ****************************************************************************/
67 static struct resource kirkwood_ehci_resources[] = {
69 .start = USB_PHYS_BASE,
70 .end = USB_PHYS_BASE + 0x0fff,
71 .flags = IORESOURCE_MEM,
72 }, {
73 .start = IRQ_KIRKWOOD_USB,
74 .end = IRQ_KIRKWOOD_USB,
75 .flags = IORESOURCE_IRQ,
79 static struct platform_device kirkwood_ehci = {
80 .name = "orion-ehci",
81 .id = 0,
82 .dev = {
83 .dma_mask = &ehci_dmamask,
84 .coherent_dma_mask = 0xffffffff,
85 .platform_data = &kirkwood_ehci_data,
87 .resource = kirkwood_ehci_resources,
88 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
91 void __init kirkwood_ehci_init(void)
93 platform_device_register(&kirkwood_ehci);
97 /*****************************************************************************
98 * GE00
99 ****************************************************************************/
100 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
101 .t_clk = KIRKWOOD_TCLK,
102 .dram = &kirkwood_mbus_dram_info,
105 static struct resource kirkwood_ge00_shared_resources[] = {
107 .name = "ge00 base",
108 .start = GE00_PHYS_BASE + 0x2000,
109 .end = GE00_PHYS_BASE + 0x3fff,
110 .flags = IORESOURCE_MEM,
114 static struct platform_device kirkwood_ge00_shared = {
115 .name = MV643XX_ETH_SHARED_NAME,
116 .id = 0,
117 .dev = {
118 .platform_data = &kirkwood_ge00_shared_data,
120 .num_resources = 1,
121 .resource = kirkwood_ge00_shared_resources,
124 static struct resource kirkwood_ge00_resources[] = {
126 .name = "ge00 irq",
127 .start = IRQ_KIRKWOOD_GE00_SUM,
128 .end = IRQ_KIRKWOOD_GE00_SUM,
129 .flags = IORESOURCE_IRQ,
133 static struct platform_device kirkwood_ge00 = {
134 .name = MV643XX_ETH_NAME,
135 .id = 0,
136 .num_resources = 1,
137 .resource = kirkwood_ge00_resources,
140 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
142 eth_data->shared = &kirkwood_ge00_shared;
143 kirkwood_ge00.dev.platform_data = eth_data;
145 platform_device_register(&kirkwood_ge00_shared);
146 platform_device_register(&kirkwood_ge00);
150 /*****************************************************************************
151 * SoC RTC
152 ****************************************************************************/
153 static struct resource kirkwood_rtc_resource = {
154 .start = RTC_PHYS_BASE,
155 .end = RTC_PHYS_BASE + SZ_16 - 1,
156 .flags = IORESOURCE_MEM,
159 void __init kirkwood_rtc_init(void)
161 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
165 /*****************************************************************************
166 * SATA
167 ****************************************************************************/
168 static struct resource kirkwood_sata_resources[] = {
170 .name = "sata base",
171 .start = SATA_PHYS_BASE,
172 .end = SATA_PHYS_BASE + 0x5000 - 1,
173 .flags = IORESOURCE_MEM,
174 }, {
175 .name = "sata irq",
176 .start = IRQ_KIRKWOOD_SATA,
177 .end = IRQ_KIRKWOOD_SATA,
178 .flags = IORESOURCE_IRQ,
182 static struct platform_device kirkwood_sata = {
183 .name = "sata_mv",
184 .id = 0,
185 .dev = {
186 .coherent_dma_mask = 0xffffffff,
188 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
189 .resource = kirkwood_sata_resources,
192 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
194 sata_data->dram = &kirkwood_mbus_dram_info;
195 kirkwood_sata.dev.platform_data = sata_data;
196 platform_device_register(&kirkwood_sata);
200 /*****************************************************************************
201 * SPI
202 ****************************************************************************/
203 static struct orion_spi_info kirkwood_spi_plat_data = {
204 .tclk = KIRKWOOD_TCLK,
207 static struct resource kirkwood_spi_resources[] = {
209 .start = SPI_PHYS_BASE,
210 .end = SPI_PHYS_BASE + SZ_512 - 1,
211 .flags = IORESOURCE_MEM,
215 static struct platform_device kirkwood_spi = {
216 .name = "orion_spi",
217 .id = 0,
218 .resource = kirkwood_spi_resources,
219 .dev = {
220 .platform_data = &kirkwood_spi_plat_data,
222 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
225 void __init kirkwood_spi_init()
227 platform_device_register(&kirkwood_spi);
231 /*****************************************************************************
232 * UART0
233 ****************************************************************************/
234 static struct plat_serial8250_port kirkwood_uart0_data[] = {
236 .mapbase = UART0_PHYS_BASE,
237 .membase = (char *)UART0_VIRT_BASE,
238 .irq = IRQ_KIRKWOOD_UART_0,
239 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
240 .iotype = UPIO_MEM,
241 .regshift = 2,
242 .uartclk = KIRKWOOD_TCLK,
243 }, {
247 static struct resource kirkwood_uart0_resources[] = {
249 .start = UART0_PHYS_BASE,
250 .end = UART0_PHYS_BASE + 0xff,
251 .flags = IORESOURCE_MEM,
252 }, {
253 .start = IRQ_KIRKWOOD_UART_0,
254 .end = IRQ_KIRKWOOD_UART_0,
255 .flags = IORESOURCE_IRQ,
259 static struct platform_device kirkwood_uart0 = {
260 .name = "serial8250",
261 .id = 0,
262 .dev = {
263 .platform_data = kirkwood_uart0_data,
265 .resource = kirkwood_uart0_resources,
266 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
269 void __init kirkwood_uart0_init(void)
271 platform_device_register(&kirkwood_uart0);
275 /*****************************************************************************
276 * UART1
277 ****************************************************************************/
278 static struct plat_serial8250_port kirkwood_uart1_data[] = {
280 .mapbase = UART1_PHYS_BASE,
281 .membase = (char *)UART1_VIRT_BASE,
282 .irq = IRQ_KIRKWOOD_UART_1,
283 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
284 .iotype = UPIO_MEM,
285 .regshift = 2,
286 .uartclk = KIRKWOOD_TCLK,
287 }, {
291 static struct resource kirkwood_uart1_resources[] = {
293 .start = UART1_PHYS_BASE,
294 .end = UART1_PHYS_BASE + 0xff,
295 .flags = IORESOURCE_MEM,
296 }, {
297 .start = IRQ_KIRKWOOD_UART_1,
298 .end = IRQ_KIRKWOOD_UART_1,
299 .flags = IORESOURCE_IRQ,
303 static struct platform_device kirkwood_uart1 = {
304 .name = "serial8250",
305 .id = 1,
306 .dev = {
307 .platform_data = kirkwood_uart1_data,
309 .resource = kirkwood_uart1_resources,
310 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
313 void __init kirkwood_uart1_init(void)
315 platform_device_register(&kirkwood_uart1);
319 /*****************************************************************************
320 * XOR
321 ****************************************************************************/
322 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
323 .dram = &kirkwood_mbus_dram_info,
326 static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
329 /*****************************************************************************
330 * XOR0
331 ****************************************************************************/
332 static struct resource kirkwood_xor0_shared_resources[] = {
334 .name = "xor 0 low",
335 .start = XOR0_PHYS_BASE,
336 .end = XOR0_PHYS_BASE + 0xff,
337 .flags = IORESOURCE_MEM,
338 }, {
339 .name = "xor 0 high",
340 .start = XOR0_HIGH_PHYS_BASE,
341 .end = XOR0_HIGH_PHYS_BASE + 0xff,
342 .flags = IORESOURCE_MEM,
346 static struct platform_device kirkwood_xor0_shared = {
347 .name = MV_XOR_SHARED_NAME,
348 .id = 0,
349 .dev = {
350 .platform_data = &kirkwood_xor_shared_data,
352 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
353 .resource = kirkwood_xor0_shared_resources,
356 static struct resource kirkwood_xor00_resources[] = {
357 [0] = {
358 .start = IRQ_KIRKWOOD_XOR_00,
359 .end = IRQ_KIRKWOOD_XOR_00,
360 .flags = IORESOURCE_IRQ,
364 static struct mv_xor_platform_data kirkwood_xor00_data = {
365 .shared = &kirkwood_xor0_shared,
366 .hw_id = 0,
367 .pool_size = PAGE_SIZE,
370 static struct platform_device kirkwood_xor00_channel = {
371 .name = MV_XOR_NAME,
372 .id = 0,
373 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
374 .resource = kirkwood_xor00_resources,
375 .dev = {
376 .dma_mask = &kirkwood_xor_dmamask,
377 .coherent_dma_mask = DMA_64BIT_MASK,
378 .platform_data = (void *)&kirkwood_xor00_data,
382 static struct resource kirkwood_xor01_resources[] = {
383 [0] = {
384 .start = IRQ_KIRKWOOD_XOR_01,
385 .end = IRQ_KIRKWOOD_XOR_01,
386 .flags = IORESOURCE_IRQ,
390 static struct mv_xor_platform_data kirkwood_xor01_data = {
391 .shared = &kirkwood_xor0_shared,
392 .hw_id = 1,
393 .pool_size = PAGE_SIZE,
396 static struct platform_device kirkwood_xor01_channel = {
397 .name = MV_XOR_NAME,
398 .id = 1,
399 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
400 .resource = kirkwood_xor01_resources,
401 .dev = {
402 .dma_mask = &kirkwood_xor_dmamask,
403 .coherent_dma_mask = DMA_64BIT_MASK,
404 .platform_data = (void *)&kirkwood_xor01_data,
408 void __init kirkwood_xor0_init(void)
410 platform_device_register(&kirkwood_xor0_shared);
413 * two engines can't do memset simultaneously, this limitation
414 * satisfied by removing memset support from one of the engines.
416 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
417 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
418 platform_device_register(&kirkwood_xor00_channel);
420 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
421 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
422 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
423 platform_device_register(&kirkwood_xor01_channel);
427 /*****************************************************************************
428 * XOR1
429 ****************************************************************************/
430 static struct resource kirkwood_xor1_shared_resources[] = {
432 .name = "xor 1 low",
433 .start = XOR1_PHYS_BASE,
434 .end = XOR1_PHYS_BASE + 0xff,
435 .flags = IORESOURCE_MEM,
436 }, {
437 .name = "xor 1 high",
438 .start = XOR1_HIGH_PHYS_BASE,
439 .end = XOR1_HIGH_PHYS_BASE + 0xff,
440 .flags = IORESOURCE_MEM,
444 static struct platform_device kirkwood_xor1_shared = {
445 .name = MV_XOR_SHARED_NAME,
446 .id = 1,
447 .dev = {
448 .platform_data = &kirkwood_xor_shared_data,
450 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
451 .resource = kirkwood_xor1_shared_resources,
454 static struct resource kirkwood_xor10_resources[] = {
455 [0] = {
456 .start = IRQ_KIRKWOOD_XOR_10,
457 .end = IRQ_KIRKWOOD_XOR_10,
458 .flags = IORESOURCE_IRQ,
462 static struct mv_xor_platform_data kirkwood_xor10_data = {
463 .shared = &kirkwood_xor1_shared,
464 .hw_id = 0,
465 .pool_size = PAGE_SIZE,
468 static struct platform_device kirkwood_xor10_channel = {
469 .name = MV_XOR_NAME,
470 .id = 2,
471 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
472 .resource = kirkwood_xor10_resources,
473 .dev = {
474 .dma_mask = &kirkwood_xor_dmamask,
475 .coherent_dma_mask = DMA_64BIT_MASK,
476 .platform_data = (void *)&kirkwood_xor10_data,
480 static struct resource kirkwood_xor11_resources[] = {
481 [0] = {
482 .start = IRQ_KIRKWOOD_XOR_11,
483 .end = IRQ_KIRKWOOD_XOR_11,
484 .flags = IORESOURCE_IRQ,
488 static struct mv_xor_platform_data kirkwood_xor11_data = {
489 .shared = &kirkwood_xor1_shared,
490 .hw_id = 1,
491 .pool_size = PAGE_SIZE,
494 static struct platform_device kirkwood_xor11_channel = {
495 .name = MV_XOR_NAME,
496 .id = 3,
497 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
498 .resource = kirkwood_xor11_resources,
499 .dev = {
500 .dma_mask = &kirkwood_xor_dmamask,
501 .coherent_dma_mask = DMA_64BIT_MASK,
502 .platform_data = (void *)&kirkwood_xor11_data,
506 void __init kirkwood_xor1_init(void)
508 platform_device_register(&kirkwood_xor1_shared);
511 * two engines can't do memset simultaneously, this limitation
512 * satisfied by removing memset support from one of the engines.
514 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
515 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
516 platform_device_register(&kirkwood_xor10_channel);
518 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
519 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
520 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
521 platform_device_register(&kirkwood_xor11_channel);
525 /*****************************************************************************
526 * Time handling
527 ****************************************************************************/
528 static void kirkwood_timer_init(void)
530 orion_time_init(IRQ_KIRKWOOD_BRIDGE, KIRKWOOD_TCLK);
533 struct sys_timer kirkwood_timer = {
534 .init = kirkwood_timer_init,
538 /*****************************************************************************
539 * General
540 ****************************************************************************/
541 static char * __init kirkwood_id(void)
543 switch (readl(DEVICE_ID) & 0x3) {
544 case 0:
545 return "88F6180";
546 case 1:
547 return "88F6192";
548 case 2:
549 return "88F6281";
552 return "unknown 88F6000 variant";
555 static int __init is_l2_writethrough(void)
557 return !!(readl(L2_CONFIG_REG) & L2_WRITETHROUGH);
560 void __init kirkwood_init(void)
562 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
563 kirkwood_id(), KIRKWOOD_TCLK);
565 kirkwood_setup_cpu_mbus();
567 #ifdef CONFIG_CACHE_FEROCEON_L2
568 feroceon_l2_init(is_l2_writethrough());
569 #endif