ANDROID: usb: typec: tcpm: Add vendor hook to update current limit

Vendor hook for making sinks comply to pSnkStby requirement.
Hook is an alternate to the following patch series:
https://patchwork.kernel.org/project/linux-usb/list/?series=461087

OOT_Bug:
Bug: 184607655
Bug: 168245874
Bug: 173252019
Bug: 162789342
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I39510690ed866cbbc74ef50a18136bf2d5a95aac
This commit is contained in:
Badhri Jagan Sridharan
2021-04-06 00:09:46 -07:00
parent c6e85ea56b
commit 6804a59039
3 changed files with 26 additions and 3 deletions

View File

@@ -234,3 +234,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_post_init_entity_util_avg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_get_timer);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_adj_current_limit);

View File

@@ -3729,6 +3729,8 @@ static void run_state_machine(struct tcpm_port *port)
unsigned int msecs, timer_val_msecs;
enum tcpm_state upcoming_state;
const char *state_name;
u32 current_limit;
bool adjust;
port->enter_state = port->state;
switch (port->state) {
@@ -4102,9 +4104,13 @@ static void run_state_machine(struct tcpm_port *port)
break;
case SNK_DISCOVERY:
if (port->vbus_present) {
tcpm_set_current_limit(port,
tcpm_get_current_limit(port),
5000);
current_limit = tcpm_get_current_limit(port);
trace_android_vh_typec_tcpm_adj_current_limit(tcpm_states[SNK_DISCOVERY],
port->current_limit,
port->supply_voltage,
port->pd_capable,
&current_limit, &adjust);
tcpm_set_current_limit(port, current_limit, 5000);
tcpm_set_charge(port, true);
tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0);
break;
@@ -4204,6 +4210,17 @@ static void run_state_machine(struct tcpm_port *port)
port->pwr_opmode = TYPEC_PWR_MODE_PD;
}
current_limit = tcpm_get_current_limit(port);
adjust = false;
trace_android_vh_typec_tcpm_adj_current_limit(tcpm_states[SNK_READY],
port->current_limit,
port->supply_voltage,
port->pd_capable,
&current_limit,
&adjust);
if (adjust)
tcpm_set_current_limit(port, current_limit, 5000);
tcpm_swap_complete(port, 0);
tcpm_typec_connect(port);
mod_enable_frs_delayed_work(port, 0);

View File

@@ -53,6 +53,11 @@ DECLARE_HOOK(android_vh_typec_store_partner_src_caps,
u32 (*source_caps)[PDO_MAX_OBJECTS]),
TP_ARGS(port, nr_source_caps, source_caps));
DECLARE_HOOK(android_vh_typec_tcpm_adj_current_limit,
TP_PROTO(const char *state, u32 port_current_limit, u32 port_voltage, bool pd_capable,
u32 *current_limit, bool *adjust),
TP_ARGS(state, port_current_limit, port_voltage, pd_capable, current_limit, adjust));
#endif /* _TRACE_HOOK_UFSHCD_H */
/* This part must be outside protection */
#include <trace/define_trace.h>