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/export.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>
29 #include <linux/i2c/pxa-i2c.h>
31 #include <asm/types.h>
32 #include <asm/setup.h>
33 #include <asm/memory.h>
34 #include <asm/mach-types.h>
36 #include <asm/sizes.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/irq.h>
41 #include <asm/mach/flash.h>
43 #include <mach/pxa27x.h>
44 #include <mach/trizeps4.h>
45 #include <mach/audio.h>
46 #include <linux/platform_data/video-pxafb.h>
47 #include <linux/platform_data/mmc-pxamci.h>
48 #include <linux/platform_data/irda-pxaficp.h>
49 #include <linux/platform_data/usb-ohci-pxa27x.h>
50 #include <mach/smemc.h>
55 /* comment out the following line if you want to use the
56 * Standard UART from PXA for serial / irda transmission
57 * and acivate it if you have status leds connected */
58 #define STATUS_LEDS_ON_STUART_PINS 1
60 /*****************************************************************************
61 * MultiFunctionPins of CPU
62 *****************************************************************************/
63 static unsigned long trizeps4_pin_config
[] __initdata
= {
65 GPIO15_nCS_1
, /* DiskOnChip CS */
66 GPIO93_GPIO
, /* TRIZEPS4_DOC_IRQ */
67 GPIO94_GPIO
, /* DOC lock */
69 GPIO78_nCS_2
, /* DM9000 CS */
70 GPIO101_GPIO
, /* TRIZEPS4_ETH_IRQ */
72 GPIO79_nCS_3
, /* Logic CS */
73 GPIO0_GPIO
| WAKEUP_ON_EDGE_RISE
, /* Logic irq */
77 GPIO29_AC97_SDATA_IN_0
,
78 GPIO30_AC97_SDATA_OUT
,
81 /* LCD - 16bpp Active TFT */
98 #ifdef STATUS_LEDS_ON_STUART_PINS
106 GPIO11_GPIO
, /* TRIZEPS4_CD_IRQ */
107 GPIO13_GPIO
, /* TRIZEPS4_READY_NINT */
126 GPIO12_GPIO
, /* TRIZEPS4_MMC_IRQ */
129 GPIO88_USBH1_PWR
, /* USBHPWR1 */
130 GPIO89_USBH1_PEN
, /* USBHPEN1 */
137 static unsigned long trizeps4wl_pin_config
[] __initdata
= {
141 GPIO53_GPIO
, /* TRIZEPS4_SPI_IRQ */
146 /****************************************************************************
148 ****************************************************************************/
149 static struct mtd_partition trizeps4_partitions
[] = {
151 .name
= "Bootloader",
152 .offset
= 0x00000000,
154 .mask_flags
= MTD_WRITEABLE
/* force read-only */
157 .offset
= 0x00040000,
161 .offset
= 0x00080000,
165 .offset
= 0x01100000,
169 .offset
= 0x01f00000,
170 .size
= MTDPART_SIZ_FULL
,
174 static struct physmap_flash_data trizeps4_flash_data
[] = {
176 .width
= 4, /* bankwidth in bytes */
177 .parts
= trizeps4_partitions
,
178 .nr_parts
= ARRAY_SIZE(trizeps4_partitions
)
182 static struct resource flash_resource
= {
183 .start
= PXA_CS0_PHYS
,
184 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
185 .flags
= IORESOURCE_MEM
,
188 static struct platform_device flash_device
= {
189 .name
= "physmap-flash",
192 .platform_data
= trizeps4_flash_data
,
194 .resource
= &flash_resource
,
198 /****************************************************************************
199 * DAVICOM DM9000 Ethernet
200 ****************************************************************************/
201 static struct resource dm9000_resources
[] = {
203 .start
= TRIZEPS4_ETH_PHYS
+0x300,
204 .end
= TRIZEPS4_ETH_PHYS
+0x400-1,
205 .flags
= IORESOURCE_MEM
,
208 .start
= TRIZEPS4_ETH_PHYS
+0x8300,
209 .end
= TRIZEPS4_ETH_PHYS
+0x8400-1,
210 .flags
= IORESOURCE_MEM
,
213 .start
= TRIZEPS4_ETH_IRQ
,
214 .end
= TRIZEPS4_ETH_IRQ
,
215 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
219 static struct dm9000_plat_data tri_dm9000_platdata
= {
220 .flags
= DM9000_PLATF_32BITONLY
,
223 static struct platform_device dm9000_device
= {
226 .num_resources
= ARRAY_SIZE(dm9000_resources
),
227 .resource
= dm9000_resources
,
229 .platform_data
= &tri_dm9000_platdata
,
233 /****************************************************************************
234 * LED's on GPIO pins of PXA
235 ****************************************************************************/
236 static struct gpio_led trizeps4_led
[] = {
237 #ifdef STATUS_LEDS_ON_STUART_PINS
239 .name
= "led0:orange:heartbeat", /* */
240 .default_trigger
= "heartbeat",
241 .gpio
= GPIO_HEARTBEAT_LED
,
245 .name
= "led1:yellow:cpubusy", /* */
246 .default_trigger
= "cpu-busy",
247 .gpio
= GPIO_SYS_BUSY_LED
,
253 static struct gpio_led_platform_data trizeps4_led_data
= {
254 .leds
= trizeps4_led
,
255 .num_leds
= ARRAY_SIZE(trizeps4_led
),
258 static struct platform_device leds_devices
= {
262 .platform_data
= &trizeps4_led_data
,
266 static struct platform_device
*trizeps4_devices
[] __initdata
= {
272 static struct platform_device
*trizeps4wl_devices
[] __initdata
= {
277 static short trizeps_conxs_bcr
;
279 /* PCCARD power switching supports only 3,3V */
280 void board_pcmcia_power(int power
)
283 /* switch power on, put in reset and enable buffers */
284 trizeps_conxs_bcr
|= power
;
285 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
286 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_BUF_EN
;
287 BCR_writew(trizeps_conxs_bcr
);
290 /* take reset away */
291 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_RESET
;
292 BCR_writew(trizeps_conxs_bcr
);
296 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
297 BCR_writew(trizeps_conxs_bcr
);
299 /* switch power off */
300 trizeps_conxs_bcr
&= ~0xf;
301 BCR_writew(trizeps_conxs_bcr
);
303 pr_debug("%s: o%s 0x%x\n", __func__
, power
? "n" : "ff",
306 EXPORT_SYMBOL(board_pcmcia_power
);
308 /* backlight power switching for LCD panel */
309 static void board_backlight_power(int on
)
312 trizeps_conxs_bcr
|= ConXS_BCR_L_DISP
;
314 trizeps_conxs_bcr
&= ~ConXS_BCR_L_DISP
;
316 pr_debug("%s: o%s 0x%x\n", __func__
, on
? "n" : "ff",
318 BCR_writew(trizeps_conxs_bcr
);
321 /* a I2C based RTC is known on CONXS board */
322 static struct i2c_board_info trizeps4_i2c_devices
[] __initdata
= {
323 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
326 /****************************************************************************
327 * MMC card slot external to module
328 ****************************************************************************/
329 static int trizeps4_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
,
334 err
= request_irq(TRIZEPS4_MMC_IRQ
, mci_detect_int
,
335 IRQF_TRIGGER_RISING
, "MMC card detect", data
);
337 printk(KERN_ERR
"trizeps4_mci_init: MMC/SD: can't request"
338 "MMC card detect IRQ\n");
344 static void trizeps4_mci_exit(struct device
*dev
, void *data
)
346 free_irq(TRIZEPS4_MMC_IRQ
, data
);
349 static struct pxamci_platform_data trizeps4_mci_platform_data
= {
350 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
351 .detect_delay_ms
= 10,
352 .init
= trizeps4_mci_init
,
353 .exit
= trizeps4_mci_exit
,
354 .get_ro
= NULL
, /* write-protection not supported */
355 .setpower
= NULL
, /* power-switching not supported */
356 .gpio_card_detect
= -1,
361 /****************************************************************************
362 * IRDA mode switching on stuart
363 ****************************************************************************/
364 #ifndef STATUS_LEDS_ON_STUART_PINS
365 static short trizeps_conxs_ircr
;
367 static int trizeps4_irda_startup(struct device
*dev
)
369 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
370 IRCR_writew(trizeps_conxs_ircr
);
374 static void trizeps4_irda_shutdown(struct device
*dev
)
376 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
377 IRCR_writew(trizeps_conxs_ircr
);
380 static void trizeps4_irda_transceiver_mode(struct device
*dev
, int mode
)
384 local_irq_save(flags
);
386 if (mode
& IR_SIRMODE
)
387 trizeps_conxs_ircr
&= ~ConXS_IRCR_MODE
; /* Slow mode */
388 else if (mode
& IR_FIRMODE
)
389 trizeps_conxs_ircr
|= ConXS_IRCR_MODE
; /* Fast mode */
393 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
395 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
397 IRCR_writew(trizeps_conxs_ircr
);
398 local_irq_restore(flags
);
400 pxa2xx_transceiver_mode(dev
, mode
);
403 static struct pxaficp_platform_data trizeps4_ficp_platform_data
= {
405 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
406 .transceiver_mode
= trizeps4_irda_transceiver_mode
,
407 .startup
= trizeps4_irda_startup
,
408 .shutdown
= trizeps4_irda_shutdown
,
412 /****************************************************************************
414 ****************************************************************************/
415 static struct pxaohci_platform_data trizeps4_ohci_platform_data
= {
416 .port_mode
= PMM_PERPORT_MODE
,
417 .flags
= ENABLE_PORT_ALL
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
420 static struct map_desc trizeps4_io_desc
[] __initdata
= {
422 .virtual = TRIZEPS4_CFSR_VIRT
,
423 .pfn
= __phys_to_pfn(TRIZEPS4_CFSR_PHYS
),
424 .length
= 0x00001000,
428 .virtual = TRIZEPS4_BOCR_VIRT
,
429 .pfn
= __phys_to_pfn(TRIZEPS4_BOCR_PHYS
),
430 .length
= 0x00001000,
434 .virtual = TRIZEPS4_IRCR_VIRT
,
435 .pfn
= __phys_to_pfn(TRIZEPS4_IRCR_PHYS
),
436 .length
= 0x00001000,
440 .virtual = TRIZEPS4_DICR_VIRT
,
441 .pfn
= __phys_to_pfn(TRIZEPS4_DICR_PHYS
),
442 .length
= 0x00001000,
446 .virtual = TRIZEPS4_UPSR_VIRT
,
447 .pfn
= __phys_to_pfn(TRIZEPS4_UPSR_PHYS
),
448 .length
= 0x00001000,
453 static struct pxafb_mode_info sharp_lcd_mode
= {
464 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
468 static struct pxafb_mach_info sharp_lcd
= {
469 .modes
= &sharp_lcd_mode
,
471 .lcd_conn
= LCD_COLOR_DSTN_16BPP
| LCD_PCLK_EDGE_FALL
,
474 .pxafb_backlight_power
= board_backlight_power
,
477 static struct pxafb_mode_info toshiba_lcd_mode
= {
492 static struct pxafb_mach_info toshiba_lcd
= {
493 .modes
= &toshiba_lcd_mode
,
495 .lcd_conn
= (LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
),
498 .pxafb_backlight_power
= board_backlight_power
,
501 static void __init
trizeps4_init(void)
503 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config
));
504 if (machine_is_trizeps4wl()) {
505 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config
));
506 platform_add_devices(trizeps4wl_devices
,
507 ARRAY_SIZE(trizeps4wl_devices
));
509 platform_add_devices(trizeps4_devices
,
510 ARRAY_SIZE(trizeps4_devices
));
513 pxa_set_ffuart_info(NULL
);
514 pxa_set_btuart_info(NULL
);
515 pxa_set_stuart_info(NULL
);
517 if (0) /* dont know how to determine LCD */
518 pxa_set_fb_info(NULL
, &sharp_lcd
);
520 pxa_set_fb_info(NULL
, &toshiba_lcd
);
522 pxa_set_mci_info(&trizeps4_mci_platform_data
);
523 #ifndef STATUS_LEDS_ON_STUART_PINS
524 pxa_set_ficp_info(&trizeps4_ficp_platform_data
);
526 pxa_set_ohci_info(&trizeps4_ohci_platform_data
);
527 pxa_set_ac97_info(NULL
);
528 pxa_set_i2c_info(NULL
);
529 i2c_register_board_info(0, trizeps4_i2c_devices
,
530 ARRAY_SIZE(trizeps4_i2c_devices
));
532 /* this is the reset value */
533 trizeps_conxs_bcr
= 0x00A0;
535 BCR_writew(trizeps_conxs_bcr
);
536 board_backlight_power(1);
539 static void __init
trizeps4_map_io(void)
542 iotable_init(trizeps4_io_desc
, ARRAY_SIZE(trizeps4_io_desc
));
544 if ((__raw_readl(MSC0
) & 0x8) && (__raw_readl(BOOT_DEF
) & 0x1)) {
545 /* if flash is 16 bit wide its a Trizeps4 WL */
546 __machine_arch_type
= MACH_TYPE_TRIZEPS4WL
;
547 trizeps4_flash_data
[0].width
= 2;
549 /* if flash is 32 bit wide its a Trizeps4 */
550 __machine_arch_type
= MACH_TYPE_TRIZEPS4
;
551 trizeps4_flash_data
[0].width
= 4;
555 MACHINE_START(TRIZEPS4
, "Keith und Koep Trizeps IV module")
556 /* MAINTAINER("Jürgen Schindele") */
557 .atag_offset
= 0x100,
558 .init_machine
= trizeps4_init
,
559 .map_io
= trizeps4_map_io
,
560 .nr_irqs
= PXA_NR_IRQS
,
561 .init_irq
= pxa27x_init_irq
,
562 .handle_irq
= pxa27x_handle_irq
,
563 .init_time
= pxa_timer_init
,
564 .restart
= pxa_restart
,
567 MACHINE_START(TRIZEPS4WL
, "Keith und Koep Trizeps IV-WL module")
568 /* MAINTAINER("Jürgen Schindele") */
569 .atag_offset
= 0x100,
570 .init_machine
= trizeps4_init
,
571 .map_io
= trizeps4_map_io
,
572 .nr_irqs
= PXA_NR_IRQS
,
573 .init_irq
= pxa27x_init_irq
,
574 .handle_irq
= pxa27x_handle_irq
,
575 .init_time
= pxa_timer_init
,
576 .restart
= pxa_restart
,