1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/trizeps4.c
5 * Support for the Keith und Koep Trizeps4 Module Platform.
7 * Author: Jürgen Schindele
9 * Copyright: Jürgen Schindele
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/interrupt.h>
16 #include <linux/leds.h>
17 #include <linux/export.h>
18 #include <linux/sched.h>
19 #include <linux/bitops.h>
21 #include <linux/ioport.h>
22 #include <linux/delay.h>
23 #include <linux/gpio.h>
24 #include <linux/dm9000.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/mtd/partitions.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/platform_data/i2c-pxa.h>
30 #include <asm/types.h>
31 #include <asm/setup.h>
32 #include <asm/memory.h>
33 #include <asm/mach-types.h>
35 #include <linux/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>
43 #include <mach/trizeps4.h>
44 #include <mach/audio.h>
45 #include <linux/platform_data/video-pxafb.h>
46 #include <linux/platform_data/mmc-pxamci.h>
47 #include <linux/platform_data/irda-pxaficp.h>
48 #include <linux/platform_data/usb-ohci-pxa27x.h>
49 #include <mach/smemc.h>
54 /* comment out the following line if you want to use the
55 * Standard UART from PXA for serial / irda transmission
56 * and acivate it if you have status leds connected */
57 #define STATUS_LEDS_ON_STUART_PINS 1
59 /*****************************************************************************
60 * MultiFunctionPins of CPU
61 *****************************************************************************/
62 static unsigned long trizeps4_pin_config
[] __initdata
= {
64 GPIO15_nCS_1
, /* DiskOnChip CS */
65 GPIO93_GPIO
, /* TRIZEPS4_DOC_IRQ */
66 GPIO94_GPIO
, /* DOC lock */
68 GPIO78_nCS_2
, /* DM9000 CS */
69 GPIO101_GPIO
, /* TRIZEPS4_ETH_IRQ */
71 GPIO79_nCS_3
, /* Logic CS */
72 GPIO0_GPIO
| WAKEUP_ON_EDGE_RISE
, /* Logic irq */
76 GPIO29_AC97_SDATA_IN_0
,
77 GPIO30_AC97_SDATA_OUT
,
80 /* LCD - 16bpp Active TFT */
97 #ifdef STATUS_LEDS_ON_STUART_PINS
105 GPIO11_GPIO
, /* TRIZEPS4_CD_IRQ */
106 GPIO13_GPIO
, /* TRIZEPS4_READY_NINT */
125 GPIO12_GPIO
, /* TRIZEPS4_MMC_IRQ */
128 GPIO88_USBH1_PWR
, /* USBHPWR1 */
129 GPIO89_USBH1_PEN
, /* USBHPEN1 */
136 static unsigned long trizeps4wl_pin_config
[] __initdata
= {
140 GPIO53_GPIO
, /* TRIZEPS4_SPI_IRQ */
145 /****************************************************************************
147 ****************************************************************************/
148 static struct mtd_partition trizeps4_partitions
[] = {
150 .name
= "Bootloader",
151 .offset
= 0x00000000,
153 .mask_flags
= MTD_WRITEABLE
/* force read-only */
156 .offset
= 0x00040000,
160 .offset
= 0x00080000,
164 .offset
= 0x01100000,
168 .offset
= 0x01f00000,
169 .size
= MTDPART_SIZ_FULL
,
173 static struct physmap_flash_data trizeps4_flash_data
[] = {
175 .width
= 4, /* bankwidth in bytes */
176 .parts
= trizeps4_partitions
,
177 .nr_parts
= ARRAY_SIZE(trizeps4_partitions
)
181 static struct resource flash_resource
= {
182 .start
= PXA_CS0_PHYS
,
183 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
184 .flags
= IORESOURCE_MEM
,
187 static struct platform_device flash_device
= {
188 .name
= "physmap-flash",
191 .platform_data
= trizeps4_flash_data
,
193 .resource
= &flash_resource
,
197 /****************************************************************************
198 * DAVICOM DM9000 Ethernet
199 ****************************************************************************/
200 static struct resource dm9000_resources
[] = {
202 .start
= TRIZEPS4_ETH_PHYS
+0x300,
203 .end
= TRIZEPS4_ETH_PHYS
+0x400-1,
204 .flags
= IORESOURCE_MEM
,
207 .start
= TRIZEPS4_ETH_PHYS
+0x8300,
208 .end
= TRIZEPS4_ETH_PHYS
+0x8400-1,
209 .flags
= IORESOURCE_MEM
,
212 .start
= TRIZEPS4_ETH_IRQ
,
213 .end
= TRIZEPS4_ETH_IRQ
,
214 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
218 static struct dm9000_plat_data tri_dm9000_platdata
= {
219 .flags
= DM9000_PLATF_32BITONLY
,
222 static struct platform_device dm9000_device
= {
225 .num_resources
= ARRAY_SIZE(dm9000_resources
),
226 .resource
= dm9000_resources
,
228 .platform_data
= &tri_dm9000_platdata
,
232 /****************************************************************************
233 * LED's on GPIO pins of PXA
234 ****************************************************************************/
235 static struct gpio_led trizeps4_led
[] = {
236 #ifdef STATUS_LEDS_ON_STUART_PINS
238 .name
= "led0:orange:heartbeat", /* */
239 .default_trigger
= "heartbeat",
240 .gpio
= GPIO_HEARTBEAT_LED
,
244 .name
= "led1:yellow:cpubusy", /* */
245 .default_trigger
= "cpu-busy",
246 .gpio
= GPIO_SYS_BUSY_LED
,
252 static struct gpio_led_platform_data trizeps4_led_data
= {
253 .leds
= trizeps4_led
,
254 .num_leds
= ARRAY_SIZE(trizeps4_led
),
257 static struct platform_device leds_devices
= {
261 .platform_data
= &trizeps4_led_data
,
265 static struct platform_device
*trizeps4_devices
[] __initdata
= {
271 static struct platform_device
*trizeps4wl_devices
[] __initdata
= {
276 static short trizeps_conxs_bcr
;
278 /* PCCARD power switching supports only 3,3V */
279 void board_pcmcia_power(int power
)
282 /* switch power on, put in reset and enable buffers */
283 trizeps_conxs_bcr
|= power
;
284 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
285 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_BUF_EN
;
286 BCR_writew(trizeps_conxs_bcr
);
289 /* take reset away */
290 trizeps_conxs_bcr
&= ~ConXS_BCR_CF_RESET
;
291 BCR_writew(trizeps_conxs_bcr
);
295 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
296 BCR_writew(trizeps_conxs_bcr
);
298 /* switch power off */
299 trizeps_conxs_bcr
&= ~0xf;
300 BCR_writew(trizeps_conxs_bcr
);
302 pr_debug("%s: o%s 0x%x\n", __func__
, power
? "n" : "ff",
305 EXPORT_SYMBOL(board_pcmcia_power
);
307 /* backlight power switching for LCD panel */
308 static void board_backlight_power(int on
)
311 trizeps_conxs_bcr
|= ConXS_BCR_L_DISP
;
313 trizeps_conxs_bcr
&= ~ConXS_BCR_L_DISP
;
315 pr_debug("%s: o%s 0x%x\n", __func__
, on
? "n" : "ff",
317 BCR_writew(trizeps_conxs_bcr
);
320 /* a I2C based RTC is known on CONXS board */
321 static struct i2c_board_info trizeps4_i2c_devices
[] __initdata
= {
322 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
325 /****************************************************************************
326 * MMC card slot external to module
327 ****************************************************************************/
328 static int trizeps4_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
,
333 err
= request_irq(TRIZEPS4_MMC_IRQ
, mci_detect_int
,
334 IRQF_TRIGGER_RISING
, "MMC card detect", data
);
336 printk(KERN_ERR
"trizeps4_mci_init: MMC/SD: can't request"
337 "MMC card detect IRQ\n");
343 static void trizeps4_mci_exit(struct device
*dev
, void *data
)
345 free_irq(TRIZEPS4_MMC_IRQ
, data
);
348 static struct pxamci_platform_data trizeps4_mci_platform_data
= {
349 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
350 .detect_delay_ms
= 10,
351 .init
= trizeps4_mci_init
,
352 .exit
= trizeps4_mci_exit
,
353 .get_ro
= NULL
, /* write-protection not supported */
354 .setpower
= NULL
, /* power-switching not supported */
357 /****************************************************************************
358 * IRDA mode switching on stuart
359 ****************************************************************************/
360 #ifndef STATUS_LEDS_ON_STUART_PINS
361 static short trizeps_conxs_ircr
;
363 static int trizeps4_irda_startup(struct device
*dev
)
365 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
366 IRCR_writew(trizeps_conxs_ircr
);
370 static void trizeps4_irda_shutdown(struct device
*dev
)
372 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
373 IRCR_writew(trizeps_conxs_ircr
);
376 static void trizeps4_irda_transceiver_mode(struct device
*dev
, int mode
)
380 local_irq_save(flags
);
382 if (mode
& IR_SIRMODE
)
383 trizeps_conxs_ircr
&= ~ConXS_IRCR_MODE
; /* Slow mode */
384 else if (mode
& IR_FIRMODE
)
385 trizeps_conxs_ircr
|= ConXS_IRCR_MODE
; /* Fast mode */
389 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
391 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
393 IRCR_writew(trizeps_conxs_ircr
);
394 local_irq_restore(flags
);
396 pxa2xx_transceiver_mode(dev
, mode
);
399 static struct pxaficp_platform_data trizeps4_ficp_platform_data
= {
401 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
402 .transceiver_mode
= trizeps4_irda_transceiver_mode
,
403 .startup
= trizeps4_irda_startup
,
404 .shutdown
= trizeps4_irda_shutdown
,
408 /****************************************************************************
410 ****************************************************************************/
411 static struct pxaohci_platform_data trizeps4_ohci_platform_data
= {
412 .port_mode
= PMM_PERPORT_MODE
,
413 .flags
= ENABLE_PORT_ALL
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
416 static struct map_desc trizeps4_io_desc
[] __initdata
= {
418 .virtual = TRIZEPS4_CFSR_VIRT
,
419 .pfn
= __phys_to_pfn(TRIZEPS4_CFSR_PHYS
),
420 .length
= 0x00001000,
424 .virtual = TRIZEPS4_BOCR_VIRT
,
425 .pfn
= __phys_to_pfn(TRIZEPS4_BOCR_PHYS
),
426 .length
= 0x00001000,
430 .virtual = TRIZEPS4_IRCR_VIRT
,
431 .pfn
= __phys_to_pfn(TRIZEPS4_IRCR_PHYS
),
432 .length
= 0x00001000,
436 .virtual = TRIZEPS4_DICR_VIRT
,
437 .pfn
= __phys_to_pfn(TRIZEPS4_DICR_PHYS
),
438 .length
= 0x00001000,
442 .virtual = TRIZEPS4_UPSR_VIRT
,
443 .pfn
= __phys_to_pfn(TRIZEPS4_UPSR_PHYS
),
444 .length
= 0x00001000,
449 static struct pxafb_mode_info sharp_lcd_mode
= {
460 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
464 static struct pxafb_mach_info sharp_lcd
= {
465 .modes
= &sharp_lcd_mode
,
467 .lcd_conn
= LCD_COLOR_DSTN_16BPP
| LCD_PCLK_EDGE_FALL
,
470 .pxafb_backlight_power
= board_backlight_power
,
473 static struct pxafb_mode_info toshiba_lcd_mode
= {
488 static struct pxafb_mach_info toshiba_lcd
= {
489 .modes
= &toshiba_lcd_mode
,
491 .lcd_conn
= (LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
),
494 .pxafb_backlight_power
= board_backlight_power
,
497 static void __init
trizeps4_init(void)
499 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config
));
500 if (machine_is_trizeps4wl()) {
501 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config
));
502 platform_add_devices(trizeps4wl_devices
,
503 ARRAY_SIZE(trizeps4wl_devices
));
505 platform_add_devices(trizeps4_devices
,
506 ARRAY_SIZE(trizeps4_devices
));
509 pxa_set_ffuart_info(NULL
);
510 pxa_set_btuart_info(NULL
);
511 pxa_set_stuart_info(NULL
);
513 if (0) /* dont know how to determine LCD */
514 pxa_set_fb_info(NULL
, &sharp_lcd
);
516 pxa_set_fb_info(NULL
, &toshiba_lcd
);
518 pxa_set_mci_info(&trizeps4_mci_platform_data
);
519 #ifndef STATUS_LEDS_ON_STUART_PINS
520 pxa_set_ficp_info(&trizeps4_ficp_platform_data
);
522 pxa_set_ohci_info(&trizeps4_ohci_platform_data
);
523 pxa_set_ac97_info(NULL
);
524 pxa_set_i2c_info(NULL
);
525 i2c_register_board_info(0, trizeps4_i2c_devices
,
526 ARRAY_SIZE(trizeps4_i2c_devices
));
528 /* this is the reset value */
529 trizeps_conxs_bcr
= 0x00A0;
531 BCR_writew(trizeps_conxs_bcr
);
532 board_backlight_power(1);
534 regulator_has_full_constraints();
537 static void __init
trizeps4_map_io(void)
540 iotable_init(trizeps4_io_desc
, ARRAY_SIZE(trizeps4_io_desc
));
542 if ((__raw_readl(MSC0
) & 0x8) && (__raw_readl(BOOT_DEF
) & 0x1)) {
543 /* if flash is 16 bit wide its a Trizeps4 WL */
544 __machine_arch_type
= MACH_TYPE_TRIZEPS4WL
;
545 trizeps4_flash_data
[0].width
= 2;
547 /* if flash is 32 bit wide its a Trizeps4 */
548 __machine_arch_type
= MACH_TYPE_TRIZEPS4
;
549 trizeps4_flash_data
[0].width
= 4;
553 MACHINE_START(TRIZEPS4
, "Keith und Koep Trizeps IV module")
554 /* MAINTAINER("Jürgen Schindele") */
555 .atag_offset
= 0x100,
556 .init_machine
= trizeps4_init
,
557 .map_io
= trizeps4_map_io
,
558 .nr_irqs
= PXA_NR_IRQS
,
559 .init_irq
= pxa27x_init_irq
,
560 .handle_irq
= pxa27x_handle_irq
,
561 .init_time
= pxa_timer_init
,
562 .restart
= pxa_restart
,
565 MACHINE_START(TRIZEPS4WL
, "Keith und Koep Trizeps IV-WL module")
566 /* MAINTAINER("Jürgen Schindele") */
567 .atag_offset
= 0x100,
568 .init_machine
= trizeps4_init
,
569 .map_io
= trizeps4_map_io
,
570 .nr_irqs
= PXA_NR_IRQS
,
571 .init_irq
= pxa27x_init_irq
,
572 .handle_irq
= pxa27x_handle_irq
,
573 .init_time
= pxa_timer_init
,
574 .restart
= pxa_restart
,