Path: blob/master/arch/arm/mach-mx5/board-cpuimx51sd.c
10817 views
/*1*2* Copyright (C) 2010 Eric Bénard <[email protected]>3*4* based on board-mx51_babbage.c which is5* Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.6* Copyright (C) 2009-2010 Amit Kucheria <[email protected]>7*8* The code contained herein is licensed under the GNU General Public9* License. You may obtain a copy of the GNU General Public License10* Version 2 or later at the following locations:11*12* http://www.opensource.org/licenses/gpl-license.html13* http://www.gnu.org/copyleft/gpl.html14*/1516#include <linux/init.h>17#include <linux/platform_device.h>18#include <linux/i2c.h>19#include <linux/i2c/tsc2007.h>20#include <linux/gpio.h>21#include <linux/delay.h>22#include <linux/io.h>23#include <linux/interrupt.h>24#include <linux/irq.h>25#include <linux/i2c-gpio.h>26#include <linux/spi/spi.h>27#include <linux/can/platform/mcp251x.h>2829#include <mach/eukrea-baseboards.h>30#include <mach/common.h>31#include <mach/hardware.h>32#include <mach/iomux-mx51.h>3334#include <asm/irq.h>35#include <asm/setup.h>36#include <asm/mach-types.h>37#include <asm/mach/arch.h>38#include <asm/mach/time.h>3940#include "devices-imx51.h"41#include "devices.h"42#include "cpu_op-mx51.h"4344#define USBH1_RST IMX_GPIO_NR(2, 28)45#define ETH_RST IMX_GPIO_NR(2, 31)46#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 12)47#define CAN_IRQGPIO IMX_GPIO_NR(1, 1)48#define CAN_RST IMX_GPIO_NR(4, 15)49#define CAN_NCS IMX_GPIO_NR(4, 24)50#define CAN_RXOBF IMX_GPIO_NR(1, 4)51#define CAN_RX1BF IMX_GPIO_NR(1, 6)52#define CAN_TXORTS IMX_GPIO_NR(1, 7)53#define CAN_TX1RTS IMX_GPIO_NR(1, 8)54#define CAN_TX2RTS IMX_GPIO_NR(1, 9)55#define I2C_SCL IMX_GPIO_NR(4, 16)56#define I2C_SDA IMX_GPIO_NR(4, 17)5758/* USB_CTRL_1 */59#define MX51_USB_CTRL_1_OFFSET 0x1060#define MX51_USB_CTRL_UH1_EXT_CLK_EN (1 << 25)6162#define MX51_USB_PLLDIV_12_MHZ 0x0063#define MX51_USB_PLL_DIV_19_2_MHZ 0x0164#define MX51_USB_PLL_DIV_24_MHZ 0x026566static iomux_v3_cfg_t eukrea_cpuimx51sd_pads[] = {67/* UART1 */68MX51_PAD_UART1_RXD__UART1_RXD,69MX51_PAD_UART1_TXD__UART1_TXD,70MX51_PAD_UART1_RTS__UART1_RTS,71MX51_PAD_UART1_CTS__UART1_CTS,7273/* USB HOST1 */74MX51_PAD_USBH1_CLK__USBH1_CLK,75MX51_PAD_USBH1_DIR__USBH1_DIR,76MX51_PAD_USBH1_NXT__USBH1_NXT,77MX51_PAD_USBH1_DATA0__USBH1_DATA0,78MX51_PAD_USBH1_DATA1__USBH1_DATA1,79MX51_PAD_USBH1_DATA2__USBH1_DATA2,80MX51_PAD_USBH1_DATA3__USBH1_DATA3,81MX51_PAD_USBH1_DATA4__USBH1_DATA4,82MX51_PAD_USBH1_DATA5__USBH1_DATA5,83MX51_PAD_USBH1_DATA6__USBH1_DATA6,84MX51_PAD_USBH1_DATA7__USBH1_DATA7,85MX51_PAD_USBH1_STP__USBH1_STP,86MX51_PAD_EIM_CS3__GPIO2_28, /* PHY nRESET */8788/* FEC */89MX51_PAD_EIM_DTACK__GPIO2_31, /* PHY nRESET */9091/* HSI2C */92MX51_PAD_I2C1_CLK__GPIO4_16,93MX51_PAD_I2C1_DAT__GPIO4_17,9495/* CAN */96MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI,97MX51_PAD_CSPI1_MISO__ECSPI1_MISO,98MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,99MX51_PAD_CSPI1_SS0__GPIO4_24, /* nCS */100MX51_PAD_CSI2_PIXCLK__GPIO4_15, /* nReset */101MX51_PAD_GPIO1_1__GPIO1_1, /* IRQ */102MX51_PAD_GPIO1_4__GPIO1_4, /* Control signals */103MX51_PAD_GPIO1_6__GPIO1_6,104MX51_PAD_GPIO1_7__GPIO1_7,105MX51_PAD_GPIO1_8__GPIO1_8,106MX51_PAD_GPIO1_9__GPIO1_9,107108/* Touchscreen */109/* IRQ */110_MX51_PAD_GPIO_NAND__GPIO_NAND | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |111PAD_CTL_PKE | PAD_CTL_SRE_FAST |112PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),113};114115static const struct imxuart_platform_data uart_pdata __initconst = {116.flags = IMXUART_HAVE_RTSCTS,117};118119static struct tsc2007_platform_data tsc2007_info = {120.model = 2007,121.x_plate_ohms = 180,122};123124static struct i2c_board_info eukrea_cpuimx51sd_i2c_devices[] = {125{126I2C_BOARD_INFO("pcf8563", 0x51),127}, {128I2C_BOARD_INFO("tsc2007", 0x49),129.type = "tsc2007",130.platform_data = &tsc2007_info,131.irq = gpio_to_irq(TSC2007_IRQGPIO),132},133};134135static const struct mxc_nand_platform_data136eukrea_cpuimx51sd_nand_board_info __initconst = {137.width = 1,138.hw_ecc = 1,139.flash_bbt = 1,140};141142/* This function is board specific as the bit mask for the plldiv will also143be different for other Freescale SoCs, thus a common bitmask is not144possible and cannot get place in /plat-mxc/ehci.c.*/145static int initialize_otg_port(struct platform_device *pdev)146{147u32 v;148void __iomem *usb_base;149void __iomem *usbother_base;150151usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);152if (!usb_base)153return -ENOMEM;154usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;155156/* Set the PHY clock to 19.2MHz */157v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);158v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;159v |= MX51_USB_PLL_DIV_19_2_MHZ;160__raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);161iounmap(usb_base);162163mdelay(10);164165return mx51_initialize_usb_hw(0, MXC_EHCI_INTERNAL_PHY);166}167168static int initialize_usbh1_port(struct platform_device *pdev)169{170u32 v;171void __iomem *usb_base;172void __iomem *usbother_base;173174usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);175if (!usb_base)176return -ENOMEM;177usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;178179/* The clock for the USBH1 ULPI port will come from the PHY. */180v = __raw_readl(usbother_base + MX51_USB_CTRL_1_OFFSET);181__raw_writel(v | MX51_USB_CTRL_UH1_EXT_CLK_EN,182usbother_base + MX51_USB_CTRL_1_OFFSET);183iounmap(usb_base);184185mdelay(10);186187return mx51_initialize_usb_hw(1, MXC_EHCI_POWER_PINS_ENABLED |188MXC_EHCI_ITC_NO_THRESHOLD);189}190191static struct mxc_usbh_platform_data dr_utmi_config = {192.init = initialize_otg_port,193.portsc = MXC_EHCI_UTMI_16BIT,194};195196static struct fsl_usb2_platform_data usb_pdata = {197.operating_mode = FSL_USB2_DR_DEVICE,198.phy_mode = FSL_USB2_PHY_UTMI_WIDE,199};200201static struct mxc_usbh_platform_data usbh1_config = {202.init = initialize_usbh1_port,203.portsc = MXC_EHCI_MODE_ULPI,204};205206static int otg_mode_host;207208static int __init eukrea_cpuimx51sd_otg_mode(char *options)209{210if (!strcmp(options, "host"))211otg_mode_host = 1;212else if (!strcmp(options, "device"))213otg_mode_host = 0;214else215pr_info("otg_mode neither \"host\" nor \"device\". "216"Defaulting to device\n");217return 0;218}219__setup("otg_mode=", eukrea_cpuimx51sd_otg_mode);220221static struct i2c_gpio_platform_data pdata = {222.sda_pin = I2C_SDA,223.sda_is_open_drain = 0,224.scl_pin = I2C_SCL,225.scl_is_open_drain = 0,226.udelay = 2,227};228229static struct platform_device hsi2c_gpio_device = {230.name = "i2c-gpio",231.id = 0,232.dev.platform_data = &pdata,233};234235static struct mcp251x_platform_data mcp251x_info = {236.oscillator_frequency = 24E6,237};238239static struct spi_board_info cpuimx51sd_spi_device[] = {240{241.modalias = "mcp2515",242.max_speed_hz = 10000000,243.bus_num = 0,244.mode = SPI_MODE_0,245.chip_select = 0,246.platform_data = &mcp251x_info,247.irq = gpio_to_irq(CAN_IRQGPIO)248},249};250251static int cpuimx51sd_spi1_cs[] = {252CAN_NCS,253};254255static const struct spi_imx_master cpuimx51sd_ecspi1_pdata __initconst = {256.chipselect = cpuimx51sd_spi1_cs,257.num_chipselect = ARRAY_SIZE(cpuimx51sd_spi1_cs),258};259260static struct platform_device *platform_devices[] __initdata = {261&hsi2c_gpio_device,262};263264static void __init eukrea_cpuimx51sd_init(void)265{266mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx51sd_pads,267ARRAY_SIZE(eukrea_cpuimx51sd_pads));268269#if defined(CONFIG_CPU_FREQ_IMX)270get_cpu_op = mx51_get_cpu_op;271#endif272273imx51_add_imx_uart(0, &uart_pdata);274imx51_add_mxc_nand(&eukrea_cpuimx51sd_nand_board_info);275276gpio_request(ETH_RST, "eth_rst");277gpio_set_value(ETH_RST, 1);278imx51_add_fec(NULL);279280gpio_request(CAN_IRQGPIO, "can_irq");281gpio_direction_input(CAN_IRQGPIO);282gpio_free(CAN_IRQGPIO);283gpio_request(CAN_NCS, "can_ncs");284gpio_direction_output(CAN_NCS, 1);285gpio_free(CAN_NCS);286gpio_request(CAN_RST, "can_rst");287gpio_direction_output(CAN_RST, 0);288msleep(20);289gpio_set_value(CAN_RST, 1);290imx51_add_ecspi(0, &cpuimx51sd_ecspi1_pdata);291spi_register_board_info(cpuimx51sd_spi_device,292ARRAY_SIZE(cpuimx51sd_spi_device));293294gpio_request(TSC2007_IRQGPIO, "tsc2007_irq");295gpio_direction_input(TSC2007_IRQGPIO);296gpio_free(TSC2007_IRQGPIO);297298i2c_register_board_info(0, eukrea_cpuimx51sd_i2c_devices,299ARRAY_SIZE(eukrea_cpuimx51sd_i2c_devices));300platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));301302if (otg_mode_host)303mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);304else {305initialize_otg_port(NULL);306mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata);307}308309gpio_request(USBH1_RST, "usb_rst");310gpio_direction_output(USBH1_RST, 0);311msleep(20);312gpio_set_value(USBH1_RST, 1);313mxc_register_device(&mxc_usbh1_device, &usbh1_config);314315#ifdef CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD316eukrea_mbimxsd51_baseboard_init();317#endif318}319320static void __init eukrea_cpuimx51sd_timer_init(void)321{322mx51_clocks_init(32768, 24000000, 22579200, 0);323}324325static struct sys_timer mxc_timer = {326.init = eukrea_cpuimx51sd_timer_init,327};328329MACHINE_START(EUKREA_CPUIMX51SD, "Eukrea CPUIMX51SD")330/* Maintainer: Eric Bénard <[email protected]> */331.boot_params = MX51_PHYS_OFFSET + 0x100,332.map_io = mx51_map_io,333.init_early = imx51_init_early,334.init_irq = mx51_init_irq,335.timer = &mxc_timer,336.init_machine = eukrea_cpuimx51sd_init,337MACHINE_END338339340