1 /* 2 * Copyright (C) 2009 Renesas Solutions Corp. 3 * 4 * Kuninori Morimoto <morimoto.kuninori@renesas.com> 5 * 6 * This file is subject to the terms and conditions of the GNU General Public 7 * License. See the file "COPYING" in the main directory of this archive 8 * for more details. 9 */ 10 11 #include <linux/init.h> 12 #include <linux/device.h> 13 #include <linux/platform_device.h> 14 #include <linux/mmc/host.h> 15 #include <linux/mmc/sh_mmcif.h> 16 #include <linux/mmc/sh_mobile_sdhi.h> 17 #include <linux/mtd/physmap.h> 18 #include <linux/gpio.h> 19 #include <linux/interrupt.h> 20 #include <linux/io.h> 21 #include <linux/delay.h> 22 #include <linux/regulator/fixed.h> 23 #include <linux/regulator/machine.h> 24 #include <linux/usb/r8a66597.h> 25 #include <linux/usb/renesas_usbhs.h> 26 #include <linux/i2c.h> 27 #include <linux/i2c/tsc2007.h> 28 #include <linux/spi/spi.h> 29 #include <linux/spi/sh_msiof.h> 30 #include <linux/spi/mmc_spi.h> 31 #include <linux/input.h> 32 #include <linux/input/sh_keysc.h> 33 #include <linux/sh_eth.h> 34 #include <linux/sh_intc.h> 35 #include <linux/videodev2.h> 36 #include <video/sh_mobile_lcdc.h> 37 #include <sound/sh_fsi.h> 38 #include <sound/simple_card.h> 39 #include <media/sh_mobile_ceu.h> 40 #include <media/soc_camera.h> 41 #include <media/tw9910.h> 42 #include <media/mt9t112.h> 43 #include <asm/heartbeat.h> 44 #include <asm/clock.h> 45 #include <asm/suspend.h> 46 #include <cpu/sh7724.h> 47 48 /* 49 * Address Interface BusWidth 50 *----------------------------------------- 51 * 0x0000_0000 uboot 16bit 52 * 0x0004_0000 Linux romImage 16bit 53 * 0x0014_0000 MTD for Linux 16bit 54 * 0x0400_0000 Internal I/O 16/32bit 55 * 0x0800_0000 DRAM 32bit 56 * 0x1800_0000 MFI 16bit 57 */ 58 59 /* SWITCH 60 *------------------------------ 61 * DS2[1] = FlashROM write protect ON : write protect 62 * OFF : No write protect 63 * DS2[2] = RMII / TS, SCIF ON : RMII 64 * OFF : TS, SCIF3 65 * DS2[3] = Camera / Video ON : Camera 66 * OFF : NTSC/PAL (IN) 67 * DS2[5] = NTSC_OUT Clock ON : On board OSC 68 * OFF : SH7724 DV_CLK 69 * DS2[6-7] = MMC / SD ON-OFF : SD 70 * OFF-ON : MMC 71 */ 72 73 /* Heartbeat */ 74 static unsigned char led_pos[] = { 0, 1, 2, 3 }; 75 76 static struct heartbeat_data heartbeat_data = { 77 .nr_bits = 4, 78 .bit_pos = led_pos, 79 }; 80 81 static struct resource heartbeat_resource = { 82 .start = 0xA405012C, /* PTG */ 83 .end = 0xA405012E - 1, 84 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT, 85 }; 86 87 static struct platform_device heartbeat_device = { 88 .name = "heartbeat", 89 .id = -1, 90 .dev = { 91 .platform_data = &heartbeat_data, 92 }, 93 .num_resources = 1, 94 .resource = &heartbeat_resource, 95 }; 96 97 /* MTD */ 98 static struct mtd_partition nor_flash_partitions[] = { 99 { 100 .name = "boot loader", 101 .offset = 0, 102 .size = (5 * 1024 * 1024), 103 .mask_flags = MTD_WRITEABLE, /* force read-only */ 104 }, { 105 .name = "free-area", 106 .offset = MTDPART_OFS_APPEND, 107 .size = MTDPART_SIZ_FULL, 108 }, 109 }; 110 111 static struct physmap_flash_data nor_flash_data = { 112 .width = 2, 113 .parts = nor_flash_partitions, 114 .nr_parts = ARRAY_SIZE(nor_flash_partitions), 115 }; 116 117 static struct resource nor_flash_resources[] = { 118 [0] = { 119 .name = "NOR Flash", 120 .start = 0x00000000, 121 .end = 0x03ffffff, 122 .flags = IORESOURCE_MEM, 123 } 124 }; 125 126 static struct platform_device nor_flash_device = { 127 .name = "physmap-flash", 128 .resource = nor_flash_resources, 129 .num_resources = ARRAY_SIZE(nor_flash_resources), 130 .dev = { 131 .platform_data = &nor_flash_data, 132 }, 133 }; 134 135 /* SH Eth */ 136 #define SH_ETH_ADDR (0xA4600000) 137 static struct resource sh_eth_resources[] = { 138 [0] = { 139 .start = SH_ETH_ADDR, 140 .end = SH_ETH_ADDR + 0x1FC, 141 .flags = IORESOURCE_MEM, 142 }, 143 [1] = { 144 .start = evt2irq(0xd60), 145 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 146 }, 147 }; 148 149 static struct sh_eth_plat_data sh_eth_plat = { 150 .phy = 0x1f, /* SMSC LAN8700 */ 151 .edmac_endian = EDMAC_LITTLE_ENDIAN, 152 .register_type = SH_ETH_REG_FAST_SH4, 153 .phy_interface = PHY_INTERFACE_MODE_MII, 154 .ether_link_active_low = 1 155 }; 156 157 static struct platform_device sh_eth_device = { 158 .name = "sh-eth", 159 .id = 0, 160 .dev = { 161 .platform_data = &sh_eth_plat, 162 }, 163 .num_resources = ARRAY_SIZE(sh_eth_resources), 164 .resource = sh_eth_resources, 165 }; 166 167 /* USB0 host */ 168 static void usb0_port_power(int port, int power) 169 { 170 gpio_set_value(GPIO_PTB4, power); 171 } 172 173 static struct r8a66597_platdata usb0_host_data = { 174 .on_chip = 1, 175 .port_power = usb0_port_power, 176 }; 177 178 static struct resource usb0_host_resources[] = { 179 [0] = { 180 .start = 0xa4d80000, 181 .end = 0xa4d80124 - 1, 182 .flags = IORESOURCE_MEM, 183 }, 184 [1] = { 185 .start = evt2irq(0xa20), 186 .end = evt2irq(0xa20), 187 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, 188 }, 189 }; 190 191 static struct platform_device usb0_host_device = { 192 .name = "r8a66597_hcd", 193 .id = 0, 194 .dev = { 195 .dma_mask = NULL, /* not use dma */ 196 .coherent_dma_mask = 0xffffffff, 197 .platform_data = &usb0_host_data, 198 }, 199 .num_resources = ARRAY_SIZE(usb0_host_resources), 200 .resource = usb0_host_resources, 201 }; 202 203 /* USB1 host/function */ 204 static void usb1_port_power(int port, int power) 205 { 206 gpio_set_value(GPIO_PTB5, power); 207 } 208 209 static struct r8a66597_platdata usb1_common_data = { 210 .on_chip = 1, 211 .port_power = usb1_port_power, 212 }; 213 214 static struct resource usb1_common_resources[] = { 215 [0] = { 216 .start = 0xa4d90000, 217 .end = 0xa4d90124 - 1, 218 .flags = IORESOURCE_MEM, 219 }, 220 [1] = { 221 .start = evt2irq(0xa40), 222 .end = evt2irq(0xa40), 223 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, 224 }, 225 }; 226 227 static struct platform_device usb1_common_device = { 228 /* .name will be added in arch_setup */ 229 .id = 1, 230 .dev = { 231 .dma_mask = NULL, /* not use dma */ 232 .coherent_dma_mask = 0xffffffff, 233 .platform_data = &usb1_common_data, 234 }, 235 .num_resources = ARRAY_SIZE(usb1_common_resources), 236 .resource = usb1_common_resources, 237 }; 238 239 /* 240 * USBHS 241 */ 242 static int usbhs_get_id(struct platform_device *pdev) 243 { 244 return gpio_get_value(GPIO_PTB3); 245 } 246 247 static void usbhs_phy_reset(struct platform_device *pdev) 248 { 249 /* enable vbus if HOST */ 250 if (!gpio_get_value(GPIO_PTB3)) 251 gpio_set_value(GPIO_PTB5, 1); 252 } 253 254 static struct renesas_usbhs_platform_info usbhs_info = { 255 .platform_callback = { 256 .get_id = usbhs_get_id, 257 .phy_reset = usbhs_phy_reset, 258 }, 259 .driver_param = { 260 .buswait_bwait = 4, 261 .detection_delay = 5, 262 .d0_tx_id = SHDMA_SLAVE_USB1D0_TX, 263 .d0_rx_id = SHDMA_SLAVE_USB1D0_RX, 264 .d1_tx_id = SHDMA_SLAVE_USB1D1_TX, 265 .d1_rx_id = SHDMA_SLAVE_USB1D1_RX, 266 }, 267 }; 268 269 static struct resource usbhs_resources[] = { 270 [0] = { 271 .start = 0xa4d90000, 272 .end = 0xa4d90124 - 1, 273 .flags = IORESOURCE_MEM, 274 }, 275 [1] = { 276 .start = evt2irq(0xa40), 277 .end = evt2irq(0xa40), 278 .flags = IORESOURCE_IRQ, 279 }, 280 }; 281 282 static struct platform_device usbhs_device = { 283 .name = "renesas_usbhs", 284 .id = 1, 285 .dev = { 286 .dma_mask = NULL, /* not use dma */ 287 .coherent_dma_mask = 0xffffffff, 288 .platform_data = &usbhs_info, 289 }, 290 .num_resources = ARRAY_SIZE(usbhs_resources), 291 .resource = usbhs_resources, 292 }; 293 294 /* LCDC */ 295 static const struct fb_videomode ecovec_lcd_modes[] = { 296 { 297 .name = "Panel", 298 .xres = 800, 299 .yres = 480, 300 .left_margin = 220, 301 .right_margin = 110, 302 .hsync_len = 70, 303 .upper_margin = 20, 304 .lower_margin = 5, 305 .vsync_len = 5, 306 .sync = 0, /* hsync and vsync are active low */ 307 }, 308 }; 309 310 static const struct fb_videomode ecovec_dvi_modes[] = { 311 { 312 .name = "DVI", 313 .xres = 1280, 314 .yres = 720, 315 .left_margin = 220, 316 .right_margin = 110, 317 .hsync_len = 40, 318 .upper_margin = 20, 319 .lower_margin = 5, 320 .vsync_len = 5, 321 .sync = 0, /* hsync and vsync are active low */ 322 }, 323 }; 324 325 static int ecovec24_set_brightness(int brightness) 326 { 327 gpio_set_value(GPIO_PTR1, brightness); 328 329 return 0; 330 } 331 332 static struct sh_mobile_lcdc_info lcdc_info = { 333 .ch[0] = { 334 .interface_type = RGB18, 335 .chan = LCDC_CHAN_MAINLCD, 336 .fourcc = V4L2_PIX_FMT_RGB565, 337 .panel_cfg = { /* 7.0 inch */ 338 .width = 152, 339 .height = 91, 340 }, 341 .bl_info = { 342 .name = "sh_mobile_lcdc_bl", 343 .max_brightness = 1, 344 .set_brightness = ecovec24_set_brightness, 345 }, 346 } 347 }; 348 349 static struct resource lcdc_resources[] = { 350 [0] = { 351 .name = "LCDC", 352 .start = 0xfe940000, 353 .end = 0xfe942fff, 354 .flags = IORESOURCE_MEM, 355 }, 356 [1] = { 357 .start = evt2irq(0xf40), 358 .flags = IORESOURCE_IRQ, 359 }, 360 }; 361 362 static struct platform_device lcdc_device = { 363 .name = "sh_mobile_lcdc_fb", 364 .num_resources = ARRAY_SIZE(lcdc_resources), 365 .resource = lcdc_resources, 366 .dev = { 367 .platform_data = &lcdc_info, 368 }, 369 }; 370 371 /* CEU0 */ 372 static struct sh_mobile_ceu_info sh_mobile_ceu0_info = { 373 .flags = SH_CEU_FLAG_USE_8BIT_BUS, 374 }; 375 376 static struct resource ceu0_resources[] = { 377 [0] = { 378 .name = "CEU0", 379 .start = 0xfe910000, 380 .end = 0xfe91009f, 381 .flags = IORESOURCE_MEM, 382 }, 383 [1] = { 384 .start = evt2irq(0x880), 385 .flags = IORESOURCE_IRQ, 386 }, 387 [2] = { 388 /* place holder for contiguous memory */ 389 }, 390 }; 391 392 static struct platform_device ceu0_device = { 393 .name = "sh_mobile_ceu", 394 .id = 0, /* "ceu0" clock */ 395 .num_resources = ARRAY_SIZE(ceu0_resources), 396 .resource = ceu0_resources, 397 .dev = { 398 .platform_data = &sh_mobile_ceu0_info, 399 }, 400 }; 401 402 /* CEU1 */ 403 static struct sh_mobile_ceu_info sh_mobile_ceu1_info = { 404 .flags = SH_CEU_FLAG_USE_8BIT_BUS, 405 }; 406 407 static struct resource ceu1_resources[] = { 408 [0] = { 409 .name = "CEU1", 410 .start = 0xfe914000, 411 .end = 0xfe91409f, 412 .flags = IORESOURCE_MEM, 413 }, 414 [1] = { 415 .start = evt2irq(0x9e0), 416 .flags = IORESOURCE_IRQ, 417 }, 418 [2] = { 419 /* place holder for contiguous memory */ 420 }, 421 }; 422 423 static struct platform_device ceu1_device = { 424 .name = "sh_mobile_ceu", 425 .id = 1, /* "ceu1" clock */ 426 .num_resources = ARRAY_SIZE(ceu1_resources), 427 .resource = ceu1_resources, 428 .dev = { 429 .platform_data = &sh_mobile_ceu1_info, 430 }, 431 }; 432 433 /* I2C device */ 434 static struct i2c_board_info i2c0_devices[] = { 435 { 436 I2C_BOARD_INFO("da7210", 0x1a), 437 }, 438 }; 439 440 static struct i2c_board_info i2c1_devices[] = { 441 { 442 I2C_BOARD_INFO("r2025sd", 0x32), 443 }, 444 { 445 I2C_BOARD_INFO("lis3lv02d", 0x1c), 446 .irq = evt2irq(0x620), 447 } 448 }; 449 450 /* KEYSC */ 451 static struct sh_keysc_info keysc_info = { 452 .mode = SH_KEYSC_MODE_1, 453 .scan_timing = 3, 454 .delay = 50, 455 .kycr2_delay = 100, 456 .keycodes = { KEY_1, 0, 0, 0, 0, 457 KEY_2, 0, 0, 0, 0, 458 KEY_3, 0, 0, 0, 0, 459 KEY_4, 0, 0, 0, 0, 460 KEY_5, 0, 0, 0, 0, 461 KEY_6, 0, 0, 0, 0, }, 462 }; 463 464 static struct resource keysc_resources[] = { 465 [0] = { 466 .name = "KEYSC", 467 .start = 0x044b0000, 468 .end = 0x044b000f, 469 .flags = IORESOURCE_MEM, 470 }, 471 [1] = { 472 .start = evt2irq(0xbe0), 473 .flags = IORESOURCE_IRQ, 474 }, 475 }; 476 477 static struct platform_device keysc_device = { 478 .name = "sh_keysc", 479 .id = 0, /* keysc0 clock */ 480 .num_resources = ARRAY_SIZE(keysc_resources), 481 .resource = keysc_resources, 482 .dev = { 483 .platform_data = &keysc_info, 484 }, 485 }; 486 487 /* TouchScreen */ 488 #define IRQ0 evt2irq(0x600) 489 490 static int ts_get_pendown_state(void) 491 { 492 int val = 0; 493 gpio_free(GPIO_FN_INTC_IRQ0); 494 gpio_request(GPIO_PTZ0, NULL); 495 gpio_direction_input(GPIO_PTZ0); 496 497 val = gpio_get_value(GPIO_PTZ0); 498 499 gpio_free(GPIO_PTZ0); 500 gpio_request(GPIO_FN_INTC_IRQ0, NULL); 501 502 return val ? 0 : 1; 503 } 504 505 static int ts_init(void) 506 { 507 gpio_request(GPIO_FN_INTC_IRQ0, NULL); 508 return 0; 509 } 510 511 static struct tsc2007_platform_data tsc2007_info = { 512 .model = 2007, 513 .x_plate_ohms = 180, 514 .get_pendown_state = ts_get_pendown_state, 515 .init_platform_hw = ts_init, 516 }; 517 518 static struct i2c_board_info ts_i2c_clients = { 519 I2C_BOARD_INFO("tsc2007", 0x48), 520 .type = "tsc2007", 521 .platform_data = &tsc2007_info, 522 .irq = IRQ0, 523 }; 524 525 static struct regulator_consumer_supply cn12_power_consumers[] = 526 { 527 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"), 528 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"), 529 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"), 530 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"), 531 }; 532 533 static struct regulator_init_data cn12_power_init_data = { 534 .constraints = { 535 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 536 }, 537 .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers), 538 .consumer_supplies = cn12_power_consumers, 539 }; 540 541 static struct fixed_voltage_config cn12_power_info = { 542 .supply_name = "CN12 SD/MMC Vdd", 543 .microvolts = 3300000, 544 .gpio = GPIO_PTB7, 545 .enable_high = 1, 546 .init_data = &cn12_power_init_data, 547 }; 548 549 static struct platform_device cn12_power = { 550 .name = "reg-fixed-voltage", 551 .id = 0, 552 .dev = { 553 .platform_data = &cn12_power_info, 554 }, 555 }; 556 557 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 558 /* SDHI0 */ 559 static struct regulator_consumer_supply sdhi0_power_consumers[] = 560 { 561 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), 562 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), 563 }; 564 565 static struct regulator_init_data sdhi0_power_init_data = { 566 .constraints = { 567 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 568 }, 569 .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers), 570 .consumer_supplies = sdhi0_power_consumers, 571 }; 572 573 static struct fixed_voltage_config sdhi0_power_info = { 574 .supply_name = "CN11 SD/MMC Vdd", 575 .microvolts = 3300000, 576 .gpio = GPIO_PTB6, 577 .enable_high = 1, 578 .init_data = &sdhi0_power_init_data, 579 }; 580 581 static struct platform_device sdhi0_power = { 582 .name = "reg-fixed-voltage", 583 .id = 1, 584 .dev = { 585 .platform_data = &sdhi0_power_info, 586 }, 587 }; 588 589 static void sdhi0_set_pwr(struct platform_device *pdev, int state) 590 { 591 static int power_gpio = -EINVAL; 592 593 if (power_gpio < 0) { 594 int ret = gpio_request(GPIO_PTB6, NULL); 595 if (!ret) { 596 power_gpio = GPIO_PTB6; 597 gpio_direction_output(power_gpio, 0); 598 } 599 } 600 601 /* 602 * Toggle the GPIO regardless, whether we managed to grab it above or 603 * the fixed regulator driver did. 604 */ 605 gpio_set_value(GPIO_PTB6, state); 606 } 607 608 static int sdhi0_get_cd(struct platform_device *pdev) 609 { 610 return !gpio_get_value(GPIO_PTY7); 611 } 612 613 static struct sh_mobile_sdhi_info sdhi0_info = { 614 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, 615 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, 616 .set_pwr = sdhi0_set_pwr, 617 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 618 MMC_CAP_NEEDS_POLL, 619 .get_cd = sdhi0_get_cd, 620 }; 621 622 static struct resource sdhi0_resources[] = { 623 [0] = { 624 .name = "SDHI0", 625 .start = 0x04ce0000, 626 .end = 0x04ce00ff, 627 .flags = IORESOURCE_MEM, 628 }, 629 [1] = { 630 .start = evt2irq(0xe80), 631 .flags = IORESOURCE_IRQ, 632 }, 633 }; 634 635 static struct platform_device sdhi0_device = { 636 .name = "sh_mobile_sdhi", 637 .num_resources = ARRAY_SIZE(sdhi0_resources), 638 .resource = sdhi0_resources, 639 .id = 0, 640 .dev = { 641 .platform_data = &sdhi0_info, 642 }, 643 }; 644 645 static void cn12_set_pwr(struct platform_device *pdev, int state) 646 { 647 static int power_gpio = -EINVAL; 648 649 if (power_gpio < 0) { 650 int ret = gpio_request(GPIO_PTB7, NULL); 651 if (!ret) { 652 power_gpio = GPIO_PTB7; 653 gpio_direction_output(power_gpio, 0); 654 } 655 } 656 657 /* 658 * Toggle the GPIO regardless, whether we managed to grab it above or 659 * the fixed regulator driver did. 660 */ 661 gpio_set_value(GPIO_PTB7, state); 662 } 663 664 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 665 /* SDHI1 */ 666 static int sdhi1_get_cd(struct platform_device *pdev) 667 { 668 return !gpio_get_value(GPIO_PTW7); 669 } 670 671 static struct sh_mobile_sdhi_info sdhi1_info = { 672 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, 673 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, 674 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 675 MMC_CAP_NEEDS_POLL, 676 .set_pwr = cn12_set_pwr, 677 .get_cd = sdhi1_get_cd, 678 }; 679 680 static struct resource sdhi1_resources[] = { 681 [0] = { 682 .name = "SDHI1", 683 .start = 0x04cf0000, 684 .end = 0x04cf00ff, 685 .flags = IORESOURCE_MEM, 686 }, 687 [1] = { 688 .start = evt2irq(0x4e0), 689 .flags = IORESOURCE_IRQ, 690 }, 691 }; 692 693 static struct platform_device sdhi1_device = { 694 .name = "sh_mobile_sdhi", 695 .num_resources = ARRAY_SIZE(sdhi1_resources), 696 .resource = sdhi1_resources, 697 .id = 1, 698 .dev = { 699 .platform_data = &sdhi1_info, 700 }, 701 }; 702 #endif /* CONFIG_MMC_SH_MMCIF */ 703 704 #else 705 706 /* MMC SPI */ 707 static int mmc_spi_get_ro(struct device *dev) 708 { 709 return gpio_get_value(GPIO_PTY6); 710 } 711 712 static int mmc_spi_get_cd(struct device *dev) 713 { 714 return !gpio_get_value(GPIO_PTY7); 715 } 716 717 static void mmc_spi_setpower(struct device *dev, unsigned int maskval) 718 { 719 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0); 720 } 721 722 static struct mmc_spi_platform_data mmc_spi_info = { 723 .get_ro = mmc_spi_get_ro, 724 .get_cd = mmc_spi_get_cd, 725 .caps = MMC_CAP_NEEDS_POLL, 726 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */ 727 .setpower = mmc_spi_setpower, 728 }; 729 730 static struct spi_board_info spi_bus[] = { 731 { 732 .modalias = "mmc_spi", 733 .platform_data = &mmc_spi_info, 734 .max_speed_hz = 5000000, 735 .mode = SPI_MODE_0, 736 .controller_data = (void *) GPIO_PTM4, 737 }, 738 }; 739 740 /* MSIOF0 */ 741 static struct sh_msiof_spi_info msiof0_data = { 742 .num_chipselect = 1, 743 }; 744 745 static struct resource msiof0_resources[] = { 746 [0] = { 747 .name = "MSIOF0", 748 .start = 0xa4c40000, 749 .end = 0xa4c40063, 750 .flags = IORESOURCE_MEM, 751 }, 752 [1] = { 753 .start = evt2irq(0xc80), 754 .flags = IORESOURCE_IRQ, 755 }, 756 }; 757 758 static struct platform_device msiof0_device = { 759 .name = "spi_sh_msiof", 760 .id = 0, /* MSIOF0 */ 761 .dev = { 762 .platform_data = &msiof0_data, 763 }, 764 .num_resources = ARRAY_SIZE(msiof0_resources), 765 .resource = msiof0_resources, 766 }; 767 768 #endif 769 770 /* I2C Video/Camera */ 771 static struct i2c_board_info i2c_camera[] = { 772 { 773 I2C_BOARD_INFO("tw9910", 0x45), 774 }, 775 { 776 /* 1st camera */ 777 I2C_BOARD_INFO("mt9t112", 0x3c), 778 }, 779 { 780 /* 2nd camera */ 781 I2C_BOARD_INFO("mt9t112", 0x3c), 782 }, 783 }; 784 785 /* tw9910 */ 786 static int tw9910_power(struct device *dev, int mode) 787 { 788 int val = mode ? 0 : 1; 789 790 gpio_set_value(GPIO_PTU2, val); 791 if (mode) 792 mdelay(100); 793 794 return 0; 795 } 796 797 static struct tw9910_video_info tw9910_info = { 798 .buswidth = SOCAM_DATAWIDTH_8, 799 .mpout = TW9910_MPO_FIELD, 800 }; 801 802 static struct soc_camera_link tw9910_link = { 803 .i2c_adapter_id = 0, 804 .bus_id = 1, 805 .power = tw9910_power, 806 .board_info = &i2c_camera[0], 807 .priv = &tw9910_info, 808 }; 809 810 /* mt9t112 */ 811 static int mt9t112_power1(struct device *dev, int mode) 812 { 813 gpio_set_value(GPIO_PTA3, mode); 814 if (mode) 815 mdelay(100); 816 817 return 0; 818 } 819 820 static struct mt9t112_camera_info mt9t112_info1 = { 821 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8, 822 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */ 823 }; 824 825 static struct soc_camera_link mt9t112_link1 = { 826 .i2c_adapter_id = 0, 827 .power = mt9t112_power1, 828 .bus_id = 0, 829 .board_info = &i2c_camera[1], 830 .priv = &mt9t112_info1, 831 }; 832 833 static int mt9t112_power2(struct device *dev, int mode) 834 { 835 gpio_set_value(GPIO_PTA4, mode); 836 if (mode) 837 mdelay(100); 838 839 return 0; 840 } 841 842 static struct mt9t112_camera_info mt9t112_info2 = { 843 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8, 844 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */ 845 }; 846 847 static struct soc_camera_link mt9t112_link2 = { 848 .i2c_adapter_id = 1, 849 .power = mt9t112_power2, 850 .bus_id = 1, 851 .board_info = &i2c_camera[2], 852 .priv = &mt9t112_info2, 853 }; 854 855 static struct platform_device camera_devices[] = { 856 { 857 .name = "soc-camera-pdrv", 858 .id = 0, 859 .dev = { 860 .platform_data = &tw9910_link, 861 }, 862 }, 863 { 864 .name = "soc-camera-pdrv", 865 .id = 1, 866 .dev = { 867 .platform_data = &mt9t112_link1, 868 }, 869 }, 870 { 871 .name = "soc-camera-pdrv", 872 .id = 2, 873 .dev = { 874 .platform_data = &mt9t112_link2, 875 }, 876 }, 877 }; 878 879 /* FSI */ 880 static struct sh_fsi_platform_info fsi_info = { 881 .port_b = { 882 .flags = SH_FSI_BRS_INV, 883 }, 884 }; 885 886 static struct resource fsi_resources[] = { 887 [0] = { 888 .name = "FSI", 889 .start = 0xFE3C0000, 890 .end = 0xFE3C021d, 891 .flags = IORESOURCE_MEM, 892 }, 893 [1] = { 894 .start = evt2irq(0xf80), 895 .flags = IORESOURCE_IRQ, 896 }, 897 }; 898 899 static struct platform_device fsi_device = { 900 .name = "sh_fsi", 901 .id = 0, 902 .num_resources = ARRAY_SIZE(fsi_resources), 903 .resource = fsi_resources, 904 .dev = { 905 .platform_data = &fsi_info, 906 }, 907 }; 908 909 static struct asoc_simple_dai_init_info fsi_da7210_init_info = { 910 .fmt = SND_SOC_DAIFMT_I2S, 911 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM, 912 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS, 913 }; 914 915 static struct asoc_simple_card_info fsi_da7210_info = { 916 .name = "DA7210", 917 .card = "FSIB-DA7210", 918 .cpu_dai = "fsib-dai", 919 .codec = "da7210.0-001a", 920 .platform = "sh_fsi.0", 921 .codec_dai = "da7210-hifi", 922 .init = &fsi_da7210_init_info, 923 }; 924 925 static struct platform_device fsi_da7210_device = { 926 .name = "asoc-simple-card", 927 .dev = { 928 .platform_data = &fsi_da7210_info, 929 }, 930 }; 931 932 933 /* IrDA */ 934 static struct resource irda_resources[] = { 935 [0] = { 936 .name = "IrDA", 937 .start = 0xA45D0000, 938 .end = 0xA45D0049, 939 .flags = IORESOURCE_MEM, 940 }, 941 [1] = { 942 .start = evt2irq(0x480), 943 .flags = IORESOURCE_IRQ, 944 }, 945 }; 946 947 static struct platform_device irda_device = { 948 .name = "sh_sir", 949 .num_resources = ARRAY_SIZE(irda_resources), 950 .resource = irda_resources, 951 }; 952 953 #include <media/ak881x.h> 954 #include <media/sh_vou.h> 955 956 static struct ak881x_pdata ak881x_pdata = { 957 .flags = AK881X_IF_MODE_SLAVE, 958 }; 959 960 static struct i2c_board_info ak8813 = { 961 I2C_BOARD_INFO("ak8813", 0x20), 962 .platform_data = &ak881x_pdata, 963 }; 964 965 static struct sh_vou_pdata sh_vou_pdata = { 966 .bus_fmt = SH_VOU_BUS_8BIT, 967 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW, 968 .board_info = &ak8813, 969 .i2c_adap = 0, 970 }; 971 972 static struct resource sh_vou_resources[] = { 973 [0] = { 974 .start = 0xfe960000, 975 .end = 0xfe962043, 976 .flags = IORESOURCE_MEM, 977 }, 978 [1] = { 979 .start = evt2irq(0x8e0), 980 .flags = IORESOURCE_IRQ, 981 }, 982 }; 983 984 static struct platform_device vou_device = { 985 .name = "sh-vou", 986 .id = -1, 987 .num_resources = ARRAY_SIZE(sh_vou_resources), 988 .resource = sh_vou_resources, 989 .dev = { 990 .platform_data = &sh_vou_pdata, 991 }, 992 }; 993 994 #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) 995 /* SH_MMCIF */ 996 static void mmcif_down_pwr(struct platform_device *pdev) 997 { 998 cn12_set_pwr(pdev, 0); 999 } 1000 1001 static struct resource sh_mmcif_resources[] = { 1002 [0] = { 1003 .name = "SH_MMCIF", 1004 .start = 0xA4CA0000, 1005 .end = 0xA4CA00FF, 1006 .flags = IORESOURCE_MEM, 1007 }, 1008 [1] = { 1009 /* MMC2I */ 1010 .start = evt2irq(0x5a0), 1011 .flags = IORESOURCE_IRQ, 1012 }, 1013 [2] = { 1014 /* MMC3I */ 1015 .start = evt2irq(0x5c0), 1016 .flags = IORESOURCE_IRQ, 1017 }, 1018 }; 1019 1020 static struct sh_mmcif_plat_data sh_mmcif_plat = { 1021 .set_pwr = cn12_set_pwr, 1022 .down_pwr = mmcif_down_pwr, 1023 .sup_pclk = 0, /* SH7724: Max Pclk/2 */ 1024 .caps = MMC_CAP_4_BIT_DATA | 1025 MMC_CAP_8_BIT_DATA | 1026 MMC_CAP_NEEDS_POLL, 1027 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34, 1028 }; 1029 1030 static struct platform_device sh_mmcif_device = { 1031 .name = "sh_mmcif", 1032 .id = 0, 1033 .dev = { 1034 .platform_data = &sh_mmcif_plat, 1035 }, 1036 .num_resources = ARRAY_SIZE(sh_mmcif_resources), 1037 .resource = sh_mmcif_resources, 1038 }; 1039 #endif 1040 1041 static struct platform_device *ecovec_devices[] __initdata = { 1042 &heartbeat_device, 1043 &nor_flash_device, 1044 &sh_eth_device, 1045 &usb0_host_device, 1046 &usb1_common_device, 1047 &usbhs_device, 1048 &lcdc_device, 1049 &ceu0_device, 1050 &ceu1_device, 1051 &keysc_device, 1052 &cn12_power, 1053 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1054 &sdhi0_power, 1055 &sdhi0_device, 1056 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1057 &sdhi1_device, 1058 #endif 1059 #else 1060 &msiof0_device, 1061 #endif 1062 &camera_devices[0], 1063 &camera_devices[1], 1064 &camera_devices[2], 1065 &fsi_device, 1066 &fsi_da7210_device, 1067 &irda_device, 1068 &vou_device, 1069 #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) 1070 &sh_mmcif_device, 1071 #endif 1072 }; 1073 1074 #ifdef CONFIG_I2C 1075 #define EEPROM_ADDR 0x50 1076 static u8 mac_read(struct i2c_adapter *a, u8 command) 1077 { 1078 struct i2c_msg msg[2]; 1079 u8 buf; 1080 int ret; 1081 1082 msg[0].addr = EEPROM_ADDR; 1083 msg[0].flags = 0; 1084 msg[0].len = 1; 1085 msg[0].buf = &command; 1086 1087 msg[1].addr = EEPROM_ADDR; 1088 msg[1].flags = I2C_M_RD; 1089 msg[1].len = 1; 1090 msg[1].buf = &buf; 1091 1092 ret = i2c_transfer(a, msg, 2); 1093 if (ret < 0) { 1094 printk(KERN_ERR "error %d\n", ret); 1095 buf = 0xff; 1096 } 1097 1098 return buf; 1099 } 1100 1101 static void __init sh_eth_init(struct sh_eth_plat_data *pd) 1102 { 1103 struct i2c_adapter *a = i2c_get_adapter(1); 1104 int i; 1105 1106 if (!a) { 1107 pr_err("can not get I2C 1\n"); 1108 return; 1109 } 1110 1111 /* read MAC address from EEPROM */ 1112 for (i = 0; i < sizeof(pd->mac_addr); i++) { 1113 pd->mac_addr[i] = mac_read(a, 0x10 + i); 1114 msleep(10); 1115 } 1116 1117 i2c_put_adapter(a); 1118 } 1119 #else 1120 static void __init sh_eth_init(struct sh_eth_plat_data *pd) 1121 { 1122 pr_err("unable to read sh_eth MAC address\n"); 1123 } 1124 #endif 1125 1126 #define PORT_HIZA 0xA4050158 1127 #define IODRIVEA 0xA405018A 1128 1129 extern char ecovec24_sdram_enter_start; 1130 extern char ecovec24_sdram_enter_end; 1131 extern char ecovec24_sdram_leave_start; 1132 extern char ecovec24_sdram_leave_end; 1133 1134 static int __init arch_setup(void) 1135 { 1136 struct clk *clk; 1137 bool cn12_enabled = false; 1138 1139 /* register board specific self-refresh code */ 1140 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | 1141 SUSP_SH_RSTANDBY, 1142 &ecovec24_sdram_enter_start, 1143 &ecovec24_sdram_enter_end, 1144 &ecovec24_sdram_leave_start, 1145 &ecovec24_sdram_leave_end); 1146 1147 /* enable STATUS0, STATUS2 and PDSTATUS */ 1148 gpio_request(GPIO_FN_STATUS0, NULL); 1149 gpio_request(GPIO_FN_STATUS2, NULL); 1150 gpio_request(GPIO_FN_PDSTATUS, NULL); 1151 1152 /* enable SCIFA0 */ 1153 gpio_request(GPIO_FN_SCIF0_TXD, NULL); 1154 gpio_request(GPIO_FN_SCIF0_RXD, NULL); 1155 1156 /* enable debug LED */ 1157 gpio_request(GPIO_PTG0, NULL); 1158 gpio_request(GPIO_PTG1, NULL); 1159 gpio_request(GPIO_PTG2, NULL); 1160 gpio_request(GPIO_PTG3, NULL); 1161 gpio_direction_output(GPIO_PTG0, 0); 1162 gpio_direction_output(GPIO_PTG1, 0); 1163 gpio_direction_output(GPIO_PTG2, 0); 1164 gpio_direction_output(GPIO_PTG3, 0); 1165 __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA); 1166 1167 /* enable SH-Eth */ 1168 gpio_request(GPIO_PTA1, NULL); 1169 gpio_direction_output(GPIO_PTA1, 1); 1170 mdelay(20); 1171 1172 gpio_request(GPIO_FN_RMII_RXD0, NULL); 1173 gpio_request(GPIO_FN_RMII_RXD1, NULL); 1174 gpio_request(GPIO_FN_RMII_TXD0, NULL); 1175 gpio_request(GPIO_FN_RMII_TXD1, NULL); 1176 gpio_request(GPIO_FN_RMII_REF_CLK, NULL); 1177 gpio_request(GPIO_FN_RMII_TX_EN, NULL); 1178 gpio_request(GPIO_FN_RMII_RX_ER, NULL); 1179 gpio_request(GPIO_FN_RMII_CRS_DV, NULL); 1180 gpio_request(GPIO_FN_MDIO, NULL); 1181 gpio_request(GPIO_FN_MDC, NULL); 1182 gpio_request(GPIO_FN_LNKSTA, NULL); 1183 1184 /* enable USB */ 1185 __raw_writew(0x0000, 0xA4D80000); 1186 __raw_writew(0x0000, 0xA4D90000); 1187 gpio_request(GPIO_PTB3, NULL); 1188 gpio_request(GPIO_PTB4, NULL); 1189 gpio_request(GPIO_PTB5, NULL); 1190 gpio_direction_input(GPIO_PTB3); 1191 gpio_direction_output(GPIO_PTB4, 0); 1192 gpio_direction_output(GPIO_PTB5, 0); 1193 __raw_writew(0x0600, 0xa40501d4); 1194 __raw_writew(0x0600, 0xa4050192); 1195 1196 if (gpio_get_value(GPIO_PTB3)) { 1197 printk(KERN_INFO "USB1 function is selected\n"); 1198 usb1_common_device.name = "r8a66597_udc"; 1199 } else { 1200 printk(KERN_INFO "USB1 host is selected\n"); 1201 usb1_common_device.name = "r8a66597_hcd"; 1202 } 1203 1204 /* enable LCDC */ 1205 gpio_request(GPIO_FN_LCDD23, NULL); 1206 gpio_request(GPIO_FN_LCDD22, NULL); 1207 gpio_request(GPIO_FN_LCDD21, NULL); 1208 gpio_request(GPIO_FN_LCDD20, NULL); 1209 gpio_request(GPIO_FN_LCDD19, NULL); 1210 gpio_request(GPIO_FN_LCDD18, NULL); 1211 gpio_request(GPIO_FN_LCDD17, NULL); 1212 gpio_request(GPIO_FN_LCDD16, NULL); 1213 gpio_request(GPIO_FN_LCDD15, NULL); 1214 gpio_request(GPIO_FN_LCDD14, NULL); 1215 gpio_request(GPIO_FN_LCDD13, NULL); 1216 gpio_request(GPIO_FN_LCDD12, NULL); 1217 gpio_request(GPIO_FN_LCDD11, NULL); 1218 gpio_request(GPIO_FN_LCDD10, NULL); 1219 gpio_request(GPIO_FN_LCDD9, NULL); 1220 gpio_request(GPIO_FN_LCDD8, NULL); 1221 gpio_request(GPIO_FN_LCDD7, NULL); 1222 gpio_request(GPIO_FN_LCDD6, NULL); 1223 gpio_request(GPIO_FN_LCDD5, NULL); 1224 gpio_request(GPIO_FN_LCDD4, NULL); 1225 gpio_request(GPIO_FN_LCDD3, NULL); 1226 gpio_request(GPIO_FN_LCDD2, NULL); 1227 gpio_request(GPIO_FN_LCDD1, NULL); 1228 gpio_request(GPIO_FN_LCDD0, NULL); 1229 gpio_request(GPIO_FN_LCDDISP, NULL); 1230 gpio_request(GPIO_FN_LCDHSYN, NULL); 1231 gpio_request(GPIO_FN_LCDDCK, NULL); 1232 gpio_request(GPIO_FN_LCDVSYN, NULL); 1233 gpio_request(GPIO_FN_LCDDON, NULL); 1234 gpio_request(GPIO_FN_LCDLCLK, NULL); 1235 __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA); 1236 1237 gpio_request(GPIO_PTE6, NULL); 1238 gpio_request(GPIO_PTU1, NULL); 1239 gpio_request(GPIO_PTR1, NULL); 1240 gpio_request(GPIO_PTA2, NULL); 1241 gpio_direction_input(GPIO_PTE6); 1242 gpio_direction_output(GPIO_PTU1, 0); 1243 gpio_direction_output(GPIO_PTR1, 0); 1244 gpio_direction_output(GPIO_PTA2, 0); 1245 1246 /* I/O buffer drive ability is high */ 1247 __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA); 1248 1249 if (gpio_get_value(GPIO_PTE6)) { 1250 /* DVI */ 1251 lcdc_info.clock_source = LCDC_CLK_EXTERNAL; 1252 lcdc_info.ch[0].clock_divider = 1; 1253 lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes; 1254 lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes); 1255 1256 gpio_set_value(GPIO_PTA2, 1); 1257 gpio_set_value(GPIO_PTU1, 1); 1258 } else { 1259 /* Panel */ 1260 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; 1261 lcdc_info.ch[0].clock_divider = 2; 1262 lcdc_info.ch[0].lcd_modes = ecovec_lcd_modes; 1263 lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_lcd_modes); 1264 1265 gpio_set_value(GPIO_PTR1, 1); 1266 1267 /* FIXME 1268 * 1269 * LCDDON control is needed for Panel, 1270 * but current sh_mobile_lcdc driver doesn't control it. 1271 * It is temporary correspondence 1272 */ 1273 gpio_request(GPIO_PTF4, NULL); 1274 gpio_direction_output(GPIO_PTF4, 1); 1275 1276 /* enable TouchScreen */ 1277 i2c_register_board_info(0, &ts_i2c_clients, 1); 1278 irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW); 1279 } 1280 1281 /* enable CEU0 */ 1282 gpio_request(GPIO_FN_VIO0_D15, NULL); 1283 gpio_request(GPIO_FN_VIO0_D14, NULL); 1284 gpio_request(GPIO_FN_VIO0_D13, NULL); 1285 gpio_request(GPIO_FN_VIO0_D12, NULL); 1286 gpio_request(GPIO_FN_VIO0_D11, NULL); 1287 gpio_request(GPIO_FN_VIO0_D10, NULL); 1288 gpio_request(GPIO_FN_VIO0_D9, NULL); 1289 gpio_request(GPIO_FN_VIO0_D8, NULL); 1290 gpio_request(GPIO_FN_VIO0_D7, NULL); 1291 gpio_request(GPIO_FN_VIO0_D6, NULL); 1292 gpio_request(GPIO_FN_VIO0_D5, NULL); 1293 gpio_request(GPIO_FN_VIO0_D4, NULL); 1294 gpio_request(GPIO_FN_VIO0_D3, NULL); 1295 gpio_request(GPIO_FN_VIO0_D2, NULL); 1296 gpio_request(GPIO_FN_VIO0_D1, NULL); 1297 gpio_request(GPIO_FN_VIO0_D0, NULL); 1298 gpio_request(GPIO_FN_VIO0_VD, NULL); 1299 gpio_request(GPIO_FN_VIO0_CLK, NULL); 1300 gpio_request(GPIO_FN_VIO0_FLD, NULL); 1301 gpio_request(GPIO_FN_VIO0_HD, NULL); 1302 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20); 1303 1304 /* enable CEU1 */ 1305 gpio_request(GPIO_FN_VIO1_D7, NULL); 1306 gpio_request(GPIO_FN_VIO1_D6, NULL); 1307 gpio_request(GPIO_FN_VIO1_D5, NULL); 1308 gpio_request(GPIO_FN_VIO1_D4, NULL); 1309 gpio_request(GPIO_FN_VIO1_D3, NULL); 1310 gpio_request(GPIO_FN_VIO1_D2, NULL); 1311 gpio_request(GPIO_FN_VIO1_D1, NULL); 1312 gpio_request(GPIO_FN_VIO1_D0, NULL); 1313 gpio_request(GPIO_FN_VIO1_FLD, NULL); 1314 gpio_request(GPIO_FN_VIO1_HD, NULL); 1315 gpio_request(GPIO_FN_VIO1_VD, NULL); 1316 gpio_request(GPIO_FN_VIO1_CLK, NULL); 1317 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20); 1318 1319 /* enable KEYSC */ 1320 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); 1321 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL); 1322 gpio_request(GPIO_FN_KEYOUT3, NULL); 1323 gpio_request(GPIO_FN_KEYOUT2, NULL); 1324 gpio_request(GPIO_FN_KEYOUT1, NULL); 1325 gpio_request(GPIO_FN_KEYOUT0, NULL); 1326 gpio_request(GPIO_FN_KEYIN0, NULL); 1327 1328 /* enable user debug switch */ 1329 gpio_request(GPIO_PTR0, NULL); 1330 gpio_request(GPIO_PTR4, NULL); 1331 gpio_request(GPIO_PTR5, NULL); 1332 gpio_request(GPIO_PTR6, NULL); 1333 gpio_direction_input(GPIO_PTR0); 1334 gpio_direction_input(GPIO_PTR4); 1335 gpio_direction_input(GPIO_PTR5); 1336 gpio_direction_input(GPIO_PTR6); 1337 1338 /* SD-card slot CN11 */ 1339 /* Card-detect, used on CN11, either with SDHI0 or with SPI */ 1340 gpio_request(GPIO_PTY7, NULL); 1341 gpio_direction_input(GPIO_PTY7); 1342 1343 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1344 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */ 1345 gpio_request(GPIO_FN_SDHI0WP, NULL); 1346 gpio_request(GPIO_FN_SDHI0CMD, NULL); 1347 gpio_request(GPIO_FN_SDHI0CLK, NULL); 1348 gpio_request(GPIO_FN_SDHI0D3, NULL); 1349 gpio_request(GPIO_FN_SDHI0D2, NULL); 1350 gpio_request(GPIO_FN_SDHI0D1, NULL); 1351 gpio_request(GPIO_FN_SDHI0D0, NULL); 1352 #else 1353 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */ 1354 gpio_request(GPIO_FN_MSIOF0_TXD, NULL); 1355 gpio_request(GPIO_FN_MSIOF0_RXD, NULL); 1356 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL); 1357 gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */ 1358 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */ 1359 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */ 1360 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ 1361 gpio_request(GPIO_PTY6, NULL); /* write protect */ 1362 gpio_direction_input(GPIO_PTY6); 1363 1364 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); 1365 #endif 1366 1367 /* MMC/SD-card slot CN12 */ 1368 #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) 1369 /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */ 1370 gpio_request(GPIO_FN_MMC_D7, NULL); 1371 gpio_request(GPIO_FN_MMC_D6, NULL); 1372 gpio_request(GPIO_FN_MMC_D5, NULL); 1373 gpio_request(GPIO_FN_MMC_D4, NULL); 1374 gpio_request(GPIO_FN_MMC_D3, NULL); 1375 gpio_request(GPIO_FN_MMC_D2, NULL); 1376 gpio_request(GPIO_FN_MMC_D1, NULL); 1377 gpio_request(GPIO_FN_MMC_D0, NULL); 1378 gpio_request(GPIO_FN_MMC_CLK, NULL); 1379 gpio_request(GPIO_FN_MMC_CMD, NULL); 1380 1381 cn12_enabled = true; 1382 #elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1383 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */ 1384 gpio_request(GPIO_FN_SDHI1WP, NULL); 1385 gpio_request(GPIO_FN_SDHI1CMD, NULL); 1386 gpio_request(GPIO_FN_SDHI1CLK, NULL); 1387 gpio_request(GPIO_FN_SDHI1D3, NULL); 1388 gpio_request(GPIO_FN_SDHI1D2, NULL); 1389 gpio_request(GPIO_FN_SDHI1D1, NULL); 1390 gpio_request(GPIO_FN_SDHI1D0, NULL); 1391 1392 /* Card-detect, used on CN12 with SDHI1 */ 1393 gpio_request(GPIO_PTW7, NULL); 1394 gpio_direction_input(GPIO_PTW7); 1395 1396 cn12_enabled = true; 1397 #endif 1398 1399 if (cn12_enabled) 1400 /* I/O buffer drive ability is high for CN12 */ 1401 __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000, 1402 IODRIVEA); 1403 1404 /* enable Video */ 1405 gpio_request(GPIO_PTU2, NULL); 1406 gpio_direction_output(GPIO_PTU2, 1); 1407 1408 /* enable Camera */ 1409 gpio_request(GPIO_PTA3, NULL); 1410 gpio_request(GPIO_PTA4, NULL); 1411 gpio_direction_output(GPIO_PTA3, 0); 1412 gpio_direction_output(GPIO_PTA4, 0); 1413 1414 /* enable FSI */ 1415 gpio_request(GPIO_FN_FSIMCKB, NULL); 1416 gpio_request(GPIO_FN_FSIIBSD, NULL); 1417 gpio_request(GPIO_FN_FSIOBSD, NULL); 1418 gpio_request(GPIO_FN_FSIIBBCK, NULL); 1419 gpio_request(GPIO_FN_FSIIBLRCK, NULL); 1420 gpio_request(GPIO_FN_FSIOBBCK, NULL); 1421 gpio_request(GPIO_FN_FSIOBLRCK, NULL); 1422 gpio_request(GPIO_FN_CLKAUDIOBO, NULL); 1423 1424 /* set SPU2 clock to 83.4 MHz */ 1425 clk = clk_get(NULL, "spu_clk"); 1426 if (!IS_ERR(clk)) { 1427 clk_set_rate(clk, clk_round_rate(clk, 83333333)); 1428 clk_put(clk); 1429 } 1430 1431 /* change parent of FSI B */ 1432 clk = clk_get(NULL, "fsib_clk"); 1433 if (!IS_ERR(clk)) { 1434 /* 48kHz dummy clock was used to make sure 1/1 divide */ 1435 clk_set_rate(&sh7724_fsimckb_clk, 48000); 1436 clk_set_parent(clk, &sh7724_fsimckb_clk); 1437 clk_set_rate(clk, 48000); 1438 clk_put(clk); 1439 } 1440 1441 gpio_request(GPIO_PTU0, NULL); 1442 gpio_direction_output(GPIO_PTU0, 0); 1443 mdelay(20); 1444 1445 /* enable motion sensor */ 1446 gpio_request(GPIO_FN_INTC_IRQ1, NULL); 1447 gpio_direction_input(GPIO_FN_INTC_IRQ1); 1448 1449 /* set VPU clock to 166 MHz */ 1450 clk = clk_get(NULL, "vpu_clk"); 1451 if (!IS_ERR(clk)) { 1452 clk_set_rate(clk, clk_round_rate(clk, 166000000)); 1453 clk_put(clk); 1454 } 1455 1456 /* enable IrDA */ 1457 gpio_request(GPIO_FN_IRDA_OUT, NULL); 1458 gpio_request(GPIO_FN_IRDA_IN, NULL); 1459 gpio_request(GPIO_PTU5, NULL); 1460 gpio_direction_output(GPIO_PTU5, 0); 1461 1462 /* enable I2C device */ 1463 i2c_register_board_info(0, i2c0_devices, 1464 ARRAY_SIZE(i2c0_devices)); 1465 1466 i2c_register_board_info(1, i2c1_devices, 1467 ARRAY_SIZE(i2c1_devices)); 1468 1469 #if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE) 1470 /* VOU */ 1471 gpio_request(GPIO_FN_DV_D15, NULL); 1472 gpio_request(GPIO_FN_DV_D14, NULL); 1473 gpio_request(GPIO_FN_DV_D13, NULL); 1474 gpio_request(GPIO_FN_DV_D12, NULL); 1475 gpio_request(GPIO_FN_DV_D11, NULL); 1476 gpio_request(GPIO_FN_DV_D10, NULL); 1477 gpio_request(GPIO_FN_DV_D9, NULL); 1478 gpio_request(GPIO_FN_DV_D8, NULL); 1479 gpio_request(GPIO_FN_DV_CLKI, NULL); 1480 gpio_request(GPIO_FN_DV_CLK, NULL); 1481 gpio_request(GPIO_FN_DV_VSYNC, NULL); 1482 gpio_request(GPIO_FN_DV_HSYNC, NULL); 1483 1484 /* AK8813 power / reset sequence */ 1485 gpio_request(GPIO_PTG4, NULL); 1486 gpio_request(GPIO_PTU3, NULL); 1487 /* Reset */ 1488 gpio_direction_output(GPIO_PTG4, 0); 1489 /* Power down */ 1490 gpio_direction_output(GPIO_PTU3, 1); 1491 1492 udelay(10); 1493 1494 /* Power up, reset */ 1495 gpio_set_value(GPIO_PTU3, 0); 1496 1497 udelay(10); 1498 1499 /* Remove reset */ 1500 gpio_set_value(GPIO_PTG4, 1); 1501 #endif 1502 1503 return platform_add_devices(ecovec_devices, 1504 ARRAY_SIZE(ecovec_devices)); 1505 } 1506 arch_initcall(arch_setup); 1507 1508 static int __init devices_setup(void) 1509 { 1510 sh_eth_init(&sh_eth_plat); 1511 return 0; 1512 } 1513 device_initcall(devices_setup); 1514 1515 static struct sh_machine_vector mv_ecovec __initmv = { 1516 .mv_name = "R0P7724 (EcoVec)", 1517 }; 1518