MLK-17313-2 imx8qm/qxp mek: Update codes to use new TCPC interfaces
authorYe Li <ye.li@nxp.com>
Mon, 8 Jan 2018 14:08:57 +0000 (08:08 -0600)
committerYe Li <ye.li@nxp.com>
Wed, 10 Jan 2018 05:46:48 +0000 (23:46 -0600)
Since the TCPC driver is updated, change the QM/QXP MEK board level codes
accordingly to use new interfaces.
Because the typec circuit on iMX8QM/QXP MEK boards only support power role
as source, so set the CONFIG_USB_TCPC_PD_SINK_DISABLE.

Signed-off-by: Ye Li <ye.li@nxp.com>
Acked-by: Jun Li <jun.li@nxp.com>
board/freescale/imx8qm_mek/Kconfig
board/freescale/imx8qm_mek/imx8qm_mek.c
board/freescale/imx8qxp_mek/Kconfig
board/freescale/imx8qxp_mek/imx8qxp_mek.c
configs/imx8qm_mek_defconfig
configs/imx8qm_mek_fspi_defconfig
configs/imx8qxp_mek_defconfig
configs/imx8qxp_mek_fspi_defconfig

index a44c8f7..93d7d5f 100644 (file)
@@ -9,4 +9,6 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
        default "imx8qm_mek"
 
+source "board/freescale/common/Kconfig"
+
 endif
index 1d5648b..9ba68c1 100644 (file)
@@ -288,50 +288,38 @@ static iomux_cfg_t ss_mux_gpio[] = {
        SC_P_QSPI1A_SS0_B | MUX_MODE_ALT(3) | MUX_PAD_CTRL(GPIO_PAD_CTRL),
 };
 
-struct udevice *tcpc_i2c_dev = NULL;
+struct tcpc_port port;
+struct tcpc_port_config port_config = {
+       .i2c_bus = 0,
+       .addr = 0x51,
+       .port_type = TYPEC_PORT_DFP,
+};
 
-static void setup_typec(void)
+void ss_mux_select(enum typec_cc_polarity pol)
 {
-       struct udevice *bus;
-       uint8_t chip = 0x51;
-       int ret;
+       if (pol == TYPEC_POLARITY_CC1)
+               gpio_direction_output(USB_TYPEC_SEL, 0);
+       else
+               gpio_direction_output(USB_TYPEC_SEL, 1);
+}
 
+static void setup_typec(void)
+{
        imx8_iomux_setup_multiple_pads(ss_mux_gpio, ARRAY_SIZE(ss_mux_gpio));
        gpio_request(USB_TYPEC_SEL, "typec_sel");
        gpio_request(USB_TYPEC_EN, "typec_en");
 
        gpio_direction_output(USB_TYPEC_EN, 1);
 
-       ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &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);
+       tcpc_init(&port, port_config, &ss_mux_select);
 }
 
 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);
+       if (init == USB_INIT_HOST)
+               ret = tcpc_setup_dfp_mode(&port);
 
        return ret;
 }
@@ -340,8 +328,8 @@ 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);
+       if (init == USB_INIT_HOST)
+               ret = tcpc_disable_src_vbus(&port);
 
        return ret;
 }
@@ -350,7 +338,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 int board_init(void)
 {
        /* Power up base board */
-       sc_pm_set_resource_power_mode(gd->arch.ipc_channel_handle, 
+       sc_pm_set_resource_power_mode(gd->arch.ipc_channel_handle,
                SC_R_BOARD_R1, SC_PM_PW_MODE_ON);
 
 #ifdef CONFIG_MXC_GPIO
index 5ed457f..b67300d 100644 (file)
@@ -9,4 +9,6 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
        default "imx8qxp_mek"
 
+source "board/freescale/common/Kconfig"
+
 endif
index 7085809..24925a0 100644 (file)
@@ -421,12 +421,23 @@ 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;
+struct tcpc_port port;
+struct tcpc_port_config port_config = {
+       .i2c_bus = 1,
+       .addr = 0x50,
+       .port_type = TYPEC_PORT_DFP,
+};
+
+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);
+}
 
 static void setup_typec(void)
 {
-       struct udevice *bus;
-       uint8_t chip = 0x50;
        int ret;
        struct gpio_desc typec_en_desc;
 
@@ -448,36 +459,15 @@ static void setup_typec(void)
        /* 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);
+       tcpc_init(&port, port_config, &ss_mux_select);
 }
 
 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);
+       if (init == USB_INIT_HOST)
+               ret = tcpc_setup_dfp_mode(&port);
 
        return ret;
 
@@ -487,8 +477,8 @@ 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);
+       if (init == USB_INIT_HOST)
+               ret = tcpc_disable_src_vbus(&port);
 
        return ret;
 }
index 9b1ee4c..e60b9fb 100644 (file)
@@ -23,7 +23,7 @@ CONFIG_DM_USB=y
 CONFIG_CMD_USB=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
-
+CONFIG_USB_TCPC=y
 
 # CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_USB_GADGET=y
index c9ffb6a..36b5f4b 100644 (file)
@@ -23,7 +23,7 @@ CONFIG_DM_USB=y
 CONFIG_CMD_USB=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
-
+CONFIG_USB_TCPC=y
 
 # CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_USB_GADGET=y
index ade0621..cd84875 100644 (file)
@@ -26,6 +26,7 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_CMD_USB=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_TCPC=y
 
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_USB_GADGET=y
index 5aff415..b621a7f 100644 (file)
@@ -26,6 +26,7 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_CMD_USB=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_TCPC=y
 
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_USB_GADGET=y