From ffacd097fc6e9c68d51e2c63dd628c887cc7cf5a Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Thu, 18 Mar 2021 16:15:41 -0700 Subject: [PATCH] ANDROID: usb: typec: tcpci: Add vendor hook to mask vbus present This hook is for addressing hardware anomalies where TCPC_POWER_STATUS_VBUS_PRES bit can return 0 even before falling below sSinkDisconnect threshold. Handler has to set bypass to override the value that would otherwise be returned by this function. Handler can set vbus or clear vbus to indicate vbus present or absent OOT_bug: Bug: 183149028 Bug: 168245874 Bug: 173252019 Signed-off-by: Badhri Jagan Sridharan Change-Id: I2ca994d49b37bf8600c5913b892fde9acd0dc896 Signed-off-by: Greg Kroah-Hartman --- drivers/android/vendor_hooks.c | 1 + drivers/usb/typec/tcpm/tcpci.c | 6 +++++- include/trace/hooks/typec.h | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index acabd22047a4..8ba5e8c9642b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -214,3 +214,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_print_slabinfo_header); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cache_show); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_override_toggling); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_check_contaminant); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_get_vbus); diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 447e3de2f5f3..372a5fb0baf4 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -417,7 +417,11 @@ static int tcpci_get_vbus(struct tcpc_dev *tcpc) { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); unsigned int reg; - int ret; + int ret, vbus, bypass = 0; + + trace_android_vh_typec_tcpci_get_vbus(tcpci, tcpci->data, &vbus, &bypass); + if (bypass) + return vbus; ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, ®); if (ret < 0) diff --git a/include/trace/hooks/typec.h b/include/trace/hooks/typec.h index c922e8683fd8..127a16b440c1 100644 --- a/include/trace/hooks/typec.h +++ b/include/trace/hooks/typec.h @@ -20,6 +20,18 @@ DECLARE_HOOK(android_vh_typec_tcpci_override_toggling, DECLARE_HOOK(android_vh_typec_tcpci_check_contaminant, TP_PROTO(struct tcpci *tcpci, struct tcpci_data *data, int *ret), TP_ARGS(tcpci, data, ret)); + +/* + * This hook is for addressing hardware anomalies where TCPC_POWER_STATUS_VBUS_PRES bit can return 0 + * even before falling below sSinkDisconnect threshold. + * Handler has to set bypass to override the value that would otherwise be returned by this + * function. + * Handler can set vbus or clear vbus to indicate vbus present or absent + */ +DECLARE_HOOK(android_vh_typec_tcpci_get_vbus, + TP_PROTO(struct tcpci *tcpci, struct tcpci_data *data, int *vbus, int *bypass), + TP_ARGS(tcpci, data, vbus, bypass)); + #endif /* _TRACE_HOOK_UFSHCD_H */ /* This part must be outside protection */ #include