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/trizeps4.h>
45 #include <asm/arch/audio.h>
46 #include <asm/arch/pxafb.h>
47 #include <asm/arch/mmc.h>
48 #include <asm/arch/irda.h>
49 #include <asm/arch/ohci.h>
54 /********************************************************************************************
56 ********************************************************************************************/
57 static struct mtd_partition trizeps4_partitions[] = {
62 .mask_flags = MTD_WRITEABLE /* force read-only */
78 .size = MTDPART_SIZ_FULL,
82 static struct physmap_flash_data trizeps4_flash_data[] = {
84 .width = 4, /* bankwidth in bytes */
85 .parts = trizeps4_partitions,
86 .nr_parts = ARRAY_SIZE(trizeps4_partitions)
90 static struct resource flash_resource = {
91 .start = PXA_CS0_PHYS,
92 .end = PXA_CS0_PHYS + SZ_32M - 1,
93 .flags = IORESOURCE_MEM,
96 static struct platform_device flash_device = {
97 .name = "physmap-flash",
100 .platform_data = trizeps4_flash_data,
102 .resource = &flash_resource,
106 /********************************************************************************************
107 * DAVICOM DM9000 Ethernet
108 ********************************************************************************************/
109 static struct resource dm9000_resources[] = {
111 .start = TRIZEPS4_ETH_PHYS+0x300,
112 .end = TRIZEPS4_ETH_PHYS+0x400-1,
113 .flags = IORESOURCE_MEM,
116 .start = TRIZEPS4_ETH_PHYS+0x8300,
117 .end = TRIZEPS4_ETH_PHYS+0x8400-1,
118 .flags = IORESOURCE_MEM,
121 .start = TRIZEPS4_ETH_IRQ,
122 .end = TRIZEPS4_ETH_IRQ,
123 .flags = (IORESOURCE_IRQ | IRQT_RISING),
127 static struct platform_device dm9000_device = {
130 .num_resources = ARRAY_SIZE(dm9000_resources),
131 .resource = dm9000_resources,
134 /********************************************************************************************
135 * PXA270 serial ports
136 ********************************************************************************************/
137 static struct plat_serial8250_port tri_serial_ports[] = {
138 #ifdef CONFIG_SERIAL_PXA
139 /* this uses the own PXA driver */
144 /* this uses the generic 8520 driver */
146 .membase = (void *)&FFUART,
148 .flags = UPF_BOOT_AUTOCONF,
149 .iotype = UPIO_MEM32,
151 .uartclk = (921600*16),
154 .membase = (void *)&BTUART,
156 .flags = UPF_BOOT_AUTOCONF,
157 .iotype = UPIO_MEM32,
159 .uartclk = (921600*16),
167 static struct platform_device uart_devices = {
168 .name = "serial8250",
171 .platform_data = tri_serial_ports,
177 /********************************************************************************************
178 * PXA270 ac97 sound codec
179 ********************************************************************************************/
180 static struct platform_device ac97_audio_device = {
181 .name = "pxa2xx-ac97",
185 static struct platform_device * trizeps4_devices[] __initdata = {
192 #ifdef CONFIG_MACH_TRIZEPS4_CONXS
193 static short trizeps_conxs_bcr;
195 /* PCCARD power switching supports only 3,3V */
196 void board_pcmcia_power(int power)
199 /* switch power on, put in reset and enable buffers */
200 trizeps_conxs_bcr |= power;
201 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
202 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_BUF_EN);
203 ConXS_BCR = trizeps_conxs_bcr;
206 /* take reset away */
207 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_RESET);
208 ConXS_BCR = trizeps_conxs_bcr;
212 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
213 ConXS_BCR = trizeps_conxs_bcr;
215 /* switch power off */
216 trizeps_conxs_bcr &= ~(0xf);
217 ConXS_BCR = trizeps_conxs_bcr;
220 pr_debug("%s: o%s 0x%x\n", __FUNCTION__, power ? "n": "ff", trizeps_conxs_bcr);
223 /* backlight power switching for LCD panel */
224 static void board_backlight_power(int on)
227 trizeps_conxs_bcr |= ConXS_BCR_L_DISP;
229 trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP;
231 pr_debug("%s: o%s 0x%x\n", __FUNCTION__, on ? "n" : "ff", trizeps_conxs_bcr);
232 ConXS_BCR = trizeps_conxs_bcr;
235 /* Powersupply for MMC/SD cardslot */
236 static void board_mci_power(struct device *dev, unsigned int vdd)
238 struct pxamci_platform_data* p_d = dev->platform_data;
240 if (( 1 << vdd) & p_d->ocr_mask) {
241 pr_debug("%s: on\n", __FUNCTION__);
242 /* FIXME fill in values here */
244 pr_debug("%s: off\n", __FUNCTION__);
245 /* FIXME fill in values here */
249 static short trizeps_conxs_ircr;
251 /* Switch modes and Power for IRDA receiver */
252 static void board_irda_mode(struct device *dev, int mode)
256 local_irq_save(flags);
257 if (mode & IR_SIRMODE) {
259 trizeps_conxs_ircr &= ~ConXS_IRCR_MODE;
260 } else if (mode & IR_FIRMODE) {
262 trizeps_conxs_ircr |= ConXS_IRCR_MODE;
265 trizeps_conxs_ircr |= ConXS_IRCR_SD;
267 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
269 /* FIXME write values to register */
270 local_irq_restore(flags);
274 /* for other baseboards define dummies */
275 void board_pcmcia_power(int power) {;}
276 #define board_backlight_power NULL
277 #define board_mci_power NULL
278 #define board_irda_mode NULL
280 #endif /* CONFIG_MACH_TRIZEPS4_CONXS */
281 EXPORT_SYMBOL(board_pcmcia_power);
283 static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int, void *data)
286 /* setup GPIO for PXA27x MMC controller */
287 pxa_gpio_mode(GPIO32_MMCCLK_MD);
288 pxa_gpio_mode(GPIO112_MMCCMD_MD);
289 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
290 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
291 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
292 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
294 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
296 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
297 IRQF_DISABLED | IRQF_TRIGGER_RISING,
298 "MMC card detect", data);
300 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
306 static void trizeps4_mci_exit(struct device *dev, void *data)
308 free_irq(TRIZEPS4_MMC_IRQ, data);
311 static struct pxamci_platform_data trizeps4_mci_platform_data = {
312 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
313 .init = trizeps4_mci_init,
314 .exit = trizeps4_mci_exit,
315 .setpower = board_mci_power,
318 static struct pxaficp_platform_data trizeps4_ficp_platform_data = {
319 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
320 .transceiver_mode = board_irda_mode,
323 static int trizeps4_ohci_init(struct device *dev)
325 /* setup Port1 GPIO pin. */
326 pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */
327 pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
329 /* Set the Power Control Polarity Low and Power Sense
330 Polarity Low to active low. */
331 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
332 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
337 static void trizeps4_ohci_exit(struct device *dev)
342 static struct pxaohci_platform_data trizeps4_ohci_platform_data = {
343 .port_mode = PMM_PERPORT_MODE,
344 .init = trizeps4_ohci_init,
345 .exit = trizeps4_ohci_exit,
348 static struct map_desc trizeps4_io_desc[] __initdata = {
350 .virtual = TRIZEPS4_CFSR_VIRT,
351 .pfn = __phys_to_pfn(TRIZEPS4_CFSR_PHYS),
352 .length = 0x00001000,
356 .virtual = TRIZEPS4_BOCR_VIRT,
357 .pfn = __phys_to_pfn(TRIZEPS4_BOCR_PHYS),
358 .length = 0x00001000,
362 .virtual = TRIZEPS4_IRCR_VIRT,
363 .pfn = __phys_to_pfn(TRIZEPS4_IRCR_PHYS),
364 .length = 0x00001000,
368 .virtual = TRIZEPS4_DICR_VIRT,
369 .pfn = __phys_to_pfn(TRIZEPS4_DICR_PHYS),
370 .length = 0x00001000,
374 .virtual = TRIZEPS4_UPSR_VIRT,
375 .pfn = __phys_to_pfn(TRIZEPS4_UPSR_PHYS),
376 .length = 0x00001000,
381 static struct pxafb_mode_info sharp_lcd_mode = {
392 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
396 static struct pxafb_mach_info sharp_lcd = {
397 .modes = &sharp_lcd_mode,
401 .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual,
403 .pxafb_backlight_power = board_backlight_power,
406 static struct pxafb_mode_info toshiba_lcd_mode = {
421 static struct pxafb_mach_info toshiba_lcd = {
422 .modes = &toshiba_lcd_mode,
426 .lccr0 = LCCR0_Color | LCCR0_Act,
428 .pxafb_backlight_power = board_backlight_power,
431 static void __init trizeps4_init(void)
433 platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices));
435 /* set_pxa_fb_info(&sharp_lcd); */
436 set_pxa_fb_info(&toshiba_lcd);
438 pxa_set_mci_info(&trizeps4_mci_platform_data);
439 pxa_set_ficp_info(&trizeps4_ficp_platform_data);
440 pxa_set_ohci_info(&trizeps4_ohci_platform_data);
443 static void __init trizeps4_map_io(void)
446 iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
449 pxa_gpio_mode(GPIO15_nCS_1_MD);
451 /* for off-module PIC on ConXS board */
452 pxa_gpio_mode(GPIO_PIC | GPIO_IN);
455 pxa_gpio_mode(GPIO_UCB1400 | GPIO_IN);
458 pxa_gpio_mode(GPIO78_nCS_2_MD);
459 pxa_gpio_mode(GPIO_DM9000 | GPIO_IN);
461 /* for PCMCIA device */
462 pxa_gpio_mode(GPIO_PCD | GPIO_IN);
463 pxa_gpio_mode(GPIO_PRDY | GPIO_IN);
465 /* for I2C adapter */
466 pxa_gpio_mode(GPIO117_I2CSCL_MD);
467 pxa_gpio_mode(GPIO118_I2CSDA_MD);
470 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
472 /* whats that for ??? */
473 pxa_gpio_mode(GPIO79_nCS_3_MD);
476 pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */
477 pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */
479 #ifdef CONFIG_MACH_TRIZEPS4_CONXS
480 #ifdef CONFIG_IDE_PXA_CF
481 /* if boot direct from compact flash dont disable power */
482 trizeps_conxs_bcr = 0x0009;
484 /* this is the reset value */
485 trizeps_conxs_bcr = 0x00A0;
487 ConXS_BCR = trizeps_conxs_bcr;
496 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
500 MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
501 /* MAINTAINER("Jürgen Schindele") */
502 .phys_io = 0x40000000,
503 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
504 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
505 .init_machine = trizeps4_init,
506 .map_io = trizeps4_map_io,
507 .init_irq = pxa27x_init_irq,