Commit 6757824c authored by Ye Li's avatar Ye Li

MLK-17313-2 imx8qm/qxp mek: Update codes to use new TCPC interfaces

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: default avatarYe Li <ye.li@nxp.com>
Acked-by: default avatarJun Li <jun.li@nxp.com>
parent e12e0701
......@@ -9,4 +9,6 @@ config SYS_VENDOR
config SYS_CONFIG_NAME
default "imx8qm_mek"
source "board/freescale/common/Kconfig"
endif
......@@ -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
......
......@@ -9,4 +9,6 @@ config SYS_VENDOR
config SYS_CONFIG_NAME
default "imx8qxp_mek"
source "board/freescale/common/Kconfig"
endif
......@@ -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;
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment