blob: 5cdd7abce51527a3cce1bd38f3218f2fdb130f34 [file] [log] [blame]
Valentin Longchampe335c752010-02-09 18:13:36 +01001/*
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.
Valentin Longchampe335c752010-02-09 18:13:36 +010013 */
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
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020023#include <linux/usb/otg.h>
24#include <linux/usb/ulpi.h>
25
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080026#include "board-mx31moboard.h"
Shawn Guoe3372472012-09-13 21:01:00 +080027#include "common.h"
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +020028#include "devices-imx31.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080029#include "ehci.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080030#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080031#include "iomux-mx3.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080032#include "ulpi.h"
Valentin Longchampe335c752010-02-09 18:13:36 +010033
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,
Valentin Longchampe335c752010-02-09 18:13:36 +010038 /* 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
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +020043static const struct imxuart_platform_data uart_pdata __initconst = {
Valentin Longchampe335c752010-02-09 18:13:36 +010044 .flags = IMXUART_HAVE_RTSCTS,
45};
46
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +010047static const struct fsl_usb2_platform_data usb_pdata __initconst = {
Philippe Rétornaz66c202a2010-05-11 16:57:50 +020048 .operating_mode = FSL_USB2_DR_DEVICE,
49 .phy_mode = FSL_USB2_PHY_ULPI,
50};
51
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020052#if defined(CONFIG_USB_ULPI)
53
Sascha Hauer4bd597b2011-01-03 11:30:28 +010054static int smartbot_otg_init(struct platform_device *pdev)
55{
56 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
57}
58
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010059static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
Sascha Hauer4bd597b2011-01-03 11:30:28 +010060 .init = smartbot_otg_init,
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020061 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020062};
63
64static int __init smartbot_otg_host_init(void)
65{
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010066 struct platform_device *pdev;
67
Sascha Hauer48f6b092011-03-02 09:27:42 +010068 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;
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020072
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010073 pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
Uwe Kleine-König2d58de22010-11-15 11:57:49 +010074
Fabian Frederickd3a22442014-07-04 21:03:10 +020075 return PTR_ERR_OR_ZERO(pdev);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +020076}
77#else
78static inline int smartbot_otg_host_init(void) { return 0; }
79#endif
80
Valentin Longchampe335c752010-02-09 18:13:36 +010081#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)
Valentin Longchamp71764412010-05-05 11:34:21 +020084#define TRSLAT_SRC_CHOICE IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)
Valentin Longchampe335c752010-02-09 18:13:36 +010085
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
Valentin Longchamp71764412010-05-05 11:34:21 +0200103 if (!gpio_request(TRSLAT_SRC_CHOICE, "translator-src-choice")) {
104 gpio_direction_output(TRSLAT_SRC_CHOICE, 0);
105 gpio_export(TRSLAT_SRC_CHOICE, false);
Valentin Longchampe335c752010-02-09 18:13:36 +0100106 }
107}
108/*
109 * system init for baseboard usage. Will be called by mx31moboard init.
110 */
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200111void __init mx31moboard_smartbot_init(int board)
Valentin Longchampe335c752010-02-09 18:13:36 +0100112{
113 printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
114
115 mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
116 "smartbot");
117
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200118 imx31_add_imx_uart1(&uart_pdata);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200119
120 switch (board) {
121 case MX31SMARTBOT:
Uwe Kleine-König9e1dde32010-11-12 16:40:06 +0100122 imx31_add_fsl_usb2_udc(&usb_pdata);
Philippe Rétornaz3a47b1a2010-05-11 16:57:51 +0200123 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 }
Philippe Rétornaz66c202a2010-05-11 16:57:50 +0200131
Valentin Longchampe335c752010-02-09 18:13:36 +0100132 smartbot_resets_init();
Valentin Longchampe335c752010-02-09 18:13:36 +0100133}