Path: blob/master/arch/sh/boards/mach-ecovec24/setup.c
15126 views
/*1* Copyright (C) 2009 Renesas Solutions Corp.2*3* Kuninori Morimoto <[email protected]>4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/910#include <linux/init.h>11#include <linux/device.h>12#include <linux/platform_device.h>13#include <linux/mmc/host.h>14#include <linux/mmc/sh_mmcif.h>15#include <linux/mmc/sh_mobile_sdhi.h>16#include <linux/mtd/physmap.h>17#include <linux/gpio.h>18#include <linux/interrupt.h>19#include <linux/io.h>20#include <linux/delay.h>21#include <linux/usb/r8a66597.h>22#include <linux/usb/renesas_usbhs.h>23#include <linux/i2c.h>24#include <linux/i2c/tsc2007.h>25#include <linux/spi/spi.h>26#include <linux/spi/sh_msiof.h>27#include <linux/spi/mmc_spi.h>28#include <linux/input.h>29#include <linux/input/sh_keysc.h>30#include <video/sh_mobile_lcdc.h>31#include <sound/sh_fsi.h>32#include <media/sh_mobile_ceu.h>33#include <media/tw9910.h>34#include <media/mt9t112.h>35#include <asm/heartbeat.h>36#include <asm/sh_eth.h>37#include <asm/clock.h>38#include <asm/suspend.h>39#include <cpu/sh7724.h>4041/*42* Address Interface BusWidth43*-----------------------------------------44* 0x0000_0000 uboot 16bit45* 0x0004_0000 Linux romImage 16bit46* 0x0014_0000 MTD for Linux 16bit47* 0x0400_0000 Internal I/O 16/32bit48* 0x0800_0000 DRAM 32bit49* 0x1800_0000 MFI 16bit50*/5152/* SWITCH53*------------------------------54* DS2[1] = FlashROM write protect ON : write protect55* OFF : No write protect56* DS2[2] = RMII / TS, SCIF ON : RMII57* OFF : TS, SCIF358* DS2[3] = Camera / Video ON : Camera59* OFF : NTSC/PAL (IN)60* DS2[5] = NTSC_OUT Clock ON : On board OSC61* OFF : SH7724 DV_CLK62* DS2[6-7] = MMC / SD ON-OFF : SD63* OFF-ON : MMC64*/6566/* Heartbeat */67static unsigned char led_pos[] = { 0, 1, 2, 3 };6869static struct heartbeat_data heartbeat_data = {70.nr_bits = 4,71.bit_pos = led_pos,72};7374static struct resource heartbeat_resource = {75.start = 0xA405012C, /* PTG */76.end = 0xA405012E - 1,77.flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,78};7980static struct platform_device heartbeat_device = {81.name = "heartbeat",82.id = -1,83.dev = {84.platform_data = &heartbeat_data,85},86.num_resources = 1,87.resource = &heartbeat_resource,88};8990/* MTD */91static struct mtd_partition nor_flash_partitions[] = {92{93.name = "boot loader",94.offset = 0,95.size = (5 * 1024 * 1024),96.mask_flags = MTD_WRITEABLE, /* force read-only */97}, {98.name = "free-area",99.offset = MTDPART_OFS_APPEND,100.size = MTDPART_SIZ_FULL,101},102};103104static struct physmap_flash_data nor_flash_data = {105.width = 2,106.parts = nor_flash_partitions,107.nr_parts = ARRAY_SIZE(nor_flash_partitions),108};109110static struct resource nor_flash_resources[] = {111[0] = {112.name = "NOR Flash",113.start = 0x00000000,114.end = 0x03ffffff,115.flags = IORESOURCE_MEM,116}117};118119static struct platform_device nor_flash_device = {120.name = "physmap-flash",121.resource = nor_flash_resources,122.num_resources = ARRAY_SIZE(nor_flash_resources),123.dev = {124.platform_data = &nor_flash_data,125},126};127128/* SH Eth */129#define SH_ETH_ADDR (0xA4600000)130static struct resource sh_eth_resources[] = {131[0] = {132.start = SH_ETH_ADDR,133.end = SH_ETH_ADDR + 0x1FC,134.flags = IORESOURCE_MEM,135},136[1] = {137.start = 91,138.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,139},140};141142static struct sh_eth_plat_data sh_eth_plat = {143.phy = 0x1f, /* SMSC LAN8700 */144.edmac_endian = EDMAC_LITTLE_ENDIAN,145.register_type = SH_ETH_REG_FAST_SH4,146.phy_interface = PHY_INTERFACE_MODE_MII,147.ether_link_active_low = 1148};149150static struct platform_device sh_eth_device = {151.name = "sh-eth",152.id = 0,153.dev = {154.platform_data = &sh_eth_plat,155},156.num_resources = ARRAY_SIZE(sh_eth_resources),157.resource = sh_eth_resources,158.archdata = {159.hwblk_id = HWBLK_ETHER,160},161};162163/* USB0 host */164static void usb0_port_power(int port, int power)165{166gpio_set_value(GPIO_PTB4, power);167}168169static struct r8a66597_platdata usb0_host_data = {170.on_chip = 1,171.port_power = usb0_port_power,172};173174static struct resource usb0_host_resources[] = {175[0] = {176.start = 0xa4d80000,177.end = 0xa4d80124 - 1,178.flags = IORESOURCE_MEM,179},180[1] = {181.start = 65,182.end = 65,183.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,184},185};186187static struct platform_device usb0_host_device = {188.name = "r8a66597_hcd",189.id = 0,190.dev = {191.dma_mask = NULL, /* not use dma */192.coherent_dma_mask = 0xffffffff,193.platform_data = &usb0_host_data,194},195.num_resources = ARRAY_SIZE(usb0_host_resources),196.resource = usb0_host_resources,197};198199/* USB1 host/function */200static void usb1_port_power(int port, int power)201{202gpio_set_value(GPIO_PTB5, power);203}204205static struct r8a66597_platdata usb1_common_data = {206.on_chip = 1,207.port_power = usb1_port_power,208};209210static struct resource usb1_common_resources[] = {211[0] = {212.start = 0xa4d90000,213.end = 0xa4d90124 - 1,214.flags = IORESOURCE_MEM,215},216[1] = {217.start = 66,218.end = 66,219.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,220},221};222223static struct platform_device usb1_common_device = {224/* .name will be added in arch_setup */225.id = 1,226.dev = {227.dma_mask = NULL, /* not use dma */228.coherent_dma_mask = 0xffffffff,229.platform_data = &usb1_common_data,230},231.num_resources = ARRAY_SIZE(usb1_common_resources),232.resource = usb1_common_resources,233};234235/*236* USBHS237*/238static int usbhs_get_id(struct platform_device *pdev)239{240return gpio_get_value(GPIO_PTB3);241}242243static struct renesas_usbhs_platform_info usbhs_info = {244.platform_callback = {245.get_id = usbhs_get_id,246},247.driver_param = {248.buswait_bwait = 4,249.detection_delay = 5,250},251};252253static struct resource usbhs_resources[] = {254[0] = {255.start = 0xa4d90000,256.end = 0xa4d90124 - 1,257.flags = IORESOURCE_MEM,258},259[1] = {260.start = 66,261.end = 66,262.flags = IORESOURCE_IRQ,263},264};265266static struct platform_device usbhs_device = {267.name = "renesas_usbhs",268.id = 1,269.dev = {270.dma_mask = NULL, /* not use dma */271.coherent_dma_mask = 0xffffffff,272.platform_data = &usbhs_info,273},274.num_resources = ARRAY_SIZE(usbhs_resources),275.resource = usbhs_resources,276.archdata = {277.hwblk_id = HWBLK_USB1,278},279};280281/* LCDC */282const static struct fb_videomode ecovec_lcd_modes[] = {283{284.name = "Panel",285.xres = 800,286.yres = 480,287.left_margin = 220,288.right_margin = 110,289.hsync_len = 70,290.upper_margin = 20,291.lower_margin = 5,292.vsync_len = 5,293.sync = 0, /* hsync and vsync are active low */294},295};296297const static struct fb_videomode ecovec_dvi_modes[] = {298{299.name = "DVI",300.xres = 1280,301.yres = 720,302.left_margin = 220,303.right_margin = 110,304.hsync_len = 40,305.upper_margin = 20,306.lower_margin = 5,307.vsync_len = 5,308.sync = 0, /* hsync and vsync are active low */309},310};311312static int ecovec24_set_brightness(void *board_data, int brightness)313{314gpio_set_value(GPIO_PTR1, brightness);315316return 0;317}318319static int ecovec24_get_brightness(void *board_data)320{321return gpio_get_value(GPIO_PTR1);322}323324static struct sh_mobile_lcdc_info lcdc_info = {325.ch[0] = {326.interface_type = RGB18,327.chan = LCDC_CHAN_MAINLCD,328.bpp = 16,329.lcd_size_cfg = { /* 7.0 inch */330.width = 152,331.height = 91,332},333.board_cfg = {334.set_brightness = ecovec24_set_brightness,335.get_brightness = ecovec24_get_brightness,336},337.bl_info = {338.name = "sh_mobile_lcdc_bl",339.max_brightness = 1,340},341}342};343344static struct resource lcdc_resources[] = {345[0] = {346.name = "LCDC",347.start = 0xfe940000,348.end = 0xfe942fff,349.flags = IORESOURCE_MEM,350},351[1] = {352.start = 106,353.flags = IORESOURCE_IRQ,354},355};356357static struct platform_device lcdc_device = {358.name = "sh_mobile_lcdc_fb",359.num_resources = ARRAY_SIZE(lcdc_resources),360.resource = lcdc_resources,361.dev = {362.platform_data = &lcdc_info,363},364.archdata = {365.hwblk_id = HWBLK_LCDC,366},367};368369/* CEU0 */370static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {371.flags = SH_CEU_FLAG_USE_8BIT_BUS,372};373374static struct resource ceu0_resources[] = {375[0] = {376.name = "CEU0",377.start = 0xfe910000,378.end = 0xfe91009f,379.flags = IORESOURCE_MEM,380},381[1] = {382.start = 52,383.flags = IORESOURCE_IRQ,384},385[2] = {386/* place holder for contiguous memory */387},388};389390static struct platform_device ceu0_device = {391.name = "sh_mobile_ceu",392.id = 0, /* "ceu0" clock */393.num_resources = ARRAY_SIZE(ceu0_resources),394.resource = ceu0_resources,395.dev = {396.platform_data = &sh_mobile_ceu0_info,397},398.archdata = {399.hwblk_id = HWBLK_CEU0,400},401};402403/* CEU1 */404static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {405.flags = SH_CEU_FLAG_USE_8BIT_BUS,406};407408static struct resource ceu1_resources[] = {409[0] = {410.name = "CEU1",411.start = 0xfe914000,412.end = 0xfe91409f,413.flags = IORESOURCE_MEM,414},415[1] = {416.start = 63,417.flags = IORESOURCE_IRQ,418},419[2] = {420/* place holder for contiguous memory */421},422};423424static struct platform_device ceu1_device = {425.name = "sh_mobile_ceu",426.id = 1, /* "ceu1" clock */427.num_resources = ARRAY_SIZE(ceu1_resources),428.resource = ceu1_resources,429.dev = {430.platform_data = &sh_mobile_ceu1_info,431},432.archdata = {433.hwblk_id = HWBLK_CEU1,434},435};436437/* I2C device */438static struct i2c_board_info i2c0_devices[] = {439{440I2C_BOARD_INFO("da7210", 0x1a),441},442};443444static struct i2c_board_info i2c1_devices[] = {445{446I2C_BOARD_INFO("r2025sd", 0x32),447},448{449I2C_BOARD_INFO("lis3lv02d", 0x1c),450.irq = 33,451}452};453454/* KEYSC */455static struct sh_keysc_info keysc_info = {456.mode = SH_KEYSC_MODE_1,457.scan_timing = 3,458.delay = 50,459.kycr2_delay = 100,460.keycodes = { KEY_1, 0, 0, 0, 0,461KEY_2, 0, 0, 0, 0,462KEY_3, 0, 0, 0, 0,463KEY_4, 0, 0, 0, 0,464KEY_5, 0, 0, 0, 0,465KEY_6, 0, 0, 0, 0, },466};467468static struct resource keysc_resources[] = {469[0] = {470.name = "KEYSC",471.start = 0x044b0000,472.end = 0x044b000f,473.flags = IORESOURCE_MEM,474},475[1] = {476.start = 79,477.flags = IORESOURCE_IRQ,478},479};480481static struct platform_device keysc_device = {482.name = "sh_keysc",483.id = 0, /* keysc0 clock */484.num_resources = ARRAY_SIZE(keysc_resources),485.resource = keysc_resources,486.dev = {487.platform_data = &keysc_info,488},489.archdata = {490.hwblk_id = HWBLK_KEYSC,491},492};493494/* TouchScreen */495#define IRQ0 32496static int ts_get_pendown_state(void)497{498int val = 0;499gpio_free(GPIO_FN_INTC_IRQ0);500gpio_request(GPIO_PTZ0, NULL);501gpio_direction_input(GPIO_PTZ0);502503val = gpio_get_value(GPIO_PTZ0);504505gpio_free(GPIO_PTZ0);506gpio_request(GPIO_FN_INTC_IRQ0, NULL);507508return val ? 0 : 1;509}510511static int ts_init(void)512{513gpio_request(GPIO_FN_INTC_IRQ0, NULL);514return 0;515}516517static struct tsc2007_platform_data tsc2007_info = {518.model = 2007,519.x_plate_ohms = 180,520.get_pendown_state = ts_get_pendown_state,521.init_platform_hw = ts_init,522};523524static struct i2c_board_info ts_i2c_clients = {525I2C_BOARD_INFO("tsc2007", 0x48),526.type = "tsc2007",527.platform_data = &tsc2007_info,528.irq = IRQ0,529};530531#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)532/* SDHI0 */533static void sdhi0_set_pwr(struct platform_device *pdev, int state)534{535gpio_set_value(GPIO_PTB6, state);536}537538static struct sh_mobile_sdhi_info sdhi0_info = {539.dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,540.dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,541.set_pwr = sdhi0_set_pwr,542.tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,543};544545static struct resource sdhi0_resources[] = {546[0] = {547.name = "SDHI0",548.start = 0x04ce0000,549.end = 0x04ce00ff,550.flags = IORESOURCE_MEM,551},552[1] = {553.start = 100,554.flags = IORESOURCE_IRQ,555},556};557558static struct platform_device sdhi0_device = {559.name = "sh_mobile_sdhi",560.num_resources = ARRAY_SIZE(sdhi0_resources),561.resource = sdhi0_resources,562.id = 0,563.dev = {564.platform_data = &sdhi0_info,565},566.archdata = {567.hwblk_id = HWBLK_SDHI0,568},569};570571#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)572/* SDHI1 */573static void sdhi1_set_pwr(struct platform_device *pdev, int state)574{575gpio_set_value(GPIO_PTB7, state);576}577578static struct sh_mobile_sdhi_info sdhi1_info = {579.dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,580.dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,581.tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,582.set_pwr = sdhi1_set_pwr,583};584585static struct resource sdhi1_resources[] = {586[0] = {587.name = "SDHI1",588.start = 0x04cf0000,589.end = 0x04cf00ff,590.flags = IORESOURCE_MEM,591},592[1] = {593.start = 23,594.flags = IORESOURCE_IRQ,595},596};597598static struct platform_device sdhi1_device = {599.name = "sh_mobile_sdhi",600.num_resources = ARRAY_SIZE(sdhi1_resources),601.resource = sdhi1_resources,602.id = 1,603.dev = {604.platform_data = &sdhi1_info,605},606.archdata = {607.hwblk_id = HWBLK_SDHI1,608},609};610#endif /* CONFIG_MMC_SH_MMCIF */611612#else613614/* MMC SPI */615static int mmc_spi_get_ro(struct device *dev)616{617return gpio_get_value(GPIO_PTY6);618}619620static int mmc_spi_get_cd(struct device *dev)621{622return !gpio_get_value(GPIO_PTY7);623}624625static void mmc_spi_setpower(struct device *dev, unsigned int maskval)626{627gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);628}629630static struct mmc_spi_platform_data mmc_spi_info = {631.get_ro = mmc_spi_get_ro,632.get_cd = mmc_spi_get_cd,633.caps = MMC_CAP_NEEDS_POLL,634.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */635.setpower = mmc_spi_setpower,636};637638static struct spi_board_info spi_bus[] = {639{640.modalias = "mmc_spi",641.platform_data = &mmc_spi_info,642.max_speed_hz = 5000000,643.mode = SPI_MODE_0,644.controller_data = (void *) GPIO_PTM4,645},646};647648/* MSIOF0 */649static struct sh_msiof_spi_info msiof0_data = {650.num_chipselect = 1,651};652653static struct resource msiof0_resources[] = {654[0] = {655.name = "MSIOF0",656.start = 0xa4c40000,657.end = 0xa4c40063,658.flags = IORESOURCE_MEM,659},660[1] = {661.start = 84,662.flags = IORESOURCE_IRQ,663},664};665666static struct platform_device msiof0_device = {667.name = "spi_sh_msiof",668.id = 0, /* MSIOF0 */669.dev = {670.platform_data = &msiof0_data,671},672.num_resources = ARRAY_SIZE(msiof0_resources),673.resource = msiof0_resources,674.archdata = {675.hwblk_id = HWBLK_MSIOF0,676},677};678679#endif680681/* I2C Video/Camera */682static struct i2c_board_info i2c_camera[] = {683{684I2C_BOARD_INFO("tw9910", 0x45),685},686{687/* 1st camera */688I2C_BOARD_INFO("mt9t112", 0x3c),689},690{691/* 2nd camera */692I2C_BOARD_INFO("mt9t112", 0x3c),693},694};695696/* tw9910 */697static int tw9910_power(struct device *dev, int mode)698{699int val = mode ? 0 : 1;700701gpio_set_value(GPIO_PTU2, val);702if (mode)703mdelay(100);704705return 0;706}707708static struct tw9910_video_info tw9910_info = {709.buswidth = SOCAM_DATAWIDTH_8,710.mpout = TW9910_MPO_FIELD,711};712713static struct soc_camera_link tw9910_link = {714.i2c_adapter_id = 0,715.bus_id = 1,716.power = tw9910_power,717.board_info = &i2c_camera[0],718.priv = &tw9910_info,719};720721/* mt9t112 */722static int mt9t112_power1(struct device *dev, int mode)723{724gpio_set_value(GPIO_PTA3, mode);725if (mode)726mdelay(100);727728return 0;729}730731static struct mt9t112_camera_info mt9t112_info1 = {732.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,733.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */734};735736static struct soc_camera_link mt9t112_link1 = {737.i2c_adapter_id = 0,738.power = mt9t112_power1,739.bus_id = 0,740.board_info = &i2c_camera[1],741.priv = &mt9t112_info1,742};743744static int mt9t112_power2(struct device *dev, int mode)745{746gpio_set_value(GPIO_PTA4, mode);747if (mode)748mdelay(100);749750return 0;751}752753static struct mt9t112_camera_info mt9t112_info2 = {754.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,755.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */756};757758static struct soc_camera_link mt9t112_link2 = {759.i2c_adapter_id = 1,760.power = mt9t112_power2,761.bus_id = 1,762.board_info = &i2c_camera[2],763.priv = &mt9t112_info2,764};765766static struct platform_device camera_devices[] = {767{768.name = "soc-camera-pdrv",769.id = 0,770.dev = {771.platform_data = &tw9910_link,772},773},774{775.name = "soc-camera-pdrv",776.id = 1,777.dev = {778.platform_data = &mt9t112_link1,779},780},781{782.name = "soc-camera-pdrv",783.id = 2,784.dev = {785.platform_data = &mt9t112_link2,786},787},788};789790/* FSI */791static struct sh_fsi_platform_info fsi_info = {792.portb_flags = SH_FSI_BRS_INV,793};794795static struct resource fsi_resources[] = {796[0] = {797.name = "FSI",798.start = 0xFE3C0000,799.end = 0xFE3C021d,800.flags = IORESOURCE_MEM,801},802[1] = {803.start = 108,804.flags = IORESOURCE_IRQ,805},806};807808static struct platform_device fsi_device = {809.name = "sh_fsi",810.id = 0,811.num_resources = ARRAY_SIZE(fsi_resources),812.resource = fsi_resources,813.dev = {814.platform_data = &fsi_info,815},816.archdata = {817.hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */818},819};820821/* IrDA */822static struct resource irda_resources[] = {823[0] = {824.name = "IrDA",825.start = 0xA45D0000,826.end = 0xA45D0049,827.flags = IORESOURCE_MEM,828},829[1] = {830.start = 20,831.flags = IORESOURCE_IRQ,832},833};834835static struct platform_device irda_device = {836.name = "sh_sir",837.num_resources = ARRAY_SIZE(irda_resources),838.resource = irda_resources,839};840841#include <media/ak881x.h>842#include <media/sh_vou.h>843844static struct ak881x_pdata ak881x_pdata = {845.flags = AK881X_IF_MODE_SLAVE,846};847848static struct i2c_board_info ak8813 = {849I2C_BOARD_INFO("ak8813", 0x20),850.platform_data = &ak881x_pdata,851};852853static struct sh_vou_pdata sh_vou_pdata = {854.bus_fmt = SH_VOU_BUS_8BIT,855.flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,856.board_info = &ak8813,857.i2c_adap = 0,858};859860static struct resource sh_vou_resources[] = {861[0] = {862.start = 0xfe960000,863.end = 0xfe962043,864.flags = IORESOURCE_MEM,865},866[1] = {867.start = 55,868.flags = IORESOURCE_IRQ,869},870};871872static struct platform_device vou_device = {873.name = "sh-vou",874.id = -1,875.num_resources = ARRAY_SIZE(sh_vou_resources),876.resource = sh_vou_resources,877.dev = {878.platform_data = &sh_vou_pdata,879},880.archdata = {881.hwblk_id = HWBLK_VOU,882},883};884885#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)886/* SH_MMCIF */887static void mmcif_set_pwr(struct platform_device *pdev, int state)888{889gpio_set_value(GPIO_PTB7, state);890}891892static void mmcif_down_pwr(struct platform_device *pdev)893{894gpio_set_value(GPIO_PTB7, 0);895}896897static struct resource sh_mmcif_resources[] = {898[0] = {899.name = "SH_MMCIF",900.start = 0xA4CA0000,901.end = 0xA4CA00FF,902.flags = IORESOURCE_MEM,903},904[1] = {905/* MMC2I */906.start = 29,907.flags = IORESOURCE_IRQ,908},909[2] = {910/* MMC3I */911.start = 30,912.flags = IORESOURCE_IRQ,913},914};915916static struct sh_mmcif_plat_data sh_mmcif_plat = {917.set_pwr = mmcif_set_pwr,918.down_pwr = mmcif_down_pwr,919.sup_pclk = 0, /* SH7724: Max Pclk/2 */920.caps = MMC_CAP_4_BIT_DATA |921MMC_CAP_8_BIT_DATA |922MMC_CAP_NEEDS_POLL,923.ocr = MMC_VDD_32_33 | MMC_VDD_33_34,924};925926static struct platform_device sh_mmcif_device = {927.name = "sh_mmcif",928.id = 0,929.dev = {930.platform_data = &sh_mmcif_plat,931},932.num_resources = ARRAY_SIZE(sh_mmcif_resources),933.resource = sh_mmcif_resources,934.archdata = {935.hwblk_id = HWBLK_MMC,936},937};938#endif939940static struct platform_device *ecovec_devices[] __initdata = {941&heartbeat_device,942&nor_flash_device,943&sh_eth_device,944&usb0_host_device,945&usb1_common_device,946&usbhs_device,947&lcdc_device,948&ceu0_device,949&ceu1_device,950&keysc_device,951#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)952&sdhi0_device,953#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)954&sdhi1_device,955#endif956#else957&msiof0_device,958#endif959&camera_devices[0],960&camera_devices[1],961&camera_devices[2],962&fsi_device,963&irda_device,964&vou_device,965#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)966&sh_mmcif_device,967#endif968};969970#ifdef CONFIG_I2C971#define EEPROM_ADDR 0x50972static u8 mac_read(struct i2c_adapter *a, u8 command)973{974struct i2c_msg msg[2];975u8 buf;976int ret;977978msg[0].addr = EEPROM_ADDR;979msg[0].flags = 0;980msg[0].len = 1;981msg[0].buf = &command;982983msg[1].addr = EEPROM_ADDR;984msg[1].flags = I2C_M_RD;985msg[1].len = 1;986msg[1].buf = &buf;987988ret = i2c_transfer(a, msg, 2);989if (ret < 0) {990printk(KERN_ERR "error %d\n", ret);991buf = 0xff;992}993994return buf;995}996997static void __init sh_eth_init(struct sh_eth_plat_data *pd)998{999struct i2c_adapter *a = i2c_get_adapter(1);1000int i;10011002if (!a) {1003pr_err("can not get I2C 1\n");1004return;1005}10061007/* read MAC address from EEPROM */1008for (i = 0; i < sizeof(pd->mac_addr); i++) {1009pd->mac_addr[i] = mac_read(a, 0x10 + i);1010msleep(10);1011}10121013i2c_put_adapter(a);1014}1015#else1016static void __init sh_eth_init(struct sh_eth_plat_data *pd)1017{1018pr_err("unable to read sh_eth MAC address\n");1019}1020#endif10211022#define PORT_HIZA 0xA40501581023#define IODRIVEA 0xA405018A10241025extern char ecovec24_sdram_enter_start;1026extern char ecovec24_sdram_enter_end;1027extern char ecovec24_sdram_leave_start;1028extern char ecovec24_sdram_leave_end;10291030static int __init arch_setup(void)1031{1032struct clk *clk;10331034/* register board specific self-refresh code */1035sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |1036SUSP_SH_RSTANDBY,1037&ecovec24_sdram_enter_start,1038&ecovec24_sdram_enter_end,1039&ecovec24_sdram_leave_start,1040&ecovec24_sdram_leave_end);10411042/* enable STATUS0, STATUS2 and PDSTATUS */1043gpio_request(GPIO_FN_STATUS0, NULL);1044gpio_request(GPIO_FN_STATUS2, NULL);1045gpio_request(GPIO_FN_PDSTATUS, NULL);10461047/* enable SCIFA0 */1048gpio_request(GPIO_FN_SCIF0_TXD, NULL);1049gpio_request(GPIO_FN_SCIF0_RXD, NULL);10501051/* enable debug LED */1052gpio_request(GPIO_PTG0, NULL);1053gpio_request(GPIO_PTG1, NULL);1054gpio_request(GPIO_PTG2, NULL);1055gpio_request(GPIO_PTG3, NULL);1056gpio_direction_output(GPIO_PTG0, 0);1057gpio_direction_output(GPIO_PTG1, 0);1058gpio_direction_output(GPIO_PTG2, 0);1059gpio_direction_output(GPIO_PTG3, 0);1060__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);10611062/* enable SH-Eth */1063gpio_request(GPIO_PTA1, NULL);1064gpio_direction_output(GPIO_PTA1, 1);1065mdelay(20);10661067gpio_request(GPIO_FN_RMII_RXD0, NULL);1068gpio_request(GPIO_FN_RMII_RXD1, NULL);1069gpio_request(GPIO_FN_RMII_TXD0, NULL);1070gpio_request(GPIO_FN_RMII_TXD1, NULL);1071gpio_request(GPIO_FN_RMII_REF_CLK, NULL);1072gpio_request(GPIO_FN_RMII_TX_EN, NULL);1073gpio_request(GPIO_FN_RMII_RX_ER, NULL);1074gpio_request(GPIO_FN_RMII_CRS_DV, NULL);1075gpio_request(GPIO_FN_MDIO, NULL);1076gpio_request(GPIO_FN_MDC, NULL);1077gpio_request(GPIO_FN_LNKSTA, NULL);10781079/* enable USB */1080__raw_writew(0x0000, 0xA4D80000);1081__raw_writew(0x0000, 0xA4D90000);1082gpio_request(GPIO_PTB3, NULL);1083gpio_request(GPIO_PTB4, NULL);1084gpio_request(GPIO_PTB5, NULL);1085gpio_direction_input(GPIO_PTB3);1086gpio_direction_output(GPIO_PTB4, 0);1087gpio_direction_output(GPIO_PTB5, 0);1088__raw_writew(0x0600, 0xa40501d4);1089__raw_writew(0x0600, 0xa4050192);10901091if (gpio_get_value(GPIO_PTB3)) {1092printk(KERN_INFO "USB1 function is selected\n");1093usb1_common_device.name = "r8a66597_udc";1094} else {1095printk(KERN_INFO "USB1 host is selected\n");1096usb1_common_device.name = "r8a66597_hcd";1097}10981099/* enable LCDC */1100gpio_request(GPIO_FN_LCDD23, NULL);1101gpio_request(GPIO_FN_LCDD22, NULL);1102gpio_request(GPIO_FN_LCDD21, NULL);1103gpio_request(GPIO_FN_LCDD20, NULL);1104gpio_request(GPIO_FN_LCDD19, NULL);1105gpio_request(GPIO_FN_LCDD18, NULL);1106gpio_request(GPIO_FN_LCDD17, NULL);1107gpio_request(GPIO_FN_LCDD16, NULL);1108gpio_request(GPIO_FN_LCDD15, NULL);1109gpio_request(GPIO_FN_LCDD14, NULL);1110gpio_request(GPIO_FN_LCDD13, NULL);1111gpio_request(GPIO_FN_LCDD12, NULL);1112gpio_request(GPIO_FN_LCDD11, NULL);1113gpio_request(GPIO_FN_LCDD10, NULL);1114gpio_request(GPIO_FN_LCDD9, NULL);1115gpio_request(GPIO_FN_LCDD8, NULL);1116gpio_request(GPIO_FN_LCDD7, NULL);1117gpio_request(GPIO_FN_LCDD6, NULL);1118gpio_request(GPIO_FN_LCDD5, NULL);1119gpio_request(GPIO_FN_LCDD4, NULL);1120gpio_request(GPIO_FN_LCDD3, NULL);1121gpio_request(GPIO_FN_LCDD2, NULL);1122gpio_request(GPIO_FN_LCDD1, NULL);1123gpio_request(GPIO_FN_LCDD0, NULL);1124gpio_request(GPIO_FN_LCDDISP, NULL);1125gpio_request(GPIO_FN_LCDHSYN, NULL);1126gpio_request(GPIO_FN_LCDDCK, NULL);1127gpio_request(GPIO_FN_LCDVSYN, NULL);1128gpio_request(GPIO_FN_LCDDON, NULL);1129gpio_request(GPIO_FN_LCDLCLK, NULL);1130__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);11311132gpio_request(GPIO_PTE6, NULL);1133gpio_request(GPIO_PTU1, NULL);1134gpio_request(GPIO_PTR1, NULL);1135gpio_request(GPIO_PTA2, NULL);1136gpio_direction_input(GPIO_PTE6);1137gpio_direction_output(GPIO_PTU1, 0);1138gpio_direction_output(GPIO_PTR1, 0);1139gpio_direction_output(GPIO_PTA2, 0);11401141/* I/O buffer drive ability is high */1142__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);11431144if (gpio_get_value(GPIO_PTE6)) {1145/* DVI */1146lcdc_info.clock_source = LCDC_CLK_EXTERNAL;1147lcdc_info.ch[0].clock_divider = 1;1148lcdc_info.ch[0].lcd_cfg = ecovec_dvi_modes;1149lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_dvi_modes);11501151gpio_set_value(GPIO_PTA2, 1);1152gpio_set_value(GPIO_PTU1, 1);1153} else {1154/* Panel */1155lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;1156lcdc_info.ch[0].clock_divider = 2;1157lcdc_info.ch[0].lcd_cfg = ecovec_lcd_modes;1158lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_lcd_modes);11591160gpio_set_value(GPIO_PTR1, 1);11611162/* FIXME1163*1164* LCDDON control is needed for Panel,1165* but current sh_mobile_lcdc driver doesn't control it.1166* It is temporary correspondence1167*/1168gpio_request(GPIO_PTF4, NULL);1169gpio_direction_output(GPIO_PTF4, 1);11701171/* enable TouchScreen */1172i2c_register_board_info(0, &ts_i2c_clients, 1);1173irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);1174}11751176/* enable CEU0 */1177gpio_request(GPIO_FN_VIO0_D15, NULL);1178gpio_request(GPIO_FN_VIO0_D14, NULL);1179gpio_request(GPIO_FN_VIO0_D13, NULL);1180gpio_request(GPIO_FN_VIO0_D12, NULL);1181gpio_request(GPIO_FN_VIO0_D11, NULL);1182gpio_request(GPIO_FN_VIO0_D10, NULL);1183gpio_request(GPIO_FN_VIO0_D9, NULL);1184gpio_request(GPIO_FN_VIO0_D8, NULL);1185gpio_request(GPIO_FN_VIO0_D7, NULL);1186gpio_request(GPIO_FN_VIO0_D6, NULL);1187gpio_request(GPIO_FN_VIO0_D5, NULL);1188gpio_request(GPIO_FN_VIO0_D4, NULL);1189gpio_request(GPIO_FN_VIO0_D3, NULL);1190gpio_request(GPIO_FN_VIO0_D2, NULL);1191gpio_request(GPIO_FN_VIO0_D1, NULL);1192gpio_request(GPIO_FN_VIO0_D0, NULL);1193gpio_request(GPIO_FN_VIO0_VD, NULL);1194gpio_request(GPIO_FN_VIO0_CLK, NULL);1195gpio_request(GPIO_FN_VIO0_FLD, NULL);1196gpio_request(GPIO_FN_VIO0_HD, NULL);1197platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);11981199/* enable CEU1 */1200gpio_request(GPIO_FN_VIO1_D7, NULL);1201gpio_request(GPIO_FN_VIO1_D6, NULL);1202gpio_request(GPIO_FN_VIO1_D5, NULL);1203gpio_request(GPIO_FN_VIO1_D4, NULL);1204gpio_request(GPIO_FN_VIO1_D3, NULL);1205gpio_request(GPIO_FN_VIO1_D2, NULL);1206gpio_request(GPIO_FN_VIO1_D1, NULL);1207gpio_request(GPIO_FN_VIO1_D0, NULL);1208gpio_request(GPIO_FN_VIO1_FLD, NULL);1209gpio_request(GPIO_FN_VIO1_HD, NULL);1210gpio_request(GPIO_FN_VIO1_VD, NULL);1211gpio_request(GPIO_FN_VIO1_CLK, NULL);1212platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);12131214/* enable KEYSC */1215gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);1216gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);1217gpio_request(GPIO_FN_KEYOUT3, NULL);1218gpio_request(GPIO_FN_KEYOUT2, NULL);1219gpio_request(GPIO_FN_KEYOUT1, NULL);1220gpio_request(GPIO_FN_KEYOUT0, NULL);1221gpio_request(GPIO_FN_KEYIN0, NULL);12221223/* enable user debug switch */1224gpio_request(GPIO_PTR0, NULL);1225gpio_request(GPIO_PTR4, NULL);1226gpio_request(GPIO_PTR5, NULL);1227gpio_request(GPIO_PTR6, NULL);1228gpio_direction_input(GPIO_PTR0);1229gpio_direction_input(GPIO_PTR4);1230gpio_direction_input(GPIO_PTR5);1231gpio_direction_input(GPIO_PTR6);12321233#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)1234/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */1235gpio_request(GPIO_FN_SDHI0CD, NULL);1236gpio_request(GPIO_FN_SDHI0WP, NULL);1237gpio_request(GPIO_FN_SDHI0CMD, NULL);1238gpio_request(GPIO_FN_SDHI0CLK, NULL);1239gpio_request(GPIO_FN_SDHI0D3, NULL);1240gpio_request(GPIO_FN_SDHI0D2, NULL);1241gpio_request(GPIO_FN_SDHI0D1, NULL);1242gpio_request(GPIO_FN_SDHI0D0, NULL);1243gpio_request(GPIO_PTB6, NULL);1244gpio_direction_output(GPIO_PTB6, 0);12451246#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)1247/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */1248gpio_request(GPIO_FN_SDHI1CD, NULL);1249gpio_request(GPIO_FN_SDHI1WP, NULL);1250gpio_request(GPIO_FN_SDHI1CMD, NULL);1251gpio_request(GPIO_FN_SDHI1CLK, NULL);1252gpio_request(GPIO_FN_SDHI1D3, NULL);1253gpio_request(GPIO_FN_SDHI1D2, NULL);1254gpio_request(GPIO_FN_SDHI1D1, NULL);1255gpio_request(GPIO_FN_SDHI1D0, NULL);1256gpio_request(GPIO_PTB7, NULL);1257gpio_direction_output(GPIO_PTB7, 0);12581259/* I/O buffer drive ability is high for SDHI1 */1260__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);1261#endif /* CONFIG_MMC_SH_MMCIF */1262#else1263/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */1264gpio_request(GPIO_FN_MSIOF0_TXD, NULL);1265gpio_request(GPIO_FN_MSIOF0_RXD, NULL);1266gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);1267gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */1268gpio_direction_output(GPIO_PTM4, 1); /* active low CS */1269gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */1270gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */1271gpio_request(GPIO_PTY6, NULL); /* write protect */1272gpio_direction_input(GPIO_PTY6);1273gpio_request(GPIO_PTY7, NULL); /* card detect */1274gpio_direction_input(GPIO_PTY7);12751276spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));1277#endif12781279/* enable Video */1280gpio_request(GPIO_PTU2, NULL);1281gpio_direction_output(GPIO_PTU2, 1);12821283/* enable Camera */1284gpio_request(GPIO_PTA3, NULL);1285gpio_request(GPIO_PTA4, NULL);1286gpio_direction_output(GPIO_PTA3, 0);1287gpio_direction_output(GPIO_PTA4, 0);12881289/* enable FSI */1290gpio_request(GPIO_FN_FSIMCKB, NULL);1291gpio_request(GPIO_FN_FSIIBSD, NULL);1292gpio_request(GPIO_FN_FSIOBSD, NULL);1293gpio_request(GPIO_FN_FSIIBBCK, NULL);1294gpio_request(GPIO_FN_FSIIBLRCK, NULL);1295gpio_request(GPIO_FN_FSIOBBCK, NULL);1296gpio_request(GPIO_FN_FSIOBLRCK, NULL);1297gpio_request(GPIO_FN_CLKAUDIOBO, NULL);12981299/* set SPU2 clock to 83.4 MHz */1300clk = clk_get(NULL, "spu_clk");1301if (!IS_ERR(clk)) {1302clk_set_rate(clk, clk_round_rate(clk, 83333333));1303clk_put(clk);1304}13051306/* change parent of FSI B */1307clk = clk_get(NULL, "fsib_clk");1308if (!IS_ERR(clk)) {1309/* 48kHz dummy clock was used to make sure 1/1 divide */1310clk_set_rate(&sh7724_fsimckb_clk, 48000);1311clk_set_parent(clk, &sh7724_fsimckb_clk);1312clk_set_rate(clk, 48000);1313clk_put(clk);1314}13151316gpio_request(GPIO_PTU0, NULL);1317gpio_direction_output(GPIO_PTU0, 0);1318mdelay(20);13191320/* enable motion sensor */1321gpio_request(GPIO_FN_INTC_IRQ1, NULL);1322gpio_direction_input(GPIO_FN_INTC_IRQ1);13231324/* set VPU clock to 166 MHz */1325clk = clk_get(NULL, "vpu_clk");1326if (!IS_ERR(clk)) {1327clk_set_rate(clk, clk_round_rate(clk, 166000000));1328clk_put(clk);1329}13301331/* enable IrDA */1332gpio_request(GPIO_FN_IRDA_OUT, NULL);1333gpio_request(GPIO_FN_IRDA_IN, NULL);1334gpio_request(GPIO_PTU5, NULL);1335gpio_direction_output(GPIO_PTU5, 0);13361337#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)1338/* enable MMCIF (needs DS2.6,7 set to OFF,ON) */1339gpio_request(GPIO_FN_MMC_D7, NULL);1340gpio_request(GPIO_FN_MMC_D6, NULL);1341gpio_request(GPIO_FN_MMC_D5, NULL);1342gpio_request(GPIO_FN_MMC_D4, NULL);1343gpio_request(GPIO_FN_MMC_D3, NULL);1344gpio_request(GPIO_FN_MMC_D2, NULL);1345gpio_request(GPIO_FN_MMC_D1, NULL);1346gpio_request(GPIO_FN_MMC_D0, NULL);1347gpio_request(GPIO_FN_MMC_CLK, NULL);1348gpio_request(GPIO_FN_MMC_CMD, NULL);1349gpio_request(GPIO_PTB7, NULL);1350gpio_direction_output(GPIO_PTB7, 0);13511352/* I/O buffer drive ability is high for MMCIF */1353__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);1354#endif13551356/* enable I2C device */1357i2c_register_board_info(0, i2c0_devices,1358ARRAY_SIZE(i2c0_devices));13591360i2c_register_board_info(1, i2c1_devices,1361ARRAY_SIZE(i2c1_devices));13621363#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)1364/* VOU */1365gpio_request(GPIO_FN_DV_D15, NULL);1366gpio_request(GPIO_FN_DV_D14, NULL);1367gpio_request(GPIO_FN_DV_D13, NULL);1368gpio_request(GPIO_FN_DV_D12, NULL);1369gpio_request(GPIO_FN_DV_D11, NULL);1370gpio_request(GPIO_FN_DV_D10, NULL);1371gpio_request(GPIO_FN_DV_D9, NULL);1372gpio_request(GPIO_FN_DV_D8, NULL);1373gpio_request(GPIO_FN_DV_CLKI, NULL);1374gpio_request(GPIO_FN_DV_CLK, NULL);1375gpio_request(GPIO_FN_DV_VSYNC, NULL);1376gpio_request(GPIO_FN_DV_HSYNC, NULL);13771378/* AK8813 power / reset sequence */1379gpio_request(GPIO_PTG4, NULL);1380gpio_request(GPIO_PTU3, NULL);1381/* Reset */1382gpio_direction_output(GPIO_PTG4, 0);1383/* Power down */1384gpio_direction_output(GPIO_PTU3, 1);13851386udelay(10);13871388/* Power up, reset */1389gpio_set_value(GPIO_PTU3, 0);13901391udelay(10);13921393/* Remove reset */1394gpio_set_value(GPIO_PTG4, 1);1395#endif13961397return platform_add_devices(ecovec_devices,1398ARRAY_SIZE(ecovec_devices));1399}1400arch_initcall(arch_setup);14011402static int __init devices_setup(void)1403{1404sh_eth_init(&sh_eth_plat);1405return 0;1406}1407device_initcall(devices_setup);14081409static struct sh_machine_vector mv_ecovec __initmv = {1410.mv_name = "R0P7724 (EcoVec)",1411};141214131414