2 * linux/arch/arm/mach-pxa/trizeps4.c
4 * Support for the Keith und Koep Trizeps4 Module Platform.
6 * Author: Jürgen Schindele
8 * Copyright: Jürgen Schindele
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/platform_device.h>
18 #include <linux/sysdev.h>
19 #include <linux/interrupt.h>
20 #include <linux/sched.h>
21 #include <linux/bitops.h>
23 #include <linux/ioport.h>
24 #include <linux/delay.h>
25 #include <linux/gpio.h>
26 #include <linux/dm9000.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/mtd/partitions.h>
30 #include <asm/types.h>
31 #include <asm/setup.h>
32 #include <asm/memory.h>
33 #include <asm/mach-types.h>
35 #include <asm/sizes.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
39 #include <asm/mach/irq.h>
40 #include <asm/mach/flash.h>
42 #include <mach/hardware.h>
43 #include <mach/pxa-regs.h>
44 #include <mach/pxa2xx-regs.h>
45 #include <mach/mfp-pxa27x.h>
46 #include <mach/pxa2xx_spi.h>
47 #include <mach/trizeps4.h>
48 #include <mach/audio.h>
49 #include <mach/pxafb.h>
51 #include <mach/irda.h>
52 #include <mach/ohci.h>
58 /* comment out the following line if you want to use the
59 * Standard UART from PXA for serial / irda transmission
60 * and acivate it if you have status leds connected */
61 #define STATUS_LEDS_ON_STUART_PINS 1
63 /*****************************************************************************
64 * MultiFunctionPins of CPU
65 *****************************************************************************/
66 static unsigned long trizeps4_pin_config
[] __initdata
= {
68 GPIO15_nCS_1
, /* DiskOnChip CS */
69 GPIO93_GPIO
, /* TRIZEPS4_DOC_IRQ */
70 GPIO94_GPIO
, /* DOC lock */
72 GPIO78_nCS_2
, /* DM9000 CS */
73 GPIO101_GPIO
, /* TRIZEPS4_ETH_IRQ */
75 GPIO79_nCS_3
, /* Logic CS */
76 GPIO0_GPIO
| WAKEUP_ON_EDGE_RISE
, /* Logic irq */
78 /* LCD - 16bpp Active TFT */
114 #ifdef STATUS_LEDS_ON_STUART_PINS
122 GPIO11_GPIO
, /* TRIZEPS4_CD_IRQ */
123 GPIO13_GPIO
, /* TRIZEPS4_READY_NINT */
142 GPIO12_GPIO
, /* TRIZEPS4_MMC_IRQ */
145 GPIO88_USBH1_PWR
, /* USBHPWR1 */
146 GPIO89_USBH1_PEN
, /* USBHPEN1 */
153 static unsigned long trizeps4wl_pin_config
[] __initdata
= {
157 GPIO53_GPIO
, /* TRIZEPS4_SPI_IRQ */
162 /****************************************************************************
164 ****************************************************************************/
165 static struct mtd_partition trizeps4_partitions
[] = {
167 .name
= "Bootloader",
168 .offset
= 0x00000000,
170 .mask_flags
= MTD_WRITEABLE
/* force read-only */
173 .offset
= 0x00040000,
177 .offset
= 0x00080000,
181 .offset
= 0x01100000,
185 .offset
= 0x01f00000,
186 .size
= MTDPART_SIZ_FULL
,
190 static struct physmap_flash_data trizeps4_flash_data
[] = {
192 .width
= 4, /* bankwidth in bytes */
193 .parts
= trizeps4_partitions
,
194 .nr_parts
= ARRAY_SIZE(trizeps4_partitions
)
198 static struct resource flash_resource
= {
199 .start
= PXA_CS0_PHYS
,
200 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
201 .flags
= IORESOURCE_MEM
,
204 static struct platform_device flash_device
= {
205 .name
= "physmap-flash",
208 .platform_data
= trizeps4_flash_data
,
210 .resource
= &flash_resource
,
214 /****************************************************************************
215 * DAVICOM DM9000 Ethernet
216 ****************************************************************************/
217 static struct resource dm9000_resources
[] = {
219 .start
= TRIZEPS4_ETH_PHYS
+0x300,
220 .end
= TRIZEPS4_ETH_PHYS
+0x400-1,
221 .flags
= IORESOURCE_MEM
,
224 .start
= TRIZEPS4_ETH_PHYS
+0x8300,
225 .end
= TRIZEPS4_ETH_PHYS
+0x8400-1,
226 .flags
= IORESOURCE_MEM
,
229 .start
= TRIZEPS4_ETH_IRQ
,
230 .end
= TRIZEPS4_ETH_IRQ
,
231 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
235 static struct dm9000_plat_data tri_dm9000_platdata
= {
236 .flags
= DM9000_PLATF_32BITONLY
,
239 static struct platform_device dm9000_device
= {
242 .num_resources
= ARRAY_SIZE(dm9000_resources
),
243 .resource
= dm9000_resources
,
245 .platform_data
= &tri_dm9000_platdata
,
249 /****************************************************************************
250 * LED's on GPIO pins of PXA
251 ****************************************************************************/
252 static struct gpio_led trizeps4_led
[] = {
253 #ifdef STATUS_LEDS_ON_STUART_PINS
255 .name
= "led0:orange:heartbeat", /* */
256 .default_trigger
= "heartbeat",
257 .gpio
= GPIO_HEARTBEAT_LED
,
261 .name
= "led1:yellow:cpubusy", /* */
262 .default_trigger
= "cpu-busy",
263 .gpio
= GPIO_SYS_BUSY_LED
,
269 static struct gpio_led_platform_data trizeps4_led_data
= {
270 .leds
= trizeps4_led
,
271 .num_leds
= ARRAY_SIZE(trizeps4_led
),
274 static struct platform_device leds_devices
= {
278 .platform_data
= &trizeps4_led_data
,
282 static struct platform_device
*trizeps4_devices
[] __initdata
= {
288 static struct platform_device
*trizeps4wl_devices
[] __initdata
= {
293 static short trizeps_conxs_bcr
;
295 /* PCCARD power switching supports only 3,3V */
296 void board_pcmcia_power(int power
)
299 /* switch power on, put in reset and enable buffers */
300 trizeps_conxs_bcr
|= power
;
301 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
302 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_BUF_EN
;
303 BCR_writew(trizeps_conxs_bcr
);
306 /* take reset away */
307 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_RESET
;
308 BCR_writew(trizeps_conxs_bcr
);
312 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
313 BCR_writew(trizeps_conxs_bcr
);
315 /* switch power off */
316 trizeps_conxs_bcr
&= ~0xf;
317 BCR_writew(trizeps_conxs_bcr
);
319 pr_debug("%s: o%s 0x%x\n", __func__
, power
? "n" : "ff",
322 EXPORT_SYMBOL(board_pcmcia_power
);
324 /* backlight power switching for LCD panel */
325 static void board_backlight_power(int on
)
328 trizeps_conxs_bcr
|= ConXS_BCR_L_DISP
;
330 trizeps_conxs_bcr
&= ~ConXS_BCR_L_DISP
;
332 pr_debug("%s: o%s 0x%x\n", __func__
, on
? "n" : "ff",
334 BCR_writew(trizeps_conxs_bcr
);
337 /* a I2C based RTC is known on CONXS board */
338 static struct i2c_board_info trizeps4_i2c_devices
[] __initdata
= {
339 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
342 /****************************************************************************
343 * MMC card slot external to module
344 ****************************************************************************/
345 static int trizeps4_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
,
350 err
= request_irq(TRIZEPS4_MMC_IRQ
, mci_detect_int
,
351 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_SAMPLE_RANDOM
,
352 "MMC card detect", data
);
354 printk(KERN_ERR
"trizeps4_mci_init: MMC/SD: can't request"
355 "MMC card detect IRQ\n");
361 static void trizeps4_mci_exit(struct device
*dev
, void *data
)
363 free_irq(TRIZEPS4_MMC_IRQ
, data
);
366 static struct pxamci_platform_data trizeps4_mci_platform_data
= {
367 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
369 .init
= trizeps4_mci_init
,
370 .exit
= trizeps4_mci_exit
,
371 .get_ro
= NULL
, /* write-protection not supported */
372 .setpower
= NULL
, /* power-switching not supported */
375 /****************************************************************************
376 * IRDA mode switching on stuart
377 ****************************************************************************/
378 #ifndef STATUS_LEDS_ON_STUART_PINS
379 static short trizeps_conxs_ircr
;
381 static int trizeps4_irda_startup(struct device
*dev
)
383 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
384 IRCR_writew(trizeps_conxs_ircr
);
388 static void trizeps4_irda_shutdown(struct device
*dev
)
390 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
391 IRCR_writew(trizeps_conxs_ircr
);
394 static void trizeps4_irda_transceiver_mode(struct device
*dev
, int mode
)
398 local_irq_save(flags
);
400 if (mode
& IR_SIRMODE
)
401 trizeps_conxs_ircr
&= ~ConXS_IRCR_MODE
; /* Slow mode */
402 else if (mode
& IR_FIRMODE
)
403 trizeps_conxs_ircr
|= ConXS_IRCR_MODE
; /* Fast mode */
407 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
409 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
411 IRCR_writew(trizeps_conxs_ircr
);
412 local_irq_restore(flags
);
414 pxa2xx_transceiver_mode(dev
, mode
);
417 static struct pxaficp_platform_data trizeps4_ficp_platform_data
= {
418 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
419 .transceiver_mode
= trizeps4_irda_transceiver_mode
,
420 .startup
= trizeps4_irda_startup
,
421 .shutdown
= trizeps4_irda_shutdown
,
425 /****************************************************************************
427 ****************************************************************************/
428 static struct pxaohci_platform_data trizeps4_ohci_platform_data
= {
429 .port_mode
= PMM_PERPORT_MODE
,
430 .flags
= ENABLE_PORT_ALL
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
433 static struct map_desc trizeps4_io_desc
[] __initdata
= {
435 .virtual = TRIZEPS4_CFSR_VIRT
,
436 .pfn
= __phys_to_pfn(TRIZEPS4_CFSR_PHYS
),
437 .length
= 0x00001000,
441 .virtual = TRIZEPS4_BOCR_VIRT
,
442 .pfn
= __phys_to_pfn(TRIZEPS4_BOCR_PHYS
),
443 .length
= 0x00001000,
447 .virtual = TRIZEPS4_IRCR_VIRT
,
448 .pfn
= __phys_to_pfn(TRIZEPS4_IRCR_PHYS
),
449 .length
= 0x00001000,
453 .virtual = TRIZEPS4_DICR_VIRT
,
454 .pfn
= __phys_to_pfn(TRIZEPS4_DICR_PHYS
),
455 .length
= 0x00001000,
459 .virtual = TRIZEPS4_UPSR_VIRT
,
460 .pfn
= __phys_to_pfn(TRIZEPS4_UPSR_PHYS
),
461 .length
= 0x00001000,
466 static struct pxafb_mode_info sharp_lcd_mode
= {
477 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
481 static struct pxafb_mach_info sharp_lcd
= {
482 .modes
= &sharp_lcd_mode
,
484 .lcd_conn
= LCD_COLOR_DSTN_16BPP
| LCD_PCLK_EDGE_FALL
,
487 .pxafb_backlight_power
= board_backlight_power
,
490 static struct pxafb_mode_info toshiba_lcd_mode
= {
505 static struct pxafb_mach_info toshiba_lcd
= {
506 .modes
= &toshiba_lcd_mode
,
508 .lcd_conn
= (LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
),
511 .pxafb_backlight_power
= board_backlight_power
,
514 static void __init
trizeps4_init(void)
516 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config
));
517 if (machine_is_trizeps4wl()) {
518 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config
));
519 platform_add_devices(trizeps4wl_devices
,
520 ARRAY_SIZE(trizeps4wl_devices
));
522 platform_add_devices(trizeps4_devices
,
523 ARRAY_SIZE(trizeps4_devices
));
526 if (0) /* dont know how to determine LCD */
527 set_pxa_fb_info(&sharp_lcd
);
529 set_pxa_fb_info(&toshiba_lcd
);
531 pxa_set_mci_info(&trizeps4_mci_platform_data
);
532 #ifndef STATUS_LEDS_ON_STUART_PINS
533 pxa_set_ficp_info(&trizeps4_ficp_platform_data
);
535 pxa_set_ohci_info(&trizeps4_ohci_platform_data
);
536 pxa_set_ac97_info(NULL
);
537 pxa_set_i2c_info(NULL
);
538 i2c_register_board_info(0, trizeps4_i2c_devices
,
539 ARRAY_SIZE(trizeps4_i2c_devices
));
541 #ifdef CONFIG_IDE_PXA_CF
542 /* if boot direct from compact flash dont disable power */
543 trizeps_conxs_bcr
= 0x0009;
545 /* this is the reset value */
546 trizeps_conxs_bcr
= 0x00A0;
548 BCR_writew(trizeps_conxs_bcr
);
549 board_backlight_power(1);
552 static void __init
trizeps4_map_io(void)
555 iotable_init(trizeps4_io_desc
, ARRAY_SIZE(trizeps4_io_desc
));
557 if ((MSC0
& 0x8) && (BOOT_DEF
& 0x1)) {
558 /* if flash is 16 bit wide its a Trizeps4 WL */
559 __machine_arch_type
= MACH_TYPE_TRIZEPS4WL
;
560 trizeps4_flash_data
[0].width
= 2;
562 /* if flash is 32 bit wide its a Trizeps4 */
563 __machine_arch_type
= MACH_TYPE_TRIZEPS4
;
564 trizeps4_flash_data
[0].width
= 4;
568 MACHINE_START(TRIZEPS4
, "Keith und Koep Trizeps IV module")
569 /* MAINTAINER("Jürgen Schindele") */
570 .phys_io
= 0x40000000,
571 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
572 .boot_params
= TRIZEPS4_SDRAM_BASE
+ 0x100,
573 .init_machine
= trizeps4_init
,
574 .map_io
= trizeps4_map_io
,
575 .init_irq
= pxa27x_init_irq
,
579 MACHINE_START(TRIZEPS4WL
, "Keith und Koep Trizeps IV-WL module")
580 /* MAINTAINER("Jürgen Schindele") */
581 .phys_io
= 0x40000000,
582 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
583 .boot_params
= TRIZEPS4_SDRAM_BASE
+ 0x100,
584 .init_machine
= trizeps4_init
,
585 .map_io
= trizeps4_map_io
,
586 .init_irq
= pxa27x_init_irq
,