From a5d3e7a334689b5c7b4e99f10c1a6044e4775699 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Thu, 16 Mar 2017 17:02:56 +0800 Subject: [PATCH] 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) --- board/freescale/mx7ulp_evk/mx7ulp_evk.c | 39 +++++++++++++++++++++++++ configs/mx7ulp_evk_defconfig | 9 ++++++ configs/mx7ulp_evk_plugin_defconfig | 9 ++++++ include/configs/mx7ulp_evk.h | 3 ++ 4 files changed, 60 insertions(+) diff --git a/board/freescale/mx7ulp_evk/mx7ulp_evk.c b/board/freescale/mx7ulp_evk/mx7ulp_evk.c index b577224246..0fed2e6650 100644 --- a/board/freescale/mx7ulp_evk/mx7ulp_evk.c +++ b/board/freescale/mx7ulp_evk/mx7ulp_evk.c @@ -8,11 +8,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) { @@ -62,6 +66,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(); @@ -78,5 +113,9 @@ 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 21fd6e8797..3f7a233afe 100644 --- a/configs/mx7ulp_evk_defconfig +++ b/configs/mx7ulp_evk_defconfig @@ -42,3 +42,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 1fc9cb8a61..42c6cd7b04 100644 --- a/configs/mx7ulp_evk_plugin_defconfig +++ b/configs/mx7ulp_evk_plugin_defconfig @@ -42,3 +42,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 2d3f6be189..6a13c3660e 100644 --- a/include/configs/mx7ulp_evk.h +++ b/include/configs/mx7ulp_evk.h @@ -181,6 +181,9 @@ #define QSPI0_AMBA_BASE 0xC0000000 #endif +/* USB Configs */ +#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) + #define CONFIG_OF_SYSTEM_SETUP #endif /* __CONFIG_H */ -- 2.17.1