From bb37015224565b7709246d8989df0779e4b46044 Mon Sep 17 00:00:00 2001 From: Haijian Ma Date: Thu, 7 Jul 2022 18:19:05 +0800 Subject: [PATCH] typec: disable vbus under 0.8V interrupt when vbus remove As vbus remove and type-c cable still inserted at BSP test, the CC voltage transfer to VBUS pin, the vbus pin voltage range is 0~1.25V frequent switch. So the interrupt of vbus under 0.8V is triggered frequently. So disable this interrupt when vbus remove. Change-Id: Ibfc26ed1e7db2c1031ac27642aa38a2dcb120f92 Signed-off-by: Haijian Ma Reviewed-on: https://gerrit.mot.com/2325805 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Lu Chai Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/usb/typec/mmi_tcpc/tcpc_rt1711h.c | 5 ----- drivers/usb/typec/mmi_tcpc/tcpci_typec.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/mmi_tcpc/tcpc_rt1711h.c b/drivers/usb/typec/mmi_tcpc/tcpc_rt1711h.c index 4f722c6ff15e..da3997ca67db 100644 --- a/drivers/usb/typec/mmi_tcpc/tcpc_rt1711h.c +++ b/drivers/usb/typec/mmi_tcpc/tcpc_rt1711h.c @@ -959,11 +959,6 @@ static int rt1711_enable_vsafe0v_detect( struct tcpc_device *tcpc, bool enable) { int ret = 0; - struct rt1711_chip *chip = tcpc_get_dev_data(tcpc); - - if (chip->chip_id == SC2150A_DID) { - enable = true; - } ret = rt1711_i2c_read8(tcpc, RT1711H_REG_RT_MASK); diff --git a/drivers/usb/typec/mmi_tcpc/tcpci_typec.c b/drivers/usb/typec/mmi_tcpc/tcpci_typec.c index b7b82f999395..c8485e5e198f 100644 --- a/drivers/usb/typec/mmi_tcpc/tcpci_typec.c +++ b/drivers/usb/typec/mmi_tcpc/tcpci_typec.c @@ -2544,8 +2544,21 @@ static inline int typec_handle_vbus_absent(struct tcpc_device *tcpc) int tcpc_typec_handle_ps_change(struct tcpc_device *tcpc, int vbus_level) { + uint32_t chip_id; + int rv = 0; + tcpc->typec_reach_vsafe0v = false; + rv = tcpci_get_chip_id(tcpc, &chip_id); + if (!rv && chip_id == SC2150A_DID) { + // open vsafe0.8v irq + if (vbus_level >= TCPC_VBUS_VALID) { + typec_disable_low_power_mode(tcpc); + } else { + typec_enter_low_power_mode(tcpc); + } + } + #ifdef CONFIG_TYPEC_CHECK_LEGACY_CABLE if (tcpc->typec_legacy_cable) { typec_legacy_handle_ps_change(tcpc, vbus_level);