Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / mach-imx / mx31moboard-smartbot.c
blobd165bd952bad5288f01b0373a41f72830fcb46af
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
4 */
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>
14 #include <linux/usb/otg.h>
15 #include <linux/usb/ulpi.h>
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"
25 static 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,
34 static const struct imxuart_platform_data uart_pdata __initconst = {
35 .flags = IMXUART_HAVE_RTSCTS,
38 static const struct fsl_usb2_platform_data usb_pdata __initconst = {
39 .operating_mode = FSL_USB2_DR_DEVICE,
40 .phy_mode = FSL_USB2_PHY_ULPI,
43 #if defined(CONFIG_USB_ULPI)
45 static int smartbot_otg_init(struct platform_device *pdev)
47 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
50 static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
51 .init = smartbot_otg_init,
52 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
55 static int __init smartbot_otg_host_init(void)
57 struct platform_device *pdev;
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;
64 pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
66 return PTR_ERR_OR_ZERO(pdev);
68 #else
69 static inline int smartbot_otg_host_init(void) { return 0; }
70 #endif
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)
77 static void smartbot_resets_init(void)
79 if (!gpio_request(POWER_EN, "power-enable")) {
80 gpio_direction_output(POWER_EN, 0);
81 gpio_export(POWER_EN, false);
84 if (!gpio_request(DSPIC_RST_B, "dspic-rst")) {
85 gpio_direction_output(DSPIC_RST_B, 0);
86 gpio_export(DSPIC_RST_B, false);
89 if (!gpio_request(TRSLAT_RST_B, "translator-rst")) {
90 gpio_direction_output(TRSLAT_RST_B, 0);
91 gpio_export(TRSLAT_RST_B, false);
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);
100 * system init for baseboard usage. Will be called by mx31moboard init.
102 void __init mx31moboard_smartbot_init(int board)
104 printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
106 mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
107 "smartbot");
109 imx31_add_imx_uart1(&uart_pdata);
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);
123 smartbot_resets_init();