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 <badhri@google.com>
Change-Id: I2ca994d49b37bf8600c5913b892fde9acd0dc896
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Badhri Jagan Sridharan
2021-03-18 16:15:41 -07:00
committed by Greg Kroah-Hartman
parent 1a93d556d7
commit ffacd097fc
3 changed files with 18 additions and 1 deletions

View File

@@ -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);

View File

@@ -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, &reg);
if (ret < 0)

View File

@@ -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 <trace/define_trace.h>