Commit fce042f0 authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Greg Kroah-Hartman

staging: typec: tcpm: Report right typec_pwr_opmode

At present, TCPM does not take into account the actual resistor
value presented in the CC line and therefore reports TYPEC_PWR_MODE_USB
irrespective of the power_op_mode it is in.
This patch makes TCPM consider the actual value of Rp.
Signed-off-by: default avatarBadhri Jagan Sridharan <Badhri@google.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c79d92bd
...@@ -2130,9 +2130,23 @@ static void tcpm_swap_complete(struct tcpm_port *port, int result) ...@@ -2130,9 +2130,23 @@ static void tcpm_swap_complete(struct tcpm_port *port, int result)
} }
} }
enum typec_pwr_opmode tcpm_get_pwr_opmode(enum typec_cc_status cc)
{
switch (cc) {
case TYPEC_CC_RP_1_5:
return TYPEC_PWR_MODE_1_5A;
case TYPEC_CC_RP_3_0:
return TYPEC_PWR_MODE_3_0A;
case TYPEC_CC_RP_DEF:
default:
return TYPEC_PWR_MODE_USB;
}
}
static void run_state_machine(struct tcpm_port *port) static void run_state_machine(struct tcpm_port *port)
{ {
int ret; int ret;
enum typec_pwr_opmode opmode;
port->enter_state = port->state; port->enter_state = port->state;
switch (port->state) { switch (port->state) {
...@@ -2209,7 +2223,8 @@ static void run_state_machine(struct tcpm_port *port) ...@@ -2209,7 +2223,8 @@ static void run_state_machine(struct tcpm_port *port)
ret < 0 ? 0 : PD_T_PS_SOURCE_ON); ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
break; break;
case SRC_STARTUP: case SRC_STARTUP:
typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB); opmode = tcpm_get_pwr_opmode(tcpm_rp_cc(port));
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB; port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->caps_count = 0; port->caps_count = 0;
port->message_id = 0; port->message_id = 0;
...@@ -2371,7 +2386,9 @@ static void run_state_machine(struct tcpm_port *port) ...@@ -2371,7 +2386,9 @@ static void run_state_machine(struct tcpm_port *port)
break; break;
case SNK_STARTUP: case SNK_STARTUP:
/* XXX: callback into infrastructure */ /* XXX: callback into infrastructure */
typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB); opmode = tcpm_get_pwr_opmode(port->polarity ?
port->cc2 : port->cc1);
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB; port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->message_id = 0; port->message_id = 0;
port->rx_msgid = -1; port->rx_msgid = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment