summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2017-09-12 04:41:45 -0500
committerYe Li <ye.li@nxp.com>2017-09-14 20:52:53 -0500
commit34be5a21002132b3908bf1aada7e15aa00353ce9 (patch)
treece573322e2a7d13ff241ccc99730038f77673120
parentc4ef7812cfa959b9ac914c58806487a0efd035b6 (diff)
MLK-16431-3 imx8qxp_mek: Enable the USB3.0 XHCI driver
Enable the USB3.0 XHCI driver to support host mode on MEK board. The USB3.0 typec on MEK board uses PTN5110 TCPC as cc logic and power control. Different like the device on ARM2 board, this IC needs driver to control and get status through I2C bus. In this patch, we simply call the TCPC API to set to DFP mode, check the CC status for SS MUX select and enable source VBUS power. When the USB host is shutdown, disable the VBUS power. Signed-off-by: Ye Li <ye.li@nxp.com>
-rw-r--r--arch/arm/dts/fsl-imx8qxp-mek.dts4
-rw-r--r--board/freescale/imx8qxp_mek/imx8qxp_mek.c86
-rw-r--r--configs/imx8qxp_mek_defconfig14
-rw-r--r--include/configs/imx8qxp_mek.h12
4 files changed, 110 insertions, 6 deletions
diff --git a/arch/arm/dts/fsl-imx8qxp-mek.dts b/arch/arm/dts/fsl-imx8qxp-mek.dts
index edc201c933..8f1f483d44 100644
--- a/arch/arm/dts/fsl-imx8qxp-mek.dts
+++ b/arch/arm/dts/fsl-imx8qxp-mek.dts
@@ -403,3 +403,7 @@
vmmc-supply = <&reg_usdhc2_vmmc>;
status = "okay";
};
+
+&usb2 {
+ status = "okay";
+};
diff --git a/board/freescale/imx8qxp_mek/imx8qxp_mek.c b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
index c0641b3a20..13dc6a98e7 100644
--- a/board/freescale/imx8qxp_mek/imx8qxp_mek.c
+++ b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
@@ -28,6 +28,7 @@
#include <asm/imx-common/video.h>
#include <asm/arch/video_common.h>
#include <power-domain.h>
+#include "../common/tcpc.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -340,6 +341,7 @@ static int setup_fec(int ind)
static iomux_cfg_t board_gpios[] = {
SC_P_SPI2_SDO | MUX_MODE_ALT(4) | MUX_PAD_CTRL(GPIO_PAD_CTRL),
+ SC_P_ENET0_REFCLK_125M_25M | MUX_MODE_ALT(4) | MUX_PAD_CTRL(GPIO_PAD_CTRL),
};
static void board_gpio_init(void)
@@ -421,6 +423,86 @@ static void setup_otg(void)
}
#endif
+#ifdef CONFIG_USB_XHCI_IMX8
+
+#define USB_TYPEC_SEL IMX_GPIO_NR(5, 9)
+static iomux_cfg_t ss_mux_gpio[] = {
+ SC_P_ENET0_REFCLK_125M_25M | MUX_MODE_ALT(4) | MUX_PAD_CTRL(GPIO_PAD_CTRL),
+};
+
+struct udevice *tcpc_i2c_dev = NULL;
+
+static void setup_typec(void)
+{
+ struct udevice *bus;
+ uint8_t chip = 0x50;
+ int ret;
+ struct gpio_desc typec_en_desc;
+
+ imx8_iomux_setup_multiple_pads(ss_mux_gpio, ARRAY_SIZE(ss_mux_gpio));
+ gpio_request(USB_TYPEC_SEL, "typec_sel");
+
+ ret = dm_gpio_lookup_name("gpio@1a_7", &typec_en_desc);
+ if (ret) {
+ printf("%s lookup gpio@1a_7 failed ret = %d\n", __func__, ret);
+ return;
+ }
+
+ ret = dm_gpio_request(&typec_en_desc, "typec_en");
+ if (ret) {
+ printf("%s request typec_en failed ret = %d\n", __func__, ret);
+ return;
+ }
+
+ /* Enable SS MUX */
+ dm_gpio_set_dir_flags(&typec_en_desc, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
+
+ ret = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
+ if (ret) {
+ printf("%s: Can't find bus\n", __func__);
+ return;
+ }
+
+ ret = dm_i2c_probe(bus, chip, 0, &tcpc_i2c_dev);
+ if (ret) {
+ printf("%s: Can't find device id=0x%x\n",
+ __func__, chip);
+ return;
+ }
+
+ tcpc_init(tcpc_i2c_dev);
+}
+
+void ss_mux_select(enum typec_cc_polarity pol)
+{
+ if (pol == TYPEC_POLARITY_CC1)
+ gpio_direction_output(USB_TYPEC_SEL, 0);
+ else
+ gpio_direction_output(USB_TYPEC_SEL, 1);
+}
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+ int ret = 0;
+
+ if (init == USB_INIT_HOST && tcpc_i2c_dev)
+ ret = tcpc_setup_dfp_mode(tcpc_i2c_dev, &ss_mux_select);
+
+ return ret;
+
+}
+
+int board_usb_cleanup(int index, enum usb_init_type init)
+{
+ int ret = 0;
+
+ if (init == USB_INIT_HOST && tcpc_i2c_dev)
+ ret = tcpc_disable_vbus(tcpc_i2c_dev);
+
+ return ret;
+}
+#endif
+
int board_init(void)
{
#ifdef CONFIG_MXC_GPIO
@@ -435,6 +517,10 @@ int board_init(void)
setup_otg();
#endif
+#ifdef CONFIG_USB_XHCI_IMX8
+ setup_typec();
+#endif
+
return 0;
}
diff --git a/configs/imx8qxp_mek_defconfig b/configs/imx8qxp_mek_defconfig
index 0cdbe607c9..9a4f8087bf 100644
--- a/configs/imx8qxp_mek_defconfig
+++ b/configs/imx8qxp_mek_defconfig
@@ -17,11 +17,15 @@ CONFIG_CMD_I2C=y
CONFIG_I2C_MUX=y
CONFIG_I2C_MUX_PCA954x=y
-# CONFIG_CMD_USB=y
-# CONFIG_USB=y
-# CONFIG_DM_USB=y
-# CONFIG_USB_EHCI_HCD=y
-# CONFIG_USB_STORAGE=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_IMX8=y
+
+CONFIG_DM_USB=y
+
+CONFIG_CMD_USB=y
+CONFIG_USB=y
+CONFIG_USB_STORAGE=y
+
# CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_USB_GADGET=y
diff --git a/include/configs/imx8qxp_mek.h b/include/configs/imx8qxp_mek.h
index 3c91400f11..a00a2f15e7 100644
--- a/include/configs/imx8qxp_mek.h
+++ b/include/configs/imx8qxp_mek.h
@@ -259,12 +259,22 @@
#include "imx8qxp_mek_android.h"
#endif
-/* USB OTG controller configs */
+/* USB Config */
#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
+
+/* USB 3.0 controller configs */
+#ifdef CONFIG_USB_XHCI_IMX8
+#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
+#endif
+
+/* USB OTG controller configs */
+#ifdef CONFIG_USB_EHCI_HCD
#define CONFIG_USB_HOST_ETHER
#define CONFIG_USB_ETHER_ASIX
#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
#endif
+#endif /* CONFIG_CMD_USB */
#ifdef CONFIG_USB_GADGET
#define CONFIG_USBD_HS