1/* 2 * linux/arch/arm/mach-pxa/trizeps4.c 3 * 4 * Support for the Keith und Koep Trizeps4 Module Platform. 5 * 6 * Author: J��rgen Schindele 7 * Created: 20 02, 2006 8 * Copyright: J��rgen Schindele 9 * 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. 13 */ 14 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> 22#include <linux/fb.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> 29 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> 35#include <asm/irq.h> 36#include <asm/sizes.h> 37 38#include <asm/mach/arch.h> 39#include <asm/mach/map.h> 40#include <asm/mach/irq.h> 41#include <asm/mach/flash.h> 42 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> 50 51#include "generic.h" 52 53/******************************************************************************************** 54 * ONBOARD FLASH 55 ********************************************************************************************/ 56static struct mtd_partition trizeps4_partitions[] = { 57 { 58 .name = "Bootloader", 59 .offset = 0x00000000, 60 .size = 0x00040000, 61 .mask_flags = MTD_WRITEABLE /* force read-only */ 62 },{ 63 .name = "Backup", 64 .offset = 0x00040000, 65 .size = 0x00040000, 66 },{ 67 .name = "Image", 68 .offset = 0x00080000, 69 .size = 0x01080000, 70 },{ 71 .name = "IPSM", 72 .offset = 0x01100000, 73 .size = 0x00e00000, 74 },{ 75 .name = "Registry", 76 .offset = 0x01f00000, 77 .size = MTDPART_SIZ_FULL, 78 } 79}; 80 81static struct physmap_flash_data trizeps4_flash_data[] = { 82 { 83 .width = 4, /* bankwidth in bytes */ 84 .parts = trizeps4_partitions, 85 .nr_parts = ARRAY_SIZE(trizeps4_partitions) 86 } 87}; 88 89static struct resource flash_resource = { 90 .start = PXA_CS0_PHYS, 91 .end = PXA_CS0_PHYS + SZ_32M - 1, 92 .flags = IORESOURCE_MEM, 93}; 94 95static struct platform_device flash_device = { 96 .name = "physmap-flash", 97 .id = 0, 98 .dev = { 99 .platform_data = trizeps4_flash_data, 100 }, 101 .resource = &flash_resource, 102 .num_resources = 1, 103}; 104 105/******************************************************************************************** 106 * DAVICOM DM9000 Ethernet 107 ********************************************************************************************/ 108static struct resource dm9000_resources[] = { 109 [0] = { 110 .start = TRIZEPS4_ETH_PHYS+0x300, 111 .end = TRIZEPS4_ETH_PHYS+0x400-1, 112 .flags = IORESOURCE_MEM, 113 }, 114 [1] = { 115 .start = TRIZEPS4_ETH_PHYS+0x8300, 116 .end = TRIZEPS4_ETH_PHYS+0x8400-1, 117 .flags = IORESOURCE_MEM, 118 }, 119 [2] = { 120 .start = TRIZEPS4_ETH_IRQ, 121 .end = TRIZEPS4_ETH_IRQ, 122 .flags = (IORESOURCE_IRQ | IRQT_RISING), 123 }, 124}; 125 126static struct platform_device dm9000_device = { 127 .name = "dm9000", 128 .id = -1, 129 .num_resources = ARRAY_SIZE(dm9000_resources), 130 .resource = dm9000_resources, 131}; 132 133/******************************************************************************************** 134 * PXA270 serial ports 135 ********************************************************************************************/ 136static struct plat_serial8250_port tri_serial_ports[] = { 137#ifdef CONFIG_SERIAL_PXA 138 /* this uses the own PXA driver */ 139 { 140 0, 141 }, 142#else 143 /* this uses the generic 8520 driver */ 144 [0] = { 145 .membase = (void *)&FFUART, 146 .irq = IRQ_FFUART, 147 .flags = UPF_BOOT_AUTOCONF, 148 .iotype = UPIO_MEM32, 149 .regshift = 2, 150 .uartclk = (921600*16), 151 }, 152 [1] = { 153 .membase = (void *)&BTUART, 154 .irq = IRQ_BTUART, 155 .flags = UPF_BOOT_AUTOCONF, 156 .iotype = UPIO_MEM32, 157 .regshift = 2, 158 .uartclk = (921600*16), 159 }, 160 { 161 0, 162 }, 163#endif 164}; 165 166static struct platform_device uart_devices = { 167 .name = "serial8250", 168 .id = 0, 169 .dev = { 170 .platform_data = tri_serial_ports, 171 }, 172 .num_resources = 0, 173 .resource = NULL, 174}; 175 176/******************************************************************************************** 177 * PXA270 ac97 sound codec 178 ********************************************************************************************/ 179static struct platform_device ac97_audio_device = { 180 .name = "pxa2xx-ac97", 181 .id = -1, 182}; 183 184static struct platform_device * trizeps4_devices[] __initdata = { 185 &flash_device, 186 &uart_devices, 187 &dm9000_device, 188 &ac97_audio_device, 189}; 190 191#ifdef CONFIG_MACH_TRIZEPS4_CONXS 192static short trizeps_conxs_bcr; 193 194/* PCCARD power switching supports only 3,3V */ 195void board_pcmcia_power(int power) 196{ 197 if (power) { 198 /* switch power on, put in reset and enable buffers */ 199 trizeps_conxs_bcr |= power; 200 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET; 201 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_BUF_EN); 202 ConXS_BCR = trizeps_conxs_bcr; 203 /* wait a little */ 204 udelay(2000); 205 /* take reset away */ 206 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_RESET); 207 ConXS_BCR = trizeps_conxs_bcr; 208 udelay(2000); 209 } else { 210 /* put in reset */ 211 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET; 212 ConXS_BCR = trizeps_conxs_bcr; 213 udelay(1000); 214 /* switch power off */ 215 trizeps_conxs_bcr &= ~(0xf); 216 ConXS_BCR = trizeps_conxs_bcr; 217 218 } 219 pr_debug("%s: o%s 0x%x\n", __FUNCTION__, power ? "n": "ff", trizeps_conxs_bcr); 220} 221 222/* backlight power switching for LCD panel */ 223static void board_backlight_power(int on) 224{ 225 if (on) { 226 trizeps_conxs_bcr |= ConXS_BCR_L_DISP; 227 } else { 228 trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP; 229 } 230 pr_debug("%s: o%s 0x%x\n", __FUNCTION__, on ? "n" : "ff", trizeps_conxs_bcr); 231 ConXS_BCR = trizeps_conxs_bcr; 232} 233 234/* Powersupply for MMC/SD cardslot */ 235static void board_mci_power(struct device *dev, unsigned int vdd) 236{ 237 struct pxamci_platform_data* p_d = dev->platform_data; 238 239 if (( 1 << vdd) & p_d->ocr_mask) { 240 pr_debug("%s: on\n", __FUNCTION__); 241 } else { 242 pr_debug("%s: off\n", __FUNCTION__); 243 } 244} 245 246static short trizeps_conxs_ircr; 247 248/* Switch modes and Power for IRDA receiver */ 249static void board_irda_mode(struct device *dev, int mode) 250{ 251 unsigned long flags; 252 253 local_irq_save(flags); 254 if (mode & IR_SIRMODE) { 255 /* Slow mode */ 256 trizeps_conxs_ircr &= ~ConXS_IRCR_MODE; 257 } else if (mode & IR_FIRMODE) { 258 /* Fast mode */ 259 trizeps_conxs_ircr |= ConXS_IRCR_MODE; 260 } 261 if (mode & IR_OFF) { 262 trizeps_conxs_ircr |= ConXS_IRCR_SD; 263 } else { 264 trizeps_conxs_ircr &= ~ConXS_IRCR_SD; 265 } 266 local_irq_restore(flags); 267} 268 269#else 270/* for other baseboards define dummies */ 271void board_pcmcia_power(int power) {;} 272#define board_backlight_power NULL 273#define board_mci_power NULL 274#define board_irda_mode NULL 275 276#endif /* CONFIG_MACH_TRIZEPS4_CONXS */ 277EXPORT_SYMBOL(board_pcmcia_power); 278 279static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int, void *data) 280{ 281 int err; 282 /* setup GPIO for PXA27x MMC controller */ 283 pxa_gpio_mode(GPIO32_MMCCLK_MD); 284 pxa_gpio_mode(GPIO112_MMCCMD_MD); 285 pxa_gpio_mode(GPIO92_MMCDAT0_MD); 286 pxa_gpio_mode(GPIO109_MMCDAT1_MD); 287 pxa_gpio_mode(GPIO110_MMCDAT2_MD); 288 pxa_gpio_mode(GPIO111_MMCDAT3_MD); 289 290 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN); 291 292 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int, 293 IRQF_DISABLED | IRQF_TRIGGER_RISING, 294 "MMC card detect", data); 295 if (err) { 296 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 297 return -1; 298 } 299 return 0; 300} 301 302static void trizeps4_mci_exit(struct device *dev, void *data) 303{ 304 free_irq(TRIZEPS4_MMC_IRQ, data); 305} 306 307static struct pxamci_platform_data trizeps4_mci_platform_data = { 308 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 309 .init = trizeps4_mci_init, 310 .exit = trizeps4_mci_exit, 311 .setpower = board_mci_power, 312}; 313 314static struct pxaficp_platform_data trizeps4_ficp_platform_data = { 315 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, 316 .transceiver_mode = board_irda_mode, 317}; 318 319static int trizeps4_ohci_init(struct device *dev) 320{ 321 /* setup Port1 GPIO pin. */ 322 pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */ 323 pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */ 324 325 /* Set the Power Control Polarity Low and Power Sense 326 Polarity Low to active low. */ 327 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) & 328 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); 329 330 return 0; 331} 332 333static void trizeps4_ohci_exit(struct device *dev) 334{ 335 ; 336} 337 338static struct pxaohci_platform_data trizeps4_ohci_platform_data = { 339 .port_mode = PMM_PERPORT_MODE, 340 .init = trizeps4_ohci_init, 341 .exit = trizeps4_ohci_exit, 342}; 343 344static struct map_desc trizeps4_io_desc[] __initdata = { 345 { /* ConXS CFSR */ 346 .virtual = TRIZEPS4_CFSR_VIRT, 347 .pfn = __phys_to_pfn(TRIZEPS4_CFSR_PHYS), 348 .length = 0x00001000, 349 .type = MT_DEVICE 350 }, 351 { /* ConXS BCR */ 352 .virtual = TRIZEPS4_BOCR_VIRT, 353 .pfn = __phys_to_pfn(TRIZEPS4_BOCR_PHYS), 354 .length = 0x00001000, 355 .type = MT_DEVICE 356 }, 357 { /* ConXS IRCR */ 358 .virtual = TRIZEPS4_IRCR_VIRT, 359 .pfn = __phys_to_pfn(TRIZEPS4_IRCR_PHYS), 360 .length = 0x00001000, 361 .type = MT_DEVICE 362 }, 363 { /* ConXS DCR */ 364 .virtual = TRIZEPS4_DICR_VIRT, 365 .pfn = __phys_to_pfn(TRIZEPS4_DICR_PHYS), 366 .length = 0x00001000, 367 .type = MT_DEVICE 368 }, 369 { /* ConXS UPSR */ 370 .virtual = TRIZEPS4_UPSR_VIRT, 371 .pfn = __phys_to_pfn(TRIZEPS4_UPSR_PHYS), 372 .length = 0x00001000, 373 .type = MT_DEVICE 374 } 375}; 376 377static struct pxafb_mode_info sharp_lcd_mode = { 378 .pixclock = 78000, 379 .xres = 640, 380 .yres = 480, 381 .bpp = 8, 382 .hsync_len = 4, 383 .left_margin = 4, 384 .right_margin = 4, 385 .vsync_len = 2, 386 .upper_margin = 0, 387 .lower_margin = 0, 388 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 389 .cmap_greyscale = 0, 390}; 391 392static struct pxafb_mach_info sharp_lcd = { 393 .modes = &sharp_lcd_mode, 394 .num_modes = 1, 395 .cmap_inverse = 0, 396 .cmap_static = 0, 397 .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual, 398 .lccr3 = 0x0340ff02, 399 .pxafb_backlight_power = board_backlight_power, 400}; 401 402static struct pxafb_mode_info toshiba_lcd_mode = { 403 .pixclock = 39720, 404 .xres = 640, 405 .yres = 480, 406 .bpp = 8, 407 .hsync_len = 63, 408 .left_margin = 12, 409 .right_margin = 12, 410 .vsync_len = 4, 411 .upper_margin = 32, 412 .lower_margin = 10, 413 .sync = 0, 414 .cmap_greyscale = 0, 415}; 416 417static struct pxafb_mach_info toshiba_lcd = { 418 .modes = &toshiba_lcd_mode, 419 .num_modes = 1, 420 .cmap_inverse = 0, 421 .cmap_static = 0, 422 .lccr0 = LCCR0_Color | LCCR0_Act, 423 .lccr3 = 0x03400002, 424 .pxafb_backlight_power = board_backlight_power, 425}; 426 427static void __init trizeps4_init(void) 428{ 429 platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices)); 430 431/* set_pxa_fb_info(&sharp_lcd); */ 432 set_pxa_fb_info(&toshiba_lcd); 433 434 pxa_set_mci_info(&trizeps4_mci_platform_data); 435 pxa_set_ficp_info(&trizeps4_ficp_platform_data); 436 pxa_set_ohci_info(&trizeps4_ohci_platform_data); 437} 438 439static void __init trizeps4_map_io(void) 440{ 441 pxa_map_io(); 442 iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc)); 443 444 /* for DiskOnChip */ 445 pxa_gpio_mode(GPIO15_nCS_1_MD); 446 447 /* for off-module PIC on ConXS board */ 448 pxa_gpio_mode(GPIO_PIC | GPIO_IN); 449 450 /* UCB1400 irq */ 451 pxa_gpio_mode(GPIO_UCB1400 | GPIO_IN); 452 453 /* for DM9000 LAN */ 454 pxa_gpio_mode(GPIO78_nCS_2_MD); 455 pxa_gpio_mode(GPIO_DM9000 | GPIO_IN); 456 457 /* for PCMCIA device */ 458 pxa_gpio_mode(GPIO_PCD | GPIO_IN); 459 pxa_gpio_mode(GPIO_PRDY | GPIO_IN); 460 461 /* for I2C adapter */ 462 pxa_gpio_mode(GPIO117_I2CSCL_MD); 463 pxa_gpio_mode(GPIO118_I2CSDA_MD); 464 465 /* MMC_DET s.o. */ 466 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN); 467 468 /* whats that for ??? */ 469 pxa_gpio_mode(GPIO79_nCS_3_MD); 470 471#ifdef CONFIG_LEDS 472 pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */ 473 pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */ 474#endif 475#ifdef CONFIG_MACH_TRIZEPS4_CONXS 476#ifdef CONFIG_IDE_PXA_CF 477 /* if boot direct from compact flash dont disable power */ 478 trizeps_conxs_bcr = 0x0009; 479#else 480 /* this is the reset value */ 481 trizeps_conxs_bcr = 0x00A0; 482#endif 483 ConXS_BCR = trizeps_conxs_bcr; 484#endif 485 486 PWER = 0x00000002; 487 PFER = 0x00000000; 488 PRER = 0x00000002; 489 PGSR0 = 0x0158C000; 490 PGSR1 = 0x00FF0080; 491 PGSR2 = 0x0001C004; 492 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 493 PCFR |= PCFR_OPDE; 494} 495 496MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module") 497 /* MAINTAINER("J��rgen Schindele") */ 498 .phys_io = 0x40000000, 499 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 500 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100, 501 .init_machine = trizeps4_init, 502 .map_io = trizeps4_map_io, 503 .init_irq = pxa_init_irq, 504 .timer = &pxa_timer, 505MACHINE_END 506