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/serial_8250.h>
26 #include <linux/mtd/mtd.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>
34 #include <asm/hardware.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 <asm/arch/pxa-regs.h>
44 #include <asm/arch/pxa2xx-regs.h>
45 #include <asm/arch/pxa2xx-gpio.h>
46 #include <asm/arch/trizeps4.h>
47 #include <asm/arch/audio.h>
48 #include <asm/arch/pxafb.h>
49 #include <asm/arch/mmc.h>
50 #include <asm/arch/irda.h>
51 #include <asm/arch/ohci.h>
56 /********************************************************************************************
58 ********************************************************************************************/
59 static struct mtd_partition trizeps4_partitions
[] = {
64 .mask_flags
= MTD_WRITEABLE
/* force read-only */
80 .size
= MTDPART_SIZ_FULL
,
84 static struct physmap_flash_data trizeps4_flash_data
[] = {
86 .width
= 4, /* bankwidth in bytes */
87 .parts
= trizeps4_partitions
,
88 .nr_parts
= ARRAY_SIZE(trizeps4_partitions
)
92 static struct resource flash_resource
= {
93 .start
= PXA_CS0_PHYS
,
94 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
95 .flags
= IORESOURCE_MEM
,
98 static struct platform_device flash_device
= {
99 .name
= "physmap-flash",
102 .platform_data
= trizeps4_flash_data
,
104 .resource
= &flash_resource
,
108 /********************************************************************************************
109 * DAVICOM DM9000 Ethernet
110 ********************************************************************************************/
111 static struct resource dm9000_resources
[] = {
113 .start
= TRIZEPS4_ETH_PHYS
+0x300,
114 .end
= TRIZEPS4_ETH_PHYS
+0x400-1,
115 .flags
= IORESOURCE_MEM
,
118 .start
= TRIZEPS4_ETH_PHYS
+0x8300,
119 .end
= TRIZEPS4_ETH_PHYS
+0x8400-1,
120 .flags
= IORESOURCE_MEM
,
123 .start
= TRIZEPS4_ETH_IRQ
,
124 .end
= TRIZEPS4_ETH_IRQ
,
125 .flags
= (IORESOURCE_IRQ
| IRQT_RISING
),
129 static struct platform_device dm9000_device
= {
132 .num_resources
= ARRAY_SIZE(dm9000_resources
),
133 .resource
= dm9000_resources
,
136 /********************************************************************************************
137 * PXA270 serial ports
138 ********************************************************************************************/
139 static struct plat_serial8250_port tri_serial_ports
[] = {
140 #ifdef CONFIG_SERIAL_PXA
141 /* this uses the own PXA driver */
146 /* this uses the generic 8520 driver */
148 .membase
= (void *)&FFUART
,
150 .flags
= UPF_BOOT_AUTOCONF
,
151 .iotype
= UPIO_MEM32
,
153 .uartclk
= (921600*16),
156 .membase
= (void *)&BTUART
,
158 .flags
= UPF_BOOT_AUTOCONF
,
159 .iotype
= UPIO_MEM32
,
161 .uartclk
= (921600*16),
169 static struct platform_device uart_devices
= {
170 .name
= "serial8250",
173 .platform_data
= tri_serial_ports
,
179 static struct platform_device
* trizeps4_devices
[] __initdata
= {
185 #ifdef CONFIG_MACH_TRIZEPS4_CONXS
186 static short trizeps_conxs_bcr
;
188 /* PCCARD power switching supports only 3,3V */
189 void board_pcmcia_power(int power
)
192 /* switch power on, put in reset and enable buffers */
193 trizeps_conxs_bcr
|= power
;
194 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
195 trizeps_conxs_bcr
&= ~(ConXS_BCR_CF_BUF_EN
);
196 ConXS_BCR
= trizeps_conxs_bcr
;
199 /* take reset away */
200 trizeps_conxs_bcr
&= ~(ConXS_BCR_CF_RESET
);
201 ConXS_BCR
= trizeps_conxs_bcr
;
205 trizeps_conxs_bcr
|= ConXS_BCR_CF_RESET
;
206 ConXS_BCR
= trizeps_conxs_bcr
;
208 /* switch power off */
209 trizeps_conxs_bcr
&= ~(0xf);
210 ConXS_BCR
= trizeps_conxs_bcr
;
213 pr_debug("%s: o%s 0x%x\n", __func__
, power
? "n": "ff", trizeps_conxs_bcr
);
216 /* backlight power switching for LCD panel */
217 static void board_backlight_power(int on
)
220 trizeps_conxs_bcr
|= ConXS_BCR_L_DISP
;
222 trizeps_conxs_bcr
&= ~ConXS_BCR_L_DISP
;
224 pr_debug("%s: o%s 0x%x\n", __func__
, on
? "n" : "ff", trizeps_conxs_bcr
);
225 ConXS_BCR
= trizeps_conxs_bcr
;
228 /* Powersupply for MMC/SD cardslot */
229 static void board_mci_power(struct device
*dev
, unsigned int vdd
)
231 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
233 if (( 1 << vdd
) & p_d
->ocr_mask
) {
234 pr_debug("%s: on\n", __func__
);
235 /* FIXME fill in values here */
237 pr_debug("%s: off\n", __func__
);
238 /* FIXME fill in values here */
242 static short trizeps_conxs_ircr
;
244 /* Switch modes and Power for IRDA receiver */
245 static void board_irda_mode(struct device
*dev
, int mode
)
249 local_irq_save(flags
);
250 if (mode
& IR_SIRMODE
) {
252 trizeps_conxs_ircr
&= ~ConXS_IRCR_MODE
;
253 } else if (mode
& IR_FIRMODE
) {
255 trizeps_conxs_ircr
|= ConXS_IRCR_MODE
;
258 trizeps_conxs_ircr
|= ConXS_IRCR_SD
;
260 trizeps_conxs_ircr
&= ~ConXS_IRCR_SD
;
262 /* FIXME write values to register */
263 local_irq_restore(flags
);
267 /* for other baseboards define dummies */
268 void board_pcmcia_power(int power
) {;}
269 #define board_backlight_power NULL
270 #define board_mci_power NULL
271 #define board_irda_mode NULL
273 #endif /* CONFIG_MACH_TRIZEPS4_CONXS */
274 EXPORT_SYMBOL(board_pcmcia_power
);
276 static int trizeps4_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
, void *data
)
279 /* setup GPIO for PXA27x MMC controller */
280 pxa_gpio_mode(GPIO32_MMCCLK_MD
);
281 pxa_gpio_mode(GPIO112_MMCCMD_MD
);
282 pxa_gpio_mode(GPIO92_MMCDAT0_MD
);
283 pxa_gpio_mode(GPIO109_MMCDAT1_MD
);
284 pxa_gpio_mode(GPIO110_MMCDAT2_MD
);
285 pxa_gpio_mode(GPIO111_MMCDAT3_MD
);
287 pxa_gpio_mode(GPIO_MMC_DET
| GPIO_IN
);
289 err
= request_irq(TRIZEPS4_MMC_IRQ
, mci_detect_int
,
290 IRQF_DISABLED
| IRQF_TRIGGER_RISING
,
291 "MMC card detect", data
);
293 printk(KERN_ERR
"trizeps4_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
298 static void trizeps4_mci_exit(struct device
*dev
, void *data
)
300 free_irq(TRIZEPS4_MMC_IRQ
, data
);
303 static struct pxamci_platform_data trizeps4_mci_platform_data
= {
304 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
305 .init
= trizeps4_mci_init
,
306 .exit
= trizeps4_mci_exit
,
307 .setpower
= board_mci_power
,
310 static struct pxaficp_platform_data trizeps4_ficp_platform_data
= {
311 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
312 .transceiver_mode
= board_irda_mode
,
315 static int trizeps4_ohci_init(struct device
*dev
)
317 /* setup Port1 GPIO pin. */
318 pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN
); /* USBHPWR1 */
319 pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT
); /* USBHPEN1 */
321 /* Set the Power Control Polarity Low and Power Sense
322 Polarity Low to active low. */
323 UHCHR
= (UHCHR
| UHCHR_PCPL
| UHCHR_PSPL
) &
324 ~(UHCHR_SSEP1
| UHCHR_SSEP2
| UHCHR_SSEP3
| UHCHR_SSE
);
329 static void trizeps4_ohci_exit(struct device
*dev
)
334 static struct pxaohci_platform_data trizeps4_ohci_platform_data
= {
335 .port_mode
= PMM_PERPORT_MODE
,
336 .init
= trizeps4_ohci_init
,
337 .exit
= trizeps4_ohci_exit
,
340 static struct map_desc trizeps4_io_desc
[] __initdata
= {
342 .virtual = TRIZEPS4_CFSR_VIRT
,
343 .pfn
= __phys_to_pfn(TRIZEPS4_CFSR_PHYS
),
344 .length
= 0x00001000,
348 .virtual = TRIZEPS4_BOCR_VIRT
,
349 .pfn
= __phys_to_pfn(TRIZEPS4_BOCR_PHYS
),
350 .length
= 0x00001000,
354 .virtual = TRIZEPS4_IRCR_VIRT
,
355 .pfn
= __phys_to_pfn(TRIZEPS4_IRCR_PHYS
),
356 .length
= 0x00001000,
360 .virtual = TRIZEPS4_DICR_VIRT
,
361 .pfn
= __phys_to_pfn(TRIZEPS4_DICR_PHYS
),
362 .length
= 0x00001000,
366 .virtual = TRIZEPS4_UPSR_VIRT
,
367 .pfn
= __phys_to_pfn(TRIZEPS4_UPSR_PHYS
),
368 .length
= 0x00001000,
373 static struct pxafb_mode_info sharp_lcd_mode
= {
384 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
388 static struct pxafb_mach_info sharp_lcd
= {
389 .modes
= &sharp_lcd_mode
,
393 .lccr0
= LCCR0_Color
| LCCR0_Pas
| LCCR0_Dual
,
395 .pxafb_backlight_power
= board_backlight_power
,
398 static struct pxafb_mode_info toshiba_lcd_mode
= {
413 static struct pxafb_mach_info toshiba_lcd
= {
414 .modes
= &toshiba_lcd_mode
,
418 .lccr0
= LCCR0_Color
| LCCR0_Act
,
420 .pxafb_backlight_power
= board_backlight_power
,
423 static void __init
trizeps4_init(void)
425 platform_add_devices(trizeps4_devices
, ARRAY_SIZE(trizeps4_devices
));
427 /* set_pxa_fb_info(&sharp_lcd); */
428 set_pxa_fb_info(&toshiba_lcd
);
430 pxa_set_mci_info(&trizeps4_mci_platform_data
);
431 pxa_set_ficp_info(&trizeps4_ficp_platform_data
);
432 pxa_set_ohci_info(&trizeps4_ohci_platform_data
);
433 pxa_set_ac97_info(NULL
);
436 static void __init
trizeps4_map_io(void)
439 iotable_init(trizeps4_io_desc
, ARRAY_SIZE(trizeps4_io_desc
));
442 pxa_gpio_mode(GPIO15_nCS_1_MD
);
444 /* for off-module PIC on ConXS board */
445 pxa_gpio_mode(GPIO_PIC
| GPIO_IN
);
448 pxa_gpio_mode(GPIO_UCB1400
| GPIO_IN
);
451 pxa_gpio_mode(GPIO78_nCS_2_MD
);
452 pxa_gpio_mode(GPIO_DM9000
| GPIO_IN
);
454 /* for PCMCIA device */
455 pxa_gpio_mode(GPIO_PCD
| GPIO_IN
);
456 pxa_gpio_mode(GPIO_PRDY
| GPIO_IN
);
458 /* for I2C adapter */
459 pxa_gpio_mode(GPIO117_I2CSCL_MD
);
460 pxa_gpio_mode(GPIO118_I2CSDA_MD
);
463 pxa_gpio_mode(GPIO_MMC_DET
| GPIO_IN
);
465 /* whats that for ??? */
466 pxa_gpio_mode(GPIO79_nCS_3_MD
);
469 pxa_gpio_mode( GPIO_SYS_BUSY_LED
| GPIO_OUT
); /* LED1 */
470 pxa_gpio_mode( GPIO_HEARTBEAT_LED
| GPIO_OUT
); /* LED2 */
472 #ifdef CONFIG_MACH_TRIZEPS4_CONXS
473 #ifdef CONFIG_IDE_PXA_CF
474 /* if boot direct from compact flash dont disable power */
475 trizeps_conxs_bcr
= 0x0009;
477 /* this is the reset value */
478 trizeps_conxs_bcr
= 0x00A0;
480 ConXS_BCR
= trizeps_conxs_bcr
;
483 #warning FIXME - accessing PM registers directly is deprecated
490 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
494 MACHINE_START(TRIZEPS4
, "Keith und Koep Trizeps IV module")
495 /* MAINTAINER("Jürgen Schindele") */
496 .phys_io
= 0x40000000,
497 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
498 .boot_params
= TRIZEPS4_SDRAM_BASE
+ 0x100,
499 .init_machine
= trizeps4_init
,
500 .map_io
= trizeps4_map_io
,
501 .init_irq
= pxa27x_init_irq
,