linux/arch/arm/mach-imx/mx31moboard-smartbot.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License as published by
   6 * the Free Software Foundation; either version 2 of the License, or
   7 * (at your option) any later version.
   8 *
   9 * This program is distributed in the hope that it will be useful,
  10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12 * GNU General Public License for more details.
  13 */
  14
  15#include <linux/delay.h>
  16#include <linux/gpio.h>
  17#include <linux/init.h>
  18#include <linux/interrupt.h>
  19#include <linux/i2c.h>
  20#include <linux/platform_device.h>
  21#include <linux/types.h>
  22
  23#include <linux/usb/otg.h>
  24#include <linux/usb/ulpi.h>
  25
  26#include "board-mx31moboard.h"
  27#include "common.h"
  28#include "devices-imx31.h"
  29#include "ehci.h"
  30#include "hardware.h"
  31#include "iomux-mx3.h"
  32#include "ulpi.h"
  33
  34static unsigned int smartbot_pins[] = {
  35        /* UART1 */
  36        MX31_PIN_CTS2__CTS2, MX31_PIN_RTS2__RTS2,
  37        MX31_PIN_TXD2__TXD2, MX31_PIN_RXD2__RXD2,
  38        /* ENABLES */
  39        MX31_PIN_DTR_DCE1__GPIO2_8, MX31_PIN_DSR_DCE1__GPIO2_9,
  40        MX31_PIN_RI_DCE1__GPIO2_10, MX31_PIN_DCD_DCE1__GPIO2_11,
  41};
  42
  43static const struct imxuart_platform_data uart_pdata __initconst = {
  44        .flags = IMXUART_HAVE_RTSCTS,
  45};
  46
  47static const struct fsl_usb2_platform_data usb_pdata __initconst = {
  48        .operating_mode = FSL_USB2_DR_DEVICE,
  49        .phy_mode       = FSL_USB2_PHY_ULPI,
  50};
  51
  52#if defined(CONFIG_USB_ULPI)
  53
  54static int smartbot_otg_init(struct platform_device *pdev)
  55{
  56        return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  57}
  58
  59static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
  60        .init   = smartbot_otg_init,
  61        .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  62};
  63
  64static int __init smartbot_otg_host_init(void)
  65{
  66        struct platform_device *pdev;
  67
  68        otg_host_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  69                ULPI_OTG_DRVVBUS_EXT);
  70        if (!otg_host_pdata.otg)
  71                return -ENODEV;
  72
  73        pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
  74
  75        return PTR_ERR_OR_ZERO(pdev);
  76}
  77#else
  78static inline int smartbot_otg_host_init(void) { return 0; }
  79#endif
  80
  81#define POWER_EN IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1)
  82#define DSPIC_RST_B IOMUX_TO_GPIO(MX31_PIN_DSR_DCE1)
  83#define TRSLAT_RST_B IOMUX_TO_GPIO(MX31_PIN_RI_DCE1)
  84#define TRSLAT_SRC_CHOICE IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)
  85
  86static void smartbot_resets_init(void)
  87{
  88        if (!gpio_request(POWER_EN, "power-enable")) {
  89                gpio_direction_output(POWER_EN, 0);
  90                gpio_export(POWER_EN, false);
  91        }
  92
  93        if (!gpio_request(DSPIC_RST_B, "dspic-rst")) {
  94                gpio_direction_output(DSPIC_RST_B, 0);
  95                gpio_export(DSPIC_RST_B, false);
  96        }
  97
  98        if (!gpio_request(TRSLAT_RST_B, "translator-rst")) {
  99                gpio_direction_output(TRSLAT_RST_B, 0);
 100                gpio_export(TRSLAT_RST_B, false);
 101        }
 102
 103        if (!gpio_request(TRSLAT_SRC_CHOICE, "translator-src-choice")) {
 104                gpio_direction_output(TRSLAT_SRC_CHOICE, 0);
 105                gpio_export(TRSLAT_SRC_CHOICE, false);
 106        }
 107}
 108/*
 109 * system init for baseboard usage. Will be called by mx31moboard init.
 110 */
 111void __init mx31moboard_smartbot_init(int board)
 112{
 113        printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
 114
 115        mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
 116                "smartbot");
 117
 118        imx31_add_imx_uart1(&uart_pdata);
 119
 120        switch (board) {
 121        case MX31SMARTBOT:
 122                imx31_add_fsl_usb2_udc(&usb_pdata);
 123                break;
 124        case MX31EYEBOT:
 125                smartbot_otg_host_init();
 126                break;
 127        default:
 128                printk(KERN_WARNING "Unknown board %d, USB OTG not initialized",
 129                        board);
 130        }
 131
 132        smartbot_resets_init();
 133}
 134