From 46cb4678ef49959f0dc077cbc9a39e846cedc0a2 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Mon, 8 Jan 2018 08:09:43 -0600 Subject: [PATCH] MLK-17313-3 imx8mq_evk: Add USB PD power sink support Enable the TCPC driver for i.MX8MQ EVK board. When booting with dead battery, the TCPC driver will setup USB PD connection to negotiate the power with PD power charger. Signed-off-by: Ye Li Acked-by: Jun Li --- board/freescale/imx8mq_evk/Kconfig | 2 ++ board/freescale/imx8mq_evk/imx8m_evk.c | 31 ++++++++++++++++++++++++++ configs/imx8mq_evk_defconfig | 1 + 3 files changed, 34 insertions(+) diff --git a/board/freescale/imx8mq_evk/Kconfig b/board/freescale/imx8mq_evk/Kconfig index 421b081c76..3f3bddf324 100644 --- a/board/freescale/imx8mq_evk/Kconfig +++ b/board/freescale/imx8mq_evk/Kconfig @@ -9,4 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "imx8mq_evk" +source "board/freescale/common/Kconfig" + endif diff --git a/board/freescale/imx8mq_evk/imx8m_evk.c b/board/freescale/imx8mq_evk/imx8m_evk.c index 618f77c605..ed5c912b81 100644 --- a/board/freescale/imx8mq_evk/imx8m_evk.c +++ b/board/freescale/imx8mq_evk/imx8m_evk.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include "../common/tcpc.h" #include "../common/pfuze.h" #include #include @@ -224,6 +226,32 @@ int board_usb_cleanup(int index, enum usb_init_type init) } #endif +#ifdef CONFIG_USB_TCPC +struct tcpc_port port; +struct tcpc_port_config port_config = { + .i2c_bus = 0, + .addr = 0x50, + .port_type = TYPEC_PORT_UFP, + .max_snk_mv = 20000, + .max_snk_ma = 3000, + .max_snk_mw = 15000, + .op_snk_mv = 9000, +}; + +static int setup_typec(void) +{ + int ret; + + ret = tcpc_init(&port, port_config, NULL); + if (ret) { + printf("%s: tcpc init failed, err=%d\n", + __func__, ret); + } + + return ret; +} +#endif + int board_init(void) { board_qspi_init(); @@ -232,6 +260,9 @@ int board_init(void) setup_fec(); #endif +#ifdef CONFIG_USB_TCPC + setup_typec(); +#endif return 0; } diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig index f1ca4b298c..671f0e06e1 100644 --- a/configs/imx8mq_evk_defconfig +++ b/configs/imx8mq_evk_defconfig @@ -34,3 +34,4 @@ CONFIG_DM_THERMAL=y CONFIG_FIT=y CONFIG_SPL_FIT=y CONFIG_SPL_LOAD_FIT=y +CONFIG_USB_TCPC=y -- 2.17.1