setup.c 35.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright (C) 2009 Renesas Solutions Corp.
 *
 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#include <linux/init.h>
#include <linux/device.h>
#include <linux/platform_device.h>
Y
Yusuke Goda 已提交
14 15
#include <linux/mmc/host.h>
#include <linux/mmc/sh_mmcif.h>
16
#include <linux/mmc/sh_mobile_sdhi.h>
17 18 19
#include <linux/mtd/physmap.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
20 21
#include <linux/io.h>
#include <linux/delay.h>
22 23
#include <linux/regulator/fixed.h>
#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 29 30
#include <linux/spi/spi.h>
#include <linux/spi/sh_msiof.h>
#include <linux/spi/mmc_spi.h>
31
#include <linux/input.h>
M
Magnus Damm 已提交
32
#include <linux/input/sh_keysc.h>
33
#include <linux/sh_eth.h>
P
Paul Mundt 已提交
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 47 48
#include <cpu/sh7724.h>

/*
49 50 51 52 53 54 55 56
 *  Address      Interface        BusWidth
 *-----------------------------------------
 *  0x0000_0000  uboot            16bit
 *  0x0004_0000  Linux romImage   16bit
 *  0x0014_0000  MTD for Linux    16bit
 *  0x0400_0000  Internal I/O     16/32bit
 *  0x0800_0000  DRAM             32bit
 *  0x1800_0000  MFI              16bit
57 58
 */

59 60 61 62 63 64 65 66 67 68 69 70 71 72
/* SWITCH
 *------------------------------
 * DS2[1] = FlashROM write protect  ON     : write protect
 *                                  OFF    : No write protect
 * DS2[2] = RMII / TS, SCIF         ON     : RMII
 *                                  OFF    : TS, SCIF3
 * DS2[3] = Camera / Video          ON     : Camera
 *                                  OFF    : NTSC/PAL (IN)
 * DS2[5] = NTSC_OUT Clock          ON     : On board OSC
 *                                  OFF    : SH7724 DV_CLK
 * DS2[6-7] = MMC / SD              ON-OFF : SD
 *                                  OFF-ON : MMC
 */

73 74 75 76 77 78 79 80 81 82
/*
 * FSI - DA7210
 *
 * it needs amixer settings for playing
 *
 * amixer set 'HeadPhone' 80
 * amixer set 'Out Mixer Left DAC Left' on
 * amixer set 'Out Mixer Right DAC Right' on
 */

83 84
/* Heartbeat */
static unsigned char led_pos[] = { 0, 1, 2, 3 };
85

86 87 88 89 90
static struct heartbeat_data heartbeat_data = {
	.nr_bits = 4,
	.bit_pos = led_pos,
};

91 92 93 94
static struct resource heartbeat_resource = {
	.start  = 0xA405012C, /* PTG */
	.end    = 0xA405012E - 1,
	.flags  = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
95 96 97 98 99 100 101 102
};

static struct platform_device heartbeat_device = {
	.name           = "heartbeat",
	.id             = -1,
	.dev = {
		.platform_data = &heartbeat_data,
	},
103 104
	.num_resources  = 1,
	.resource       = &heartbeat_resource,
105 106 107 108 109
};

/* MTD */
static struct mtd_partition nor_flash_partitions[] = {
	{
110
		.name = "boot loader",
111
		.offset = 0,
112
		.size = (5 * 1024 * 1024),
113
		.mask_flags = MTD_WRITEABLE,  /* force read-only */
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
	}, {
		.name = "free-area",
		.offset = MTDPART_OFS_APPEND,
		.size = MTDPART_SIZ_FULL,
	},
};

static struct physmap_flash_data nor_flash_data = {
	.width		= 2,
	.parts		= nor_flash_partitions,
	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
};

static struct resource nor_flash_resources[] = {
	[0] = {
		.name	= "NOR Flash",
		.start	= 0x00000000,
		.end	= 0x03ffffff,
		.flags	= IORESOURCE_MEM,
	}
};

static struct platform_device nor_flash_device = {
	.name		= "physmap-flash",
	.resource	= nor_flash_resources,
	.num_resources	= ARRAY_SIZE(nor_flash_resources),
	.dev		= {
		.platform_data = &nor_flash_data,
	},
};

145 146 147 148 149 150 151 152 153
/* SH Eth */
#define SH_ETH_ADDR	(0xA4600000)
static struct resource sh_eth_resources[] = {
	[0] = {
		.start = SH_ETH_ADDR,
		.end   = SH_ETH_ADDR + 0x1FC,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
154
		.start = evt2irq(0xd60),
155 156 157 158
		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
	},
};

159
static struct sh_eth_plat_data sh_eth_plat = {
160 161
	.phy = 0x1f, /* SMSC LAN8700 */
	.edmac_endian = EDMAC_LITTLE_ENDIAN,
162 163
	.register_type = SH_ETH_REG_FAST_SH4,
	.phy_interface = PHY_INTERFACE_MODE_MII,
164
	.ether_link_active_low = 1
165 166 167
};

static struct platform_device sh_eth_device = {
168 169
	.name = "sh7724-ether",
	.id = 0,
170 171 172 173 174 175 176
	.dev = {
		.platform_data = &sh_eth_plat,
	},
	.num_resources = ARRAY_SIZE(sh_eth_resources),
	.resource = sh_eth_resources,
};

177
/* USB0 host */
178
static void usb0_port_power(int port, int power)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
{
	gpio_set_value(GPIO_PTB4, power);
}

static struct r8a66597_platdata usb0_host_data = {
	.on_chip = 1,
	.port_power = usb0_port_power,
};

static struct resource usb0_host_resources[] = {
	[0] = {
		.start	= 0xa4d80000,
		.end	= 0xa4d80124 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
195 196
		.start	= evt2irq(0xa20),
		.end	= evt2irq(0xa20),
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
	},
};

static struct platform_device usb0_host_device = {
	.name		= "r8a66597_hcd",
	.id		= 0,
	.dev = {
		.dma_mask		= NULL,         /*  not use dma */
		.coherent_dma_mask	= 0xffffffff,
		.platform_data		= &usb0_host_data,
	},
	.num_resources	= ARRAY_SIZE(usb0_host_resources),
	.resource	= usb0_host_resources,
};

213
/* USB1 host/function */
214
static void usb1_port_power(int port, int power)
215 216 217 218
{
	gpio_set_value(GPIO_PTB5, power);
}

219
static struct r8a66597_platdata usb1_common_data = {
220 221 222 223
	.on_chip = 1,
	.port_power = usb1_port_power,
};

