From: Ye Li Date: Thu, 16 Mar 2017 09:02:56 +0000 (+0800) Subject: MLK-14445-6 mx7ulp_evk: Add USB OTG0 support X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~555 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=fef193218f24baee61479b3c551e2b0d376cc5bc;p=u-boot.git MLK-14445-6 mx7ulp_evk: Add USB OTG0 support Porting codes to support USB OTG0 on the EVK board. Convert to use DM USB driver. Signed-off-by: Ye Li (cherry picked from commit b4e01a67a0740c524e7522da7ace0488f86261db) (cherry picked from commit 23144983d3347f8f91695cea73aab8558cc66629) (cherry picked from commit a5d3e7a334689b5c7b4e99f10c1a6044e4775699) (cherry picked from commit 4906e4b9ff0e75ad517fa3ed3d49430d3533d3f6) (cherry picked from commit c315588cf84d2a4b61ad11827444891edf17a35a) --- diff --git a/board/freescale/mx7ulp_evk/mx7ulp_evk.c b/board/freescale/mx7ulp_evk/mx7ulp_evk.c index 1e304a205d..ce58cc05d8 100644 --- a/board/freescale/mx7ulp_evk/mx7ulp_evk.c +++ b/board/freescale/mx7ulp_evk/mx7ulp_evk.c @@ -12,11 +12,15 @@ #include #include #include +#include +#include +#include DECLARE_GLOBAL_DATA_PTR; #define UART_PAD_CTRL (PAD_CTL_PUS_UP) #define QSPI_PAD_CTRL1 (PAD_CTL_PUS_UP | PAD_CTL_DSE) +#define OTG_ID_GPIO_PAD_CTRL (PAD_CTL_IBE_ENABLE) int dram_init(void) { @@ -66,6 +70,37 @@ int board_qspi_init(void) } #endif +#ifdef CONFIG_DM_USB +static iomux_cfg_t const usb_otg1_pads[] = { + MX7ULP_PAD_PTC8__PTC8 | MUX_PAD_CTRL(OTG_ID_GPIO_PAD_CTRL), /* gpio for OTG ID*/ +}; + +static void setup_usb(void) +{ + mx7ulp_iomux_setup_multiple_pads(usb_otg1_pads, + ARRAY_SIZE(usb_otg1_pads)); + + gpio_request(IMX_GPIO_NR(3, 8), "otg_id"); + gpio_direction_input(IMX_GPIO_NR(3, 8)); +} + +int board_ehci_usb_phy_mode(struct udevice *dev) +{ + int ret = 0; + + if (devfdt_get_addr(dev) == USBOTG0_RBASE) { + ret = gpio_get_value(IMX_GPIO_NR(3, 8)); + + if (ret) + return USB_INIT_DEVICE; + else + return USB_INIT_HOST; + } + + return USB_INIT_HOST; +} +#endif + int board_early_init_f(void) { setup_iomux_uart(); @@ -82,6 +117,10 @@ int board_init(void) board_qspi_init(); #endif +#ifdef CONFIG_DM_USB + setup_usb(); +#endif + return 0; } diff --git a/configs/mx7ulp_evk_defconfig b/configs/mx7ulp_evk_defconfig index 5d8cd601ad..8f7f406141 100644 --- a/configs/mx7ulp_evk_defconfig +++ b/configs/mx7ulp_evk_defconfig @@ -55,3 +55,12 @@ CONFIG_SF_DEFAULT_CS=0 CONFIG_SF_DEFAULT_SPEED=40000000 CONFIG_SF_DEFAULT_MODE=0 CONFIG_ULP_WATCHDOG=y +CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_MXC_USB_OTG_HACTIVE=y +CONFIG_USB_STORAGE=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX=y +CONFIG_USB_ETHER_RTL8152=y diff --git a/configs/mx7ulp_evk_plugin_defconfig b/configs/mx7ulp_evk_plugin_defconfig index 981d6310d9..907744116f 100644 --- a/configs/mx7ulp_evk_plugin_defconfig +++ b/configs/mx7ulp_evk_plugin_defconfig @@ -54,3 +54,12 @@ CONFIG_SF_DEFAULT_CS=0 CONFIG_SF_DEFAULT_SPEED=40000000 CONFIG_SF_DEFAULT_MODE=0 CONFIG_ULP_WATCHDOG=y +CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_MXC_USB_OTG_HACTIVE=y +CONFIG_USB_STORAGE=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX=y +CONFIG_USB_ETHER_RTL8152=y diff --git a/include/configs/mx7ulp_evk.h b/include/configs/mx7ulp_evk.h index 0c3103082c..f1c2be5c0c 100644 --- a/include/configs/mx7ulp_evk.h +++ b/include/configs/mx7ulp_evk.h @@ -135,4 +135,7 @@ #define CONFIG_SYS_INIT_SP_ADDR \ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET) +/* USB Configs */ +#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) + #endif /* __CONFIG_H */