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
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>
24 #include <asm/mach/map.h>
25 #include <mach/hardware.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,
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,
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,
55 static struct resource iop13xx_uart0_resources[] = {
57 .start = IOP13XX_UART0_PHYS,
58 .end = IOP13XX_UART0_PHYS + 0x3f,
59 .flags = IORESOURCE_MEM,
62 .start = IRQ_IOP13XX_UART0,
63 .end = IRQ_IOP13XX_UART0,
64 .flags = IORESOURCE_IRQ
68 static struct resource iop13xx_uart1_resources[] = {
70 .start = IOP13XX_UART1_PHYS,
71 .end = IOP13XX_UART1_PHYS + 0x3f,
72 .flags = IORESOURCE_MEM,
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,
89 .flags = UPF_SKIP_TEST,
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,
102 .flags = UPF_SKIP_TEST,
107 /* The ids are fixed up later in iop13xx_platform_init */
108 static struct platform_device iop13xx_uart0 = {
109 .name = "serial8250",
111 .dev.platform_data = iop13xx_uart0_data,
113 .resource = iop13xx_uart0_resources,
116 static struct platform_device iop13xx_uart1 = {
117 .name = "serial8250",
119 .dev.platform_data = iop13xx_uart1_data,
121 .resource = iop13xx_uart1_resources
124 static struct resource iop13xx_i2c_0_resources[] = {
126 .start = IOP13XX_I2C0_PHYS,
127 .end = IOP13XX_I2C0_PHYS + 0x18,
128 .flags = IORESOURCE_MEM,
131 .start = IRQ_IOP13XX_I2C_0,
132 .end = IRQ_IOP13XX_I2C_0,
133 .flags = IORESOURCE_IRQ
137 static struct resource iop13xx_i2c_1_resources[] = {
139 .start = IOP13XX_I2C1_PHYS,
140 .end = IOP13XX_I2C1_PHYS + 0x18,
141 .flags = IORESOURCE_MEM,
144 .start = IRQ_IOP13XX_I2C_1,
145 .end = IRQ_IOP13XX_I2C_1,
146 .flags = IORESOURCE_IRQ
150 static struct resource iop13xx_i2c_2_resources[] = {
152 .start = IOP13XX_I2C2_PHYS,
153 .end = IOP13XX_I2C2_PHYS + 0x18,
154 .flags = IORESOURCE_MEM,
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",
172 .resource = iop13xx_i2c_0_resources
175 static struct platform_device iop13xx_i2c_1_controller = {
176 .name = "IOP3xx-I2C",
179 .resource = iop13xx_i2c_1_resources
182 static struct platform_device iop13xx_i2c_2_controller = {
183 .name = "IOP3xx-I2C",
186 .resource = iop13xx_i2c_2_resources
189 #ifdef CONFIG_MTD_PHYSMAP
192 static struct physmap_flash_data iq8134x_flash_data = {
196 static struct resource iq8134x_flash_resource = {
197 .start = IQ81340_FLASHBASE,
199 .flags = IORESOURCE_MEM,
202 static struct platform_device iq8134x_flash = {
203 .name = "physmap-flash",
205 .dev = { .platform_data = &iq8134x_flash_data, },
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);
215 unsigned long size = 0;
216 int width = iq8134x_flash_data.width;
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);
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);
241 static struct resource iop13xx_adma_0_resources[] = {
243 .start = IOP13XX_ADMA_PHYS_BASE(0),
244 .end = IOP13XX_ADMA_UPPER_PA(0),
245 .flags = IORESOURCE_MEM,
248 .start = IRQ_IOP13XX_ADMA0_EOT,
249 .end = IRQ_IOP13XX_ADMA0_EOT,
250 .flags = IORESOURCE_IRQ
253 .start = IRQ_IOP13XX_ADMA0_EOC,
254 .end = IRQ_IOP13XX_ADMA0_EOC,
255 .flags = IORESOURCE_IRQ
258 .start = IRQ_IOP13XX_ADMA0_ERR,
259 .end = IRQ_IOP13XX_ADMA0_ERR,
260 .flags = IORESOURCE_IRQ
264 static struct resource iop13xx_adma_1_resources[] = {
266 .start = IOP13XX_ADMA_PHYS_BASE(1),
267 .end = IOP13XX_ADMA_UPPER_PA(1),
268 .flags = IORESOURCE_MEM,
271 .start = IRQ_IOP13XX_ADMA1_EOT,
272 .end = IRQ_IOP13XX_ADMA1_EOT,
273 .flags = IORESOURCE_IRQ
276 .start = IRQ_IOP13XX_ADMA1_EOC,
277 .end = IRQ_IOP13XX_ADMA1_EOC,
278 .flags = IORESOURCE_IRQ
281 .start = IRQ_IOP13XX_ADMA1_ERR,
282 .end = IRQ_IOP13XX_ADMA1_ERR,
283 .flags = IORESOURCE_IRQ
287 static struct resource iop13xx_adma_2_resources[] = {
289 .start = IOP13XX_ADMA_PHYS_BASE(2),
290 .end = IOP13XX_ADMA_UPPER_PA(2),
291 .flags = IORESOURCE_MEM,
294 .start = IRQ_IOP13XX_ADMA2_EOT,
295 .end = IRQ_IOP13XX_ADMA2_EOT,
296 .flags = IORESOURCE_IRQ
299 .start = IRQ_IOP13XX_ADMA2_EOC,
300 .end = IRQ_IOP13XX_ADMA2_EOC,
301 .flags = IORESOURCE_IRQ
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 = {
313 .pool_size = PAGE_SIZE,
316 static struct iop_adma_platform_data iop13xx_adma_1_data = {
318 .pool_size = PAGE_SIZE,
321 static struct iop_adma_platform_data iop13xx_adma_2_data = {
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 = {
331 .resource = iop13xx_adma_0_resources,
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 = {
343 .resource = iop13xx_adma_1_resources,
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 = {
355 .resource = iop13xx_adma_2_resources,
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;
371 static int init_adma;
373 void __init iop13xx_platform_init(void)
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 */
391 init_uart |= IOP13XX_INIT_UART_0;
392 init_uart |= IOP13XX_INIT_UART_1;
394 /* only enable uart 1 */
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 */
411 init_i2c |= IOP13XX_INIT_I2C_0;
412 init_i2c |= IOP13XX_INIT_I2C_1;
413 init_i2c |= IOP13XX_INIT_I2C_2;
415 /* only enable i2c 1 and 2 */
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;
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;
453 case IOP13XX_INIT_I2C_1:
454 iop13xx_i2c_1_controller.id = i2c_idx++;
455 iop13xx_devices[plat_idx++] =
456 &iop13xx_i2c_1_controller;
458 case IOP13XX_INIT_I2C_2:
459 iop13xx_i2c_2_controller.id = i2c_idx++;
460 iop13xx_devices[plat_idx++] =
461 &iop13xx_i2c_2_controller;
466 /* initialize adma channel ids and capabilities */
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)
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);
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);
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);
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;
522 printk(KERN_ERR "%s: Failed to probe flash size\n", __func__);
525 platform_add_devices(iop13xx_devices, plat_idx);
528 static int __init iop13xx_init_uart_setup(char *str)
531 while (*str != '\0') {
534 init_uart |= IOP13XX_INIT_UART_0;
537 init_uart |= IOP13XX_INIT_UART_1;
543 PRINTK("\"iop13xx_init_uart\" malformed"
544 " at character: \'%c\'", *str);
546 init_uart = IOP13XX_INIT_UART_DEFAULT;
554 static int __init iop13xx_init_i2c_setup(char *str)
557 while (*str != '\0') {
560 init_i2c |= IOP13XX_INIT_I2C_0;
563 init_i2c |= IOP13XX_INIT_I2C_1;
566 init_i2c |= IOP13XX_INIT_I2C_2;
572 PRINTK("\"iop13xx_init_i2c\" malformed"
573 " at character: \'%c\'", *str);
575 init_i2c = IOP13XX_INIT_I2C_DEFAULT;
583 static int __init iop13xx_init_adma_setup(char *str)
586 while (*str != '\0') {
589 init_adma |= IOP13XX_INIT_ADMA_0;
592 init_adma |= IOP13XX_INIT_ADMA_1;
595 init_adma |= IOP13XX_INIT_ADMA_2;
601 PRINTK("\"iop13xx_init_adma\" malformed"
602 " at character: \'%c\'", *str);
604 init_adma = IOP13XX_INIT_ADMA_DEFAULT;
612 __setup("iop13xx_init_adma", iop13xx_init_adma_setup);
613 __setup("iop13xx_init_uart", iop13xx_init_uart_setup);
614 __setup("iop13xx_init_i2c", iop13xx_init_i2c_setup);