2019-05-27 09:55:06 +03:00
// SPDX-License-Identifier: GPL-2.0-or-later
2010-02-09 20:13:36 +03:00
/*
* Copyright ( C ) 2009 Valentin Longchamp , EPFL Mobots group
*/
# include <linux/delay.h>
# include <linux/gpio.h>
# include <linux/init.h>
# include <linux/interrupt.h>
# include <linux/i2c.h>
# include <linux/platform_device.h>
# include <linux/types.h>
2010-05-11 18:57:51 +04:00
# include <linux/usb/otg.h>
# include <linux/usb/ulpi.h>
2012-09-13 05:37:49 +04:00
# include "board-mx31moboard.h"
2012-09-13 17:01:00 +04:00
# include "common.h"
2010-06-23 13:46:16 +04:00
# include "devices-imx31.h"
2014-05-19 16:41:52 +04:00
# include "ehci.h"
2012-09-14 10:14:45 +04:00
# include "hardware.h"
2012-09-13 09:26:00 +04:00
# include "iomux-mx3.h"
2012-09-13 17:46:09 +04:00
# include "ulpi.h"
2010-02-09 20:13:36 +03:00
static unsigned int smartbot_pins [ ] = {
/* UART1 */
MX31_PIN_CTS2__CTS2 , MX31_PIN_RTS2__RTS2 ,
MX31_PIN_TXD2__TXD2 , MX31_PIN_RXD2__RXD2 ,
/* ENABLES */
MX31_PIN_DTR_DCE1__GPIO2_8 , MX31_PIN_DSR_DCE1__GPIO2_9 ,
MX31_PIN_RI_DCE1__GPIO2_10 , MX31_PIN_DCD_DCE1__GPIO2_11 ,
} ;
2010-06-23 13:46:16 +04:00
static const struct imxuart_platform_data uart_pdata __initconst = {
2010-02-09 20:13:36 +03:00
. flags = IMXUART_HAVE_RTSCTS ,
} ;
2010-11-12 18:40:06 +03:00
static const struct fsl_usb2_platform_data usb_pdata __initconst = {
2010-05-11 18:57:50 +04:00
. operating_mode = FSL_USB2_DR_DEVICE ,
. phy_mode = FSL_USB2_PHY_ULPI ,
} ;
2010-05-11 18:57:51 +04:00
# if defined(CONFIG_USB_ULPI)
2011-01-03 13:30:28 +03:00
static int smartbot_otg_init ( struct platform_device * pdev )
{
return mx31_initialize_usb_hw ( pdev - > id , MXC_EHCI_POWER_PINS_ENABLED ) ;
}
2010-11-15 13:57:49 +03:00
static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
2011-01-03 13:30:28 +03:00
. init = smartbot_otg_init ,
2010-05-11 18:57:51 +04:00
. portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT ,
} ;
static int __init smartbot_otg_host_init ( void )
{
2010-11-15 13:57:49 +03:00
struct platform_device * pdev ;
2011-03-02 11:27:42 +03:00
otg_host_pdata . otg = imx_otg_ulpi_create ( ULPI_OTG_DRVVBUS |
ULPI_OTG_DRVVBUS_EXT ) ;
if ( ! otg_host_pdata . otg )
return - ENODEV ;
2010-05-11 18:57:51 +04:00
2010-11-15 13:57:49 +03:00
pdev = imx31_add_mxc_ehci_otg ( & otg_host_pdata ) ;
2014-07-04 23:03:10 +04:00
return PTR_ERR_OR_ZERO ( pdev ) ;
2010-05-11 18:57:51 +04:00
}
# else
static inline int smartbot_otg_host_init ( void ) { return 0 ; }
# endif
2010-02-09 20:13:36 +03:00
# define POWER_EN IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1)
# define DSPIC_RST_B IOMUX_TO_GPIO(MX31_PIN_DSR_DCE1)
# define TRSLAT_RST_B IOMUX_TO_GPIO(MX31_PIN_RI_DCE1)
2010-05-05 13:34:21 +04:00
# define TRSLAT_SRC_CHOICE IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)
2010-02-09 20:13:36 +03:00
static void smartbot_resets_init ( void )
{
if ( ! gpio_request ( POWER_EN , " power-enable " ) ) {
gpio_direction_output ( POWER_EN , 0 ) ;
gpio_export ( POWER_EN , false ) ;
}
if ( ! gpio_request ( DSPIC_RST_B , " dspic-rst " ) ) {
gpio_direction_output ( DSPIC_RST_B , 0 ) ;
gpio_export ( DSPIC_RST_B , false ) ;
}
if ( ! gpio_request ( TRSLAT_RST_B , " translator-rst " ) ) {
gpio_direction_output ( TRSLAT_RST_B , 0 ) ;
gpio_export ( TRSLAT_RST_B , false ) ;
}
2010-05-05 13:34:21 +04:00
if ( ! gpio_request ( TRSLAT_SRC_CHOICE , " translator-src-choice " ) ) {
gpio_direction_output ( TRSLAT_SRC_CHOICE , 0 ) ;
gpio_export ( TRSLAT_SRC_CHOICE , false ) ;
2010-02-09 20:13:36 +03:00
}
}
/*
* system init for baseboard usage . Will be called by mx31moboard init .
*/
2010-05-11 18:57:51 +04:00
void __init mx31moboard_smartbot_init ( int board )
2010-02-09 20:13:36 +03:00
{
printk ( KERN_INFO " Initializing mx31smartbot peripherals \n " ) ;
mxc_iomux_setup_multiple_pins ( smartbot_pins , ARRAY_SIZE ( smartbot_pins ) ,
" smartbot " ) ;
2010-06-23 13:46:16 +04:00
imx31_add_imx_uart1 ( & uart_pdata ) ;
2010-05-11 18:57:51 +04:00
switch ( board ) {
case MX31SMARTBOT :
2010-11-12 18:40:06 +03:00
imx31_add_fsl_usb2_udc ( & usb_pdata ) ;
2010-05-11 18:57:51 +04:00
break ;
case MX31EYEBOT :
smartbot_otg_host_init ( ) ;
break ;
default :
printk ( KERN_WARNING " Unknown board %d, USB OTG not initialized " ,
board ) ;
}
2010-05-11 18:57:50 +04:00
2010-02-09 20:13:36 +03:00
smartbot_resets_init ( ) ;
}