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

Squashed <89f633a9f41259a168473917674dd5cb1bfb991d>
"ANDROID: usb: typec: tcpci: Migrate restricted vendor hook"

OOT_bug:
Bug: 183149028
Bug: 168245874
Bug: 173252019
Bug: 271294543
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I2ca994d49b37bf8600c5913b892fde9acd0dc896
This commit is contained in:
Badhri Jagan Sridharan
2021-03-18 16:15:41 -07:00
committed by Treehugger Robot
parent b6325c997c
commit eeffe02c96
3 changed files with 17 additions and 1 deletions

View File

@@ -171,3 +171,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_audio_usb_offload_connect);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_audio_usb_offload_disconnect);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_override_toggling);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_get_vbus);

View File

@@ -461,7 +461,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_rvh_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

@@ -16,6 +16,17 @@ DECLARE_HOOK(android_vh_typec_tcpci_override_toggling,
TP_PROTO(struct tcpci *tcpci, struct tcpci_data *data, int *override_toggling),
TP_ARGS(tcpci, data, override_toggling));
/*
* 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_RESTRICTED_HOOK(android_rvh_typec_tcpci_get_vbus,
TP_PROTO(struct tcpci *tcpci, struct tcpci_data *data, int *vbus, int *bypass),
TP_ARGS(tcpci, data, vbus, bypass), 1);
#endif /* _TRACE_HOOK_UFSHCD_H */
/* This part must be outside protection */
#include <trace/define_trace.h>