Path: blob/master/arch/arm/mach-imx/mach-mx31_3ds.c
10817 views
/*1* Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; either version 2 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*/1314#include <linux/delay.h>15#include <linux/types.h>16#include <linux/init.h>17#include <linux/clk.h>18#include <linux/irq.h>19#include <linux/gpio.h>20#include <linux/platform_device.h>21#include <linux/mfd/mc13783.h>22#include <linux/spi/spi.h>23#include <linux/spi/l4f00242t03.h>24#include <linux/regulator/machine.h>25#include <linux/usb/otg.h>26#include <linux/usb/ulpi.h>27#include <linux/memblock.h>2829#include <media/soc_camera.h>3031#include <mach/hardware.h>32#include <asm/mach-types.h>33#include <asm/mach/arch.h>34#include <asm/mach/time.h>35#include <asm/memory.h>36#include <asm/mach/map.h>37#include <mach/common.h>38#include <mach/iomux-mx3.h>39#include <mach/3ds_debugboard.h>40#include <mach/ulpi.h>4142#include "devices-imx31.h"4344/* CPLD IRQ line for external uart, external ethernet etc */45#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)4647static int mx31_3ds_pins[] = {48/* UART1 */49MX31_PIN_CTS1__CTS1,50MX31_PIN_RTS1__RTS1,51MX31_PIN_TXD1__TXD1,52MX31_PIN_RXD1__RXD1,53IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO),54/*SPI0*/55MX31_PIN_CSPI1_SCLK__SCLK,56MX31_PIN_CSPI1_MOSI__MOSI,57MX31_PIN_CSPI1_MISO__MISO,58MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,59MX31_PIN_CSPI1_SS2__SS2, /* CS for LCD */60/* SPI 1 */61MX31_PIN_CSPI2_SCLK__SCLK,62MX31_PIN_CSPI2_MOSI__MOSI,63MX31_PIN_CSPI2_MISO__MISO,64MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,65MX31_PIN_CSPI2_SS0__SS0,66MX31_PIN_CSPI2_SS2__SS2, /*CS for MC13783 */67/* MC13783 IRQ */68IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO),69/* USB OTG reset */70IOMUX_MODE(MX31_PIN_USB_PWR, IOMUX_CONFIG_GPIO),71/* USB OTG */72MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,73MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,74MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,75MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,76MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,77MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,78MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,79MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,80MX31_PIN_USBOTG_CLK__USBOTG_CLK,81MX31_PIN_USBOTG_DIR__USBOTG_DIR,82MX31_PIN_USBOTG_NXT__USBOTG_NXT,83MX31_PIN_USBOTG_STP__USBOTG_STP,84/*Keyboard*/85MX31_PIN_KEY_ROW0_KEY_ROW0,86MX31_PIN_KEY_ROW1_KEY_ROW1,87MX31_PIN_KEY_ROW2_KEY_ROW2,88MX31_PIN_KEY_COL0_KEY_COL0,89MX31_PIN_KEY_COL1_KEY_COL1,90MX31_PIN_KEY_COL2_KEY_COL2,91MX31_PIN_KEY_COL3_KEY_COL3,92/* USB Host 2 */93IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC),94IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC),95IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC),96IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC),97IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC),98IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC),99IOMUX_MODE(MX31_PIN_PC_VS2, IOMUX_CONFIG_ALT1),100IOMUX_MODE(MX31_PIN_PC_BVD1, IOMUX_CONFIG_ALT1),101IOMUX_MODE(MX31_PIN_PC_BVD2, IOMUX_CONFIG_ALT1),102IOMUX_MODE(MX31_PIN_PC_RST, IOMUX_CONFIG_ALT1),103IOMUX_MODE(MX31_PIN_IOIS16, IOMUX_CONFIG_ALT1),104IOMUX_MODE(MX31_PIN_PC_RW_B, IOMUX_CONFIG_ALT1),105/* USB Host2 reset */106IOMUX_MODE(MX31_PIN_USB_BYP, IOMUX_CONFIG_GPIO),107/* I2C1 */108MX31_PIN_I2C_CLK__I2C1_SCL,109MX31_PIN_I2C_DAT__I2C1_SDA,110/* SDHC1 */111MX31_PIN_SD1_DATA3__SD1_DATA3,112MX31_PIN_SD1_DATA2__SD1_DATA2,113MX31_PIN_SD1_DATA1__SD1_DATA1,114MX31_PIN_SD1_DATA0__SD1_DATA0,115MX31_PIN_SD1_CLK__SD1_CLK,116MX31_PIN_SD1_CMD__SD1_CMD,117MX31_PIN_GPIO3_1__GPIO3_1, /* Card detect */118MX31_PIN_GPIO3_0__GPIO3_0, /* OE */119/* Framebuffer */120MX31_PIN_LD0__LD0,121MX31_PIN_LD1__LD1,122MX31_PIN_LD2__LD2,123MX31_PIN_LD3__LD3,124MX31_PIN_LD4__LD4,125MX31_PIN_LD5__LD5,126MX31_PIN_LD6__LD6,127MX31_PIN_LD7__LD7,128MX31_PIN_LD8__LD8,129MX31_PIN_LD9__LD9,130MX31_PIN_LD10__LD10,131MX31_PIN_LD11__LD11,132MX31_PIN_LD12__LD12,133MX31_PIN_LD13__LD13,134MX31_PIN_LD14__LD14,135MX31_PIN_LD15__LD15,136MX31_PIN_LD16__LD16,137MX31_PIN_LD17__LD17,138MX31_PIN_VSYNC3__VSYNC3,139MX31_PIN_HSYNC__HSYNC,140MX31_PIN_FPSHIFT__FPSHIFT,141MX31_PIN_CONTRAST__CONTRAST,142/* CSI */143MX31_PIN_CSI_D6__CSI_D6,144MX31_PIN_CSI_D7__CSI_D7,145MX31_PIN_CSI_D8__CSI_D8,146MX31_PIN_CSI_D9__CSI_D9,147MX31_PIN_CSI_D10__CSI_D10,148MX31_PIN_CSI_D11__CSI_D11,149MX31_PIN_CSI_D12__CSI_D12,150MX31_PIN_CSI_D13__CSI_D13,151MX31_PIN_CSI_D14__CSI_D14,152MX31_PIN_CSI_D15__CSI_D15,153MX31_PIN_CSI_HSYNC__CSI_HSYNC,154MX31_PIN_CSI_MCLK__CSI_MCLK,155MX31_PIN_CSI_PIXCLK__CSI_PIXCLK,156MX31_PIN_CSI_VSYNC__CSI_VSYNC,157MX31_PIN_CSI_D5__GPIO3_5, /* CMOS PWDN */158IOMUX_MODE(MX31_PIN_RI_DTE1, IOMUX_CONFIG_GPIO), /* CMOS reset */159};160161/*162* Camera support163*/164static phys_addr_t mx3_camera_base __initdata;165#define MX31_3DS_CAMERA_BUF_SIZE SZ_8M166167#define MX31_3DS_GPIO_CAMERA_PW IOMUX_TO_GPIO(MX31_PIN_CSI_D5)168#define MX31_3DS_GPIO_CAMERA_RST IOMUX_TO_GPIO(MX31_PIN_RI_DTE1)169170static struct gpio mx31_3ds_camera_gpios[] = {171{ MX31_3DS_GPIO_CAMERA_PW, GPIOF_OUT_INIT_HIGH, "camera-power" },172{ MX31_3DS_GPIO_CAMERA_RST, GPIOF_OUT_INIT_HIGH, "camera-reset" },173};174175static const struct mx3_camera_pdata mx31_3ds_camera_pdata __initconst = {176.flags = MX3_CAMERA_DATAWIDTH_10,177.mclk_10khz = 2600,178};179180static int __init mx31_3ds_init_camera(void)181{182int dma, ret = -ENOMEM;183struct platform_device *pdev =184imx31_alloc_mx3_camera(&mx31_3ds_camera_pdata);185186if (IS_ERR(pdev))187return PTR_ERR(pdev);188189if (!mx3_camera_base)190goto err;191192dma = dma_declare_coherent_memory(&pdev->dev,193mx3_camera_base, mx3_camera_base,194MX31_3DS_CAMERA_BUF_SIZE,195DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);196197if (!(dma & DMA_MEMORY_MAP))198goto err;199200ret = platform_device_add(pdev);201if (ret)202err:203platform_device_put(pdev);204205return ret;206}207208static int mx31_3ds_camera_power(struct device *dev, int on)209{210/* enable or disable the camera */211pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");212gpio_set_value(MX31_3DS_GPIO_CAMERA_PW, on ? 0 : 1);213214if (!on)215goto out;216217/* If enabled, give a reset impulse */218gpio_set_value(MX31_3DS_GPIO_CAMERA_RST, 0);219msleep(20);220gpio_set_value(MX31_3DS_GPIO_CAMERA_RST, 1);221msleep(100);222223out:224return 0;225}226227static struct i2c_board_info mx31_3ds_i2c_camera = {228I2C_BOARD_INFO("ov2640", 0x30),229};230231static struct regulator_bulk_data mx31_3ds_camera_regs[] = {232{ .supply = "cmos_vcore" },233{ .supply = "cmos_2v8" },234};235236static struct soc_camera_link iclink_ov2640 = {237.bus_id = 0,238.board_info = &mx31_3ds_i2c_camera,239.i2c_adapter_id = 0,240.power = mx31_3ds_camera_power,241.regulators = mx31_3ds_camera_regs,242.num_regulators = ARRAY_SIZE(mx31_3ds_camera_regs),243};244245static struct platform_device mx31_3ds_ov2640 = {246.name = "soc-camera-pdrv",247.id = 0,248.dev = {249.platform_data = &iclink_ov2640,250},251};252253/*254* FB support255*/256static const struct fb_videomode fb_modedb[] = {257{ /* 480x640 @ 60 Hz */258.name = "Epson-VGA",259.refresh = 60,260.xres = 480,261.yres = 640,262.pixclock = 41701,263.left_margin = 20,264.right_margin = 41,265.upper_margin = 10,266.lower_margin = 5,267.hsync_len = 20,268.vsync_len = 10,269.sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,270.vmode = FB_VMODE_NONINTERLACED,271.flag = 0,272},273};274275static struct ipu_platform_data mx3_ipu_data = {276.irq_base = MXC_IPU_IRQ_START,277};278279static struct mx3fb_platform_data mx3fb_pdata __initdata = {280.name = "Epson-VGA",281.mode = fb_modedb,282.num_modes = ARRAY_SIZE(fb_modedb),283};284285/* LCD */286static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = {287.reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1),288.data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS),289.core_supply = "lcd_2v8",290.io_supply = "vdd_lcdio",291};292293/*294* Support for SD card slot in personality board295*/296#define MX31_3DS_GPIO_SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)297#define MX31_3DS_GPIO_SDHC1_BE IOMUX_TO_GPIO(MX31_PIN_GPIO3_0)298299static struct gpio mx31_3ds_sdhc1_gpios[] = {300{ MX31_3DS_GPIO_SDHC1_CD, GPIOF_IN, "sdhc1-card-detect" },301{ MX31_3DS_GPIO_SDHC1_BE, GPIOF_OUT_INIT_LOW, "sdhc1-bus-en" },302};303304static int mx31_3ds_sdhc1_init(struct device *dev,305irq_handler_t detect_irq,306void *data)307{308int ret;309310ret = gpio_request_array(mx31_3ds_sdhc1_gpios,311ARRAY_SIZE(mx31_3ds_sdhc1_gpios));312if (ret) {313pr_warning("Unable to request the SD/MMC GPIOs.\n");314return ret;315}316317ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),318detect_irq, IRQF_DISABLED |319IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,320"sdhc1-detect", data);321if (ret) {322pr_warning("Unable to request the SD/MMC card-detect IRQ.\n");323goto gpio_free;324}325326return 0;327328gpio_free:329gpio_free_array(mx31_3ds_sdhc1_gpios,330ARRAY_SIZE(mx31_3ds_sdhc1_gpios));331return ret;332}333334static void mx31_3ds_sdhc1_exit(struct device *dev, void *data)335{336free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), data);337gpio_free_array(mx31_3ds_sdhc1_gpios,338ARRAY_SIZE(mx31_3ds_sdhc1_gpios));339}340341static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd)342{343/*344* While the voltage stuff is done by the driver, activate the345* Buffer Enable Pin only if there is a card in slot to fix the card346* voltage issue caused by bi-directional chip TXB0108 on 3Stack.347* Done here because at this stage we have for sure a debounced value348* of the presence of the card, showed by the value of vdd.349* 7 == ilog2(MMC_VDD_165_195)350*/351if (vdd > 7)352gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 1);353else354gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 0);355}356357static struct imxmmc_platform_data sdhc1_pdata = {358.init = mx31_3ds_sdhc1_init,359.exit = mx31_3ds_sdhc1_exit,360.setpower = mx31_3ds_sdhc1_setpower,361};362363/*364* Matrix keyboard365*/366367static const uint32_t mx31_3ds_keymap[] = {368KEY(0, 0, KEY_UP),369KEY(0, 1, KEY_DOWN),370KEY(1, 0, KEY_RIGHT),371KEY(1, 1, KEY_LEFT),372KEY(1, 2, KEY_ENTER),373KEY(2, 0, KEY_F6),374KEY(2, 1, KEY_F8),375KEY(2, 2, KEY_F9),376KEY(2, 3, KEY_F10),377};378379static const struct matrix_keymap_data mx31_3ds_keymap_data __initconst = {380.keymap = mx31_3ds_keymap,381.keymap_size = ARRAY_SIZE(mx31_3ds_keymap),382};383384/* Regulators */385static struct regulator_init_data pwgtx_init = {386.constraints = {387.boot_on = 1,388.always_on = 1,389},390};391392static struct regulator_init_data gpo_init = {393.constraints = {394.boot_on = 1,395.always_on = 1,396}397};398399static struct regulator_consumer_supply vmmc2_consumers[] = {400REGULATOR_SUPPLY("vmmc", "mxc-mmc.0"),401};402403static struct regulator_init_data vmmc2_init = {404.constraints = {405.min_uV = 3000000,406.max_uV = 3000000,407.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |408REGULATOR_CHANGE_STATUS,409},410.num_consumer_supplies = ARRAY_SIZE(vmmc2_consumers),411.consumer_supplies = vmmc2_consumers,412};413414static struct regulator_consumer_supply vmmc1_consumers[] = {415REGULATOR_SUPPLY("lcd_2v8", NULL),416REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),417};418419static struct regulator_init_data vmmc1_init = {420.constraints = {421.min_uV = 2800000,422.max_uV = 2800000,423.apply_uV = 1,424.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |425REGULATOR_CHANGE_STATUS,426},427.num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers),428.consumer_supplies = vmmc1_consumers,429};430431static struct regulator_consumer_supply vgen_consumers[] = {432REGULATOR_SUPPLY("vdd_lcdio", NULL),433};434435static struct regulator_init_data vgen_init = {436.constraints = {437.min_uV = 1800000,438.max_uV = 1800000,439.apply_uV = 1,440.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |441REGULATOR_CHANGE_STATUS,442},443.num_consumer_supplies = ARRAY_SIZE(vgen_consumers),444.consumer_supplies = vgen_consumers,445};446447static struct regulator_consumer_supply vvib_consumers[] = {448REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),449};450451static struct regulator_init_data vvib_init = {452.constraints = {453.min_uV = 1300000,454.max_uV = 1300000,455.apply_uV = 1,456.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |457REGULATOR_CHANGE_STATUS,458},459.num_consumer_supplies = ARRAY_SIZE(vvib_consumers),460.consumer_supplies = vvib_consumers,461};462463static struct mc13xxx_regulator_init_data mx31_3ds_regulators[] = {464{465.id = MC13783_REG_PWGT1SPI, /* Power Gate for ARM core. */466.init_data = &pwgtx_init,467}, {468.id = MC13783_REG_PWGT2SPI, /* Power Gate for L2 Cache. */469.init_data = &pwgtx_init,470}, {471472.id = MC13783_REG_GPO1, /* Turn on 1.8V */473.init_data = &gpo_init,474}, {475.id = MC13783_REG_GPO3, /* Turn on 3.3V */476.init_data = &gpo_init,477}, {478.id = MC13783_REG_VMMC2, /* Power MMC/SD, WiFi/Bluetooth. */479.init_data = &vmmc2_init,480}, {481.id = MC13783_REG_VMMC1, /* Power LCD, CMOS, FM, GPS, Accel. */482.init_data = &vmmc1_init,483}, {484.id = MC13783_REG_VGEN, /* Power LCD */485.init_data = &vgen_init,486}, {487.id = MC13783_REG_VVIB, /* Power CMOS */488.init_data = &vvib_init,489},490};491492/* MC13783 */493static struct mc13xxx_platform_data mc13783_pdata = {494.regulators = {495.regulators = mx31_3ds_regulators,496.num_regulators = ARRAY_SIZE(mx31_3ds_regulators),497},498.flags = MC13783_USE_REGULATOR | MC13783_USE_TOUCHSCREEN,499};500501/* SPI */502static int spi0_internal_chipselect[] = {503MXC_SPI_CS(2),504};505506static const struct spi_imx_master spi0_pdata __initconst = {507.chipselect = spi0_internal_chipselect,508.num_chipselect = ARRAY_SIZE(spi0_internal_chipselect),509};510511static int spi1_internal_chipselect[] = {512MXC_SPI_CS(0),513MXC_SPI_CS(2),514};515516static const struct spi_imx_master spi1_pdata __initconst = {517.chipselect = spi1_internal_chipselect,518.num_chipselect = ARRAY_SIZE(spi1_internal_chipselect),519};520521static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {522{523.modalias = "mc13783",524.max_speed_hz = 1000000,525.bus_num = 1,526.chip_select = 1, /* SS2 */527.platform_data = &mc13783_pdata,528.irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),529.mode = SPI_CS_HIGH,530}, {531.modalias = "l4f00242t03",532.max_speed_hz = 5000000,533.bus_num = 0,534.chip_select = 0, /* SS2 */535.platform_data = &mx31_3ds_l4f00242t03_pdata,536},537};538539/*540* NAND Flash541*/542static const struct mxc_nand_platform_data543mx31_3ds_nand_board_info __initconst = {544.width = 1,545.hw_ecc = 1,546#ifdef MACH_MX31_3DS_MXC_NAND_USE_BBT547.flash_bbt = 1,548#endif549};550551/*552* USB OTG553*/554555#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \556PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)557558#define USBOTG_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_PWR)559#define USBH2_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_BYP)560561static int mx31_3ds_usbotg_init(void)562{563int err;564565mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);566mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);567mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);568mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);569mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);570mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);571mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);572mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);573mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);574mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);575mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);576mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);577578err = gpio_request(USBOTG_RST_B, "otgusb-reset");579if (err) {580pr_err("Failed to request the USB OTG reset gpio\n");581return err;582}583584err = gpio_direction_output(USBOTG_RST_B, 0);585if (err) {586pr_err("Failed to drive the USB OTG reset gpio\n");587goto usbotg_free_reset;588}589590mdelay(1);591gpio_set_value(USBOTG_RST_B, 1);592return 0;593594usbotg_free_reset:595gpio_free(USBOTG_RST_B);596return err;597}598599static int mx31_3ds_otg_init(struct platform_device *pdev)600{601return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);602}603604static int mx31_3ds_host2_init(struct platform_device *pdev)605{606int err;607608mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);609mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);610mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);611mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);612mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);613mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);614mxc_iomux_set_pad(MX31_PIN_PC_VS2, USB_PAD_CFG);615mxc_iomux_set_pad(MX31_PIN_PC_BVD1, USB_PAD_CFG);616mxc_iomux_set_pad(MX31_PIN_PC_BVD2, USB_PAD_CFG);617mxc_iomux_set_pad(MX31_PIN_PC_RST, USB_PAD_CFG);618mxc_iomux_set_pad(MX31_PIN_IOIS16, USB_PAD_CFG);619mxc_iomux_set_pad(MX31_PIN_PC_RW_B, USB_PAD_CFG);620621err = gpio_request(USBH2_RST_B, "usbh2-reset");622if (err) {623pr_err("Failed to request the USB Host 2 reset gpio\n");624return err;625}626627err = gpio_direction_output(USBH2_RST_B, 0);628if (err) {629pr_err("Failed to drive the USB Host 2 reset gpio\n");630goto usbotg_free_reset;631}632633mdelay(1);634gpio_set_value(USBH2_RST_B, 1);635636mdelay(10);637638return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);639640usbotg_free_reset:641gpio_free(USBH2_RST_B);642return err;643}644645static struct mxc_usbh_platform_data otg_pdata __initdata = {646.init = mx31_3ds_otg_init,647.portsc = MXC_EHCI_MODE_ULPI,648};649650static struct mxc_usbh_platform_data usbh2_pdata __initdata = {651.init = mx31_3ds_host2_init,652.portsc = MXC_EHCI_MODE_ULPI,653};654655static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {656.operating_mode = FSL_USB2_DR_DEVICE,657.phy_mode = FSL_USB2_PHY_ULPI,658};659660static int otg_mode_host;661662static int __init mx31_3ds_otg_mode(char *options)663{664if (!strcmp(options, "host"))665otg_mode_host = 1;666else if (!strcmp(options, "device"))667otg_mode_host = 0;668else669pr_info("otg_mode neither \"host\" nor \"device\". "670"Defaulting to device\n");671return 0;672}673__setup("otg_mode=", mx31_3ds_otg_mode);674675static const struct imxuart_platform_data uart_pdata __initconst = {676.flags = IMXUART_HAVE_RTSCTS,677};678679static const struct imxi2c_platform_data mx31_3ds_i2c0_data __initconst = {680.bitrate = 100000,681};682683static struct platform_device *devices[] __initdata = {684&mx31_3ds_ov2640,685};686687static void __init mx31_3ds_init(void)688{689int ret;690691mxc_iomux_setup_multiple_pins(mx31_3ds_pins, ARRAY_SIZE(mx31_3ds_pins),692"mx31_3ds");693694imx31_add_imx_uart0(&uart_pdata);695imx31_add_mxc_nand(&mx31_3ds_nand_board_info);696697imx31_add_spi_imx1(&spi1_pdata);698spi_register_board_info(mx31_3ds_spi_devs,699ARRAY_SIZE(mx31_3ds_spi_devs));700701platform_add_devices(devices, ARRAY_SIZE(devices));702703imx31_add_imx_keypad(&mx31_3ds_keymap_data);704705mx31_3ds_usbotg_init();706if (otg_mode_host) {707otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |708ULPI_OTG_DRVVBUS_EXT);709if (otg_pdata.otg)710imx31_add_mxc_ehci_otg(&otg_pdata);711}712usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |713ULPI_OTG_DRVVBUS_EXT);714if (usbh2_pdata.otg)715imx31_add_mxc_ehci_hs(2, &usbh2_pdata);716717if (!otg_mode_host)718imx31_add_fsl_usb2_udc(&usbotg_pdata);719720if (mxc_expio_init(MX31_CS5_BASE_ADDR, EXPIO_PARENT_INT))721printk(KERN_WARNING "Init of the debug board failed, all "722"devices on the debug board are unusable.\n");723imx31_add_imx2_wdt(NULL);724imx31_add_imx_i2c0(&mx31_3ds_i2c0_data);725imx31_add_mxc_mmc(0, &sdhc1_pdata);726727imx31_add_spi_imx0(&spi0_pdata);728imx31_add_ipu_core(&mx3_ipu_data);729imx31_add_mx3_sdc_fb(&mx3fb_pdata);730731/* CSI */732/* Camera power: default - off */733ret = gpio_request_array(mx31_3ds_camera_gpios,734ARRAY_SIZE(mx31_3ds_camera_gpios));735if (ret) {736pr_err("Failed to request camera gpios");737iclink_ov2640.power = NULL;738}739740mx31_3ds_init_camera();741}742743static void __init mx31_3ds_timer_init(void)744{745mx31_clocks_init(26000000);746}747748static struct sys_timer mx31_3ds_timer = {749.init = mx31_3ds_timer_init,750};751752static void __init mx31_3ds_reserve(void)753{754/* reserve MX31_3DS_CAMERA_BUF_SIZE bytes for mx3-camera */755mx3_camera_base = memblock_alloc(MX31_3DS_CAMERA_BUF_SIZE,756MX31_3DS_CAMERA_BUF_SIZE);757memblock_free(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);758memblock_remove(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);759}760761MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")762/* Maintainer: Freescale Semiconductor, Inc. */763.boot_params = MX3x_PHYS_OFFSET + 0x100,764.map_io = mx31_map_io,765.init_early = imx31_init_early,766.init_irq = mx31_init_irq,767.timer = &mx31_3ds_timer,768.init_machine = mx31_3ds_init,769.reserve = mx31_3ds_reserve,770MACHINE_END771772773