Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / mach-imx / mx31moboard-smartbot.c
blob5cdd7abce51527a3cce1bd38f3218f2fdb130f34
1 /*
2 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
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.
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.
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>
23 #include <linux/usb/otg.h>
24 #include <linux/usb/ulpi.h>
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"
34 static 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,
43 static const struct imxuart_platform_data uart_pdata __initconst = {
44 .flags = IMXUART_HAVE_RTSCTS,
47 static const struct fsl_usb2_platform_data usb_pdata __initconst = {
48 .operating_mode = FSL_USB2_DR_DEVICE,
49 .phy_mode = FSL_USB2_PHY_ULPI,
52 #if defined(CONFIG_USB_ULPI)
54 static int smartbot_otg_init(struct platform_device *pdev)
56 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
59 static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
60 .init = smartbot_otg_init,
61 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
64 static int __init smartbot_otg_host_init(void)
66 struct platform_device *pdev;
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;
73 pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
75 return PTR_ERR_OR_ZERO(pdev);
77 #else
78 static inline int smartbot_otg_host_init(void) { return 0; }
79 #endif
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)
86 static void smartbot_resets_init(void)
88 if (!gpio_request(POWER_EN, "power-enable")) {
89 gpio_direction_output(POWER_EN, 0);
90 gpio_export(POWER_EN, false);
93 if (!gpio_request(DSPIC_RST_B, "dspic-rst")) {
94 gpio_direction_output(DSPIC_RST_B, 0);
95 gpio_export(DSPIC_RST_B, false);
98 if (!gpio_request(TRSLAT_RST_B, "translator-rst")) {
99 gpio_direction_output(TRSLAT_RST_B, 0);
100 gpio_export(TRSLAT_RST_B, false);
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);
109 * system init for baseboard usage. Will be called by mx31moboard init.
111 void __init mx31moboard_smartbot_init(int board)
113 printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
115 mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
116 "smartbot");
118 imx31_add_imx_uart1(&uart_pdata);
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);
132 smartbot_resets_init();