224
static struct resource usb1_common_resources[] = {
225 226 227 228 229 230
	[0] = {
		.start	= 0xa4d90000,
		.end	= 0xa4d90124 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
231 232
		.start	= evt2irq(0xa40),
		.end	= evt2irq(0xa40),
233 234 235 236
		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
	},
};

237 238
static struct platform_device usb1_common_device = {
	/* .name will be added in arch_setup */
239 240 241 242
	.id		= 1,
	.dev = {
		.dma_mask		= NULL,         /*  not use dma */
		.coherent_dma_mask	= 0xffffffff,
243
		.platform_data		= &usb1_common_data,
244
	},
245 246
	.num_resources	= ARRAY_SIZE(usb1_common_resources),
	.resource	= usb1_common_resources,
247 248
};

249 250 251 252 253 254 255 256
/*
 * USBHS
 */
static int usbhs_get_id(struct platform_device *pdev)
{
	return gpio_get_value(GPIO_PTB3);
}

257
static int usbhs_phy_reset(struct platform_device *pdev)
258 259 260 261
{
	/* enable vbus if HOST */
	if (!gpio_get_value(GPIO_PTB3))
		gpio_set_value(GPIO_PTB5, 1);
262 263

	return 0;
264 265
}

266 267 268
static struct renesas_usbhs_platform_info usbhs_info = {
	.platform_callback = {
		.get_id		= usbhs_get_id,
269
		.phy_reset	= usbhs_phy_reset,
270 271 272 273
	},
	.driver_param = {
		.buswait_bwait		= 4,
		.detection_delay	= 5,
274 275 276 277
		.d0_tx_id = SHDMA_SLAVE_USB1D0_TX,
		.d0_rx_id = SHDMA_SLAVE_USB1D0_RX,
		.d1_tx_id = SHDMA_SLAVE_USB1D1_TX,
		.d1_rx_id = SHDMA_SLAVE_USB1D1_RX,
278 279 280 281 282 283 284 285 286 287
	},
};

