Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mach-iop13xx / setup.c
blob30dbfca91f9444f23a5568949afad7602f0f0975
1 /*
2 * iop13xx platform Initialization
3 * Copyright (c) 2005-2006, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
20 #include <linux/serial_8250.h>
21 #ifdef CONFIG_MTD_PHYSMAP
22 #include <linux/mtd/physmap.h>
23 #endif
24 #include <asm/mach/map.h>
25 #include <asm/hardware.h>
26 #include <asm/irq.h>
27 #include <asm/io.h>
28 #include <asm/hardware/iop_adma.h>
30 #define IOP13XX_UART_XTAL 33334000
31 #define IOP13XX_SETUP_DEBUG 0
32 #define PRINTK(x...) ((void)(IOP13XX_SETUP_DEBUG && printk(x)))
34 /* Standard IO mapping for all IOP13XX based systems
36 static struct map_desc iop13xx_std_desc[] __initdata = {
37 { /* mem mapped registers */
38 .virtual = IOP13XX_PMMR_VIRT_MEM_BASE,
39 .pfn = __phys_to_pfn(IOP13XX_PMMR_PHYS_MEM_BASE),
40 .length = IOP13XX_PMMR_SIZE,
41 .type = MT_DEVICE,
42 }, { /* PCIE IO space */
43 .virtual = IOP13XX_PCIE_LOWER_IO_VA,
44 .pfn = __phys_to_pfn(IOP13XX_PCIE_LOWER_IO_PA),
45 .length = IOP13XX_PCIX_IO_WINDOW_SIZE,
46 .type = MT_DEVICE,
47 }, { /* PCIX IO space */
48 .virtual = IOP13XX_PCIX_LOWER_IO_VA,
49 .pfn = __phys_to_pfn(IOP13XX_PCIX_LOWER_IO_PA),
50 .length = IOP13XX_PCIX_IO_WINDOW_SIZE,
51 .type = MT_DEVICE,
55 static struct resource iop13xx_uart0_resources[] = {
56 [0] = {
57 .start = IOP13XX_UART0_PHYS,
58 .end = IOP13XX_UART0_PHYS + 0x3f,
59 .flags = IORESOURCE_MEM,
61 [1] = {
62 .start = IRQ_IOP13XX_UART0,
63 .end = IRQ_IOP13XX_UART0,
64 .flags = IORESOURCE_IRQ
68 static struct resource iop13xx_uart1_resources[] = {
69 [0] = {
70 .start = IOP13XX_UART1_PHYS,
71 .end = IOP13XX_UART1_PHYS + 0x3f,
72 .flags = IORESOURCE_MEM,
74 [1] = {
75 .start = IRQ_IOP13XX_UART1,
76 .end = IRQ_IOP13XX_UART1,
77 .flags = IORESOURCE_IRQ
81 static struct plat_serial8250_port iop13xx_uart0_data[] = {
83 .membase = (char*)(IOP13XX_UART0_VIRT),
84 .mapbase = (IOP13XX_UART0_PHYS),
85 .irq = IRQ_IOP13XX_UART0,
86 .uartclk = IOP13XX_UART_XTAL,
87 .regshift = 2,
88 .iotype = UPIO_MEM,
89 .flags = UPF_SKIP_TEST,
91 { },
94 static struct plat_serial8250_port iop13xx_uart1_data[] = {
96 .membase = (char*)(IOP13XX_UART1_VIRT),
97 .mapbase = (IOP13XX_UART1_PHYS),
98 .irq = IRQ_IOP13XX_UART1,
99 .uartclk = IOP13XX_UART_XTAL,
100 .regshift = 2,
101 .iotype = UPIO_MEM,
102 .flags = UPF_SKIP_TEST,
104 { },
107 /* The ids are fixed up later in iop13xx_platform_init */
108 static struct platform_device iop13xx_uart0 = {
109 .name = "serial8250",
110 .id = 0,
111 .dev.platform_data = iop13xx_uart0_data,
112 .num_resources = 2,
113 .resource = iop13xx_uart0_resources,
116 static struct platform_device iop13xx_uart1 = {
117 .name = "serial8250",
118 .id = 0,
119 .dev.platform_data = iop13xx_uart1_data,
120 .num_resources = 2,
121 .resource = iop13xx_uart1_resources
124 static struct resource iop13xx_i2c_0_resources[] = {
125 [0] = {
126 .start = IOP13XX_I2C0_PHYS,
127 .end = IOP13XX_I2C0_PHYS + 0x18,
128 .flags = IORESOURCE_MEM,
130 [1] = {
131 .start = IRQ_IOP13XX_I2C_0,
132 .end = IRQ_IOP13XX_I2C_0,
133 .flags = IORESOURCE_IRQ
137 static struct resource iop13xx_i2c_1_resources[] = {
138 [0] = {
139 .start = IOP13XX_I2C1_PHYS,
140 .end = IOP13XX_I2C1_PHYS + 0x18,
141 .flags = IORESOURCE_MEM,
143 [1] = {
144 .start = IRQ_IOP13XX_I2C_1,
145 .end = IRQ_IOP13XX_I2C_1,
146 .flags = IORESOURCE_IRQ
150 static struct resource iop13xx_i2c_2_resources[] = {
151 [0] = {
152 .start = IOP13XX_I2C2_PHYS,
153 .end = IOP13XX_I2C2_PHYS + 0x18,
154 .flags = IORESOURCE_MEM,
156 [1] = {
157 .start = IRQ_IOP13XX_I2C_2,
158 .end = IRQ_IOP13XX_I2C_2,
159 .flags = IORESOURCE_IRQ
163 /* I2C controllers. The IOP13XX uses the same block as the IOP3xx, so
164 * we just use the same device name.
167 /* The ids are fixed up later in iop13xx_platform_init */
168 static struct platform_device iop13xx_i2c_0_controller = {
169 .name = "IOP3xx-I2C",
170 .id = 0,
171 .num_resources = 2,
172 .resource = iop13xx_i2c_0_resources
175 static struct platform_device iop13xx_i2c_1_controller = {
176 .name = "IOP3xx-I2C",
177 .id = 0,
178 .num_resources = 2,
179 .resource = iop13xx_i2c_1_resources
182 static struct platform_device iop13xx_i2c_2_controller = {
183 .name = "IOP3xx-I2C",
184 .id = 0,
185 .num_resources = 2,
186 .resource = iop13xx_i2c_2_resources
189 #ifdef CONFIG_MTD_PHYSMAP
190 /* PBI Flash Device
192 static struct physmap_flash_data iq8134x_flash_data = {
193 .width = 2,
196 static struct resource iq8134x_flash_resource = {
197 .start = IQ81340_FLASHBASE,
198 .end = 0,
199 .flags = IORESOURCE_MEM,
202 static struct platform_device iq8134x_flash = {
203 .name = "physmap-flash",
204 .id = 0,
205 .dev = { .platform_data = &iq8134x_flash_data, },
206 .num_resources = 1,
207 .resource = &iq8134x_flash_resource,
210 static unsigned long iq8134x_probe_flash_size(void)
212 uint8_t __iomem *flash_addr = ioremap(IQ81340_FLASHBASE, PAGE_SIZE);
213 int i;
214 char query[3];
215 unsigned long size = 0;
216 int width = iq8134x_flash_data.width;
218 if (flash_addr) {
219 /* send CFI 'query' command */
220 writew(0x98, flash_addr);
222 /* check for CFI compliance */
223 for (i = 0; i < 3 * width; i += width)
224 query[i / width] = readb(flash_addr + (0x10 * width) + i);
226 /* read the size */
227 if (memcmp(query, "QRY", 3) == 0)
228 size = 1 << readb(flash_addr + (0x27 * width));
230 /* send CFI 'read array' command */
231 writew(0xff, flash_addr);
233 iounmap(flash_addr);
236 return size;
238 #endif
240 /* ADMA Channels */
241 static struct resource iop13xx_adma_0_resources[] = {
242 [0] = {
243 .start = IOP13XX_ADMA_PHYS_BASE(0),
244 .end = IOP13XX_ADMA_UPPER_PA(0),
245 .flags = IORESOURCE_MEM,
247 [1] = {
248 .start = IRQ_IOP13XX_ADMA0_EOT,
249 .end = IRQ_IOP13XX_ADMA0_EOT,
250 .flags = IORESOURCE_IRQ
252 [2] = {
253 .start = IRQ_IOP13XX_ADMA0_EOC,
254 .end = IRQ_IOP13XX_ADMA0_EOC,
255 .flags = IORESOURCE_IRQ
257 [3] = {
258 .start = IRQ_IOP13XX_ADMA0_ERR,
259 .end = IRQ_IOP13XX_ADMA0_ERR,
260 .flags = IORESOURCE_IRQ
264 static struct resource iop13xx_adma_1_resources[] = {
265 [0] = {
266 .start = IOP13XX_ADMA_PHYS_BASE(1),
267 .end = IOP13XX_ADMA_UPPER_PA(1),
268 .flags = IORESOURCE_MEM,
270 [1] = {
271 .start = IRQ_IOP13XX_ADMA1_EOT,
272 .end = IRQ_IOP13XX_ADMA1_EOT,
273 .flags = IORESOURCE_IRQ
275 [2] = {
276 .start = IRQ_IOP13XX_ADMA1_EOC,
277 .end = IRQ_IOP13XX_ADMA1_EOC,
278 .flags = IORESOURCE_IRQ
280 [3] = {
281 .start = IRQ_IOP13XX_ADMA1_ERR,
282 .end = IRQ_IOP13XX_ADMA1_ERR,
283 .flags = IORESOURCE_IRQ
287 static struct resource iop13xx_adma_2_resources[] = {
288 [0] = {
289 .start = IOP13XX_ADMA_PHYS_BASE(2),
290 .end = IOP13XX_ADMA_UPPER_PA(2),
291 .flags = IORESOURCE_MEM,
293 [1] = {
294 .start = IRQ_IOP13XX_ADMA2_EOT,
295 .end = IRQ_IOP13XX_ADMA2_EOT,
296 .flags = IORESOURCE_IRQ
298 [2] = {
299 .start = IRQ_IOP13XX_ADMA2_EOC,
300 .end = IRQ_IOP13XX_ADMA2_EOC,
301 .flags = IORESOURCE_IRQ
303 [3] = {
304 .start = IRQ_IOP13XX_ADMA2_ERR,
305 .end = IRQ_IOP13XX_ADMA2_ERR,
306 .flags = IORESOURCE_IRQ
310 static u64 iop13xx_adma_dmamask = DMA_64BIT_MASK;
311 static struct iop_adma_platform_data iop13xx_adma_0_data = {
312 .hw_id = 0,
313 .pool_size = PAGE_SIZE,
316 static struct iop_adma_platform_data iop13xx_adma_1_data = {
317 .hw_id = 1,
318 .pool_size = PAGE_SIZE,
321 static struct iop_adma_platform_data iop13xx_adma_2_data = {
322 .hw_id = 2,
323 .pool_size = PAGE_SIZE,
326 /* The ids are fixed up later in iop13xx_platform_init */
327 static struct platform_device iop13xx_adma_0_channel = {
328 .name = "iop-adma",
329 .id = 0,
330 .num_resources = 4,
331 .resource = iop13xx_adma_0_resources,
332 .dev = {
333 .dma_mask = &iop13xx_adma_dmamask,
334 .coherent_dma_mask = DMA_64BIT_MASK,
335 .platform_data = (void *) &iop13xx_adma_0_data,
339 static struct platform_device iop13xx_adma_1_channel = {
340 .name = "iop-adma",
341 .id = 0,
342 .num_resources = 4,
343 .resource = iop13xx_adma_1_resources,
344 .dev = {
345 .dma_mask = &iop13xx_adma_dmamask,
346 .coherent_dma_mask = DMA_64BIT_MASK,
347 .platform_data = (void *) &iop13xx_adma_1_data,
351 static struct platform_device iop13xx_adma_2_channel = {
352 .name = "iop-adma",
353 .id = 0,
354 .num_resources = 4,
355 .resource = iop13xx_adma_2_resources,
356 .dev = {
357 .dma_mask = &iop13xx_adma_dmamask,
358 .coherent_dma_mask = DMA_64BIT_MASK,
359 .platform_data = (void *) &iop13xx_adma_2_data,
363 void __init iop13xx_map_io(void)
365 /* Initialize the Static Page Table maps */
366 iotable_init(iop13xx_std_desc, ARRAY_SIZE(iop13xx_std_desc));
369 static int init_uart;
370 static int init_i2c;
371 static int init_adma;
373 void __init iop13xx_platform_init(void)
375 int i;
376 u32 uart_idx, i2c_idx, adma_idx, plat_idx;
377 struct platform_device *iop13xx_devices[IQ81340_MAX_PLAT_DEVICES];
379 /* set the bases so we can read the device id */
380 iop13xx_set_atu_mmr_bases();
382 memset(iop13xx_devices, 0, sizeof(iop13xx_devices));
384 if (init_uart == IOP13XX_INIT_UART_DEFAULT) {
385 switch (iop13xx_dev_id()) {
386 /* enable both uarts on iop341 */
387 case 0x3380:
388 case 0x3384:
389 case 0x3388:
390 case 0x338c:
391 init_uart |= IOP13XX_INIT_UART_0;
392 init_uart |= IOP13XX_INIT_UART_1;
393 break;
394 /* only enable uart 1 */
395 default:
396 init_uart |= IOP13XX_INIT_UART_1;
400 if (init_i2c == IOP13XX_INIT_I2C_DEFAULT) {
401 switch (iop13xx_dev_id()) {
402 /* enable all i2c units on iop341 and iop342 */
403 case 0x3380:
404 case 0x3384:
405 case 0x3388:
406 case 0x338c:
407 case 0x3382:
408 case 0x3386:
409 case 0x338a:
410 case 0x338e:
411 init_i2c |= IOP13XX_INIT_I2C_0;
412 init_i2c |= IOP13XX_INIT_I2C_1;
413 init_i2c |= IOP13XX_INIT_I2C_2;
414 break;
415 /* only enable i2c 1 and 2 */
416 default:
417 init_i2c |= IOP13XX_INIT_I2C_1;
418 init_i2c |= IOP13XX_INIT_I2C_2;
422 if (init_adma == IOP13XX_INIT_ADMA_DEFAULT) {
423 init_adma |= IOP13XX_INIT_ADMA_0;
424 init_adma |= IOP13XX_INIT_ADMA_1;
425 init_adma |= IOP13XX_INIT_ADMA_2;
428 plat_idx = 0;
429 uart_idx = 0;
430 i2c_idx = 0;
432 /* uart 1 (if enabled) is ttyS0 */
433 if (init_uart & IOP13XX_INIT_UART_1) {
434 PRINTK("Adding uart1 to platform device list\n");
435 iop13xx_uart1.id = uart_idx++;
436 iop13xx_devices[plat_idx++] = &iop13xx_uart1;
438 if (init_uart & IOP13XX_INIT_UART_0) {
439 PRINTK("Adding uart0 to platform device list\n");
440 iop13xx_uart0.id = uart_idx++;
441 iop13xx_devices[plat_idx++] = &iop13xx_uart0;
444 for(i = 0; i < IQ81340_NUM_I2C; i++) {
445 if ((init_i2c & (1 << i)) && IOP13XX_SETUP_DEBUG)
446 printk("Adding i2c%d to platform device list\n", i);
447 switch(init_i2c & (1 << i)) {
448 case IOP13XX_INIT_I2C_0:
449 iop13xx_i2c_0_controller.id = i2c_idx++;
450 iop13xx_devices[plat_idx++] =
451 &iop13xx_i2c_0_controller;
452 break;
453 case IOP13XX_INIT_I2C_1:
454 iop13xx_i2c_1_controller.id = i2c_idx++;
455 iop13xx_devices[plat_idx++] =
456 &iop13xx_i2c_1_controller;
457 break;
458 case IOP13XX_INIT_I2C_2:
459 iop13xx_i2c_2_controller.id = i2c_idx++;
460 iop13xx_devices[plat_idx++] =
461 &iop13xx_i2c_2_controller;
462 break;
466 /* initialize adma channel ids and capabilities */
467 adma_idx = 0;
468 for (i = 0; i < IQ81340_NUM_ADMA; i++) {
469 struct iop_adma_platform_data *plat_data;
470 if ((init_adma & (1 << i)) && IOP13XX_SETUP_DEBUG)
471 printk(KERN_INFO
472 "Adding adma%d to platform device list\n", i);
473 switch (init_adma & (1 << i)) {
474 case IOP13XX_INIT_ADMA_0:
475 iop13xx_adma_0_channel.id = adma_idx++;
476 iop13xx_devices[plat_idx++] = &iop13xx_adma_0_channel;
477 plat_data = &iop13xx_adma_0_data;
478 dma_cap_set(DMA_MEMCPY, plat_data->cap_mask);
479 dma_cap_set(DMA_XOR, plat_data->cap_mask);
480 dma_cap_set(DMA_DUAL_XOR, plat_data->cap_mask);
481 dma_cap_set(DMA_ZERO_SUM, plat_data->cap_mask);
482 dma_cap_set(DMA_MEMSET, plat_data->cap_mask);
483 dma_cap_set(DMA_MEMCPY_CRC32C, plat_data->cap_mask);
484 dma_cap_set(DMA_INTERRUPT, plat_data->cap_mask);
485 break;
486 case IOP13XX_INIT_ADMA_1:
487 iop13xx_adma_1_channel.id = adma_idx++;
488 iop13xx_devices[plat_idx++] = &iop13xx_adma_1_channel;
489 plat_data = &iop13xx_adma_1_data;
490 dma_cap_set(DMA_MEMCPY, plat_data->cap_mask);
491 dma_cap_set(DMA_XOR, plat_data->cap_mask);
492 dma_cap_set(DMA_DUAL_XOR, plat_data->cap_mask);
493 dma_cap_set(DMA_ZERO_SUM, plat_data->cap_mask);
494 dma_cap_set(DMA_MEMSET, plat_data->cap_mask);
495 dma_cap_set(DMA_MEMCPY_CRC32C, plat_data->cap_mask);
496 dma_cap_set(DMA_INTERRUPT, plat_data->cap_mask);
497 break;
498 case IOP13XX_INIT_ADMA_2:
499 iop13xx_adma_2_channel.id = adma_idx++;
500 iop13xx_devices[plat_idx++] = &iop13xx_adma_2_channel;
501 plat_data = &iop13xx_adma_2_data;
502 dma_cap_set(DMA_MEMCPY, plat_data->cap_mask);
503 dma_cap_set(DMA_XOR, plat_data->cap_mask);
504 dma_cap_set(DMA_DUAL_XOR, plat_data->cap_mask);
505 dma_cap_set(DMA_ZERO_SUM, plat_data->cap_mask);
506 dma_cap_set(DMA_MEMSET, plat_data->cap_mask);
507 dma_cap_set(DMA_MEMCPY_CRC32C, plat_data->cap_mask);
508 dma_cap_set(DMA_INTERRUPT, plat_data->cap_mask);
509 dma_cap_set(DMA_PQ_XOR, plat_data->cap_mask);
510 dma_cap_set(DMA_PQ_UPDATE, plat_data->cap_mask);
511 dma_cap_set(DMA_PQ_ZERO_SUM, plat_data->cap_mask);
512 break;
516 #ifdef CONFIG_MTD_PHYSMAP
517 iq8134x_flash_resource.end = iq8134x_flash_resource.start +
518 iq8134x_probe_flash_size() - 1;
519 if (iq8134x_flash_resource.end > iq8134x_flash_resource.start)
520 iop13xx_devices[plat_idx++] = &iq8134x_flash;
521 else
522 <<<<<<< HEAD:arch/arm/mach-iop13xx/setup.c
523 printk(KERN_ERR "%s: Failed to probe flash size\n", __FUNCTION__);
524 =======
525 printk(KERN_ERR "%s: Failed to probe flash size\n", __func__);
526 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-iop13xx/setup.c
527 #endif
529 platform_add_devices(iop13xx_devices, plat_idx);
532 static int __init iop13xx_init_uart_setup(char *str)
534 if (str) {
535 while (*str != '\0') {
536 switch(*str) {
537 case '0':
538 init_uart |= IOP13XX_INIT_UART_0;
539 break;
540 case '1':
541 init_uart |= IOP13XX_INIT_UART_1;
542 break;
543 case ',':
544 case '=':
545 break;
546 default:
547 PRINTK("\"iop13xx_init_uart\" malformed"
548 " at character: \'%c\'", *str);
549 *(str + 1) = '\0';
550 init_uart = IOP13XX_INIT_UART_DEFAULT;
552 str++;
555 return 1;
558 static int __init iop13xx_init_i2c_setup(char *str)
560 if (str) {
561 while (*str != '\0') {
562 switch(*str) {
563 case '0':
564 init_i2c |= IOP13XX_INIT_I2C_0;
565 break;
566 case '1':
567 init_i2c |= IOP13XX_INIT_I2C_1;
568 break;
569 case '2':
570 init_i2c |= IOP13XX_INIT_I2C_2;
571 break;
572 case ',':
573 case '=':
574 break;
575 default:
576 PRINTK("\"iop13xx_init_i2c\" malformed"
577 " at character: \'%c\'", *str);
578 *(str + 1) = '\0';
579 init_i2c = IOP13XX_INIT_I2C_DEFAULT;
581 str++;
584 return 1;
587 static int __init iop13xx_init_adma_setup(char *str)
589 if (str) {
590 while (*str != '\0') {
591 switch (*str) {
592 case '0':
593 init_adma |= IOP13XX_INIT_ADMA_0;
594 break;
595 case '1':
596 init_adma |= IOP13XX_INIT_ADMA_1;
597 break;
598 case '2':
599 init_adma |= IOP13XX_INIT_ADMA_2;
600 break;
601 case ',':
602 case '=':
603 break;
604 default:
605 PRINTK("\"iop13xx_init_adma\" malformed"
606 " at character: \'%c\'", *str);
607 *(str + 1) = '\0';
608 init_adma = IOP13XX_INIT_ADMA_DEFAULT;
610 str++;
613 return 1;
616 __setup("iop13xx_init_adma", iop13xx_init_adma_setup);
617 __setup("iop13xx_init_uart", iop13xx_init_uart_setup);
618 __setup("iop13xx_init_i2c", iop13xx_init_i2c_setup);