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/pxa27x.h>
43 #include <mach/pxa2xx_spi.h>
44 #include <mach/trizeps4.h>
45 #include <mach/audio.h>
46 #include <mach/pxafb.h>
48 #include <mach/irda.h>
49 #include <mach/ohci.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 */
75 /* LCD - 16bpp Active TFT */
111 #ifdef STATUS_LEDS_ON_STUART_PINS
119 GPIO11_GPIO, /* TRIZEPS4_CD_IRQ */
120 GPIO13_GPIO, /* TRIZEPS4_READY_NINT */
139 GPIO12_GPIO, /* TRIZEPS4_MMC_IRQ */
142 GPIO88_USBH1_PWR, /* USBHPWR1 */
143 GPIO89_USBH1_PEN, /* USBHPEN1 */
150 static unsigned long trizeps4wl_pin_config[] __initdata = {
154 GPIO53_GPIO, /* TRIZEPS4_SPI_IRQ */
159 /****************************************************************************
161 ****************************************************************************/
162 static struct mtd_partition trizeps4_partitions[] = {
164 .name = "Bootloader",
165 .offset = 0x00000000,
167 .mask_flags = MTD_WRITEABLE /* force read-only */
170 .offset = 0x00040000,
174 .offset = 0x00080000,
178 .offset = 0x01100000,
182 .offset = 0x01f00000,
183 .size = MTDPART_SIZ_FULL,
187 static struct physmap_flash_data trizeps4_flash_data[] = {
189 .width = 4, /* bankwidth in bytes */
190 .parts = trizeps4_partitions,
191 .nr_parts = ARRAY_SIZE(trizeps4_partitions)
195 static struct resource flash_resource = {
196 .start = PXA_CS0_PHYS,
197 .end = PXA_CS0_PHYS + SZ_32M - 1,
198 .flags = IORESOURCE_MEM,
201 static struct platform_device flash_device = {
202 .name = "physmap-flash",
205 .platform_data = trizeps4_flash_data,
207 .resource = &flash_resource,
211 /****************************************************************************
212 * DAVICOM DM9000 Ethernet
213 ****************************************************************************/
214 static struct resource dm9000_resources[] = {
216 .start = TRIZEPS4_ETH_PHYS+0x300,
217 .end = TRIZEPS4_ETH_PHYS+0x400-1,
218 .flags = IORESOURCE_MEM,
221 .start = TRIZEPS4_ETH_PHYS+0x8300,
222 .end = TRIZEPS4_ETH_PHYS+0x8400-1,
223 .flags = IORESOURCE_MEM,
226 .start = TRIZEPS4_ETH_IRQ,
227 .end = TRIZEPS4_ETH_IRQ,
228 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
232 static struct dm9000_plat_data tri_dm9000_platdata = {
233 .flags = DM9000_PLATF_32BITONLY,
236 static struct platform_device dm9000_device = {
239 .num_resources = ARRAY_SIZE(dm9000_resources),
240 .resource = dm9000_resources,
242 .platform_data = &tri_dm9000_platdata,
246 /****************************************************************************
247 * LED's on GPIO pins of PXA
248 ****************************************************************************/
249 static struct gpio_led trizeps4_led[] = {
250 #ifdef STATUS_LEDS_ON_STUART_PINS
252 .name = "led0:orange:heartbeat", /* */
253 .default_trigger = "heartbeat",
254 .gpio = GPIO_HEARTBEAT_LED,
258 .name = "led1:yellow:cpubusy", /* */
259 .default_trigger = "cpu-busy",
260 .gpio = GPIO_SYS_BUSY_LED,
266 static struct gpio_led_platform_data trizeps4_led_data = {
267 .leds = trizeps4_led,
268 .num_leds = ARRAY_SIZE(trizeps4_led),
271 static struct platform_device leds_devices = {
275 .platform_data = &trizeps4_led_data,
279 static struct platform_device *trizeps4_devices[] __initdata = {
285 static struct platform_device *trizeps4wl_devices[] __initdata = {
290 static short trizeps_conxs_bcr;
292 /* PCCARD power switching supports only 3,3V */
293 void board_pcmcia_power(int power)
296 /* switch power on, put in reset and enable buffers */
297 trizeps_conxs_bcr |= power;
298 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
299 trizeps_conxs_bcr &= ~ConXS_BCR_CF_BUF_EN;
300 BCR_writew(trizeps_conxs_bcr);
303 /* take reset away */
304 trizeps_conxs_bcr &= ~ConXS_BCR_CF_RESET;
305 BCR_writew(trizeps_conxs_bcr);
309 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
310 BCR_writew(trizeps_conxs_bcr);
312 /* switch power off */
313 trizeps_conxs_bcr &= ~0xf;
314 BCR_writew(trizeps_conxs_bcr);
316 pr_debug("%s: o%s 0x%x\n", __func__, power ? "n" : "ff",
319 EXPORT_SYMBOL(board_pcmcia_power);
321 /* backlight power switching for LCD panel */
322 static void board_backlight_power(int on)
325 trizeps_conxs_bcr |= ConXS_BCR_L_DISP;
327 trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP;
329 pr_debug("%s: o%s 0x%x\n", __func__, on ? "n" : "ff",
331 BCR_writew(trizeps_conxs_bcr);
334 /* a I2C based RTC is known on CONXS board */
335 static struct i2c_board_info trizeps4_i2c_devices[] __initdata = {
336 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
339 /****************************************************************************
340 * MMC card slot external to module
341 ****************************************************************************/
342 static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int,
347 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
348 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_SAMPLE_RANDOM,
349 "MMC card detect", data);
351 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request"
352 "MMC card detect IRQ\n");
358 static void trizeps4_mci_exit(struct device *dev, void *data)
360 free_irq(TRIZEPS4_MMC_IRQ, data);
363 static struct pxamci_platform_data trizeps4_mci_platform_data = {
364 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
366 .init = trizeps4_mci_init,
367 .exit = trizeps4_mci_exit,
368 .get_ro = NULL, /* write-protection not supported */
369 .setpower = NULL, /* power-switching not supported */
372 /****************************************************************************
373 * IRDA mode switching on stuart
374 ****************************************************************************/
375 #ifndef STATUS_LEDS_ON_STUART_PINS
376 static short trizeps_conxs_ircr;
378 static int trizeps4_irda_startup(struct device *dev)
380 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
381 IRCR_writew(trizeps_conxs_ircr);
385 static void trizeps4_irda_shutdown(struct device *dev)
387 trizeps_conxs_ircr |= ConXS_IRCR_SD;
388 IRCR_writew(trizeps_conxs_ircr);
391 static void trizeps4_irda_transceiver_mode(struct device *dev, int mode)
395 local_irq_save(flags);
397 if (mode & IR_SIRMODE)
398 trizeps_conxs_ircr &= ~ConXS_IRCR_MODE; /* Slow mode */
399 else if (mode & IR_FIRMODE)
400 trizeps_conxs_ircr |= ConXS_IRCR_MODE; /* Fast mode */
404 trizeps_conxs_ircr |= ConXS_IRCR_SD;
406 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
408 IRCR_writew(trizeps_conxs_ircr);
409 local_irq_restore(flags);
411 pxa2xx_transceiver_mode(dev, mode);
414 static struct pxaficp_platform_data trizeps4_ficp_platform_data = {
415 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
416 .transceiver_mode = trizeps4_irda_transceiver_mode,
417 .startup = trizeps4_irda_startup,
418 .shutdown = trizeps4_irda_shutdown,
422 /****************************************************************************
424 ****************************************************************************/
425 static struct pxaohci_platform_data trizeps4_ohci_platform_data = {
426 .port_mode = PMM_PERPORT_MODE,
427 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
430 static struct map_desc trizeps4_io_desc[] __initdata = {
432 .virtual = TRIZEPS4_CFSR_VIRT,
433 .pfn = __phys_to_pfn(TRIZEPS4_CFSR_PHYS),
434 .length = 0x00001000,
438 .virtual = TRIZEPS4_BOCR_VIRT,
439 .pfn = __phys_to_pfn(TRIZEPS4_BOCR_PHYS),
440 .length = 0x00001000,
444 .virtual = TRIZEPS4_IRCR_VIRT,
445 .pfn = __phys_to_pfn(TRIZEPS4_IRCR_PHYS),
446 .length = 0x00001000,
450 .virtual = TRIZEPS4_DICR_VIRT,
451 .pfn = __phys_to_pfn(TRIZEPS4_DICR_PHYS),
452 .length = 0x00001000,
456 .virtual = TRIZEPS4_UPSR_VIRT,
457 .pfn = __phys_to_pfn(TRIZEPS4_UPSR_PHYS),
458 .length = 0x00001000,
463 static struct pxafb_mode_info sharp_lcd_mode = {
474 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
478 static struct pxafb_mach_info sharp_lcd = {
479 .modes = &sharp_lcd_mode,
481 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL,
484 .pxafb_backlight_power = board_backlight_power,
487 static struct pxafb_mode_info toshiba_lcd_mode = {
502 static struct pxafb_mach_info toshiba_lcd = {
503 .modes = &toshiba_lcd_mode,
505 .lcd_conn = (LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL),
508 .pxafb_backlight_power = board_backlight_power,
511 static void __init trizeps4_init(void)
513 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config));
514 if (machine_is_trizeps4wl()) {
515 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config));
516 platform_add_devices(trizeps4wl_devices,
517 ARRAY_SIZE(trizeps4wl_devices));
519 platform_add_devices(trizeps4_devices,
520 ARRAY_SIZE(trizeps4_devices));
523 if (0) /* dont know how to determine LCD */
524 set_pxa_fb_info(&sharp_lcd);
526 set_pxa_fb_info(&toshiba_lcd);
528 pxa_set_mci_info(&trizeps4_mci_platform_data);
529 #ifndef STATUS_LEDS_ON_STUART_PINS
530 pxa_set_ficp_info(&trizeps4_ficp_platform_data);
532 pxa_set_ohci_info(&trizeps4_ohci_platform_data);
533 pxa_set_ac97_info(NULL);
534 pxa_set_i2c_info(NULL);
535 i2c_register_board_info(0, trizeps4_i2c_devices,
536 ARRAY_SIZE(trizeps4_i2c_devices));
538 #ifdef CONFIG_IDE_PXA_CF
539 /* if boot direct from compact flash dont disable power */
540 trizeps_conxs_bcr = 0x0009;
542 /* this is the reset value */
543 trizeps_conxs_bcr = 0x00A0;
545 BCR_writew(trizeps_conxs_bcr);
546 board_backlight_power(1);
549 static void __init trizeps4_map_io(void)
552 iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
554 if ((MSC0 & 0x8) && (BOOT_DEF & 0x1)) {
555 /* if flash is 16 bit wide its a Trizeps4 WL */
556 __machine_arch_type = MACH_TYPE_TRIZEPS4WL;
557 trizeps4_flash_data[0].width = 2;
559 /* if flash is 32 bit wide its a Trizeps4 */
560 __machine_arch_type = MACH_TYPE_TRIZEPS4;
561 trizeps4_flash_data[0].width = 4;
565 MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
566 /* MAINTAINER("Jürgen Schindele") */
567 .phys_io = 0x40000000,
568 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
569 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
570 .init_machine = trizeps4_init,
571 .map_io = trizeps4_map_io,
572 .init_irq = pxa27x_init_irq,
576 MACHINE_START(TRIZEPS4WL, "Keith und Koep Trizeps IV-WL module")
577 /* MAINTAINER("Jürgen Schindele") */
578 .phys_io = 0x40000000,
579 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
580 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
581 .init_machine = trizeps4_init,
582 .map_io = trizeps4_map_io,
583 .init_irq = pxa27x_init_irq,