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/dma-mapping.h>
21 #include <linux/serial_8250.h>
23 #ifdef CONFIG_MTD_PHYSMAP
24 #include <linux/mtd/physmap.h>
26 #include <asm/mach/map.h>
27 #include <mach/hardware.h>
29 #include <asm/hardware/iop_adma.h>
31 #define IOP13XX_UART_XTAL 33334000
32 #define IOP13XX_SETUP_DEBUG 0
33 #define PRINTK(x...) ((void)(IOP13XX_SETUP_DEBUG && printk(x)))
35 /* Standard IO mapping for all IOP13XX based systems
37 static struct map_desc iop13xx_std_desc
[] __initdata
= {
38 { /* mem mapped registers */
39 .virtual = IOP13XX_PMMR_VIRT_MEM_BASE
,
40 .pfn
= __phys_to_pfn(IOP13XX_PMMR_PHYS_MEM_BASE
),
41 .length
= IOP13XX_PMMR_SIZE
,
43 }, { /* PCIE IO space */
44 .virtual = IOP13XX_PCIE_LOWER_IO_VA
,
45 .pfn
= __phys_to_pfn(IOP13XX_PCIE_LOWER_IO_PA
),
46 .length
= IOP13XX_PCIX_IO_WINDOW_SIZE
,
48 }, { /* PCIX IO space */
49 .virtual = IOP13XX_PCIX_LOWER_IO_VA
,
50 .pfn
= __phys_to_pfn(IOP13XX_PCIX_LOWER_IO_PA
),
51 .length
= IOP13XX_PCIX_IO_WINDOW_SIZE
,
56 static struct resource iop13xx_uart0_resources
[] = {
58 .start
= IOP13XX_UART0_PHYS
,
59 .end
= IOP13XX_UART0_PHYS
+ 0x3f,
60 .flags
= IORESOURCE_MEM
,
63 .start
= IRQ_IOP13XX_UART0
,
64 .end
= IRQ_IOP13XX_UART0
,
65 .flags
= IORESOURCE_IRQ
69 static struct resource iop13xx_uart1_resources
[] = {
71 .start
= IOP13XX_UART1_PHYS
,
72 .end
= IOP13XX_UART1_PHYS
+ 0x3f,
73 .flags
= IORESOURCE_MEM
,
76 .start
= IRQ_IOP13XX_UART1
,
77 .end
= IRQ_IOP13XX_UART1
,
78 .flags
= IORESOURCE_IRQ
82 static struct plat_serial8250_port iop13xx_uart0_data
[] = {
84 .membase
= (char*)(IOP13XX_UART0_VIRT
),
85 .mapbase
= (IOP13XX_UART0_PHYS
),
86 .irq
= IRQ_IOP13XX_UART0
,
87 .uartclk
= IOP13XX_UART_XTAL
,
90 .flags
= UPF_SKIP_TEST
,
95 static struct plat_serial8250_port iop13xx_uart1_data
[] = {
97 .membase
= (char*)(IOP13XX_UART1_VIRT
),
98 .mapbase
= (IOP13XX_UART1_PHYS
),
99 .irq
= IRQ_IOP13XX_UART1
,
100 .uartclk
= IOP13XX_UART_XTAL
,
103 .flags
= UPF_SKIP_TEST
,
108 /* The ids are fixed up later in iop13xx_platform_init */
109 static struct platform_device iop13xx_uart0
= {
110 .name
= "serial8250",
112 .dev
.platform_data
= iop13xx_uart0_data
,
114 .resource
= iop13xx_uart0_resources
,
117 static struct platform_device iop13xx_uart1
= {
118 .name
= "serial8250",
120 .dev
.platform_data
= iop13xx_uart1_data
,
122 .resource
= iop13xx_uart1_resources
125 static struct resource iop13xx_i2c_0_resources
[] = {
127 .start
= IOP13XX_I2C0_PHYS
,
128 .end
= IOP13XX_I2C0_PHYS
+ 0x18,
129 .flags
= IORESOURCE_MEM
,
132 .start
= IRQ_IOP13XX_I2C_0
,
133 .end
= IRQ_IOP13XX_I2C_0
,
134 .flags
= IORESOURCE_IRQ
138 static struct resource iop13xx_i2c_1_resources
[] = {
140 .start
= IOP13XX_I2C1_PHYS
,
141 .end
= IOP13XX_I2C1_PHYS
+ 0x18,
142 .flags
= IORESOURCE_MEM
,
145 .start
= IRQ_IOP13XX_I2C_1
,
146 .end
= IRQ_IOP13XX_I2C_1
,
147 .flags
= IORESOURCE_IRQ
151 static struct resource iop13xx_i2c_2_resources
[] = {
153 .start
= IOP13XX_I2C2_PHYS
,
154 .end
= IOP13XX_I2C2_PHYS
+ 0x18,
155 .flags
= IORESOURCE_MEM
,
158 .start
= IRQ_IOP13XX_I2C_2
,
159 .end
= IRQ_IOP13XX_I2C_2
,
160 .flags
= IORESOURCE_IRQ
164 /* I2C controllers. The IOP13XX uses the same block as the IOP3xx, so
165 * we just use the same device name.
168 /* The ids are fixed up later in iop13xx_platform_init */
169 static struct platform_device iop13xx_i2c_0_controller
= {
170 .name
= "IOP3xx-I2C",
173 .resource
= iop13xx_i2c_0_resources
176 static struct platform_device iop13xx_i2c_1_controller
= {
177 .name
= "IOP3xx-I2C",
180 .resource
= iop13xx_i2c_1_resources
183 static struct platform_device iop13xx_i2c_2_controller
= {
184 .name
= "IOP3xx-I2C",
187 .resource
= iop13xx_i2c_2_resources
190 #ifdef CONFIG_MTD_PHYSMAP
193 static struct physmap_flash_data iq8134x_flash_data
= {
197 static struct resource iq8134x_flash_resource
= {
198 .start
= IQ81340_FLASHBASE
,
200 .flags
= IORESOURCE_MEM
,
203 static struct platform_device iq8134x_flash
= {
204 .name
= "physmap-flash",
206 .dev
= { .platform_data
= &iq8134x_flash_data
, },
208 .resource
= &iq8134x_flash_resource
,
211 static unsigned long iq8134x_probe_flash_size(void)
213 uint8_t __iomem
*flash_addr
= ioremap(IQ81340_FLASHBASE
, PAGE_SIZE
);
216 unsigned long size
= 0;
217 int width
= iq8134x_flash_data
.width
;
220 /* send CFI 'query' command */
221 writew(0x98, flash_addr
);
223 /* check for CFI compliance */
224 for (i
= 0; i
< 3 * width
; i
+= width
)
225 query
[i
/ width
] = readb(flash_addr
+ (0x10 * width
) + i
);
228 if (memcmp(query
, "QRY", 3) == 0)
229 size
= 1 << readb(flash_addr
+ (0x27 * width
));
231 /* send CFI 'read array' command */
232 writew(0xff, flash_addr
);
242 static struct resource iop13xx_adma_0_resources
[] = {
244 .start
= IOP13XX_ADMA_PHYS_BASE(0),
245 .end
= IOP13XX_ADMA_UPPER_PA(0),
246 .flags
= IORESOURCE_MEM
,
249 .start
= IRQ_IOP13XX_ADMA0_EOT
,
250 .end
= IRQ_IOP13XX_ADMA0_EOT
,
251 .flags
= IORESOURCE_IRQ
254 .start
= IRQ_IOP13XX_ADMA0_EOC
,
255 .end
= IRQ_IOP13XX_ADMA0_EOC
,
256 .flags
= IORESOURCE_IRQ
259 .start
= IRQ_IOP13XX_ADMA0_ERR
,
260 .end
= IRQ_IOP13XX_ADMA0_ERR
,
261 .flags
= IORESOURCE_IRQ
265 static struct resource iop13xx_adma_1_resources
[] = {
267 .start
= IOP13XX_ADMA_PHYS_BASE(1),
268 .end
= IOP13XX_ADMA_UPPER_PA(1),
269 .flags
= IORESOURCE_MEM
,
272 .start
= IRQ_IOP13XX_ADMA1_EOT
,
273 .end
= IRQ_IOP13XX_ADMA1_EOT
,
274 .flags
= IORESOURCE_IRQ
277 .start
= IRQ_IOP13XX_ADMA1_EOC
,
278 .end
= IRQ_IOP13XX_ADMA1_EOC
,
279 .flags
= IORESOURCE_IRQ
282 .start
= IRQ_IOP13XX_ADMA1_ERR
,
283 .end
= IRQ_IOP13XX_ADMA1_ERR
,
284 .flags
= IORESOURCE_IRQ
288 static struct resource iop13xx_adma_2_resources
[] = {
290 .start
= IOP13XX_ADMA_PHYS_BASE(2),
291 .end
= IOP13XX_ADMA_UPPER_PA(2),
292 .flags
= IORESOURCE_MEM
,
295 .start
= IRQ_IOP13XX_ADMA2_EOT
,
296 .end
= IRQ_IOP13XX_ADMA2_EOT
,
297 .flags
= IORESOURCE_IRQ
300 .start
= IRQ_IOP13XX_ADMA2_EOC
,
301 .end
= IRQ_IOP13XX_ADMA2_EOC
,
302 .flags
= IORESOURCE_IRQ
305 .start
= IRQ_IOP13XX_ADMA2_ERR
,
306 .end
= IRQ_IOP13XX_ADMA2_ERR
,
307 .flags
= IORESOURCE_IRQ
311 static u64 iop13xx_adma_dmamask
= DMA_BIT_MASK(64);
312 static struct iop_adma_platform_data iop13xx_adma_0_data
= {
314 .pool_size
= PAGE_SIZE
,
317 static struct iop_adma_platform_data iop13xx_adma_1_data
= {
319 .pool_size
= PAGE_SIZE
,
322 static struct iop_adma_platform_data iop13xx_adma_2_data
= {
324 .pool_size
= PAGE_SIZE
,
327 /* The ids are fixed up later in iop13xx_platform_init */
328 static struct platform_device iop13xx_adma_0_channel
= {
332 .resource
= iop13xx_adma_0_resources
,
334 .dma_mask
= &iop13xx_adma_dmamask
,
335 .coherent_dma_mask
= DMA_BIT_MASK(64),
336 .platform_data
= (void *) &iop13xx_adma_0_data
,
340 static struct platform_device iop13xx_adma_1_channel
= {
344 .resource
= iop13xx_adma_1_resources
,
346 .dma_mask
= &iop13xx_adma_dmamask
,
347 .coherent_dma_mask
= DMA_BIT_MASK(64),
348 .platform_data
= (void *) &iop13xx_adma_1_data
,
352 static struct platform_device iop13xx_adma_2_channel
= {
356 .resource
= iop13xx_adma_2_resources
,
358 .dma_mask
= &iop13xx_adma_dmamask
,
359 .coherent_dma_mask
= DMA_BIT_MASK(64),
360 .platform_data
= (void *) &iop13xx_adma_2_data
,
364 void __init
iop13xx_map_io(void)
366 /* Initialize the Static Page Table maps */
367 iotable_init(iop13xx_std_desc
, ARRAY_SIZE(iop13xx_std_desc
));
370 static int init_uart
;
372 static int init_adma
;
374 void __init
iop13xx_platform_init(void)
377 u32 uart_idx
, i2c_idx
, adma_idx
, plat_idx
;
378 struct platform_device
*iop13xx_devices
[IQ81340_MAX_PLAT_DEVICES
];
380 /* set the bases so we can read the device id */
381 iop13xx_set_atu_mmr_bases();
383 memset(iop13xx_devices
, 0, sizeof(iop13xx_devices
));
385 if (init_uart
== IOP13XX_INIT_UART_DEFAULT
) {
386 switch (iop13xx_dev_id()) {
387 /* enable both uarts on iop341 */
392 init_uart
|= IOP13XX_INIT_UART_0
;
393 init_uart
|= IOP13XX_INIT_UART_1
;
395 /* only enable uart 1 */
397 init_uart
|= IOP13XX_INIT_UART_1
;
401 if (init_i2c
== IOP13XX_INIT_I2C_DEFAULT
) {
402 switch (iop13xx_dev_id()) {
403 /* enable all i2c units on iop341 and iop342 */
412 init_i2c
|= IOP13XX_INIT_I2C_0
;
413 init_i2c
|= IOP13XX_INIT_I2C_1
;
414 init_i2c
|= IOP13XX_INIT_I2C_2
;
416 /* only enable i2c 1 and 2 */
418 init_i2c
|= IOP13XX_INIT_I2C_1
;
419 init_i2c
|= IOP13XX_INIT_I2C_2
;
423 if (init_adma
== IOP13XX_INIT_ADMA_DEFAULT
) {
424 init_adma
|= IOP13XX_INIT_ADMA_0
;
425 init_adma
|= IOP13XX_INIT_ADMA_1
;
426 init_adma
|= IOP13XX_INIT_ADMA_2
;
433 /* uart 1 (if enabled) is ttyS0 */
434 if (init_uart
& IOP13XX_INIT_UART_1
) {
435 PRINTK("Adding uart1 to platform device list\n");
436 iop13xx_uart1
.id
= uart_idx
++;
437 iop13xx_devices
[plat_idx
++] = &iop13xx_uart1
;
439 if (init_uart
& IOP13XX_INIT_UART_0
) {
440 PRINTK("Adding uart0 to platform device list\n");
441 iop13xx_uart0
.id
= uart_idx
++;
442 iop13xx_devices
[plat_idx
++] = &iop13xx_uart0
;
445 for(i
= 0; i
< IQ81340_NUM_I2C
; i
++) {
446 if ((init_i2c
& (1 << i
)) && IOP13XX_SETUP_DEBUG
)
447 printk("Adding i2c%d to platform device list\n", i
);
448 switch(init_i2c
& (1 << i
)) {
449 case IOP13XX_INIT_I2C_0
:
450 iop13xx_i2c_0_controller
.id
= i2c_idx
++;
451 iop13xx_devices
[plat_idx
++] =
452 &iop13xx_i2c_0_controller
;
454 case IOP13XX_INIT_I2C_1
:
455 iop13xx_i2c_1_controller
.id
= i2c_idx
++;
456 iop13xx_devices
[plat_idx
++] =
457 &iop13xx_i2c_1_controller
;
459 case IOP13XX_INIT_I2C_2
:
460 iop13xx_i2c_2_controller
.id
= i2c_idx
++;
461 iop13xx_devices
[plat_idx
++] =
462 &iop13xx_i2c_2_controller
;
467 /* initialize adma channel ids and capabilities */
469 for (i
= 0; i
< IQ81340_NUM_ADMA
; i
++) {
470 struct iop_adma_platform_data
*plat_data
;
471 if ((init_adma
& (1 << i
)) && IOP13XX_SETUP_DEBUG
)
473 "Adding adma%d to platform device list\n", i
);
474 switch (init_adma
& (1 << i
)) {
475 case IOP13XX_INIT_ADMA_0
:
476 iop13xx_adma_0_channel
.id
= adma_idx
++;
477 iop13xx_devices
[plat_idx
++] = &iop13xx_adma_0_channel
;
478 plat_data
= &iop13xx_adma_0_data
;
479 dma_cap_set(DMA_MEMCPY
, plat_data
->cap_mask
);
480 dma_cap_set(DMA_XOR
, plat_data
->cap_mask
);
481 dma_cap_set(DMA_XOR_VAL
, plat_data
->cap_mask
);
482 dma_cap_set(DMA_MEMSET
, plat_data
->cap_mask
);
483 dma_cap_set(DMA_INTERRUPT
, plat_data
->cap_mask
);
485 case IOP13XX_INIT_ADMA_1
:
486 iop13xx_adma_1_channel
.id
= adma_idx
++;
487 iop13xx_devices
[plat_idx
++] = &iop13xx_adma_1_channel
;
488 plat_data
= &iop13xx_adma_1_data
;
489 dma_cap_set(DMA_MEMCPY
, plat_data
->cap_mask
);
490 dma_cap_set(DMA_XOR
, plat_data
->cap_mask
);
491 dma_cap_set(DMA_XOR_VAL
, plat_data
->cap_mask
);
492 dma_cap_set(DMA_MEMSET
, plat_data
->cap_mask
);
493 dma_cap_set(DMA_INTERRUPT
, plat_data
->cap_mask
);
495 case IOP13XX_INIT_ADMA_2
:
496 iop13xx_adma_2_channel
.id
= adma_idx
++;
497 iop13xx_devices
[plat_idx
++] = &iop13xx_adma_2_channel
;
498 plat_data
= &iop13xx_adma_2_data
;
499 dma_cap_set(DMA_MEMCPY
, plat_data
->cap_mask
);
500 dma_cap_set(DMA_XOR
, plat_data
->cap_mask
);
501 dma_cap_set(DMA_XOR_VAL
, plat_data
->cap_mask
);
502 dma_cap_set(DMA_MEMSET
, plat_data
->cap_mask
);
503 dma_cap_set(DMA_INTERRUPT
, plat_data
->cap_mask
);
504 dma_cap_set(DMA_PQ
, plat_data
->cap_mask
);
505 dma_cap_set(DMA_PQ_VAL
, plat_data
->cap_mask
);
510 #ifdef CONFIG_MTD_PHYSMAP
511 iq8134x_flash_resource
.end
= iq8134x_flash_resource
.start
+
512 iq8134x_probe_flash_size() - 1;
513 if (iq8134x_flash_resource
.end
> iq8134x_flash_resource
.start
)
514 iop13xx_devices
[plat_idx
++] = &iq8134x_flash
;
516 printk(KERN_ERR
"%s: Failed to probe flash size\n", __func__
);
519 platform_add_devices(iop13xx_devices
, plat_idx
);
522 static int __init
iop13xx_init_uart_setup(char *str
)
525 while (*str
!= '\0') {
528 init_uart
|= IOP13XX_INIT_UART_0
;
531 init_uart
|= IOP13XX_INIT_UART_1
;
537 PRINTK("\"iop13xx_init_uart\" malformed"
538 " at character: \'%c\'", *str
);
540 init_uart
= IOP13XX_INIT_UART_DEFAULT
;
548 static int __init
iop13xx_init_i2c_setup(char *str
)
551 while (*str
!= '\0') {
554 init_i2c
|= IOP13XX_INIT_I2C_0
;
557 init_i2c
|= IOP13XX_INIT_I2C_1
;
560 init_i2c
|= IOP13XX_INIT_I2C_2
;
566 PRINTK("\"iop13xx_init_i2c\" malformed"
567 " at character: \'%c\'", *str
);
569 init_i2c
= IOP13XX_INIT_I2C_DEFAULT
;
577 static int __init
iop13xx_init_adma_setup(char *str
)
580 while (*str
!= '\0') {
583 init_adma
|= IOP13XX_INIT_ADMA_0
;
586 init_adma
|= IOP13XX_INIT_ADMA_1
;
589 init_adma
|= IOP13XX_INIT_ADMA_2
;
595 PRINTK("\"iop13xx_init_adma\" malformed"
596 " at character: \'%c\'", *str
);
598 init_adma
= IOP13XX_INIT_ADMA_DEFAULT
;
606 __setup("iop13xx_init_adma", iop13xx_init_adma_setup
);
607 __setup("iop13xx_init_uart", iop13xx_init_uart_setup
);
608 __setup("iop13xx_init_i2c", iop13xx_init_i2c_setup
);