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