* [PATCH] usb: typec: tcpm: detect orientation in debug acc mode
@ 2025-05-05 11:06 Michael Grzeschik
2025-05-05 11:21 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Michael Grzeschik @ 2025-05-05 11:06 UTC (permalink / raw)
To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, Michael Grzeschik
For the debug accessory case, the orientation can be detected by reading
the cc resistor values. The will be TYPEC_CC_RP_DEF and TYPEC_CC_RP_1_5
in sink mode and TYPEC_CC_RA TYPEC_CC_RD in src mode.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
drivers/usb/typec/tcpm/tcpm.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 784fa23102f90..478e9c80fc8c2 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -611,6 +611,12 @@ static const char * const pd_rev[] = {
#define tcpm_port_is_sink(port) \
(tcpm_cc_is_sink((port)->cc1) || tcpm_cc_is_sink((port)->cc2))
+#define tcpm_port_is_debug_pol_cc1(port) \
+ ((tcpm_port_is_sink(port) && \
+ (port->cc2 == TYPEC_CC_RP_DEF && port->cc1 == TYPEC_CC_RP_1_5)) || \
+ (!tcpm_port_is_sink(port) && \
+ (port->cc2 == TYPEC_CC_RA && port->cc1 == TYPEC_CC_RD)))
+
#define tcpm_cc_is_source(cc) ((cc) == TYPEC_CC_RD)
#define tcpm_cc_is_audio(cc) ((cc) == TYPEC_CC_RA)
#define tcpm_cc_is_open(cc) ((cc) == TYPEC_CC_OPEN)
@@ -4569,8 +4575,11 @@ static int tcpm_acc_attach(struct tcpm_port *port)
if (tcpm_port_is_audio(port))
state = TYPEC_MODE_AUDIO;
- if (tcpm_port_is_debug(port))
+ if (tcpm_port_is_debug(port)) {
+ port->polarity = tcpm_port_is_debug_pol_cc1(port) ?
+ TYPEC_POLARITY_CC1 : TYPEC_POLARITY_CC2;
state = TYPEC_MODE_DEBUG;
+ }
ret = tcpm_set_roles(port, true, state, role, data);
if (ret < 0)
---
base-commit: 588d032e9e566997db3213dee145dbe3bda297b6
change-id: 20250505-tcpm-41b4ba7ea0ec
Best regards,
--
Michael Grzeschik <m.grzeschik@pengutronix.de>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: typec: tcpm: detect orientation in debug acc mode
2025-05-05 11:06 [PATCH] usb: typec: tcpm: detect orientation in debug acc mode Michael Grzeschik
@ 2025-05-05 11:21 ` Greg Kroah-Hartman
2025-05-05 11:27 ` Michael Grzeschik
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-05 11:21 UTC (permalink / raw)
To: Michael Grzeschik
Cc: Badhri Jagan Sridharan, Heikki Krogerus, linux-usb, linux-kernel
On Mon, May 05, 2025 at 01:06:16PM +0200, Michael Grzeschik wrote:
> For the debug accessory case, the orientation can be detected by reading
> the cc resistor values. The will be TYPEC_CC_RP_DEF and TYPEC_CC_RP_1_5
> in sink mode and TYPEC_CC_RA TYPEC_CC_RD in src mode.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
What commit id does this fix?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: typec: tcpm: detect orientation in debug acc mode
2025-05-05 11:21 ` Greg Kroah-Hartman
@ 2025-05-05 11:27 ` Michael Grzeschik
2025-05-05 13:06 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Michael Grzeschik @ 2025-05-05 11:27 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Badhri Jagan Sridharan, Heikki Krogerus, linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 844 bytes --]
On Mon, May 05, 2025 at 01:21:18PM +0200, Greg Kroah-Hartman wrote:
>On Mon, May 05, 2025 at 01:06:16PM +0200, Michael Grzeschik wrote:
>> For the debug accessory case, the orientation can be detected by reading
>> the cc resistor values. The will be TYPEC_CC_RP_DEF and TYPEC_CC_RP_1_5
>> in sink mode and TYPEC_CC_RA TYPEC_CC_RD in src mode.
>>
>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>
>What commit id does this fix?
This applies on 64843d0ba96 .
>thanks,
>
>greg k-h
Thanks,
Michael
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: typec: tcpm: detect orientation in debug acc mode
2025-05-05 11:27 ` Michael Grzeschik
@ 2025-05-05 13:06 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-05 13:06 UTC (permalink / raw)
To: Michael Grzeschik
Cc: Badhri Jagan Sridharan, Heikki Krogerus, linux-usb, linux-kernel
On Mon, May 05, 2025 at 01:27:29PM +0200, Michael Grzeschik wrote:
> On Mon, May 05, 2025 at 01:21:18PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, May 05, 2025 at 01:06:16PM +0200, Michael Grzeschik wrote:
> > > For the debug accessory case, the orientation can be detected by reading
> > > the cc resistor values. The will be TYPEC_CC_RP_DEF and TYPEC_CC_RP_1_5
> > > in sink mode and TYPEC_CC_RA TYPEC_CC_RD in src mode.
> > >
> > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> >
> > What commit id does this fix?
>
> This applies on 64843d0ba96 .
Great, can you resend with the proper Fixes: tag added?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-05 13:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-05 11:06 [PATCH] usb: typec: tcpm: detect orientation in debug acc mode Michael Grzeschik
2025-05-05 11:21 ` Greg Kroah-Hartman
2025-05-05 11:27 ` Michael Grzeschik
2025-05-05 13:06 ` Greg Kroah-Hartman
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).