Path: blob/master/arch/arm/mach-imx/mach-mx31lilly.c
10817 views
/*1* LILLY-1131 module support2*3* Copyright (c) 2009 Daniel Mack <[email protected]>4*5* based on code for other MX31 boards,6*7* Copyright 2005-2007 Freescale Semiconductor8* Copyright (c) 2009 Alberto Panizzo <[email protected]>9* Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group10*11* This program is free software; you can redistribute it and/or modify12* it under the terms of the GNU General Public License as published by13* the Free Software Foundation; either version 2 of the License, or14* (at your option) any later version.15*16* This program is distributed in the hope that it will be useful,17* but WITHOUT ANY WARRANTY; without even the implied warranty of18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19* GNU General Public License for more details.20*/2122#include <linux/types.h>23#include <linux/init.h>24#include <linux/clk.h>25#include <linux/gpio.h>26#include <linux/delay.h>27#include <linux/platform_device.h>28#include <linux/interrupt.h>29#include <linux/smsc911x.h>30#include <linux/mtd/physmap.h>31#include <linux/spi/spi.h>32#include <linux/mfd/mc13783.h>33#include <linux/usb/otg.h>34#include <linux/usb/ulpi.h>3536#include <asm/mach-types.h>37#include <asm/mach/arch.h>38#include <asm/mach/time.h>39#include <asm/mach/map.h>4041#include <mach/hardware.h>42#include <mach/common.h>43#include <mach/iomux-mx3.h>44#include <mach/board-mx31lilly.h>45#include <mach/ulpi.h>4647#include "devices-imx31.h"4849/*50* This file contains module-specific initialization routines for LILLY-1131.51* Initialization of peripherals found on the baseboard is implemented in the52* appropriate baseboard support code.53*/5455/* SMSC ethernet support */5657static struct resource smsc91x_resources[] = {58{59.start = MX31_CS4_BASE_ADDR,60.end = MX31_CS4_BASE_ADDR + 0xffff,61.flags = IORESOURCE_MEM,62},63{64.start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),65.end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),66.flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,67}68};6970static struct smsc911x_platform_config smsc911x_config = {71.phy_interface = PHY_INTERFACE_MODE_MII,72.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,73.irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,74.flags = SMSC911X_USE_32BIT |75SMSC911X_SAVE_MAC_ADDRESS |76SMSC911X_FORCE_INTERNAL_PHY,77};7879static struct platform_device smsc91x_device = {80.name = "smsc911x",81.id = -1,82.num_resources = ARRAY_SIZE(smsc91x_resources),83.resource = smsc91x_resources,84.dev = {85.platform_data = &smsc911x_config,86}87};8889/* NOR flash */90static struct physmap_flash_data nor_flash_data = {91.width = 2,92};9394static struct resource nor_flash_resource = {95.start = 0xa0000000,96.end = 0xa1ffffff,97.flags = IORESOURCE_MEM,98};99100static struct platform_device physmap_flash_device = {101.name = "physmap-flash",102.id = 0,103.dev = {104.platform_data = &nor_flash_data,105},106.resource = &nor_flash_resource,107.num_resources = 1,108};109110/* USB */111112#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \113PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)114115static int usbh1_init(struct platform_device *pdev)116{117int pins[] = {118MX31_PIN_CSPI1_MOSI__USBH1_RXDM,119MX31_PIN_CSPI1_MISO__USBH1_RXDP,120MX31_PIN_CSPI1_SS0__USBH1_TXDM,121MX31_PIN_CSPI1_SS1__USBH1_TXDP,122MX31_PIN_CSPI1_SS2__USBH1_RCV,123MX31_PIN_CSPI1_SCLK__USBH1_OEB,124MX31_PIN_CSPI1_SPI_RDY__USBH1_FS,125};126127mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");128129mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI, USB_PAD_CFG);130mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO, USB_PAD_CFG);131mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0, USB_PAD_CFG);132mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1, USB_PAD_CFG);133mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2, USB_PAD_CFG);134mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK, USB_PAD_CFG);135mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY, USB_PAD_CFG);136137mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND, true);138139mdelay(10);140141return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |142MXC_EHCI_INTERFACE_SINGLE_UNI);143}144145static int usbh2_init(struct platform_device *pdev)146{147int pins[] = {148MX31_PIN_USBH2_DATA0__USBH2_DATA0,149MX31_PIN_USBH2_DATA1__USBH2_DATA1,150MX31_PIN_USBH2_CLK__USBH2_CLK,151MX31_PIN_USBH2_DIR__USBH2_DIR,152MX31_PIN_USBH2_NXT__USBH2_NXT,153MX31_PIN_USBH2_STP__USBH2_STP,154};155156mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");157158mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);159mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);160mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);161mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);162mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);163mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);164mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);165mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);166mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);167mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);168mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);169mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);170171mxc_iomux_set_gpr(MUX_PGP_UH2, true);172173/* chip select */174mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),175"USBH2_CS");176gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");177gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);178179mdelay(10);180181return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);182}183184static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {185.init = usbh1_init,186.portsc = MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,187};188189static struct mxc_usbh_platform_data usbh2_pdata __initdata = {190.init = usbh2_init,191.portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,192};193194static void lilly1131_usb_init(void)195{196imx31_add_mxc_ehci_hs(1, &usbh1_pdata);197198usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |199ULPI_OTG_DRVVBUS_EXT);200if (usbh2_pdata.otg)201imx31_add_mxc_ehci_hs(2, &usbh2_pdata);202}203204/* SPI */205206static int spi_internal_chipselect[] = {207MXC_SPI_CS(0),208MXC_SPI_CS(1),209MXC_SPI_CS(2),210};211212static const struct spi_imx_master spi0_pdata __initconst = {213.chipselect = spi_internal_chipselect,214.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),215};216217static const struct spi_imx_master spi1_pdata __initconst = {218.chipselect = spi_internal_chipselect,219.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),220};221222static struct mc13xxx_platform_data mc13783_pdata __initdata = {223.flags = MC13XXX_USE_RTC | MC13XXX_USE_TOUCHSCREEN,224};225226static struct spi_board_info mc13783_dev __initdata = {227.modalias = "mc13783",228.max_speed_hz = 1000000,229.bus_num = 1,230.chip_select = 0,231.platform_data = &mc13783_pdata,232.irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),233};234235static struct platform_device *devices[] __initdata = {236&smsc91x_device,237&physmap_flash_device,238};239240static int mx31lilly_baseboard;241core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);242243static void __init mx31lilly_board_init(void)244{245switch (mx31lilly_baseboard) {246case MX31LILLY_NOBOARD:247break;248case MX31LILLY_DB:249mx31lilly_db_init();250break;251default:252printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",253mx31lilly_baseboard);254}255256mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");257258/* SPI */259mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");260mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");261mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");262mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");263mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");264mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");265mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");266267mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");268mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");269mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");270mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");271mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");272mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");273mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");274275imx31_add_spi_imx0(&spi0_pdata);276imx31_add_spi_imx1(&spi1_pdata);277spi_register_board_info(&mc13783_dev, 1);278279platform_add_devices(devices, ARRAY_SIZE(devices));280281/* USB */282lilly1131_usb_init();283}284285static void __init mx31lilly_timer_init(void)286{287mx31_clocks_init(26000000);288}289290static struct sys_timer mx31lilly_timer = {291.init = mx31lilly_timer_init,292};293294MACHINE_START(LILLY1131, "INCO startec LILLY-1131")295.boot_params = MX3x_PHYS_OFFSET + 0x100,296.map_io = mx31_map_io,297.init_early = imx31_init_early,298.init_irq = mx31_init_irq,299.timer = &mx31lilly_timer,300.init_machine = mx31lilly_board_init,301MACHINE_END302303304