1 /* 2 * DBAu1300 init and platform device setup. 3 * 4 * (c) 2009 Manuel Lauss <manuel.lauss@googlemail.com> 5 */ 6 7 #include <linux/dma-mapping.h> 8 #include <linux/gpio.h> 9 #include <linux/gpio_keys.h> 10 #include <linux/init.h> 11 #include <linux/input.h> /* KEY_* codes */ 12 #include <linux/i2c.h> 13 #include <linux/io.h> 14 #include <linux/leds.h> 15 #include <linux/ata_platform.h> 16 #include <linux/mmc/host.h> 17 #include <linux/module.h> 18 #include <linux/mtd/mtd.h> 19 #include <linux/mtd/nand.h> 20 #include <linux/mtd/partitions.h> 21 #include <linux/platform_device.h> 22 #include <linux/smsc911x.h> 23 24 #include <asm/mach-au1x00/au1000.h> 25 #include <asm/mach-au1x00/au1100_mmc.h> 26 #include <asm/mach-au1x00/au1200fb.h> 27 #include <asm/mach-au1x00/au1xxx_dbdma.h> 28 #include <asm/mach-au1x00/au1xxx_psc.h> 29 #include <asm/mach-db1x00/db1300.h> 30 #include <asm/mach-db1x00/bcsr.h> 31 #include <asm/mach-au1x00/prom.h> 32 33 #include "platform.h" 34 35 static struct i2c_board_info db1300_i2c_devs[] __initdata = { 36 { I2C_BOARD_INFO("wm8731", 0x1b), }, /* I2S audio codec */ 37 { I2C_BOARD_INFO("ne1619", 0x2d), }, /* adm1025-compat hwmon */ 38 }; 39 40 /* multifunction pins to assign to GPIO controller */ 41 static int db1300_gpio_pins[] __initdata = { 42 AU1300_PIN_LCDPWM0, AU1300_PIN_PSC2SYNC1, AU1300_PIN_WAKE1, 43 AU1300_PIN_WAKE2, AU1300_PIN_WAKE3, AU1300_PIN_FG3AUX, 44 AU1300_PIN_EXTCLK1, 45 -1, /* terminator */ 46 }; 47 48 /* multifunction pins to assign to device functions */ 49 static int db1300_dev_pins[] __initdata = { 50 /* wake-from-str pins 0-3 */ 51 AU1300_PIN_WAKE0, 52 /* external clock sources for PSC0 */ 53 AU1300_PIN_EXTCLK0, 54 /* 8bit MMC interface on SD0: 6-9 */ 55 AU1300_PIN_SD0DAT4, AU1300_PIN_SD0DAT5, AU1300_PIN_SD0DAT6, 56 AU1300_PIN_SD0DAT7, 57 /* UART1 pins: 11-18 */ 58 AU1300_PIN_U1RI, AU1300_PIN_U1DCD, AU1300_PIN_U1DSR, 59 AU1300_PIN_U1CTS, AU1300_PIN_U1RTS, AU1300_PIN_U1DTR, 60 AU1300_PIN_U1RX, AU1300_PIN_U1TX, 61 /* UART0 pins: 19-24 */ 62 AU1300_PIN_U0RI, AU1300_PIN_U0DCD, AU1300_PIN_U0DSR, 63 AU1300_PIN_U0CTS, AU1300_PIN_U0RTS, AU1300_PIN_U0DTR, 64 /* UART2: 25-26 */ 65 AU1300_PIN_U2RX, AU1300_PIN_U2TX, 66 /* UART3: 27-28 */ 67 AU1300_PIN_U3RX, AU1300_PIN_U3TX, 68 /* LCD controller PWMs, ext pixclock: 30-31 */ 69 AU1300_PIN_LCDPWM1, AU1300_PIN_LCDCLKIN, 70 /* SD1 interface: 32-37 */ 71 AU1300_PIN_SD1DAT0, AU1300_PIN_SD1DAT1, AU1300_PIN_SD1DAT2, 72 AU1300_PIN_SD1DAT3, AU1300_PIN_SD1CMD, AU1300_PIN_SD1CLK, 73 /* SD2 interface: 38-43 */ 74 AU1300_PIN_SD2DAT0, AU1300_PIN_SD2DAT1, AU1300_PIN_SD2DAT2, 75 AU1300_PIN_SD2DAT3, AU1300_PIN_SD2CMD, AU1300_PIN_SD2CLK, 76 /* PSC0/1 clocks: 44-45 */ 77 AU1300_PIN_PSC0CLK, AU1300_PIN_PSC1CLK, 78 /* PSCs: 46-49/50-53/54-57/58-61 */ 79 AU1300_PIN_PSC0SYNC0, AU1300_PIN_PSC0SYNC1, AU1300_PIN_PSC0D0, 80 AU1300_PIN_PSC0D1, 81 AU1300_PIN_PSC1SYNC0, AU1300_PIN_PSC1SYNC1, AU1300_PIN_PSC1D0, 82 AU1300_PIN_PSC1D1, 83 AU1300_PIN_PSC2SYNC0, AU1300_PIN_PSC2D0, 84 AU1300_PIN_PSC2D1, 85 AU1300_PIN_PSC3SYNC0, AU1300_PIN_PSC3SYNC1, AU1300_PIN_PSC3D0, 86 AU1300_PIN_PSC3D1, 87 /* PCMCIA interface: 62-70 */ 88 AU1300_PIN_PCE2, AU1300_PIN_PCE1, AU1300_PIN_PIOS16, 89 AU1300_PIN_PIOR, AU1300_PIN_PWE, AU1300_PIN_PWAIT, 90 AU1300_PIN_PREG, AU1300_PIN_POE, AU1300_PIN_PIOW, 91 /* camera interface H/V sync inputs: 71-72 */ 92 AU1300_PIN_CIMLS, AU1300_PIN_CIMFS, 93 /* PSC2/3 clocks: 73-74 */ 94 AU1300_PIN_PSC2CLK, AU1300_PIN_PSC3CLK, 95 -1, /* terminator */ 96 }; 97 98 static void __init db1300_gpio_config(void) 99 { 100 int *i; 101 102 i = &db1300_dev_pins[0]; 103 while (*i != -1) 104 au1300_pinfunc_to_dev(*i++); 105 106 i = &db1300_gpio_pins[0]; 107 while (*i != -1) 108 au1300_gpio_direction_input(*i++);/* implies pin_to_gpio */ 109 110 au1300_set_dbdma_gpio(1, AU1300_PIN_FG3AUX); 111 } 112 113 char *get_system_type(void) 114 { 115 return "DB1300"; 116 } 117 118 /**********************************************************************/ 119 120 static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, 121 unsigned int ctrl) 122 { 123 struct nand_chip *this = mtd->priv; 124 unsigned long ioaddr = (unsigned long)this->IO_ADDR_W; 125 126 ioaddr &= 0xffffff00; 127 128 if (ctrl & NAND_CLE) { 129 ioaddr += MEM_STNAND_CMD; 130 } else if (ctrl & NAND_ALE) { 131 ioaddr += MEM_STNAND_ADDR; 132 } else { 133 /* assume we want to r/w real data by default */ 134 ioaddr += MEM_STNAND_DATA; 135 } 136 this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; 137 if (cmd != NAND_CMD_NONE) { 138 __raw_writeb(cmd, this->IO_ADDR_W); 139 wmb(); 140 } 141 } 142 143 static int au1300_nand_device_ready(struct mtd_info *mtd) 144 { 145 return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 146 } 147 148 static struct mtd_partition db1300_nand_parts[] = { 149 { 150 .name = "NAND FS 0", 151 .offset = 0, 152 .size = 8 * 1024 * 1024, 153 }, 154 { 155 .name = "NAND FS 1", 156 .offset = MTDPART_OFS_APPEND, 157 .size = MTDPART_SIZ_FULL 158 }, 159 }; 160 161 struct platform_nand_data db1300_nand_platdata = { 162 .chip = { 163 .nr_chips = 1, 164 .chip_offset = 0, 165 .nr_partitions = ARRAY_SIZE(db1300_nand_parts), 166 .partitions = db1300_nand_parts, 167 .chip_delay = 20, 168 }, 169 .ctrl = { 170 .dev_ready = au1300_nand_device_ready, 171 .cmd_ctrl = au1300_nand_cmd_ctrl, 172 }, 173 }; 174 175 static struct resource db1300_nand_res[] = { 176 [0] = { 177 .start = DB1300_NAND_PHYS_ADDR, 178 .end = DB1300_NAND_PHYS_ADDR + 0xff, 179 .flags = IORESOURCE_MEM, 180 }, 181 }; 182 183 static struct platform_device db1300_nand_dev = { 184 .name = "gen_nand", 185 .num_resources = ARRAY_SIZE(db1300_nand_res), 186 .resource = db1300_nand_res, 187 .id = -1, 188 .dev = { 189 .platform_data = &db1300_nand_platdata, 190 } 191 }; 192 193 /**********************************************************************/ 194 195 static struct resource db1300_eth_res[] = { 196 [0] = { 197 .start = DB1300_ETH_PHYS_ADDR, 198 .end = DB1300_ETH_PHYS_END, 199 .flags = IORESOURCE_MEM, 200 }, 201 [1] = { 202 .start = DB1300_ETH_INT, 203 .end = DB1300_ETH_INT, 204 .flags = IORESOURCE_IRQ, 205 }, 206 }; 207 208 static struct smsc911x_platform_config db1300_eth_config = { 209 .phy_interface = PHY_INTERFACE_MODE_MII, 210 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, 211 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, 212 .flags = SMSC911X_USE_32BIT, 213 }; 214 215 static struct platform_device db1300_eth_dev = { 216 .name = "smsc911x", 217 .id = -1, 218 .num_resources = ARRAY_SIZE(db1300_eth_res), 219 .resource = db1300_eth_res, 220 .dev = { 221 .platform_data = &db1300_eth_config, 222 }, 223 }; 224 225 /**********************************************************************/ 226 227 static struct resource au1300_psc1_res[] = { 228 [0] = { 229 .start = AU1300_PSC1_PHYS_ADDR, 230 .end = AU1300_PSC1_PHYS_ADDR + 0x0fff, 231 .flags = IORESOURCE_MEM, 232 }, 233 [1] = { 234 .start = AU1300_PSC1_INT, 235 .end = AU1300_PSC1_INT, 236 .flags = IORESOURCE_IRQ, 237 }, 238 [2] = { 239 .start = AU1300_DSCR_CMD0_PSC1_TX, 240 .end = AU1300_DSCR_CMD0_PSC1_TX, 241 .flags = IORESOURCE_DMA, 242 }, 243 [3] = { 244 .start = AU1300_DSCR_CMD0_PSC1_RX, 245 .end = AU1300_DSCR_CMD0_PSC1_RX, 246 .flags = IORESOURCE_DMA, 247 }, 248 }; 249 250 static struct platform_device db1300_ac97_dev = { 251 .name = "au1xpsc_ac97", 252 .id = 1, /* PSC ID. match with AC97 codec ID! */ 253 .num_resources = ARRAY_SIZE(au1300_psc1_res), 254 .resource = au1300_psc1_res, 255 }; 256 257 /**********************************************************************/ 258 259 static struct resource au1300_psc2_res[] = { 260 [0] = { 261 .start = AU1300_PSC2_PHYS_ADDR, 262 .end = AU1300_PSC2_PHYS_ADDR + 0x0fff, 263 .flags = IORESOURCE_MEM, 264 }, 265 [1] = { 266 .start = AU1300_PSC2_INT, 267 .end = AU1300_PSC2_INT, 268 .flags = IORESOURCE_IRQ, 269 }, 270 [2] = { 271 .start = AU1300_DSCR_CMD0_PSC2_TX, 272 .end = AU1300_DSCR_CMD0_PSC2_TX, 273 .flags = IORESOURCE_DMA, 274 }, 275 [3] = { 276 .start = AU1300_DSCR_CMD0_PSC2_RX, 277 .end = AU1300_DSCR_CMD0_PSC2_RX, 278 .flags = IORESOURCE_DMA, 279 }, 280 }; 281 282 static struct platform_device db1300_i2s_dev = { 283 .name = "au1xpsc_i2s", 284 .id = 2, /* PSC ID */ 285 .num_resources = ARRAY_SIZE(au1300_psc2_res), 286 .resource = au1300_psc2_res, 287 }; 288 289 /**********************************************************************/ 290 291 static struct resource au1300_psc3_res[] = { 292 [0] = { 293 .start = AU1300_PSC3_PHYS_ADDR, 294 .end = AU1300_PSC3_PHYS_ADDR + 0x0fff, 295 .flags = IORESOURCE_MEM, 296 }, 297 [1] = { 298 .start = AU1300_PSC3_INT, 299 .end = AU1300_PSC3_INT, 300 .flags = IORESOURCE_IRQ, 301 }, 302 [2] = { 303 .start = AU1300_DSCR_CMD0_PSC3_TX, 304 .end = AU1300_DSCR_CMD0_PSC3_TX, 305 .flags = IORESOURCE_DMA, 306 }, 307 [3] = { 308 .start = AU1300_DSCR_CMD0_PSC3_RX, 309 .end = AU1300_DSCR_CMD0_PSC3_RX, 310 .flags = IORESOURCE_DMA, 311 }, 312 }; 313 314 static struct platform_device db1300_i2c_dev = { 315 .name = "au1xpsc_smbus", 316 .id = 0, /* bus number */ 317 .num_resources = ARRAY_SIZE(au1300_psc3_res), 318 .resource = au1300_psc3_res, 319 }; 320 321 /**********************************************************************/ 322 323 /* proper key assignments when facing the LCD panel. For key assignments 324 * according to the schematics swap up with down and left with right. 325 * I chose to use it to emulate the arrow keys of a keyboard. 326 */ 327 static struct gpio_keys_button db1300_5waysw_arrowkeys[] = { 328 { 329 .code = KEY_DOWN, 330 .gpio = AU1300_PIN_LCDPWM0, 331 .type = EV_KEY, 332 .debounce_interval = 1, 333 .active_low = 1, 334 .desc = "5waysw-down", 335 }, 336 { 337 .code = KEY_UP, 338 .gpio = AU1300_PIN_PSC2SYNC1, 339 .type = EV_KEY, 340 .debounce_interval = 1, 341 .active_low = 1, 342 .desc = "5waysw-up", 343 }, 344 { 345 .code = KEY_RIGHT, 346 .gpio = AU1300_PIN_WAKE3, 347 .type = EV_KEY, 348 .debounce_interval = 1, 349 .active_low = 1, 350 .desc = "5waysw-right", 351 }, 352 { 353 .code = KEY_LEFT, 354 .gpio = AU1300_PIN_WAKE2, 355 .type = EV_KEY, 356 .debounce_interval = 1, 357 .active_low = 1, 358 .desc = "5waysw-left", 359 }, 360 { 361 .code = KEY_ENTER, 362 .gpio = AU1300_PIN_WAKE1, 363 .type = EV_KEY, 364 .debounce_interval = 1, 365 .active_low = 1, 366 .desc = "5waysw-push", 367 }, 368 }; 369 370 static struct gpio_keys_platform_data db1300_5waysw_data = { 371 .buttons = db1300_5waysw_arrowkeys, 372 .nbuttons = ARRAY_SIZE(db1300_5waysw_arrowkeys), 373 .rep = 1, 374 .name = "db1300-5wayswitch", 375 }; 376 377 static struct platform_device db1300_5waysw_dev = { 378 .name = "gpio-keys", 379 .dev = { 380 .platform_data = &db1300_5waysw_data, 381 }, 382 }; 383 384 /**********************************************************************/ 385 386 static struct pata_platform_info db1300_ide_info = { 387 .ioport_shift = DB1300_IDE_REG_SHIFT, 388 }; 389 390 #define IDE_ALT_START (14 << DB1300_IDE_REG_SHIFT) 391 static struct resource db1300_ide_res[] = { 392 [0] = { 393 .start = DB1300_IDE_PHYS_ADDR, 394 .end = DB1300_IDE_PHYS_ADDR + IDE_ALT_START - 1, 395 .flags = IORESOURCE_MEM, 396 }, 397 [1] = { 398 .start = DB1300_IDE_PHYS_ADDR + IDE_ALT_START, 399 .end = DB1300_IDE_PHYS_ADDR + DB1300_IDE_PHYS_LEN - 1, 400 .flags = IORESOURCE_MEM, 401 }, 402 [2] = { 403 .start = DB1300_IDE_INT, 404 .end = DB1300_IDE_INT, 405 .flags = IORESOURCE_IRQ, 406 }, 407 }; 408 409 static struct platform_device db1300_ide_dev = { 410 .dev = { 411 .platform_data = &db1300_ide_info, 412 }, 413 .name = "pata_platform", 414 .resource = db1300_ide_res, 415 .num_resources = ARRAY_SIZE(db1300_ide_res), 416 }; 417 418 /**********************************************************************/ 419 420 static irqreturn_t db1300_mmc_cd(int irq, void *ptr) 421 { 422 void(*mmc_cd)(struct mmc_host *, unsigned long); 423 424 /* disable the one currently screaming. No other way to shut it up */ 425 if (irq == DB1300_SD1_INSERT_INT) { 426 disable_irq_nosync(DB1300_SD1_INSERT_INT); 427 enable_irq(DB1300_SD1_EJECT_INT); 428 } else { 429 disable_irq_nosync(DB1300_SD1_EJECT_INT); 430 enable_irq(DB1300_SD1_INSERT_INT); 431 } 432 433 /* link against CONFIG_MMC=m. We can only be called once MMC core has 434 * initialized the controller, so symbol_get() should always succeed. 435 */ 436 mmc_cd = symbol_get(mmc_detect_change); 437 mmc_cd(ptr, msecs_to_jiffies(500)); 438 symbol_put(mmc_detect_change); 439 440 return IRQ_HANDLED; 441 } 442 443 static int db1300_mmc_card_readonly(void *mmc_host) 444 { 445 /* it uses SD1 interface, but the DB1200's SD0 bit in the CPLD */ 446 return bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP; 447 } 448 449 static int db1300_mmc_card_inserted(void *mmc_host) 450 { 451 return bcsr_read(BCSR_SIGSTAT) & (1 << 12); /* insertion irq signal */ 452 } 453 454 static int db1300_mmc_cd_setup(void *mmc_host, int en) 455 { 456 int ret; 457 458 if (en) { 459 ret = request_irq(DB1300_SD1_INSERT_INT, db1300_mmc_cd, 0, 460 "sd_insert", mmc_host); 461 if (ret) 462 goto out; 463 464 ret = request_irq(DB1300_SD1_EJECT_INT, db1300_mmc_cd, 0, 465 "sd_eject", mmc_host); 466 if (ret) { 467 free_irq(DB1300_SD1_INSERT_INT, mmc_host); 468 goto out; 469 } 470 471 if (db1300_mmc_card_inserted(mmc_host)) 472 enable_irq(DB1300_SD1_EJECT_INT); 473 else 474 enable_irq(DB1300_SD1_INSERT_INT); 475 476 } else { 477 free_irq(DB1300_SD1_INSERT_INT, mmc_host); 478 free_irq(DB1300_SD1_EJECT_INT, mmc_host); 479 } 480 ret = 0; 481 out: 482 return ret; 483 } 484 485 static void db1300_mmcled_set(struct led_classdev *led, 486 enum led_brightness brightness) 487 { 488 if (brightness != LED_OFF) 489 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0); 490 else 491 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0); 492 } 493 494 static struct led_classdev db1300_mmc_led = { 495 .brightness_set = db1300_mmcled_set, 496 }; 497 498 struct au1xmmc_platform_data db1300_sd1_platdata = { 499 .cd_setup = db1300_mmc_cd_setup, 500 .card_inserted = db1300_mmc_card_inserted, 501 .card_readonly = db1300_mmc_card_readonly, 502 .led = &db1300_mmc_led, 503 }; 504 505 static struct resource au1300_sd1_res[] = { 506 [0] = { 507 .start = AU1300_SD1_PHYS_ADDR, 508 .end = AU1300_SD1_PHYS_ADDR, 509 .flags = IORESOURCE_MEM, 510 }, 511 [1] = { 512 .start = AU1300_SD1_INT, 513 .end = AU1300_SD1_INT, 514 .flags = IORESOURCE_IRQ, 515 }, 516 [2] = { 517 .start = AU1300_DSCR_CMD0_SDMS_TX1, 518 .end = AU1300_DSCR_CMD0_SDMS_TX1, 519 .flags = IORESOURCE_DMA, 520 }, 521 [3] = { 522 .start = AU1300_DSCR_CMD0_SDMS_RX1, 523 .end = AU1300_DSCR_CMD0_SDMS_RX1, 524 .flags = IORESOURCE_DMA, 525 }, 526 }; 527 528 static struct platform_device db1300_sd1_dev = { 529 .dev = { 530 .platform_data = &db1300_sd1_platdata, 531 }, 532 .name = "au1xxx-mmc", 533 .id = 1, 534 .resource = au1300_sd1_res, 535 .num_resources = ARRAY_SIZE(au1300_sd1_res), 536 }; 537 538 /**********************************************************************/ 539 540 static int db1300_movinand_inserted(void *mmc_host) 541 { 542 return 0; /* disable for now, it doesn't work yet */ 543 } 544 545 static int db1300_movinand_readonly(void *mmc_host) 546 { 547 return 0; 548 } 549 550 static void db1300_movinand_led_set(struct led_classdev *led, 551 enum led_brightness brightness) 552 { 553 if (brightness != LED_OFF) 554 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0); 555 else 556 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1); 557 } 558 559 static struct led_classdev db1300_movinand_led = { 560 .brightness_set = db1300_movinand_led_set, 561 }; 562 563 struct au1xmmc_platform_data db1300_sd0_platdata = { 564 .card_inserted = db1300_movinand_inserted, 565 .card_readonly = db1300_movinand_readonly, 566 .led = &db1300_movinand_led, 567 .mask_host_caps = MMC_CAP_NEEDS_POLL, 568 }; 569 570 static struct resource au1300_sd0_res[] = { 571 [0] = { 572 .start = AU1100_SD0_PHYS_ADDR, 573 .end = AU1100_SD0_PHYS_ADDR, 574 .flags = IORESOURCE_MEM, 575 }, 576 [1] = { 577 .start = AU1300_SD0_INT, 578 .end = AU1300_SD0_INT, 579 .flags = IORESOURCE_IRQ, 580 }, 581 [2] = { 582 .start = AU1300_DSCR_CMD0_SDMS_TX0, 583 .end = AU1300_DSCR_CMD0_SDMS_TX0, 584 .flags = IORESOURCE_DMA, 585 }, 586 [3] = { 587 .start = AU1300_DSCR_CMD0_SDMS_RX0, 588 .end = AU1300_DSCR_CMD0_SDMS_RX0, 589 .flags = IORESOURCE_DMA, 590 }, 591 }; 592 593 static struct platform_device db1300_sd0_dev = { 594 .dev = { 595 .platform_data = &db1300_sd0_platdata, 596 }, 597 .name = "au1xxx-mmc", 598 .id = 0, 599 .resource = au1300_sd0_res, 600 .num_resources = ARRAY_SIZE(au1300_sd0_res), 601 }; 602 603 /**********************************************************************/ 604 605 static struct platform_device db1300_wm9715_dev = { 606 .name = "wm9712-codec", 607 .id = 1, /* ID of PSC for AC97 audio, see asoc glue! */ 608 }; 609 610 static struct platform_device db1300_ac97dma_dev = { 611 .name = "au1xpsc-pcm", 612 .id = 1, /* PSC ID */ 613 }; 614 615 static struct platform_device db1300_i2sdma_dev = { 616 .name = "au1xpsc-pcm", 617 .id = 2, /* PSC ID */ 618 }; 619 620 static struct platform_device db1300_sndac97_dev = { 621 .name = "db1300-ac97", 622 }; 623 624 static struct platform_device db1300_sndi2s_dev = { 625 .name = "db1300-i2s", 626 }; 627 628 /**********************************************************************/ 629 630 static int db1300fb_panel_index(void) 631 { 632 return 9; /* DB1300_800x480 */ 633 } 634 635 static int db1300fb_panel_init(void) 636 { 637 /* Apply power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */ 638 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD, 639 BCSR_BOARD_LCDBL); 640 return 0; 641 } 642 643 static int db1300fb_panel_shutdown(void) 644 { 645 /* Remove power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */ 646 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDBL, 647 BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD); 648 return 0; 649 } 650 651 static struct au1200fb_platdata db1300fb_pd = { 652 .panel_index = db1300fb_panel_index, 653 .panel_init = db1300fb_panel_init, 654 .panel_shutdown = db1300fb_panel_shutdown, 655 }; 656 657 static struct resource au1300_lcd_res[] = { 658 [0] = { 659 .start = AU1200_LCD_PHYS_ADDR, 660 .end = AU1200_LCD_PHYS_ADDR + 0x800 - 1, 661 .flags = IORESOURCE_MEM, 662 }, 663 [1] = { 664 .start = AU1300_LCD_INT, 665 .end = AU1300_LCD_INT, 666 .flags = IORESOURCE_IRQ, 667 } 668 }; 669 670 static u64 au1300_lcd_dmamask = DMA_BIT_MASK(32); 671 672 static struct platform_device db1300_lcd_dev = { 673 .name = "au1200-lcd", 674 .id = 0, 675 .dev = { 676 .dma_mask = &au1300_lcd_dmamask, 677 .coherent_dma_mask = DMA_BIT_MASK(32), 678 .platform_data = &db1300fb_pd, 679 }, 680 .num_resources = ARRAY_SIZE(au1300_lcd_res), 681 .resource = au1300_lcd_res, 682 }; 683 684 /**********************************************************************/ 685 686 static struct platform_device *db1300_dev[] __initdata = { 687 &db1300_eth_dev, 688 &db1300_i2c_dev, 689 &db1300_5waysw_dev, 690 &db1300_nand_dev, 691 &db1300_ide_dev, 692 &db1300_sd0_dev, 693 &db1300_sd1_dev, 694 &db1300_lcd_dev, 695 &db1300_ac97_dev, 696 &db1300_i2s_dev, 697 &db1300_wm9715_dev, 698 &db1300_ac97dma_dev, 699 &db1300_i2sdma_dev, 700 &db1300_sndac97_dev, 701 &db1300_sndi2s_dev, 702 }; 703 704 static int __init db1300_device_init(void) 705 { 706 int swapped, cpldirq; 707 708 /* setup CPLD IRQ muxer */ 709 cpldirq = au1300_gpio_to_irq(AU1300_PIN_EXTCLK1); 710 irq_set_irq_type(cpldirq, IRQ_TYPE_LEVEL_HIGH); 711 bcsr_init_irq(DB1300_FIRST_INT, DB1300_LAST_INT, cpldirq); 712 713 /* insert/eject IRQs: one always triggers so don't enable them 714 * when doing request_irq() on them. DB1200 has this bug too. 715 */ 716 irq_set_status_flags(DB1300_SD1_INSERT_INT, IRQ_NOAUTOEN); 717 irq_set_status_flags(DB1300_SD1_EJECT_INT, IRQ_NOAUTOEN); 718 irq_set_status_flags(DB1300_CF_INSERT_INT, IRQ_NOAUTOEN); 719 irq_set_status_flags(DB1300_CF_EJECT_INT, IRQ_NOAUTOEN); 720 721 /* 722 * setup board 723 */ 724 prom_get_ethernet_addr(&db1300_eth_config.mac[0]); 725 726 i2c_register_board_info(0, db1300_i2c_devs, 727 ARRAY_SIZE(db1300_i2c_devs)); 728 729 /* Audio PSC clock is supplied by codecs (PSC1, 2) */ 730 __raw_writel(PSC_SEL_CLK_SERCLK, 731 (void __iomem *)KSEG1ADDR(AU1300_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET); 732 wmb(); 733 __raw_writel(PSC_SEL_CLK_SERCLK, 734 (void __iomem *)KSEG1ADDR(AU1300_PSC2_PHYS_ADDR) + PSC_SEL_OFFSET); 735 wmb(); 736 /* I2C uses internal 48MHz EXTCLK1 */ 737 __raw_writel(PSC_SEL_CLK_INTCLK, 738 (void __iomem *)KSEG1ADDR(AU1300_PSC3_PHYS_ADDR) + PSC_SEL_OFFSET); 739 wmb(); 740 741 /* enable power to USB ports */ 742 bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_USBHPWR | BCSR_RESETS_OTGPWR); 743 744 /* although it is socket #0, it uses the CPLD bits which previous boards 745 * have used for socket #1. 746 */ 747 db1x_register_pcmcia_socket( 748 AU1000_PCMCIA_ATTR_PHYS_ADDR, 749 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x00400000 - 1, 750 AU1000_PCMCIA_MEM_PHYS_ADDR, 751 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x00400000 - 1, 752 AU1000_PCMCIA_IO_PHYS_ADDR, 753 AU1000_PCMCIA_IO_PHYS_ADDR + 0x00010000 - 1, 754 DB1300_CF_INT, DB1300_CF_INSERT_INT, 0, DB1300_CF_EJECT_INT, 1); 755 756 swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT; 757 db1x_register_norflash(64 << 20, 2, swapped); 758 759 return platform_add_devices(db1300_dev, ARRAY_SIZE(db1300_dev)); 760 } 761 device_initcall(db1300_device_init); 762 763 764 void __init board_setup(void) 765 { 766 unsigned short whoami; 767 768 db1300_gpio_config(); 769 bcsr_init(DB1300_BCSR_PHYS_ADDR, 770 DB1300_BCSR_PHYS_ADDR + DB1300_BCSR_HEXLED_OFS); 771 772 whoami = bcsr_read(BCSR_WHOAMI); 773 printk(KERN_INFO "NetLogic DBAu1300 Development Platform.\n\t" 774 "BoardID %d CPLD Rev %d DaughtercardID %d\n", 775 BCSR_WHOAMI_BOARD(whoami), BCSR_WHOAMI_CPLD(whoami), 776 BCSR_WHOAMI_DCID(whoami)); 777 778 /* enable UARTs, YAMON only enables #2 */ 779 alchemy_uart_enable(AU1300_UART0_PHYS_ADDR); 780 alchemy_uart_enable(AU1300_UART1_PHYS_ADDR); 781 alchemy_uart_enable(AU1300_UART3_PHYS_ADDR); 782 } 783