static struct resource usbhs_resources[] = {
	[0] = {
		.start	= 0xa4d90000,
		.end	= 0xa4d90124 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
288 289
		.start	= evt2irq(0xa40),
		.end	= evt2irq(0xa40),
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device usbhs_device = {
	.name	= "renesas_usbhs",
	.id	= 1,
	.dev = {
		.dma_mask		= NULL,         /*  not use dma */
		.coherent_dma_mask	= 0xffffffff,
		.platform_data		= &usbhs_info,
	},
	.num_resources	= ARRAY_SIZE(usbhs_resources),
	.resource	= usbhs_resources,
};

306
/* LCDC */
307
static const struct fb_videomode ecovec_lcd_modes[] = {
308 309 310 311 312 313 314 315 316 317 318 319 320 321
	{
		.name		= "Panel",
		.xres		= 800,
		.yres		= 480,
		.left_margin	= 220,
		.right_margin	= 110,
		.hsync_len	= 70,
		.upper_margin	= 20,
		.lower_margin	= 5,
		.vsync_len	= 5,
		.sync		= 0, /* hsync and vsync are active low */
	},
};

322
static const struct fb_videomode ecovec_dvi_modes[] = {
323 324 325 326 327 328 329 330 331 332 333 334 335 336
	{
		.name		= "DVI",
		.xres		= 1280,
		.yres		= 720,
		.left_margin	= 220,
		.right_margin	= 110,
		.hsync_len	= 40,
		.upper_margin	= 20,
		.lower_margin	= 5,
		.vsync_len	= 5,
		.sync = 0, /* hsync and vsync are active low */
	},
};

337
static int ecovec24_set_brightness(int brightness)
338 339 340 341 342 343
{
	gpio_set_value(GPIO_PTR1, brightness);

	return 0;
}

344 345 346 347
static struct sh_mobile_lcdc_info lcdc_info = {
	.ch[0] = {
		.interface_type = RGB18,
		.chan = LCDC_CHAN_MAINLCD,
348
		.fourcc = V4L2_PIX_FMT_RGB565,
349
		.panel_cfg = { /* 7.0 inch */
350 351 352
			.width = 152,
			.height = 91,
		},
353 354 355
		.bl_info = {
			.name = "sh_mobile_lcdc_bl",
			.max_brightness = 1,
356
			.set_brightness = ecovec24_set_brightness,
357 358 359 360 361 362 363 364
		},
	}
};

static struct resource lcdc_resources[] = {
	[0] = {
		.name	= "LCDC",
		.start	= 0xfe940000,
365
		.end	= 0xfe942fff,
366 367 368
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
369
		.start	= evt2irq(0xf40),
370 371 372 373 374 375 376 377 378 379 380 381 382
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device lcdc_device = {
	.name		= "sh_mobile_lcdc_fb",
	.num_resources	= ARRAY_SIZE(lcdc_resources),
	.resource	= lcdc_resources,
	.dev		= {
		.platform_data	= &lcdc_info,
	},
};

383 384 385 386 387 388 389 390 391 392 393 394 395
/* CEU0 */
static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
};

static struct resource ceu0_resources[] = {
	[0] = {
		.name	= "CEU0",
		.start	= 0xfe910000,
		.end	= 0xfe91009f,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
396
		.start  = evt2irq(0x880),
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
		.flags  = IORESOURCE_IRQ,
	},
	[2] = {
		/* place holder for contiguous memory */
	},
};

static struct platform_device ceu0_device = {
	.name		= "sh_mobile_ceu",
	.id             = 0, /* "ceu0" clock */
	.num_resources	= ARRAY_SIZE(ceu0_resources),
	.resource	= ceu0_resources,
	.dev	= {
		.platform_data	= &sh_mobile_ceu0_info,
	},
};

/* CEU1 */
static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
};

static struct resource ceu1_resources[] = {
	[0] = {
		.name	= "CEU1",
		.start	= 0xfe914000,
		.end	= 0xfe91409f,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
427
		.start  = evt2irq(0x9e0),
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
		.flags  = IORESOURCE_IRQ,
	},
	[2] = {
		/* place holder for contiguous memory */
	},
};

static struct platform_device ceu1_device = {
	.name		= "sh_mobile_ceu",
	.id             = 1, /* "ceu1" clock */
	.num_resources	= ARRAY_SIZE(ceu1_resources),
	.resource	= ceu1_resources,
	.dev	= {
		.platform_data	= &sh_mobile_ceu1_info,
	},
};

445
/* I2C device */
446 447 448 449 450 451
static struct i2c_board_info i2c0_devices[] = {
	{
		I2C_BOARD_INFO("da7210", 0x1a),
	},
};

452 453 454 455
static struct i2c_board_info i2c1_devices[] = {
	{
		I2C_BOARD_INFO("r2025sd", 0x32),
	},
456 457
	{
		I2C_BOARD_INFO("lis3lv02d", 0x1c),
P
Paul Mundt 已提交
458
		.irq = evt2irq(0x620),
459
	}
460 461
};

462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
/* KEYSC */
static struct sh_keysc_info keysc_info = {
	.mode		= SH_KEYSC_MODE_1,
	.scan_timing	= 3,
	.delay		= 50,
	.kycr2_delay	= 100,
	.keycodes	= { KEY_1, 0, 0, 0, 0,
			    KEY_2, 0, 0, 0, 0,
			    KEY_3, 0, 0, 0, 0,
			    KEY_4, 0, 0, 0, 0,
			    KEY_5, 0, 0, 0, 0,
			    KEY_6, 0, 0, 0, 0, },
};

static struct resource keysc_resources[] = {
	[0] = {
		.name	= "KEYSC",
		.start  = 0x044b0000,
		.end    = 0x044b000f,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
484
		.start  = evt2irq(0xbe0),
485 486 487 488 489 490 491 492 493 494 495 496 497 498
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device keysc_device = {
	.name           = "sh_keysc",
	.id             = 0, /* keysc0 clock */
	.num_resources  = ARRAY_SIZE(keysc_resources),
	.resource       = keysc_resources,
	.dev	= {
		.platform_data	= &keysc_info,
	},
};

499
/* TouchScreen */
P
Paul Mundt 已提交
500 501
#define IRQ0 evt2irq(0x600)

502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
static int ts_get_pendown_state(void)
{
	int val = 0;
	gpio_free(GPIO_FN_INTC_IRQ0);
	gpio_request(GPIO_PTZ0, NULL);
	gpio_direction_input(GPIO_PTZ0);

	val = gpio_get_value(GPIO_PTZ0);

	gpio_free(GPIO_PTZ0);
	gpio_request(GPIO_FN_INTC_IRQ0, NULL);

	return val ? 0 : 1;
}

static int ts_init(void)
{
	gpio_request(GPIO_FN_INTC_IRQ0, NULL);
	return 0;
}

523
static struct tsc2007_platform_data tsc2007_info = {
524
	.model			= 2007,
525 526 527
	.x_plate_ohms		= 180,
	.get_pendown_state	= ts_get_pendown_state,
	.init_platform_hw	= ts_init,
528 529 530 531 532 533 534 535 536
};

static struct i2c_board_info ts_i2c_clients = {
	I2C_BOARD_INFO("tsc2007", 0x48),
	.type		= "tsc2007",
	.platform_data	= &tsc2007_info,
	.irq		= IRQ0,
};

537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
static struct regulator_consumer_supply cn12_power_consumers[] =
{
	REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
	REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
	REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
	REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
};

static struct regulator_init_data cn12_power_init_data = {
	.constraints = {
		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
	},
	.num_consumer_supplies  = ARRAY_SIZE(cn12_power_consumers),
	.consumer_supplies      = cn12_power_consumers,
};

static struct fixed_voltage_config cn12_power_info = {
	.supply_name = "CN12 SD/MMC Vdd",
	.microvolts = 3300000,
	.gpio = GPIO_PTB7,
	.enable_high = 1,
	.init_data = &cn12_power_init_data,
};

static struct platform_device cn12_power = {
	.name = "reg-fixed-voltage",
	.id   = 0,
	.dev  = {
		.platform_data = &cn12_power_info,
	},
};

569
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
Y
Yusuke Goda 已提交
570
/* SDHI0 */
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
static struct regulator_consumer_supply sdhi0_power_consumers[] =
{
	REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
	REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
};

static struct regulator_init_data sdhi0_power_init_data = {
	.constraints = {
		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
	},
	.num_consumer_supplies  = ARRAY_SIZE(sdhi0_power_consumers),
	.consumer_supplies      = sdhi0_power_consumers,
};

static struct fixed_voltage_config sdhi0_power_info = {
	.supply_name = "CN11 SD/MMC Vdd",
	.microvolts = 3300000,
	.gpio = GPIO_PTB6,
	.enable_high = 1,
	.init_data = &sdhi0_power_init_data,
};

static struct platform_device sdhi0_power = {
	.name = "reg-fixed-voltage",
	.id   = 1,
	.dev  = {
		.platform_data = &sdhi0_power_info,
	},
};

601 602
static void sdhi0_set_pwr(struct platform_device *pdev, int state)
{
603 604 605 606 607 608 609 610 611 612 613 614 615 616
	static int power_gpio = -EINVAL;

	if (power_gpio < 0) {
		int ret = gpio_request(GPIO_PTB6, NULL);
		if (!ret) {
			power_gpio = GPIO_PTB6;
			gpio_direction_output(power_gpio, 0);
		}
	}

	/*
	 * Toggle the GPIO regardless, whether we managed to grab it above or
	 * the fixed regulator driver did.
	 */
617 618 619
	gpio_set_value(GPIO_PTB6, state);
}

620 621 622 623 624
static int sdhi0_get_cd(struct platform_device *pdev)
{
	return !gpio_get_value(GPIO_PTY7);
}

625
static struct sh_mobile_sdhi_info sdhi0_info = {
626 627 628
	.dma_slave_tx	= SHDMA_SLAVE_SDHI0_TX,
	.dma_slave_rx	= SHDMA_SLAVE_SDHI0_RX,
	.set_pwr	= sdhi0_set_pwr,
629 630 631
	.tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
			  MMC_CAP_NEEDS_POLL,
	.get_cd		= sdhi0_get_cd,
632 633
};

634 635 636 637
static struct resource sdhi0_resources[] = {
	[0] = {
		.name	= "SDHI0",
		.start  = 0x04ce0000,
638
		.end    = 0x04ce00ff,
639 640 641
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
642
		.start  = evt2irq(0xe80),
643 644 645 646 647 648 649 650 651
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device sdhi0_device = {
	.name           = "sh_mobile_sdhi",
	.num_resources  = ARRAY_SIZE(sdhi0_resources),
	.resource       = sdhi0_resources,
	.id             = 0,
652 653 654
	.dev	= {
		.platform_data	= &sdhi0_info,
	},
655 656
};

657
static void cn12_set_pwr(struct platform_device *pdev, int state)
658
{
659 660 661 662 663 664 665 666 667 668 669 670 671 672
	static int power_gpio = -EINVAL;

	if (power_gpio < 0) {
		int ret = gpio_request(GPIO_PTB7, NULL);
		if (!ret) {
			power_gpio = GPIO_PTB7;
			gpio_direction_output(power_gpio, 0);
		}
	}

	/*
	 * Toggle the GPIO regardless, whether we managed to grab it above or
	 * the fixed regulator driver did.
	 */
673 674 675
	gpio_set_value(GPIO_PTB7, state);
}

676 677
#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
/* SDHI1 */
678 679 680 681 682
static int sdhi1_get_cd(struct platform_device *pdev)
{
	return !gpio_get_value(GPIO_PTW7);
}

683
static struct sh_mobile_sdhi_info sdhi1_info = {
684 685
	.dma_slave_tx	= SHDMA_SLAVE_SDHI1_TX,
	.dma_slave_rx	= SHDMA_SLAVE_SDHI1_RX,
686 687
	.tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
			  MMC_CAP_NEEDS_POLL,
688
	.set_pwr	= cn12_set_pwr,
689
	.get_cd		= sdhi1_get_cd,
690 691
};

692 693 694 695
static struct resource sdhi1_resources[] = {
	[0] = {
		.name	= "SDHI1",
		.start  = 0x04cf0000,
696
		.end    = 0x04cf00ff,
697 698 699
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
700
		.start  = evt2irq(0x4e0),
701 702 703 704 705 706 707 708 709
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device sdhi1_device = {
	.name           = "sh_mobile_sdhi",
	.num_resources  = ARRAY_SIZE(sdhi1_resources),
	.resource       = sdhi1_resources,
	.id             = 1,
710 711 712
	.dev	= {
		.platform_data	= &sdhi1_info,
	},
713
};
Y
Yusuke Goda 已提交
714
#endif /* CONFIG_MMC_SH_MMCIF */
715

716 717
#else

718
/* MMC SPI */
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
static int mmc_spi_get_ro(struct device *dev)
{
	return gpio_get_value(GPIO_PTY6);
}

static int mmc_spi_get_cd(struct device *dev)
{
	return !gpio_get_value(GPIO_PTY7);
}

static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
{
	gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
}

static struct mmc_spi_platform_data mmc_spi_info = {
	.get_ro = mmc_spi_get_ro,
	.get_cd = mmc_spi_get_cd,
	.caps = MMC_CAP_NEEDS_POLL,
	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
	.setpower = mmc_spi_setpower,
};

static struct spi_board_info spi_bus[] = {
	{
		.modalias	= "mmc_spi",
		.platform_data	= &mmc_spi_info,
		.max_speed_hz	= 5000000,
		.mode		= SPI_MODE_0,
		.controller_data = (void *) GPIO_PTM4,
	},
};

752
/* MSIOF0 */
753 754 755 756 757 758 759 760 761 762 763 764
static struct sh_msiof_spi_info msiof0_data = {
	.num_chipselect = 1,
};

static struct resource msiof0_resources[] = {
	[0] = {
		.name	= "MSIOF0",
		.start	= 0xa4c40000,
		.end	= 0xa4c40063,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
765
		.start	= evt2irq(0xc80),
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device msiof0_device = {
	.name		= "spi_sh_msiof",
	.id		= 0, /* MSIOF0 */
	.dev = {
		.platform_data = &msiof0_data,
	},
	.num_resources	= ARRAY_SIZE(msiof0_resources),
	.resource	= msiof0_resources,
};

#endif

782
/* I2C Video/Camera */
783 784 785 786
static struct i2c_board_info i2c_camera[] = {
	{
		I2C_BOARD_INFO("tw9910", 0x45),
	},
787 788 789 790 791 792 793 794
	{
		/* 1st camera */
		I2C_BOARD_INFO("mt9t112", 0x3c),
	},
	{
		/* 2nd camera */
		I2C_BOARD_INFO("mt9t112", 0x3c),
	},
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
};

/* tw9910 */
static int tw9910_power(struct device *dev, int mode)
{
	int val = mode ? 0 : 1;

	gpio_set_value(GPIO_PTU2, val);
	if (mode)
		mdelay(100);

	return 0;
}

static struct tw9910_video_info tw9910_info = {
	.buswidth	= SOCAM_DATAWIDTH_8,
	.mpout		= TW9910_MPO_FIELD,
};

static struct soc_camera_link tw9910_link = {
	.i2c_adapter_id	= 0,
	.bus_id		= 1,
	.power		= tw9910_power,
	.board_info	= &i2c_camera[0],
	.priv		= &tw9910_info,
};

822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865
/* mt9t112 */
static int mt9t112_power1(struct device *dev, int mode)
{
	gpio_set_value(GPIO_PTA3, mode);
	if (mode)
		mdelay(100);

	return 0;
}

static struct mt9t112_camera_info mt9t112_info1 = {
	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
};

static struct soc_camera_link mt9t112_link1 = {
	.i2c_adapter_id	= 0,
	.power		= mt9t112_power1,
	.bus_id		= 0,
	.board_info	= &i2c_camera[1],
	.priv		= &mt9t112_info1,
};

static int mt9t112_power2(struct device *dev, int mode)
{
	gpio_set_value(GPIO_PTA4, mode);
	if (mode)
		mdelay(100);

	return 0;
}

static struct mt9t112_camera_info mt9t112_info2 = {
	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
};

static struct soc_camera_link mt9t112_link2 = {
	.i2c_adapter_id	= 1,
	.power		= mt9t112_power2,
	.bus_id		= 1,
	.board_info	= &i2c_camera[2],
	.priv		= &mt9t112_info2,
};
866 867 868 869 870 871 872 873 874

static struct platform_device camera_devices[] = {
	{
		.name	= "soc-camera-pdrv",
		.id	= 0,
		.dev	= {
			.platform_data = &tw9910_link,
		},
	},
875 876 877 878 879 880 881 882 883 884 885 886 887 888
	{
		.name	= "soc-camera-pdrv",
		.id	= 1,
		.dev	= {
			.platform_data = &mt9t112_link1,
		},
	},
	{
		.name	= "soc-camera-pdrv",
		.id	= 2,
		.dev	= {
			.platform_data = &mt9t112_link2,
		},
	},
889 890
};

891 892 893 894 895 896 897 898 899
/* FSI */
static struct resource fsi_resources[] = {
	[0] = {
		.name	= "FSI",
		.start	= 0xFE3C0000,
		.end	= 0xFE3C021d,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
900
		.start  = evt2irq(0xf80),
901 902 903 904 905 906 907 908 909 910 911
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device fsi_device = {
	.name		= "sh_fsi",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(fsi_resources),
	.resource	= fsi_resources,
};

912 913 914 915 916
static struct asoc_simple_card_info fsi_da7210_info = {
	.name		= "DA7210",
	.card		= "FSIB-DA7210",
	.codec		= "da7210.0-001a",
	.platform	= "sh_fsi.0",
917 918 919 920 921 922 923 924 925
	.daifmt		= SND_SOC_DAIFMT_I2S,
	.cpu_dai = {
		.name	= "fsib-dai",
		.fmt	= SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
	},
	.codec_dai = {
		.name	= "da7210-hifi",
		.fmt	= SND_SOC_DAIFMT_CBM_CFM,
	},
926 927 928 929 930 931 932 933 934 935
};

static struct platform_device fsi_da7210_device = {
	.name	= "asoc-simple-card",
	.dev	= {
		.platform_data	= &fsi_da7210_info,
	},
};


936 937 938 939 940 941 942 943 944
/* IrDA */
static struct resource irda_resources[] = {
	[0] = {
		.name	= "IrDA",
		.start  = 0xA45D0000,
		.end    = 0xA45D0049,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
945
		.start  = evt2irq(0x480),
946 947 948 949 950 951 952 953 954 955
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device irda_device = {
	.name           = "sh_sir",
	.num_resources  = ARRAY_SIZE(irda_resources),
	.resource       = irda_resources,
};

956 957 958
#include <media/ak881x.h>
#include <media/sh_vou.h>

959
static struct ak881x_pdata ak881x_pdata = {
960 961 962 963 964 965 966 967
	.flags = AK881X_IF_MODE_SLAVE,
};

static struct i2c_board_info ak8813 = {
	I2C_BOARD_INFO("ak8813", 0x20),
	.platform_data = &ak881x_pdata,
};

968
static struct sh_vou_pdata sh_vou_pdata = {
969 970 971 972 973 974 975 976 977 978 979 980 981
	.bus_fmt	= SH_VOU_BUS_8BIT,
	.flags		= SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
	.board_info	= &ak8813,
	.i2c_adap	= 0,
};

static struct resource sh_vou_resources[] = {
	[0] = {
		.start  = 0xfe960000,
		.end    = 0xfe962043,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
P
Paul Mundt 已提交
982
		.start  = evt2irq(0x8e0),
983 984 985 986 987 988 989 990 991 992 993 994 995 996
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device vou_device = {
	.name           = "sh-vou",
	.id		= -1,
	.num_resources  = ARRAY_SIZE(sh_vou_resources),
	.resource       = sh_vou_resources,
	.dev		= {
		.platform_data	= &sh_vou_pdata,
	},
};

997
#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
Y
Yusuke Goda 已提交
998 999 1000
/* SH_MMCIF */
static void mmcif_down_pwr(struct platform_device *pdev)
{
1001
	cn12_set_pwr(pdev, 0);
Y
Yusuke Goda 已提交
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
}

static struct resource sh_mmcif_resources[] = {
	[0] = {
		.name	= "SH_MMCIF",
		.start	= 0xA4CA0000,
		.end	= 0xA4CA00FF,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		/* MMC2I */
P
Paul Mundt 已提交
1013
		.start	= evt2irq(0x5a0),
Y
Yusuke Goda 已提交
1014 1015 1016 1017
		.flags	= IORESOURCE_IRQ,
	},
	[2] = {
		/* MMC3I */
P
Paul Mundt 已提交
1018
		.start	= evt2irq(0x5c0),
Y
Yusuke Goda 已提交
1019 1020 1021 1022
		.flags	= IORESOURCE_IRQ,
	},
};

1023
static struct sh_mmcif_plat_data sh_mmcif_plat = {
1024
	.set_pwr	= cn12_set_pwr,
Y
Yusuke Goda 已提交
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
	.down_pwr	= mmcif_down_pwr,
	.sup_pclk	= 0, /* SH7724: Max Pclk/2 */
	.caps		= MMC_CAP_4_BIT_DATA |
			  MMC_CAP_8_BIT_DATA |
			  MMC_CAP_NEEDS_POLL,
	.ocr		= MMC_VDD_32_33 | MMC_VDD_33_34,
};

static struct platform_device sh_mmcif_device = {
	.name		= "sh_mmcif",
	.id		= 0,
	.dev		= {
		.platform_data		= &sh_mmcif_plat,
	},
	.num_resources	= ARRAY_SIZE(sh_mmcif_resources),
	.resource	= sh_mmcif_resources,
};
#endif

1044 1045 1046
static struct platform_device *ecovec_devices[] __initdata = {
	&heartbeat_device,
	&nor_flash_device,
1047
	&sh_eth_device,
1048
	&usb0_host_device,
1049
	&usb1_common_device,
1050
	&usbhs_device,
1051
	&lcdc_device,
1052 1053
	&ceu0_device,
	&ceu1_device,
1054
	&keysc_device,
1055
	&cn12_power,
1056
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1057
	&sdhi0_power,
1058
	&sdhi0_device,
1059
#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1060
	&sdhi1_device,
Y
Yusuke Goda 已提交
1061
#endif
1062 1063 1064
#else
	&msiof0_device,
#endif
1065
	&camera_devices[0],
1066 1067
	&camera_devices[1],
	&camera_devices[2],
1068
	&fsi_device,
1069
	&fsi_da7210_device,
1070
	&irda_device,
1071
	&vou_device,
1072
#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
Y
Yusuke Goda 已提交
1073 1074
	&sh_mmcif_device,
#endif
1075 1076
};

1077
#ifdef CONFIG_I2C
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
#define EEPROM_ADDR 0x50
static u8 mac_read(struct i2c_adapter *a, u8 command)
{
	struct i2c_msg msg[2];
	u8 buf;
	int ret;

	msg[0].addr  = EEPROM_ADDR;
	msg[0].flags = 0;
	msg[0].len   = 1;
	msg[0].buf   = &command;

	msg[1].addr  = EEPROM_ADDR;
	msg[1].flags = I2C_M_RD;
	msg[1].len   = 1;
	msg[1].buf   = &buf;

	ret = i2c_transfer(a, msg, 2);
	if (ret < 0) {
		printk(KERN_ERR "error %d\n", ret);
		buf = 0xff;
	}

	return buf;
}

1104
static void __init sh_eth_init(struct sh_eth_plat_data *pd)
1105 1106 1107 1108 1109 1110 1111 1112 1113
{
	struct i2c_adapter *a = i2c_get_adapter(1);
	int i;

	if (!a) {
		pr_err("can not get I2C 1\n");
		return;
	}

L
Lucas De Marchi 已提交
1114
	/* read MAC address from EEPROM */
1115 1116
	for (i = 0; i < sizeof(pd->mac_addr); i++) {
		pd->mac_addr[i] = mac_read(a, 0x10 + i);
1117 1118
		msleep(10);
	}
1119 1120

	i2c_put_adapter(a);
1121
}
1122 1123 1124 1125 1126 1127
#else
static void __init sh_eth_init(struct sh_eth_plat_data *pd)
{
	pr_err("unable to read sh_eth MAC address\n");
}
#endif
1128

1129
#define PORT_HIZA 0xA4050158
1130
#define IODRIVEA  0xA405018A
1131 1132 1133 1134 1135 1136

extern char ecovec24_sdram_enter_start;
extern char ecovec24_sdram_enter_end;
extern char ecovec24_sdram_leave_start;
extern char ecovec24_sdram_leave_end;

1137
static int __init arch_setup(void)
1138
{
1139
	struct clk *clk;
1140
	bool cn12_enabled = false;
1141

1142
	/* register board specific self-refresh code */
M
Magnus Damm 已提交
1143 1144
	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
					SUSP_SH_RSTANDBY,
1145 1146 1147 1148 1149
					&ecovec24_sdram_enter_start,
					&ecovec24_sdram_enter_end,
					&ecovec24_sdram_leave_start,
					&ecovec24_sdram_leave_end);

1150 1151 1152 1153 1154
	/* enable STATUS0, STATUS2 and PDSTATUS */
	gpio_request(GPIO_FN_STATUS0, NULL);
	gpio_request(GPIO_FN_STATUS2, NULL);
	gpio_request(GPIO_FN_PDSTATUS, NULL);

1155 1156 1157 1158 1159 1160 1161 1162 1163
	/* enable SCIFA0 */
	gpio_request(GPIO_FN_SCIF0_TXD, NULL);
	gpio_request(GPIO_FN_SCIF0_RXD, NULL);

	/* enable debug LED */
	gpio_request(GPIO_PTG0, NULL);
	gpio_request(GPIO_PTG1, NULL);
	gpio_request(GPIO_PTG2, NULL);
	gpio_request(GPIO_PTG3, NULL);
1164 1165 1166 1167
	gpio_direction_output(GPIO_PTG0, 0);
	gpio_direction_output(GPIO_PTG1, 0);
	gpio_direction_output(GPIO_PTG2, 0);
	gpio_direction_output(GPIO_PTG3, 0);
1168
	__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
1169

1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186
	/* enable SH-Eth */
	gpio_request(GPIO_PTA1, NULL);
	gpio_direction_output(GPIO_PTA1, 1);
	mdelay(20);

	gpio_request(GPIO_FN_RMII_RXD0,    NULL);
	gpio_request(GPIO_FN_RMII_RXD1,    NULL);
	gpio_request(GPIO_FN_RMII_TXD0,    NULL);
	gpio_request(GPIO_FN_RMII_TXD1,    NULL);
	gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
	gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
	gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
	gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
	gpio_request(GPIO_FN_MDIO,         NULL);
	gpio_request(GPIO_FN_MDC,          NULL);
	gpio_request(GPIO_FN_LNKSTA,       NULL);

1187
	/* enable USB */
1188 1189
	__raw_writew(0x0000, 0xA4D80000);
	__raw_writew(0x0000, 0xA4D90000);
1190 1191 1192 1193 1194 1195
	gpio_request(GPIO_PTB3,  NULL);
	gpio_request(GPIO_PTB4,  NULL);
	gpio_request(GPIO_PTB5,  NULL);
	gpio_direction_input(GPIO_PTB3);
	gpio_direction_output(GPIO_PTB4, 0);
	gpio_direction_output(GPIO_PTB5, 0);
1196 1197
	__raw_writew(0x0600, 0xa40501d4);
	__raw_writew(0x0600, 0xa4050192);
1198

1199 1200 1201 1202 1203 1204 1205 1206
	if (gpio_get_value(GPIO_PTB3)) {
		printk(KERN_INFO "USB1 function is selected\n");
		usb1_common_device.name = "r8a66597_udc";
	} else {
		printk(KERN_INFO "USB1 host is selected\n");
		usb1_common_device.name = "r8a66597_hcd";
	}

1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
	/* enable LCDC */
	gpio_request(GPIO_FN_LCDD23,   NULL);
	gpio_request(GPIO_FN_LCDD22,   NULL);
	gpio_request(GPIO_FN_LCDD21,   NULL);
	gpio_request(GPIO_FN_LCDD20,   NULL);
	gpio_request(GPIO_FN_LCDD19,   NULL);
	gpio_request(GPIO_FN_LCDD18,   NULL);
	gpio_request(GPIO_FN_LCDD17,   NULL);
	gpio_request(GPIO_FN_LCDD16,   NULL);
	gpio_request(GPIO_FN_LCDD15,   NULL);
	gpio_request(GPIO_FN_LCDD14,   NULL);
	gpio_request(GPIO_FN_LCDD13,   NULL);
	gpio_request(GPIO_FN_LCDD12,   NULL);
	gpio_request(GPIO_FN_LCDD11,   NULL);
	gpio_request(GPIO_FN_LCDD10,   NULL);
	gpio_request(GPIO_FN_LCDD9,    NULL);
	gpio_request(GPIO_FN_LCDD8,    NULL);
	gpio_request(GPIO_FN_LCDD7,    NULL);
	gpio_request(GPIO_FN_LCDD6,    NULL);
	gpio_request(GPIO_FN_LCDD5,    NULL);
	gpio_request(GPIO_FN_LCDD4,    NULL);
	gpio_request(GPIO_FN_LCDD3,    NULL);
	gpio_request(GPIO_FN_LCDD2,    NULL);
	gpio_request(GPIO_FN_LCDD1,    NULL);
	gpio_request(GPIO_FN_LCDD0,    NULL);
	gpio_request(GPIO_FN_LCDDISP,  NULL);
	gpio_request(GPIO_FN_LCDHSYN,  NULL);
	gpio_request(GPIO_FN_LCDDCK,   NULL);
	gpio_request(GPIO_FN_LCDVSYN,  NULL);
	gpio_request(GPIO_FN_LCDDON,   NULL);
	gpio_request(GPIO_FN_LCDLCLK,  NULL);
1238
	__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248

	gpio_request(GPIO_PTE6, NULL);
	gpio_request(GPIO_PTU1, NULL);
	gpio_request(GPIO_PTR1, NULL);
	gpio_request(GPIO_PTA2, NULL);
	gpio_direction_input(GPIO_PTE6);
	gpio_direction_output(GPIO_PTU1, 0);
	gpio_direction_output(GPIO_PTR1, 0);
	gpio_direction_output(GPIO_PTA2, 0);

1249
	/* I/O buffer drive ability is high */
1250
	__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
1251

1252 1253 1254
	if (gpio_get_value(GPIO_PTE6)) {
		/* DVI */
		lcdc_info.clock_source			= LCDC_CLK_EXTERNAL;
1255
		lcdc_info.ch[0].clock_divider		= 1;
1256 1257
		lcdc_info.ch[0].lcd_modes		= ecovec_dvi_modes;
		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_dvi_modes);
1258 1259 1260 1261 1262

		gpio_set_value(GPIO_PTA2, 1);
		gpio_set_value(GPIO_PTU1, 1);
	} else {
		/* Panel */
1263
		lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
1264
		lcdc_info.ch[0].clock_divider		= 2;
1265 1266
		lcdc_info.ch[0].lcd_modes		= ecovec_lcd_modes;
		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_lcd_modes);
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277

		gpio_set_value(GPIO_PTR1, 1);

		/* FIXME
		 *
		 * LCDDON control is needed for Panel,
		 * but current sh_mobile_lcdc driver doesn't control it.
		 * It is temporary correspondence
		 */
		gpio_request(GPIO_PTF4, NULL);
		gpio_direction_output(GPIO_PTF4, 1);
1278 1279 1280

		/* enable TouchScreen */
		i2c_register_board_info(0, &ts_i2c_clients, 1);
1281
		irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
1282 1283
	}

1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
	/* enable CEU0 */
	gpio_request(GPIO_FN_VIO0_D15, NULL);
	gpio_request(GPIO_FN_VIO0_D14, NULL);
	gpio_request(GPIO_FN_VIO0_D13, NULL);
	gpio_request(GPIO_FN_VIO0_D12, NULL);
	gpio_request(GPIO_FN_VIO0_D11, NULL);
	gpio_request(GPIO_FN_VIO0_D10, NULL);
	gpio_request(GPIO_FN_VIO0_D9,  NULL);
	gpio_request(GPIO_FN_VIO0_D8,  NULL);
	gpio_request(GPIO_FN_VIO0_D7,  NULL);
	gpio_request(GPIO_FN_VIO0_D6,  NULL);
	gpio_request(GPIO_FN_VIO0_D5,  NULL);
	gpio_request(GPIO_FN_VIO0_D4,  NULL);
	gpio_request(GPIO_FN_VIO0_D3,  NULL);
	gpio_request(GPIO_FN_VIO0_D2,  NULL);
	gpio_request(GPIO_FN_VIO0_D1,  NULL);
	gpio_request(GPIO_FN_VIO0_D0,  NULL);
	gpio_request(GPIO_FN_VIO0_VD,  NULL);
	gpio_request(GPIO_FN_VIO0_CLK, NULL);
	gpio_request(GPIO_FN_VIO0_FLD, NULL);
	gpio_request(GPIO_FN_VIO0_HD,  NULL);
	platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);

	/* enable CEU1 */
	gpio_request(GPIO_FN_VIO1_D7,  NULL);
	gpio_request(GPIO_FN_VIO1_D6,  NULL);
	gpio_request(GPIO_FN_VIO1_D5,  NULL);
	gpio_request(GPIO_FN_VIO1_D4,  NULL);
	gpio_request(GPIO_FN_VIO1_D3,  NULL);
	gpio_request(GPIO_FN_VIO1_D2,  NULL);
	gpio_request(GPIO_FN_VIO1_D1,  NULL);
	gpio_request(GPIO_FN_VIO1_D0,  NULL);
	gpio_request(GPIO_FN_VIO1_FLD, NULL);
	gpio_request(GPIO_FN_VIO1_HD,  NULL);
	gpio_request(GPIO_FN_VIO1_VD,  NULL);
	gpio_request(GPIO_FN_VIO1_CLK, NULL);
	platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);

1322 1323 1324 1325 1326 1327 1328 1329 1330
	/* enable KEYSC */
	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
	gpio_request(GPIO_FN_KEYOUT3,     NULL);
	gpio_request(GPIO_FN_KEYOUT2,     NULL);
	gpio_request(GPIO_FN_KEYOUT1,     NULL);
	gpio_request(GPIO_FN_KEYOUT0,     NULL);
	gpio_request(GPIO_FN_KEYIN0,      NULL);

1331 1332 1333 1334 1335 1336 1337 1338 1339 1340
	/* enable user debug switch */
	gpio_request(GPIO_PTR0, NULL);
	gpio_request(GPIO_PTR4, NULL);
	gpio_request(GPIO_PTR5, NULL);
	gpio_request(GPIO_PTR6, NULL);
	gpio_direction_input(GPIO_PTR0);
	gpio_direction_input(GPIO_PTR4);
	gpio_direction_input(GPIO_PTR5);
	gpio_direction_input(GPIO_PTR6);

1341 1342 1343 1344 1345
	/* SD-card slot CN11 */
	/* Card-detect, used on CN11, either with SDHI0 or with SPI */
	gpio_request(GPIO_PTY7, NULL);
	gpio_direction_input(GPIO_PTY7);

1346
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1347
	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
1348 1349 1350 1351 1352 1353 1354
	gpio_request(GPIO_FN_SDHI0WP,  NULL);
	gpio_request(GPIO_FN_SDHI0CMD, NULL);
	gpio_request(GPIO_FN_SDHI0CLK, NULL);
	gpio_request(GPIO_FN_SDHI0D3,  NULL);
	gpio_request(GPIO_FN_SDHI0D2,  NULL);
	gpio_request(GPIO_FN_SDHI0D1,  NULL);
	gpio_request(GPIO_FN_SDHI0D0,  NULL);
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
#else
	/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
	gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
	gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
	gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
	gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
	gpio_request(GPIO_PTY6, NULL); /* write protect */
	gpio_direction_input(GPIO_PTY6);

	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
#endif
1369

1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
	/* MMC/SD-card slot CN12 */
#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
	/* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
	gpio_request(GPIO_FN_MMC_D7, NULL);
	gpio_request(GPIO_FN_MMC_D6, NULL);
	gpio_request(GPIO_FN_MMC_D5, NULL);
	gpio_request(GPIO_FN_MMC_D4, NULL);
	gpio_request(GPIO_FN_MMC_D3, NULL);
	gpio_request(GPIO_FN_MMC_D2, NULL);
	gpio_request(GPIO_FN_MMC_D1, NULL);
	gpio_request(GPIO_FN_MMC_D0, NULL);
	gpio_request(GPIO_FN_MMC_CLK, NULL);
	gpio_request(GPIO_FN_MMC_CMD, NULL);

	cn12_enabled = true;
#elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
	/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
	gpio_request(GPIO_FN_SDHI1WP,  NULL);
	gpio_request(GPIO_FN_SDHI1CMD, NULL);
	gpio_request(GPIO_FN_SDHI1CLK, NULL);
	gpio_request(GPIO_FN_SDHI1D3,  NULL);
	gpio_request(GPIO_FN_SDHI1D2,  NULL);
	gpio_request(GPIO_FN_SDHI1D1,  NULL);
	gpio_request(GPIO_FN_SDHI1D0,  NULL);

	/* Card-detect, used on CN12 with SDHI1 */
	gpio_request(GPIO_PTW7, NULL);
	gpio_direction_input(GPIO_PTW7);

	cn12_enabled = true;
#endif

	if (cn12_enabled)
		/* I/O buffer drive ability is high for CN12 */
		__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000,
			     IODRIVEA);

1407 1408 1409 1410
	/* enable Video */
	gpio_request(GPIO_PTU2, NULL);
	gpio_direction_output(GPIO_PTU2, 1);

1411 1412 1413 1414 1415 1416
	/* enable Camera */
	gpio_request(GPIO_PTA3, NULL);
	gpio_request(GPIO_PTA4, NULL);
	gpio_direction_output(GPIO_PTA3, 0);
	gpio_direction_output(GPIO_PTA4, 0);

1417 1418 1419 1420 1421 1422 1423 1424 1425 1426
	/* enable FSI */
	gpio_request(GPIO_FN_FSIMCKB,    NULL);
	gpio_request(GPIO_FN_FSIIBSD,    NULL);
	gpio_request(GPIO_FN_FSIOBSD,    NULL);
	gpio_request(GPIO_FN_FSIIBBCK,   NULL);
	gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
	gpio_request(GPIO_FN_FSIOBBCK,   NULL);
	gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
	gpio_request(GPIO_FN_CLKAUDIOBO, NULL);

1427 1428
	/* set SPU2 clock to 83.4 MHz */
	clk = clk_get(NULL, "spu_clk");
1429
	if (!IS_ERR(clk)) {
1430 1431 1432
		clk_set_rate(clk, clk_round_rate(clk, 83333333));
		clk_put(clk);
	}
1433

1434 1435
	/* change parent of FSI B */
	clk = clk_get(NULL, "fsib_clk");
1436
	if (!IS_ERR(clk)) {
1437 1438 1439 1440
		/* 48kHz dummy clock was used to make sure 1/1 divide */
		clk_set_rate(&sh7724_fsimckb_clk, 48000);
		clk_set_parent(clk, &sh7724_fsimckb_clk);
		clk_set_rate(clk, 48000);
1441 1442
		clk_put(clk);
	}
1443 1444 1445 1446 1447

	gpio_request(GPIO_PTU0, NULL);
	gpio_direction_output(GPIO_PTU0, 0);
	mdelay(20);

1448 1449 1450 1451
	/* enable motion sensor */
	gpio_request(GPIO_FN_INTC_IRQ1, NULL);
	gpio_direction_input(GPIO_FN_INTC_IRQ1);

1452 1453
	/* set VPU clock to 166 MHz */
	clk = clk_get(NULL, "vpu_clk");
1454
	if (!IS_ERR(clk)) {
1455 1456 1457
		clk_set_rate(clk, clk_round_rate(clk, 166000000));
		clk_put(clk);
	}
1458

1459 1460 1461 1462 1463 1464
	/* enable IrDA */
	gpio_request(GPIO_FN_IRDA_OUT, NULL);
	gpio_request(GPIO_FN_IRDA_IN,  NULL);
	gpio_request(GPIO_PTU5, NULL);
	gpio_direction_output(GPIO_PTU5, 0);

1465
	/* enable I2C device */
1466 1467 1468
	i2c_register_board_info(0, i2c0_devices,
				ARRAY_SIZE(i2c0_devices));

1469 1470 1471
	i2c_register_board_info(1, i2c1_devices,
				ARRAY_SIZE(i2c1_devices));

1472
#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
	/* VOU */
	gpio_request(GPIO_FN_DV_D15, NULL);
	gpio_request(GPIO_FN_DV_D14, NULL);
	gpio_request(GPIO_FN_DV_D13, NULL);
	gpio_request(GPIO_FN_DV_D12, NULL);
	gpio_request(GPIO_FN_DV_D11, NULL);
	gpio_request(GPIO_FN_DV_D10, NULL);
	gpio_request(GPIO_FN_DV_D9, NULL);
	gpio_request(GPIO_FN_DV_D8, NULL);
	gpio_request(GPIO_FN_DV_CLKI, NULL);
	gpio_request(GPIO_FN_DV_CLK, NULL);
	gpio_request(GPIO_FN_DV_VSYNC, NULL);
	gpio_request(GPIO_FN_DV_HSYNC, NULL);

	/* AK8813 power / reset sequence */
	gpio_request(GPIO_PTG4, NULL);
	gpio_request(GPIO_PTU3, NULL);
	/* Reset */
	gpio_direction_output(GPIO_PTG4, 0);
	/* Power down */
	gpio_direction_output(GPIO_PTU3, 1);

	udelay(10);

	/* Power up, reset */
	gpio_set_value(GPIO_PTU3, 0);

	udelay(10);

	/* Remove reset */
	gpio_set_value(GPIO_PTG4, 1);
1504
#endif
1505

1506 1507 1508
	return platform_add_devices(ecovec_devices,
				    ARRAY_SIZE(ecovec_devices));
}
1509 1510 1511 1512
arch_initcall(arch_setup);

static int __init devices_setup(void)
{
1513
	sh_eth_init(&sh_eth_plat);
1514 1515 1516 1517
	return 0;
}
device_initcall(devices_setup);

1518 1519 1520
static struct sh_machine_vector mv_ecovec __initmv = {
	.mv_name	= "R0P7724 (EcoVec)",
};