mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: usb: typec: tcpm: Bring back tcpm_update_sink_capabilities
https://lkml.org/lkml/2019/2/12/701 removed tcpm_update_sink_capabilities. However, Pixel started using this at a later point in time. The client code is not in upstream though. Bug: 169695061 Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Change-Id: Icb206c902187c90b38dd14924987725e9977e47c
This commit is contained in:
@@ -4629,6 +4629,49 @@ sink:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo, unsigned int nr_pdo)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (nr_pdo > PDO_MAX_OBJECTS)
|
||||
nr_pdo = PDO_MAX_OBJECTS;
|
||||
|
||||
for (i = 0; i < nr_pdo; i++)
|
||||
dest_pdo[i] = src_pdo[i];
|
||||
|
||||
return nr_pdo;
|
||||
}
|
||||
|
||||
int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo,
|
||||
unsigned int operating_snk_mw)
|
||||
{
|
||||
if (tcpm_validate_caps(port, pdo, nr_pdo))
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&port->lock);
|
||||
port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo);
|
||||
port->operating_snk_mw = operating_snk_mw;
|
||||
port->update_sink_caps = true;
|
||||
|
||||
switch (port->state) {
|
||||
case SNK_NEGOTIATE_CAPABILITIES:
|
||||
case SNK_NEGOTIATE_PPS_CAPABILITIES:
|
||||
case SNK_READY:
|
||||
case SNK_TRANSITION_SINK:
|
||||
case SNK_TRANSITION_SINK_VBUS:
|
||||
if (port->pps_data.active)
|
||||
tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0);
|
||||
else
|
||||
tcpm_set_state(port, SNK_NEGOTIATE_CAPABILITIES, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&port->lock);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities);
|
||||
|
||||
/* Power Supply access to expose source power information */
|
||||
enum tcpm_psy_online_states {
|
||||
TCPM_PSY_OFFLINE = 0,
|
||||
|
||||
@@ -121,6 +121,10 @@ struct tcpm_port;
|
||||
struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc);
|
||||
void tcpm_unregister_port(struct tcpm_port *port);
|
||||
|
||||
int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
|
||||
unsigned int nr_pdo,
|
||||
unsigned int operating_snk_mw);
|
||||
|
||||
void tcpm_vbus_change(struct tcpm_port *port);
|
||||
void tcpm_cc_change(struct tcpm_port *port);
|
||||
void tcpm_pd_receive(struct tcpm_port *port,
|
||||
|
||||
Reference in New Issue
Block a user