Skip to content

Commit 910e678

Browse files
author
Desnes Nunes
committed
usb: typec: tcpm: Use configured PD revision for negotiation
JIRA: https://issues.redhat.com/browse/RHEL-116016 commit f9bd09e Author: Cosmo Chou <chou.cosmo@gmail.com> Date: Tue, 13 May 2025 21:08:34 +0800 Initialize negotiated_rev and negotiated_rev_prime based on the port's configured PD revision (rev_major) rather than always defaulting to PD_MAX_REV. This ensures ports start PD communication using their appropriate revision level. This allows proper communication with devices that require specific PD revision levels, especially for the hardware designed for PD 1.0 or 2.0 specifications. Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> Link: https://lore.kernel.org/r/20250513130834.1612602-1-chou.cosmo@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 115ce72 commit 910e678

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ struct pd_data {
314314
unsigned int operating_snk_mw;
315315
};
316316

317+
#define PD_CAP_REV10 0x1
318+
#define PD_CAP_REV20 0x2
319+
#define PD_CAP_REV30 0x3
320+
317321
struct pd_revision_info {
318322
u8 rev_major;
319323
u8 rev_minor;
@@ -4732,6 +4736,25 @@ static void tcpm_set_initial_svdm_version(struct tcpm_port *port)
47324736
}
47334737
}
47344738

4739+
static void tcpm_set_initial_negotiated_rev(struct tcpm_port *port)
4740+
{
4741+
switch (port->pd_rev.rev_major) {
4742+
case PD_CAP_REV10:
4743+
port->negotiated_rev = PD_REV10;
4744+
break;
4745+
case PD_CAP_REV20:
4746+
port->negotiated_rev = PD_REV20;
4747+
break;
4748+
case PD_CAP_REV30:
4749+
port->negotiated_rev = PD_REV30;
4750+
break;
4751+
default:
4752+
port->negotiated_rev = PD_MAX_REV;
4753+
break;
4754+
}
4755+
port->negotiated_rev_prime = port->negotiated_rev;
4756+
}
4757+
47354758
static void run_state_machine(struct tcpm_port *port)
47364759
{
47374760
int ret;
@@ -4849,8 +4872,7 @@ static void run_state_machine(struct tcpm_port *port)
48494872
typec_set_pwr_opmode(port->typec_port, opmode);
48504873
port->pwr_opmode = TYPEC_PWR_MODE_USB;
48514874
port->caps_count = 0;
4852-
port->negotiated_rev = PD_MAX_REV;
4853-
port->negotiated_rev_prime = PD_MAX_REV;
4875+
tcpm_set_initial_negotiated_rev(port);
48544876
port->message_id = 0;
48554877
port->message_id_prime = 0;
48564878
port->rx_msgid = -1;
@@ -5127,8 +5149,7 @@ static void run_state_machine(struct tcpm_port *port)
51275149
port->cc2 : port->cc1);
51285150
typec_set_pwr_opmode(port->typec_port, opmode);
51295151
port->pwr_opmode = TYPEC_PWR_MODE_USB;
5130-
port->negotiated_rev = PD_MAX_REV;
5131-
port->negotiated_rev_prime = PD_MAX_REV;
5152+
tcpm_set_initial_negotiated_rev(port);
51325153
port->message_id = 0;
51335154
port->message_id_prime = 0;
51345155
port->rx_msgid = -1;

0 commit comments

Comments
 (0)