mx31moboard: OTG host support
Subsystems (3)
v2 cover mx31moboard: OTG host support
Hello
This patch set add the OTG host support for the eyebot robot.
The first patch fix the usb PHY reset so we really do reset and configure the pad pull-up/down so the signal are stable while applying the reset signal (observed with an oscilloscope).
The last two patches are adding a new number to the mx31moboard_baseboard bootparam so we can choose at boot if we want an usb device or host on the smartbot board.
v2: I've added Acked-by from Valentin on the first two patches, fixed some typo and modified the last patch according to Valentin comment.
Regards,
Philippe
Philippe R?tornaz (3):
mx31moboard: Fix usb PHY reset
mx31moboard: Move usb OTG device registration
mx31moboard: OTG host support for smartbot board
arch/arm/mach-mx3/mach-mx31moboard.c | 104 +++++++------------- arch/arm/mach-mx3/mx31moboard-devboard.c | 9 ++ arch/arm/mach-mx3/mx31moboard-marxbot.c | 8 ++ arch/arm/mach-mx3/mx31moboard-smartbot.c | 45 ++++++++- arch/arm/plat-mxc/include/mach/board-mx31moboard.h | 3 +- 5 files changed, 100 insertions(+), 69 deletions(-)
PATCH v2 1/3 mx31moboard: Fix usb PHY reset
Setup the pad with correct pull-up/down before doing the reset. Assert the PHY enable signal so the reset is really done.
--- arch/arm/mach-mx3/mach-mx31moboard.c | 98 +++++++++++++--------------------- 1 files changed, 37 insertions(+), 61 deletions(-)
arch/arm/mach-mx3/mach-mx31moboard.c +37 -61
@@ -306,37 +306,51 @@ static struct imxmmc_platform_data sdhc1_pdata = {* this pin is dedicated for all mx31moboard systems, so we do it here */ #define USB_RESET_B IOMUX_TO_GPIO(MX31_PIN_GPIO1_0) - -static void usb_xcvr_reset (void ) -{ -gpio_request (USB_RESET_B ,"usb-reset" ); -gpio_direction_output (USB_RESET_B ,0 ); -mdelay (1 ); -gpio_set_value (USB_RESET_B ,1 ); -} -#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ - PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) + PAD_CTL_ODE_CMOS)#define OTG_EN_B IOMUX_TO_GPIO(MX31_PIN_USB_OC) +#define USBH2_EN_B IOMUX_TO_GPIO(MX31_PIN_SCK6) -static void moboard_usbotg_init (void ) +static void usb_xcvr_reset (void ) { -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA0 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA1 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA2 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA3 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA4 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA5 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA6 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA7 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_CLK ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DIR ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_NXT ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_STP ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA0 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA1 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA2 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA3 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA4 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA5 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA6 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA7 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_CLK ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_DIR ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_NXT ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBOTG_STP ,USB_PAD_CFG |PAD_CTL_100K_PU ); + +mxc_iomux_set_gpr (MUX_PGP_UH2 , true); +mxc_iomux_set_pad (MX31_PIN_USBH2_CLK ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DIR ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBH2_NXT ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBH2_STP ,USB_PAD_CFG |PAD_CTL_100K_PU ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA0 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA1 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_SRXD6 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_STXD6 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_SFS3 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_SCK3 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_SRXD3 ,USB_PAD_CFG |PAD_CTL_100K_PD ); +mxc_iomux_set_pad (MX31_PIN_STXD3 ,USB_PAD_CFG |PAD_CTL_100K_PD );gpio_request (OTG_EN_B ,"usb-udc-en" );gpio_direction_output (OTG_EN_B ,0 ); +gpio_request (USBH2_EN_B ,"usbh2-en" ); +gpio_direction_output (USBH2_EN_B ,0 ); + +gpio_request (USB_RESET_B ,"usb-reset" ); +gpio_direction_output (USB_RESET_B ,0 ); +mdelay (1 ); +gpio_set_value (USB_RESET_B ,1 ); +mdelay (1 ); }static struct fsl_usb2_platform_data usb_pdata = {
@@ -346,44 +360,7 @@ static struct fsl_usb2_platform_data usb_pdata = {#if defined(CONFIG_USB_ULPI ) -#define USBH2_EN_B IOMUX_TO_GPIO(MX31_PIN_SCK6) - -static int moboard_usbh2_hw_init (struct platform_device *pdev) -{ -int ret; - -mxc_iomux_set_gpr (MUX_PGP_UH2 , true); - -mxc_iomux_set_pad (MX31_PIN_USBH2_CLK ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBH2_DIR ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBH2_NXT ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBH2_STP ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBH2_DATA0 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_USBH2_DATA1 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_SRXD6 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_STXD6 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_SFS3 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_SCK3 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_SRXD3 ,USB_PAD_CFG ); -mxc_iomux_set_pad (MX31_PIN_STXD3 ,USB_PAD_CFG ); - - ret =gpio_request (USBH2_EN_B ,"usbh2-en" ); -if (ret) -return ret; -gpio_direction_output (USBH2_EN_B ,0 ); - -return 0 ; -} - -static int moboard_usbh2_hw_exit (struct platform_device *pdev) -{ -gpio_free (USBH2_EN_B ); -return 0 ; -} -static struct mxc_usbh_platform_data usbh2_pdata = { - .init = moboard_usbh2_hw_init, - .exit = moboard_usbh2_hw_exit, .portsc =MXC_EHCI_MODE_ULPI |MXC_EHCI_UTMI_8BIT , .flags =MXC_EHCI_POWER_PINS_ENABLED , };
@@ -508,7 +485,6 @@ static void __init mxc_board_init(void)usb_xcvr_reset (); -moboard_usbotg_init ();mxc_register_device (&mxc_otg_udc_device, &usb_pdata);moboard_usbh2_init ();
Signature · 1 line
1.6.3.3
PATCH v2 2/3 mx31moboard: Move usb OTG device registration
In preparation for a new robot which needs the
OTG port as host.
This moves the OTG device registration into board
initialisation.
--- arch/arm/mach-mx3/mach-mx31moboard.c | 7 ------- arch/arm/mach-mx3/mx31moboard-devboard.c | 9 +++++++++ arch/arm/mach-mx3/mx31moboard-marxbot.c | 8 ++++++++ arch/arm/mach-mx3/mx31moboard-smartbot.c | 8 ++++++++ 4 files changed, 25 insertions(+), 7 deletions(-)
arch/arm/mach-mx3/mach-mx31moboard.c +0 -7
@@ -18,7 +18,6 @@#include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/fsl_devices.h> #include <linux/gfp.h> #include <linux/gpio.h> #include <linux/init.h>
@@ -353,11 +352,6 @@ static void usb_xcvr_reset(void)mdelay (1 ); } -static struct fsl_usb2_platform_data usb_pdata = { - .operating_mode =FSL_USB2_DR_DEVICE , - .phy_mode =FSL_USB2_PHY_ULPI , -}; -#if defined(CONFIG_USB_ULPI ) static struct mxc_usbh_platform_data usbh2_pdata = {
@@ -485,7 +479,6 @@ static void __init mxc_board_init(void)usb_xcvr_reset (); -mxc_register_device (&mxc_otg_udc_device, &usb_pdata);moboard_usbh2_init ();switch (mx31moboard_baseboard) {
arch/arm/mach-mx3/mx31moboard-devboard.c +9 -0
@@ -22,6 +22,7 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/fsl_devices.h> #include <linux/usb/otg.h>
@@ -213,6 +214,12 @@ static int __init devboard_usbh1_init(void)return mxc_register_device (&mxc_usbh1, &usbh1_pdata); } + +static struct fsl_usb2_platform_data usb_pdata = { + .operating_mode =FSL_USB2_DR_DEVICE , + .phy_mode =FSL_USB2_PHY_ULPI , +}; +/* * system init for baseboard usage. Will be called by mx31moboard init. */
@@ -229,5 +236,7 @@ void __init mx31moboard_devboard_init(void)devboard_init_sel_gpios (); +mxc_register_device (&mxc_otg_udc_device, &usb_pdata); +devboard_usbh1_init (); }
arch/arm/mach-mx3/mx31moboard-marxbot.c +8 -0
@@ -25,6 +25,7 @@#include <linux/slab.h> #include <linux/platform_device.h> #include <linux/types.h> +#include <linux/fsl_devices.h> #include <linux/usb/otg.h>
@@ -331,6 +332,11 @@ static int __init marxbot_usbh1_init(void)return mxc_register_device (&mxc_usbh1, &usbh1_pdata); } +static struct fsl_usb2_platform_data usb_pdata = { + .operating_mode =FSL_USB2_DR_DEVICE , + .phy_mode =FSL_USB2_PHY_ULPI , +}; +/* * system init for baseboard usage. Will be called by mx31moboard init. */
@@ -358,5 +364,7 @@ void __init mx31moboard_marxbot_init(void)gpio_direction_input (IOMUX_TO_GPIO (MX31_PIN_LCS0 ));gpio_export (IOMUX_TO_GPIO (MX31_PIN_LCS0 ), false); +mxc_register_device (&mxc_otg_udc_device, &usb_pdata); +marxbot_usbh1_init (); }
arch/arm/mach-mx3/mx31moboard-smartbot.c +8 -0
@@ -23,6 +23,7 @@#include <linux/i2c.h> #include <linux/platform_device.h> #include <linux/types.h> +#include <linux/fsl_devices.h> #include <mach/common.h> #include <mach/hardware.h>
@@ -116,6 +117,11 @@ static int __init smartbot_cam_init(void)return 0 ; } +static struct fsl_usb2_platform_data usb_pdata = { + .operating_mode =FSL_USB2_DR_DEVICE , + .phy_mode =FSL_USB2_PHY_ULPI , +}; +#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)
@@ -155,6 +161,8 @@ void __init mx31moboard_smartbot_init(void)mxc_register_device (&mxc_uart_device1, &uart_pdata); +mxc_register_device (&mxc_otg_udc_device, &usb_pdata); +smartbot_resets_init ();smartbot_cam_init ();
Signature · 1 line
1.6.3.3
PATCH v2 3/3 mx31moboard: OTG host support for smartbot board
The Eyebot robot needs the OTG port in host mode on the smartbot.
Add a new board definition so we can select the usb host/device mode at boot with the mx31moboard_baseboard boot parameter.
--- arch/arm/mach-mx3/mach-mx31moboard.c | 3 +- arch/arm/mach-mx3/mx31moboard-smartbot.c | 39 +++++++++++++++++++- arch/arm/plat-mxc/include/mach/board-mx31moboard.h | 3 +- 3 files changed, 41 insertions(+), 4 deletions(-)
arch/arm/mach-mx3/mach-mx31moboard.c +2 -1
@@ -491,7 +491,8 @@ static void __init mxc_board_init(void)mx31moboard_marxbot_init ();break ;case MX31SMARTBOT : -mx31moboard_smartbot_init (); +case MX31EYEBOT : +mx31moboard_smartbot_init (mx31moboard_baseboard);break ;default : printk(KERN_ERR "Illegal mx31moboard_baseboard type %d\n",
arch/arm/mach-mx3/mx31moboard-smartbot.c +37 -2
@@ -25,10 +25,16 @@#include <linux/types.h> #include <linux/fsl_devices.h> +#include <linux/usb/otg.h> +#include <linux/usb/ulpi.h> +#include <mach/common.h> #include <mach/hardware.h> #include <mach/imx-uart.h> #include <mach/iomux-mx3.h> +#include <mach/board-mx31moboard.h> +#include <mach/mxc_ehci.h> +#include <mach/ulpi.h> #include <media/soc_camera.h>
@@ -122,6 +128,24 @@ static struct fsl_usb2_platform_data usb_pdata = { .phy_mode = FSL_USB2_PHY_ULPI, }; +#if defined(CONFIG_USB_ULPI ) + +static struct mxc_usbh_platform_data otg_host_pdata = { + .portsc =MXC_EHCI_MODE_ULPI |MXC_EHCI_UTMI_8BIT , + .flags =MXC_EHCI_POWER_PINS_ENABLED , +}; + +static int __init smartbot_otg_host_init (void ) +{ + otg_host_pdata.otg =otg_ulpi_create (&mxc_ulpi_access_ops, +USB_OTG_DRV_VBUS |USB_OTG_DRV_VBUS_EXT ); + +return mxc_register_device (&mxc_otg_host, &otg_host_pdata); +} +#else +static inline int smartbot_otg_host_init (void ) {return 0 ; } +#endif +#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)
@@ -152,7 +176,7 @@ static void smartbot_resets_init(void)/* * system init for baseboard usage. Will be called by mx31moboard init. */ -void __init mx31moboard_smartbot_init (void ) +void __init mx31moboard_smartbot_init (int board) {printk (KERN_INFO "Initializing mx31smartbot peripherals\n" );
@@ -161,7 +185,18 @@ void __init mx31moboard_smartbot_init(void)mxc_register_device (&mxc_uart_device1, &uart_pdata); -mxc_register_device (&mxc_otg_udc_device, &usb_pdata); + +switch (board) { +case MX31SMARTBOT : +mxc_register_device (&mxc_otg_udc_device, &usb_pdata); +break ; +case MX31EYEBOT : +smartbot_otg_host_init (); +break ; +default : +printk (KERN_WARNING "Unknown board %d, USB OTG not initialized" , + board); + }smartbot_resets_init ();
arch/arm/plat-mxc/include/mach/board-mx31moboard.h +2 -1
@@ -26,6 +26,7 @@ enum mx31moboard_boards {MX31DEVBOARD =1 ,MX31MARXBOT =2 ,MX31SMARTBOT =3 , + MX31EYEBOT = 4, };/*
@@ -35,7 +36,7 @@ enum mx31moboard_boards {extern void mx31moboard_devboard_init (void );extern void mx31moboard_marxbot_init (void ); -extern void mx31moboard_smartbot_init (void ); +extern void mx31moboard_smartbot_init (int board);#endif
Signature · 1 line
1.6.3.3
Sascha Hauer
maintainerv2 cover mx31moboard: OTG host support
In reply to Philippe RétornazQuoted 8 lines · Philippe R?tornaz
Hello
This patch set add the OTG host support for the eyebot robot.
The first patch fix the usb PHY reset so we really do reset and configure the pad pull-up/down so the signal are stable while applying the reset signal (observed with an oscilloscope).
Quoted 6 lines
The last two patches are adding a new number to the
mx31moboard_baseboardbootparam so we can choose at boot if we want an usb device or host on the smartbot board.v2: I've added Acked-by from Valentin on the first two patches, fixed some typo and modified the last patch according to Valentin comment.
Ok, applied.
Sascha
Quoted 17 lines
Regards,
PhilippePhilippe R?tornaz (3):
mx31moboard: Fix usb PHY reset
mx31moboard: Move usb OTG device registration
mx31moboard: OTG host support for smartbot boardarch/arm/mach-mx3/mach-mx31moboard.c | 104 +++++++------------- arch/arm/mach-mx3/mx31moboard-devboard.c | 9 ++ arch/arm/mach-mx3/mx31moboard-marxbot.c | 8 ++ arch/arm/mach-mx3/mx31moboard-smartbot.c | 45 ++++++++- arch/arm/plat-mxc/include/mach/board-mx31moboard.h | 3 +- 5 files changed, 100 insertions(+), 69 deletions(-)
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |