blob: d165bd952bad5288f01b0373a41f72830fcb46af [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Valentin Longchampe335c752010-02-09 18:13:36 +01002/*
3 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
Valentin Longchampe335c752010-02-09 18:13:36 +01004 */
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
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020014#include <linux/usb/otg.h>
15#include <linux/usb/ulpi.h>
16
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080017#include "board-mx31moboard.h"
Shawn Guoe3372472012-09-13 21:01:00 +080018#include "common.h"
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +020019#include "devices-imx31.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080020#include "ehci.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080021#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080022#include "iomux-mx3.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080023#include "ulpi.h"
Valentin Longchampe335c752010-02-09 18:13:36 +010024
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,
Valentin Longchampe335c752010-02-09 18:13:36 +010029 /* 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
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +020034static const struct imxuart_platform_data uart_pdata __initconst = {
Valentin Longchampe335c752010-02-09 18:13:36 +010035 .flags = IMXUART_HAVE_RTSCTS,
36};
37
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +010038static const struct fsl_usb2_platform_data usb_pdata __initconst = {
Philippe Rétornaz66c202a2010-05-11 16:57:50 +020039 .operating_mode = FSL_USB2_DR_DEVICE,
40 .phy_mode = FSL_USB2_PHY_ULPI,
41};
42
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020043#if defined(CONFIG_USB_ULPI)
44
Sascha Hauer4bd597b2011-01-03 11:30:28 +010045static int smartbot_otg_init(struct platform_device *pdev)
46{
47 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
48}
49
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010050static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +010051 .init = smartbot_otg_init,
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020052 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020053};
54
55static int __init smartbot_otg_host_init(void)
56{
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010057 struct platform_device *pdev;
58
Sascha Hauer48f6b092011-03-02 09:27:42 +010059 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;
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020063
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010064 pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010065
Fabian Frederickd3a22442014-07-04 21:03:10 +020066 return PTR_ERR_OR_ZERO(pdev);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020067}
68#else
69static inline int smartbot_otg_host_init(void) { return 0; }
70#endif
71
Valentin Longchampe335c752010-02-09 18:13:36 +010072#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)
Valentin Longchamp71764412010-05-05 11:34:21 +020075#define TRSLAT_SRC_CHOICE IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)
Valentin Longchampe335c752010-02-09 18:13:36 +010076
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
Valentin Longchamp71764412010-05-05 11:34:21 +020094 if (!gpio_request(TRSLAT_SRC_CHOICE, "translator-src-choice")) {
95 gpio_direction_output(TRSLAT_SRC_CHOICE, 0);
96 gpio_export(TRSLAT_SRC_CHOICE, false);
Valentin Longchampe335c752010-02-09 18:13:36 +010097 }
98}
99/*
100 * system init for baseboard usage. Will be called by mx31moboard init.
101 */
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200102void __init mx31moboard_smartbot_init(int board)
Valentin Longchampe335c752010-02-09 18:13:36 +0100103{
104 printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
105
106 mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
107 "smartbot");
108
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200109 imx31_add_imx_uart1(&uart_pdata);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200110
111 switch (board) {
112 case MX31SMARTBOT:
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +0100113 imx31_add_fsl_usb2_udc(&usb_pdata);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200114 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 }
Philippe Rétornaz66c202a2010-05-11 16:57:50 +0200122
Valentin Longchampe335c752010-02-09 18:13:36 +0100123 smartbot_resets_init();
Valentin Longchampe335c752010-02-09 18:13:36 +0100124}