From b6325c997ce0eae420bca907779aba97afb32a91 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Wed, 17 Mar 2021 15:02:21 -0700 Subject: [PATCH] ANDROID: usb: typec: tcpci: Add vendor hooks for tcpci interface Needed for controlling BC1.2 detection logic specific to the chip architecture. Also, needed to implement additional logic to make debug accessorires specifically designed for Pixel work. These are outside the purview of Type-C spec. OOT_bug: Bug: 169213252 Bug: 168245874 Bug: 173252019 Bug: 271294543 Signed-off-by: Badhri Jagan Sridharan Change-Id: I36fe75dddd8cd4e2054db01ed4fee7ea08dd8702 (cherry picked from commit 08879ea0d6b55ada45b43c015f1d075629c0c460) --- drivers/android/vendor_hooks.c | 2 ++ drivers/usb/typec/tcpm/tcpci.c | 6 +++++- include/trace/hooks/typec.h | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 include/trace/hooks/typec.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 3fc5ac4f3dc1..2b79318a9a9c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -55,6 +55,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -169,3 +170,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_disable_thermal_cooling_stats); 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); diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 28daef821974..a821761b0973 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -16,6 +16,7 @@ #include #include #include +#include #define PD_RETRY_COUNT_DEFAULT 3 #define PD_RETRY_COUNT_3_0_OR_HIGHER 2 @@ -179,8 +180,11 @@ static int tcpci_start_toggling(struct tcpc_dev *tcpc, /* Handle vendor drp toggling */ if (tcpci->data->start_drp_toggling) { + int override_toggling = 0; + trace_android_vh_typec_tcpci_override_toggling(tcpci, tcpci->data, + &override_toggling); ret = tcpci->data->start_drp_toggling(tcpci, tcpci->data, cc); - if (ret < 0) + if (ret < 0 || override_toggling) return ret; } diff --git a/include/trace/hooks/typec.h b/include/trace/hooks/typec.h new file mode 100644 index 000000000000..1f3cb079f9e8 --- /dev/null +++ b/include/trace/hooks/typec.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM typec +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_TYPEC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_TYPEC_H +#include +/* + * Following tracepoints are not exported in tracefs and provide a + * mechanism for vendor modules to hook and extend functionality + */ +struct tcpci; +struct tcpci_data; + +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)); + +#endif /* _TRACE_HOOK_UFSHCD_H */ +/* This part must be outside protection */ +#include