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/interrupt.h>
19 #include <linux/leds.h>
20 #include <linux/export.h>
21 #include <linux/sched.h>
22 #include <linux/bitops.h>
24 #include <linux/ioport.h>
25 #include <linux/delay.h>
26 #include <linux/gpio.h>
27 #include <linux/dm9000.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/regulator/machine.h>
31 #include <linux/i2c/pxa-i2c.h>
33 #include <asm/types.h>
34 #include <asm/setup.h>
35 #include <asm/memory.h>
36 #include <asm/mach-types.h>
38 #include <asm/sizes.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
43 #include <asm/mach/flash.h>
46 #include <mach/trizeps4.h>
47 #include <mach/audio.h>
48 #include <linux/platform_data/video-pxafb.h>
49 #include <linux/platform_data/mmc-pxamci.h>
50 #include <linux/platform_data/irda-pxaficp.h>
51 #include <linux/platform_data/usb-ohci-pxa27x.h>
52 #include <mach/smemc.h>
57 /* comment out the following line if you want to use the
58 * Standard UART from PXA for serial / irda transmission
59 * and acivate it if you have status leds connected */
60 #define STATUS_LEDS_ON_STUART_PINS 1
62 /*****************************************************************************
63 * MultiFunctionPins of CPU
64 *****************************************************************************/
65 static unsigned long trizeps4_pin_config
[] __initdata
= {
67 GPIO15_nCS_1
, /* DiskOnChip CS */
68 GPIO93_GPIO
, /* TRIZEPS4_DOC_IRQ */
69 GPIO94_GPIO
, /* DOC lock */
71 GPIO78_nCS_2
, /* DM9000 CS */
72 GPIO101_GPIO
, /* TRIZEPS4_ETH_IRQ */
74 GPIO79_nCS_3
, /* Logic CS */
75 GPIO0_GPIO
| WAKEUP_ON_EDGE_RISE
, /* Logic irq */
79 GPIO29_AC97_SDATA_IN_0
,
80 GPIO30_AC97_SDATA_OUT
,
83 /* LCD - 16bpp Active TFT */
100 #ifdef STATUS_LEDS_ON_STUART_PINS
108 GPIO11_GPIO
, /* TRIZEPS4_CD_IRQ */
109 GPIO13_GPIO
, /* TRIZEPS4_READY_NINT */
128 GPIO12_GPIO
, /* TRIZEPS4_MMC_IRQ */
131 GPIO88_USBH1_PWR
, /* USBHPWR1 */
132 GPIO89_USBH1_PEN
, /* USBHPEN1 */
139 static unsigned long trizeps4wl_pin_config
[] __initdata
= {
143 GPIO53_GPIO
, /* TRIZEPS4_SPI_IRQ */
148 /****************************************************************************
150 ****************************************************************************/
151 static struct mtd_partition trizeps4_partitions
[] = {
153 .name
= "Bootloader",
154 .offset
= 0x00000000,
156 .mask_flags
= MTD_WRITEABLE
/* force read-only */
159 .offset
= 0x00040000,
163 .offset
= 0x00080000,
167 .offset
= 0x01100000,
171 .offset
= 0x01f00000,
172 .size
= MTDPART_SIZ_FULL
,
176 static struct physmap_flash_data trizeps4_flash_data
[] = {
178 .width
= 4, /* bankwidth in bytes */
179 .parts
= trizeps4_partitions
,
180 .nr_parts
= ARRAY_SIZE(trizeps4_partitions
)
184 static struct resource flash_resource
= {
185 .start
= PXA_CS0_PHYS
,
186 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
187 .flags
= IORESOURCE_MEM
,
190 static struct platform_device flash_device
= {
191 .name
= "physmap-flash",
194 .platform_data
= trizeps4_flash_data
,
196 .resource
= &flash_resource
,
200 /****************************************************************************
201 * DAVICOM DM9000 Ethernet
202 ****************************************************************************/
203 static struct resource dm9000_resources
[] = {
205 .start
= TRIZEPS4_ETH_PHYS
+0x300,
206 .end
= TRIZEPS4_ETH_PHYS
+0x400-1,
207 .flags
= IORESOURCE_MEM
,
210 .start
= TRIZEPS4_ETH_PHYS
+0x8300,
211 .end
= TRIZEPS4_ETH_PHYS
+0x8400-1,
212 .flags
= IORESOURCE_MEM
,
215 .start
= TRIZEPS4_ETH_IRQ
,
216 .end
= TRIZEPS4_ETH_IRQ
,
217 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
221 static struct dm9000_plat_data tri_dm9000_platdata
= {
222 .flags
= DM9000_PLATF_32BITONLY
,
225 static struct platform_device dm9000_device
= {
228 .num_resources
= ARRAY_SIZE(dm9000_resources
),
229 .resource
= dm9000_resources
,
231 .platform_data
= &tri_dm9000_platdata
,
235 /****************************************************************************
236 * LED's on GPIO pins of PXA
237 ****************************************************************************/
238 static struct gpio_led trizeps4_led
[] = {
239 #ifdef STATUS_LEDS_ON_STUART_PINS
241 .name
= "led0:orange:heartbeat", /* */
242 .default_trigger
= "heartbeat",
243 .gpio
= GPIO_HEARTBEAT_LED
,
247 .name
= "led1:yellow:cpubusy", /* */
248 .default_trigger
= "cpu-busy",
249 .gpio
= GPIO_SYS_BUSY_LED
,
255 static struct gpio_led_platform_data trizeps4_led_data
= {
256 .leds
= trizeps4_led
,
257 .num_leds
= ARRAY_SIZE(trizeps4_led
),
260 static struct platform_device leds_devices
= {
264 .platform_data
= &trizeps4_led_data
,
268 static struct platform_device
*trizeps4_devices
[] __initdata
= {
274 static struct platform_device
*trizeps4wl_devices
[] __initdata
= {
279 static short trizeps_conxs_bcr
;
281 /* PCCARD power switching supports only 3,3V */
282 void board_pcmcia_power(int power
)
285 /* switch power on, put in reset and enable buffers */
286 trizeps_conxs_bcr
|= power
;
287 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
288 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_BUF_EN
;
289 BCR_writew(trizeps_conxs_bcr
);
292 /* take reset away */
293 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_RESET
;
294 BCR_writew(trizeps_conxs_bcr
);
298 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
299 BCR_writew(trizeps_conxs_bcr
);
301 /* switch power off */
302 trizeps_conxs_bcr
&= ~0xf;
303 BCR_writew(trizeps_conxs_bcr
);
305 pr_debug("%s: o%s 0x%x\n", __func__
, power
? "n" : "ff",
308 EXPORT_SYMBOL(board_pcmcia_power
);
310 /* backlight power switching for LCD panel */
311 static void board_backlight_power(int on
)
314 trizeps_conxs_bcr
|= ConXS_BCR_L_DISP
;
316 trizeps_conxs_bcr
&= ~ConXS_BCR_L_DISP
;
318 pr_debug("%s: o%s 0x%x\n", __func__
, on
? "n" : "ff",
320 BCR_writew(trizeps_conxs_bcr
);
323 /* a I2C based RTC is known on CONXS board */
324 static struct i2c_board_info trizeps4_i2c_devices
[] __initdata
= {
325 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
328 /****************************************************************************
329 * MMC card slot external to module
330 ****************************************************************************/
331 static int trizeps4_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
,
336 err
= request_irq(TRIZEPS4_MMC_IRQ
, mci_detect_int
,
337 IRQF_TRIGGER_RISING
, "MMC card detect", data
);
339 printk(KERN_ERR
"trizeps4_mci_init: MMC/SD: can't request"
340 "MMC card detect IRQ\n");
346 static void trizeps4_mci_exit(struct device
*dev
, void *data
)
348 free_irq(TRIZEPS4_MMC_IRQ
, data
);
351 static struct pxamci_platform_data trizeps4_mci_platform_data
= {
352 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
353 .detect_delay_ms
= 10,
354 .init
= trizeps4_mci_init
,
355 .exit
= trizeps4_mci_exit
,
356 .get_ro
= NULL
, /* write-protection not supported */
357 .setpower
= NULL
, /* power-switching not supported */
358 .gpio_card_detect
= -1,
363 /****************************************************************************
364 * IRDA mode switching on stuart
365 ****************************************************************************/
366 #ifndef STATUS_LEDS_ON_STUART_PINS
367 static short trizeps_conxs_ircr
;
369 static int trizeps4_irda_startup(struct device
*dev
)
371 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
372 IRCR_writew(trizeps_conxs_ircr
);
376 static void trizeps4_irda_shutdown(struct device
*dev
)
378 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
379 IRCR_writew(trizeps_conxs_ircr
);
382 static void trizeps4_irda_transceiver_mode(struct device
*dev
, int mode
)
386 local_irq_save(flags
);
388 if (mode
& IR_SIRMODE
)
389 trizeps_conxs_ircr
&= ~ConXS_IRCR_MODE
; /* Slow mode */
390 else if (mode
& IR_FIRMODE
)
391 trizeps_conxs_ircr
|= ConXS_IRCR_MODE
; /* Fast mode */
395 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
397 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
399 IRCR_writew(trizeps_conxs_ircr
);
400 local_irq_restore(flags
);
402 pxa2xx_transceiver_mode(dev
, mode
);
405 static struct pxaficp_platform_data trizeps4_ficp_platform_data
= {
407 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
408 .transceiver_mode
= trizeps4_irda_transceiver_mode
,
409 .startup
= trizeps4_irda_startup
,
410 .shutdown
= trizeps4_irda_shutdown
,
414 /****************************************************************************
416 ****************************************************************************/
417 static struct pxaohci_platform_data trizeps4_ohci_platform_data
= {
418 .port_mode
= PMM_PERPORT_MODE
,
419 .flags
= ENABLE_PORT_ALL
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
422 static struct map_desc trizeps4_io_desc
[] __initdata
= {
424 .virtual = TRIZEPS4_CFSR_VIRT
,
425 .pfn
= __phys_to_pfn(TRIZEPS4_CFSR_PHYS
),
426 .length
= 0x00001000,
430 .virtual = TRIZEPS4_BOCR_VIRT
,
431 .pfn
= __phys_to_pfn(TRIZEPS4_BOCR_PHYS
),
432 .length
= 0x00001000,
436 .virtual = TRIZEPS4_IRCR_VIRT
,
437 .pfn
= __phys_to_pfn(TRIZEPS4_IRCR_PHYS
),
438 .length
= 0x00001000,
442 .virtual = TRIZEPS4_DICR_VIRT
,
443 .pfn
= __phys_to_pfn(TRIZEPS4_DICR_PHYS
),
444 .length
= 0x00001000,
448 .virtual = TRIZEPS4_UPSR_VIRT
,
449 .pfn
= __phys_to_pfn(TRIZEPS4_UPSR_PHYS
),
450 .length
= 0x00001000,
455 static struct pxafb_mode_info sharp_lcd_mode
= {
466 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
470 static struct pxafb_mach_info sharp_lcd
= {
471 .modes
= &sharp_lcd_mode
,
473 .lcd_conn
= LCD_COLOR_DSTN_16BPP
| LCD_PCLK_EDGE_FALL
,
476 .pxafb_backlight_power
= board_backlight_power
,
479 static struct pxafb_mode_info toshiba_lcd_mode
= {
494 static struct pxafb_mach_info toshiba_lcd
= {
495 .modes
= &toshiba_lcd_mode
,
497 .lcd_conn
= (LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
),
500 .pxafb_backlight_power
= board_backlight_power
,
503 static void __init
trizeps4_init(void)
505 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config
));
506 if (machine_is_trizeps4wl()) {
507 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config
));
508 platform_add_devices(trizeps4wl_devices
,
509 ARRAY_SIZE(trizeps4wl_devices
));
511 platform_add_devices(trizeps4_devices
,
512 ARRAY_SIZE(trizeps4_devices
));
515 pxa_set_ffuart_info(NULL
);
516 pxa_set_btuart_info(NULL
);
517 pxa_set_stuart_info(NULL
);
519 if (0) /* dont know how to determine LCD */
520 pxa_set_fb_info(NULL
, &sharp_lcd
);
522 pxa_set_fb_info(NULL
, &toshiba_lcd
);
524 pxa_set_mci_info(&trizeps4_mci_platform_data
);
525 #ifndef STATUS_LEDS_ON_STUART_PINS
526 pxa_set_ficp_info(&trizeps4_ficp_platform_data
);
528 pxa_set_ohci_info(&trizeps4_ohci_platform_data
);
529 pxa_set_ac97_info(NULL
);
530 pxa_set_i2c_info(NULL
);
531 i2c_register_board_info(0, trizeps4_i2c_devices
,
532 ARRAY_SIZE(trizeps4_i2c_devices
));
534 /* this is the reset value */
535 trizeps_conxs_bcr
= 0x00A0;
537 BCR_writew(trizeps_conxs_bcr
);
538 board_backlight_power(1);
540 regulator_has_full_constraints();
543 static void __init
trizeps4_map_io(void)
546 iotable_init(trizeps4_io_desc
, ARRAY_SIZE(trizeps4_io_desc
));
548 if ((__raw_readl(MSC0
) & 0x8) && (__raw_readl(BOOT_DEF
) & 0x1)) {
549 /* if flash is 16 bit wide its a Trizeps4 WL */
550 __machine_arch_type
= MACH_TYPE_TRIZEPS4WL
;
551 trizeps4_flash_data
[0].width
= 2;
553 /* if flash is 32 bit wide its a Trizeps4 */
554 __machine_arch_type
= MACH_TYPE_TRIZEPS4
;
555 trizeps4_flash_data
[0].width
= 4;
559 MACHINE_START(TRIZEPS4
, "Keith und Koep Trizeps IV module")
560 /* MAINTAINER("Jürgen Schindele") */
561 .atag_offset
= 0x100,
562 .init_machine
= trizeps4_init
,
563 .map_io
= trizeps4_map_io
,
564 .nr_irqs
= PXA_NR_IRQS
,
565 .init_irq
= pxa27x_init_irq
,
566 .handle_irq
= pxa27x_handle_irq
,
567 .init_time
= pxa_timer_init
,
568 .restart
= pxa_restart
,
571 MACHINE_START(TRIZEPS4WL
, "Keith und Koep Trizeps IV-WL module")
572 /* MAINTAINER("Jürgen Schindele") */
573 .atag_offset
= 0x100,
574 .init_machine
= trizeps4_init
,
575 .map_io
= trizeps4_map_io
,
576 .nr_irqs
= PXA_NR_IRQS
,
577 .init_irq
= pxa27x_init_irq
,
578 .handle_irq
= pxa27x_handle_irq
,
579 .init_time
= pxa_timer_init
,
580 .restart
= pxa_restart
,