Commit f6ec9bb
usb: typec: tcpm: fix debug accessory mode detection for sink ports
The port in debug accessory mode can be either a source or sink. The
previous tcpm_port_is_debug() function only checked for source port.
Commit 8db73e6 ("usb: typec: tcpm: allow sink (ufp) to toggle into
accessory mode debug") changed the detection logic to support both roles,
but left some logic in _tcpm_cc_change() unchanged, This causes the state
machine to transition to an incorrect state when operating as a sink in
debug accessory mode. Log as below:
[ 978.637541] CC1: 0 -> 5, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
[ 978.637567] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
[ 978.637596] pending state change SRC_ATTACH_WAIT -> DEBUG_ACC_ATTACHED @ 180 ms [rev1 NONE_AMS]
[ 978.647098] CC1: 5 -> 0, CC2: 5 -> 5 [state SRC_ATTACH_WAIT, polarity 0, connected]
[ 978.647115] state change SRC_ATTACH_WAIT -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
It should go to SNK_ATTACH_WAIT instead of SRC_ATTACH_WAIT state.
To fix this, add tcpm_port_is_debug_source() and tcpm_port_is_debug_sink()
helper to explicitly identify the power mode in debug accessory mode.
Update the state transition logic in _tcpm_cc_change() to ensure the state
machine transitions comply with Type-C specification. Also update the logic
in run_state_machine() to keep consistency.
Fixes: 8db73e6 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug")
Cc: stable <stable@kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Amit Sunil Dhamne <amitsd@google.com>
Link: https://patch.msgid.link/20260424074009.2979266-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 2909f0d commit f6ec9bb
1 file changed
Lines changed: 16 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
735 | 741 | | |
736 | | - | |
737 | | - | |
| 742 | + | |
738 | 743 | | |
739 | 744 | | |
740 | 745 | | |
| |||
5176 | 5181 | | |
5177 | 5182 | | |
5178 | 5183 | | |
5179 | | - | |
| 5184 | + | |
5180 | 5185 | | |
5181 | 5186 | | |
5182 | 5187 | | |
| |||
5434 | 5439 | | |
5435 | 5440 | | |
5436 | 5441 | | |
5437 | | - | |
| 5442 | + | |
5438 | 5443 | | |
5439 | 5444 | | |
5440 | 5445 | | |
| |||
5454 | 5459 | | |
5455 | 5460 | | |
5456 | 5461 | | |
5457 | | - | |
| 5462 | + | |
5458 | 5463 | | |
5459 | 5464 | | |
5460 | 5465 | | |
| |||
6362 | 6367 | | |
6363 | 6368 | | |
6364 | 6369 | | |
6365 | | - | |
| 6370 | + | |
6366 | 6371 | | |
6367 | 6372 | | |
6368 | | - | |
| 6373 | + | |
6369 | 6374 | | |
6370 | 6375 | | |
6371 | 6376 | | |
6372 | 6377 | | |
6373 | 6378 | | |
6374 | 6379 | | |
6375 | 6380 | | |
6376 | | - | |
| 6381 | + | |
6377 | 6382 | | |
6378 | 6383 | | |
| 6384 | + | |
| 6385 | + | |
6379 | 6386 | | |
6380 | 6387 | | |
6381 | 6388 | | |
| |||
6397 | 6404 | | |
6398 | 6405 | | |
6399 | 6406 | | |
6400 | | - | |
| 6407 | + | |
6401 | 6408 | | |
6402 | 6409 | | |
6403 | 6410 | | |
| |||
0 commit comments