From: Cosmo Chou <chou.cosmo@gmail.com>
To: badhri@google.com, heikki.krogerus@linux.intel.com,
gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
chou.cosmo@gmail.com, cosmo.chou@quantatw.com
Subject: [PATCH] usb: typec: tcpm: Use configured PD revision for negotiation
Date: Fri, 9 May 2025 01:47:56 +0800 [thread overview]
Message-ID: <20250508174756.1300942-1-chou.cosmo@gmail.com> (raw)
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>
---
drivers/usb/typec/tcpm/tcpm.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index a99db4e025cd..5a58c21c4d14 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4782,8 +4782,13 @@ static void run_state_machine(struct tcpm_port *port)
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->caps_count = 0;
- port->negotiated_rev = PD_MAX_REV;
- port->negotiated_rev_prime = PD_MAX_REV;
+ if (port->pd_rev.rev_major > 0 && port->pd_rev.rev_major <= PD_MAX_REV + 1) {
+ port->negotiated_rev = port->pd_rev.rev_major - 1;
+ port->negotiated_rev_prime = port->pd_rev.rev_major - 1;
+ } else {
+ port->negotiated_rev = PD_MAX_REV;
+ port->negotiated_rev_prime = PD_MAX_REV;
+ }
port->message_id = 0;
port->message_id_prime = 0;
port->rx_msgid = -1;
@@ -5048,8 +5053,13 @@ static void run_state_machine(struct tcpm_port *port)
port->cc2 : port->cc1);
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
- port->negotiated_rev = PD_MAX_REV;
- port->negotiated_rev_prime = PD_MAX_REV;
+ if (port->pd_rev.rev_major > 0 && port->pd_rev.rev_major <= PD_MAX_REV + 1) {
+ port->negotiated_rev = port->pd_rev.rev_major - 1;
+ port->negotiated_rev_prime = port->pd_rev.rev_major - 1;
+ } else {
+ port->negotiated_rev = PD_MAX_REV;
+ port->negotiated_rev_prime = PD_MAX_REV;
+ }
port->message_id = 0;
port->message_id_prime = 0;
port->rx_msgid = -1;
--
2.43.0
next reply other threads:[~2025-05-08 17:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 17:47 Cosmo Chou [this message]
2025-05-12 22:00 ` [PATCH] usb: typec: tcpm: Use configured PD revision for negotiation Amit Sunil Dhamne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250508174756.1300942-1-chou.cosmo@gmail.com \
--to=chou.cosmo@gmail.com \
--cc=badhri@google.com \
--cc=cosmo.chou@quantatw.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).