* [PATCH 0/3] Add support for responding to Get_Revision request
@ 2024-12-06 7:46 Amit Sunil Dhamne via B4 Relay
2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus
Cc: Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb,
Amit Sunil Dhamne
Currently TCPM doesn't support responding to Get_Revision request
message. However, as per Message Applicability in USB PD Spec 3.1 v1.8
("6.13.2 Applicability of Data Messages") "Revision" is a Normative
(compulsory) message and needs to be supported. As part of this patchset
add support for responding to Get_Revision requests as part of
Revision_Information AMS.
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
---
Amit Sunil Dhamne (3):
dt-bindings: connector: Add pd-revision property
usb: typec: tcpm: Add support for parsing pd-revision DT property
usb: typec: tcpm: Add new AMS for Get_Revision response
.../bindings/connector/usb-connector.yaml | 6 ++
.../devicetree/bindings/usb/maxim,max33359.yaml | 1 +
drivers/usb/typec/tcpm/tcpm.c | 87 +++++++++++++++++++++-
include/linux/usb/pd.h | 22 +++++-
4 files changed, 111 insertions(+), 5 deletions(-)
---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241205-get_rev_upstream-6b60000630af
Best regards,
--
Amit Sunil Dhamne <amitsd@google.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-06 7:46 [PATCH 0/3] Add support for responding to Get_Revision request Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 ` Amit Sunil Dhamne via B4 Relay 2024-12-06 16:52 ` Conor Dooley 2024-12-10 23:06 ` Rob Herring 2024-12-06 7:46 ` [PATCH 2/3] usb: typec: tcpm: Add support for parsing pd-revision DT property Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 3/3] usb: typec: tcpm: Add new AMS for Get_Revision response Amit Sunil Dhamne via B4 Relay 2 siblings, 2 replies; 9+ messages in thread From: Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus Cc: Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb, Amit Sunil Dhamne From: Amit Sunil Dhamne <amitsd@google.com> Add pd-revision property definition, to specify the maximum Power Delivery Revision and Version supported by the connector. Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> --- Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + 2 files changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -293,6 +293,12 @@ properties: PD negotiation till BC1.2 detection completes. default: 0 + pd-revision: + description: Specifies the maximum USB PD revision and version supported by + the connector. This property is specified in the following order; + <revision_major, revision_minor, version_major, version_minor>. + $ref: /schemas/types.yaml#/definitions/uint8-array + dependencies: sink-vdos-v1: [ sink-vdos ] sink-vdos: [ sink-vdos-v1 ] diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml @@ -70,6 +70,7 @@ examples: PDO_FIXED_DUAL_ROLE) PDO_FIXED(9000, 2000, 0)>; sink-bc12-completion-time-ms = <500>; + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; }; }; }; -- 2.47.0.338.g60cca15819-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay @ 2024-12-06 16:52 ` Conor Dooley 2024-12-07 0:43 ` Amit Sunil Dhamne 2024-12-10 23:06 ` Rob Herring 1 sibling, 1 reply; 9+ messages in thread From: Conor Dooley @ 2024-12-06 16:52 UTC (permalink / raw) To: amitsd Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus, Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb [-- Attachment #1: Type: text/plain, Size: 2265 bytes --] On Thu, Dec 05, 2024 at 11:46:08PM -0800, Amit Sunil Dhamne via B4 Relay wrote: > From: Amit Sunil Dhamne <amitsd@google.com> > > Add pd-revision property definition, to specify the maximum Power > Delivery Revision and Version supported by the connector. > > Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> > --- > Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ > Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml > index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml > @@ -293,6 +293,12 @@ properties: > PD negotiation till BC1.2 detection completes. > default: 0 > > + pd-revision: > + description: Specifies the maximum USB PD revision and version supported by > + the connector. This property is specified in the following order; > + <revision_major, revision_minor, version_major, version_minor>. > + $ref: /schemas/types.yaml#/definitions/uint8-array > + > dependencies: > sink-vdos-v1: [ sink-vdos ] > sink-vdos: [ sink-vdos-v1 ] > diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 > --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > @@ -70,6 +70,7 @@ examples: > PDO_FIXED_DUAL_ROLE) > PDO_FIXED(9000, 2000, 0)>; > sink-bc12-completion-time-ms = <500>; > + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; Why do you need this? Doesn't the compatible already give you this information? > }; > }; > }; > > -- > 2.47.0.338.g60cca15819-goog > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-06 16:52 ` Conor Dooley @ 2024-12-07 0:43 ` Amit Sunil Dhamne 2024-12-15 15:37 ` Conor Dooley 0 siblings, 1 reply; 9+ messages in thread From: Amit Sunil Dhamne @ 2024-12-07 0:43 UTC (permalink / raw) To: Conor Dooley Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus, Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb Hi Conor, On 12/6/24 8:52 AM, Conor Dooley wrote: > On Thu, Dec 05, 2024 at 11:46:08PM -0800, Amit Sunil Dhamne via B4 Relay wrote: >> From: Amit Sunil Dhamne<amitsd@google.com> >> >> Add pd-revision property definition, to specify the maximum Power >> Delivery Revision and Version supported by the connector. >> >> Signed-off-by: Amit Sunil Dhamne<amitsd@google.com> >> --- >> Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ >> Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + >> 2 files changed, 7 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml >> index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 >> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml >> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml >> @@ -293,6 +293,12 @@ properties: >> PD negotiation till BC1.2 detection completes. >> default: 0 >> >> + pd-revision: >> + description: Specifies the maximum USB PD revision and version supported by >> + the connector. This property is specified in the following order; >> + <revision_major, revision_minor, version_major, version_minor>. >> + $ref: /schemas/types.yaml#/definitions/uint8-array >> + >> dependencies: >> sink-vdos-v1: [ sink-vdos ] >> sink-vdos: [ sink-vdos-v1 ] >> diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 >> --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> @@ -70,6 +70,7 @@ examples: >> PDO_FIXED_DUAL_ROLE) >> PDO_FIXED(9000, 2000, 0)>; >> sink-bc12-completion-time-ms = <500>; >> + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; > Why do you need this? This DT property helps Type-C Port Manager (TCPM, consumer of the connector class properties) fetch the exact Power Delivery (PD) revision & version information of the Type-C port controller (TCPC)'s connector. In turn, we require it to be able to support "Revision_Information" Atomic Message Sequence (AMS) in TCPM to be USB PD spec compliant for all revision & versions after PD3.1 v1.x. > Doesn't the compatible already give you this > information? Compatible property does not give information regarding the PD revision & version but only gives info on the type of connector (usb a, b or c). Also, connector class is used by several TCPCs like maxim,max33359, ptn5110, etc. and each of them may be compliant to different combinations of revision & version. This feature would help users set these values based on the revision/versions their TCPC supports. Currently TCPM driver hardcodes the Revision value to 3.0 and doesn't provide any info on version (undesirable). It should be noted that: 1. There are multiple versions & revisions of the USB PD spec and they keep evolving frequently. A certain connector hardware may only be spec compliant for up to a certain version + version. Thus, this is the only way for TCPM to know what ver + rev the connector hardware supports. This will enable the TCPC system to present the exact rev & ver values when requested for revision info by the port partner. 2. I also considered incrementing the revision & version information values in the TCPM code. However, that won't be backward compatible for connectors whose hardware doesn't support features in the latest spec. In this case we would be presenting incorrect revision & version values (higher than what is actually supported by the hardware). Regards, Amit >> }; >> }; >> }; >> >> -- >> 2.47.0.338.g60cca15819-goog >> >> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-07 0:43 ` Amit Sunil Dhamne @ 2024-12-15 15:37 ` Conor Dooley 0 siblings, 0 replies; 9+ messages in thread From: Conor Dooley @ 2024-12-15 15:37 UTC (permalink / raw) To: Amit Sunil Dhamne Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus, Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb [-- Attachment #1: Type: text/plain, Size: 4677 bytes --] On Fri, Dec 06, 2024 at 04:43:44PM -0800, Amit Sunil Dhamne wrote: > Hi Conor, > > On 12/6/24 8:52 AM, Conor Dooley wrote: > > On Thu, Dec 05, 2024 at 11:46:08PM -0800, Amit Sunil Dhamne via B4 Relay wrote: > > > From: Amit Sunil Dhamne<amitsd@google.com> > > > > > > Add pd-revision property definition, to specify the maximum Power > > > Delivery Revision and Version supported by the connector. > > > > > > Signed-off-by: Amit Sunil Dhamne<amitsd@google.com> > > > --- > > > Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ > > > Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + > > > 2 files changed, 7 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml > > > index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 > > > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml > > > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml > > > @@ -293,6 +293,12 @@ properties: > > > PD negotiation till BC1.2 detection completes. > > > default: 0 > > > + pd-revision: > > > + description: Specifies the maximum USB PD revision and version supported by > > > + the connector. This property is specified in the following order; > > > + <revision_major, revision_minor, version_major, version_minor>. > > > + $ref: /schemas/types.yaml#/definitions/uint8-array > > > + > > > dependencies: > > > sink-vdos-v1: [ sink-vdos ] > > > sink-vdos: [ sink-vdos-v1 ] > > > diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > > > index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 > > > --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > > > +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > > > @@ -70,6 +70,7 @@ examples: > > > PDO_FIXED_DUAL_ROLE) > > > PDO_FIXED(9000, 2000, 0)>; > > > sink-bc12-completion-time-ms = <500>; > > > + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; > > Why do you need this? > > This DT property helps Type-C Port Manager (TCPM, consumer of the connector > class properties) fetch the exact Power Delivery (PD) revision & version > information of the Type-C port controller (TCPC)'s connector. In turn, we > require it to be able to support "Revision_Information" Atomic Message > Sequence (AMS) in TCPM to be USB PD spec compliant for all revision & > versions after PD3.1 v1.x. This information should be in hte commit message. > > > Doesn't the compatible already give you this > > information? > > Compatible property does not give information regarding the PD revision & > version but only gives info on the type of connector (usb a, b or c). Also, > connector class is used by several TCPCs like maxim,max33359, ptn5110, etc. > and each of them may be compliant to different combinations of revision & > version. This feature would help users set these values based on the > revision/versions their TCPC supports. Is the version fixed for a given TCPC? If so, the driver would be able to determine the correct revision based on the compatible. If not, then you commit message needs to mention that this is variable. > Currently TCPM driver hardcodes the Revision value to 3.0 and doesn't > provide any info on version (undesirable). > > It should be noted that: > > 1. There are multiple versions & revisions of the USB PD spec and they keep > evolving frequently. A certain connector hardware may only be spec compliant > for up to a certain version + version. Thus, this is the only way for TCPM > to know what ver + rev the connector hardware supports. This will enable the > TCPC system to present the exact rev & ver values when requested for > revision info by the port partner. > > 2. I also considered incrementing the revision & version information values > in the TCPM code. However, that won't be backward compatible for connectors > whose hardware doesn't support features in the latest spec. In this case we > would be presenting incorrect revision & version values (higher than what is > actually supported by the hardware). > > Regards, > > Amit > > > > }; > > > }; > > > }; > > > > > > -- > > > 2.47.0.338.g60cca15819-goog > > > > > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay 2024-12-06 16:52 ` Conor Dooley @ 2024-12-10 23:06 ` Rob Herring 2024-12-11 2:55 ` Amit Sunil Dhamne 1 sibling, 1 reply; 9+ messages in thread From: Rob Herring @ 2024-12-10 23:06 UTC (permalink / raw) To: Amit Sunil Dhamne Cc: Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus, Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb On Thu, Dec 05, 2024 at 11:46:08PM -0800, Amit Sunil Dhamne wrote: > Add pd-revision property definition, to specify the maximum Power > Delivery Revision and Version supported by the connector. > > Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> > --- > Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ > Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml > index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml > @@ -293,6 +293,12 @@ properties: > PD negotiation till BC1.2 detection completes. > default: 0 > > + pd-revision: > + description: Specifies the maximum USB PD revision and version supported by > + the connector. This property is specified in the following order; > + <revision_major, revision_minor, version_major, version_minor>. > + $ref: /schemas/types.yaml#/definitions/uint8-array Always exactly 4 entries? Then: maxItems: 4 > + > dependencies: > sink-vdos-v1: [ sink-vdos ] > sink-vdos: [ sink-vdos-v1 ] > diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 > --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml > @@ -70,6 +70,7 @@ examples: > PDO_FIXED_DUAL_ROLE) > PDO_FIXED(9000, 2000, 0)>; > sink-bc12-completion-time-ms = <500>; > + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; > }; > }; > }; > > -- > 2.47.0.338.g60cca15819-goog > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: connector: Add pd-revision property 2024-12-10 23:06 ` Rob Herring @ 2024-12-11 2:55 ` Amit Sunil Dhamne 0 siblings, 0 replies; 9+ messages in thread From: Amit Sunil Dhamne @ 2024-12-11 2:55 UTC (permalink / raw) To: Rob Herring Cc: Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus, Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb Hi Rob, On 12/10/24 3:06 PM, Rob Herring wrote: > On Thu, Dec 05, 2024 at 11:46:08PM -0800, Amit Sunil Dhamne wrote: >> Add pd-revision property definition, to specify the maximum Power >> Delivery Revision and Version supported by the connector. >> >> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> >> --- >> Documentation/devicetree/bindings/connector/usb-connector.yaml | 6 ++++++ >> Documentation/devicetree/bindings/usb/maxim,max33359.yaml | 1 + >> 2 files changed, 7 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml >> index 67700440e23b5b7ca0db2c395c8a455bcf650864..341d2872e8d43450d219b7b72d48790051dc4e2b 100644 >> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml >> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml >> @@ -293,6 +293,12 @@ properties: >> PD negotiation till BC1.2 detection completes. >> default: 0 >> >> + pd-revision: >> + description: Specifies the maximum USB PD revision and version supported by >> + the connector. This property is specified in the following order; >> + <revision_major, revision_minor, version_major, version_minor>. >> + $ref: /schemas/types.yaml#/definitions/uint8-array > Always exactly 4 entries? Then: > > maxItems: 4 Thanks for the catch! Updating it in the next revision. Regards, Amit >> + >> dependencies: >> sink-vdos-v1: [ sink-vdos ] >> sink-vdos: [ sink-vdos-v1 ] >> diff --git a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> index 20b62228371bdedf2fe92767ffe443bec87babc5..350d39fbf2dcd4d99db07cb8f099467e6fc653ee 100644 >> --- a/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> +++ b/Documentation/devicetree/bindings/usb/maxim,max33359.yaml >> @@ -70,6 +70,7 @@ examples: >> PDO_FIXED_DUAL_ROLE) >> PDO_FIXED(9000, 2000, 0)>; >> sink-bc12-completion-time-ms = <500>; >> + pd-revision = /bits/ 8 <0x03 0x01 0x01 0x08>; >> }; >> }; >> }; >> >> -- >> 2.47.0.338.g60cca15819-goog >> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] usb: typec: tcpm: Add support for parsing pd-revision DT property 2024-12-06 7:46 [PATCH 0/3] Add support for responding to Get_Revision request Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 ` Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 3/3] usb: typec: tcpm: Add new AMS for Get_Revision response Amit Sunil Dhamne via B4 Relay 2 siblings, 0 replies; 9+ messages in thread From: Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus Cc: Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb, Amit Sunil Dhamne From: Amit Sunil Dhamne <amitsd@google.com> Add support for parsing "pd-revision" DT property in TCPM and store PD revision and version supported by the Type-C connnector. It should be noted that the PD revision is the maximum possible revision supported by the port. This is different from the 2 bit revision set in PD msg headers. The purpose of the 2 bit revision value is to negotiate between Rev 2.X & 3.X spec rev as part of contract negotiation, while this is used for Get_Revision AMS after a contract is in place. Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> --- drivers/usb/typec/tcpm/tcpm.c | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 6021eeb903fec53316dfa2d6b825c334d55b7cab..59621cfaee3d67a36f3ad6870bd1aa92d382f33a 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -310,6 +310,13 @@ struct pd_data { unsigned int operating_snk_mw; }; +struct pd_revision_info { + u8 rev_major; + u8 rev_minor; + u8 ver_major; + u8 ver_minor; +}; + /* * @sink_wait_cap_time: Deadline (in ms) for tTypeCSinkWaitCap timer * @ps_src_wait_off_time: Deadline (in ms) for tPSSourceOff timer @@ -567,6 +574,9 @@ struct tcpm_port { /* Timer deadline values configured at runtime */ struct pd_timings timings; + + /* Indicates maximum (revision, version) supported */ + struct pd_revision_info pd_rev; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; struct mutex logbuffer_lock; /* log buffer access lock */ @@ -7036,7 +7046,9 @@ static void tcpm_port_unregister_pd(struct tcpm_port *port) static int tcpm_port_register_pd(struct tcpm_port *port) { - struct usb_power_delivery_desc desc = { port->typec_caps.pd_revision }; + u16 pd_revision = port->typec_caps.pd_revision; + u16 pd_version = port->pd_rev.ver_major << 8 | port->pd_rev.ver_minor; + struct usb_power_delivery_desc desc = { pd_revision, pd_version }; struct usb_power_delivery_capabilities *cap; int ret, i; @@ -7331,6 +7343,29 @@ static int tcpm_fw_get_snk_vdos(struct tcpm_port *port, struct fwnode_handle *fw return 0; } +static void tcpm_fw_get_pd_revision(struct tcpm_port *port, struct fwnode_handle *fwnode) +{ + int ret; + u8 val[4]; + + ret = fwnode_property_count_u8(fwnode, "pd-revision"); + if (!ret || ret != 4) { + tcpm_log(port, "Unable to find pd-revision property or incorrect array size"); + return; + } + + ret = fwnode_property_read_u8_array(fwnode, "pd-revision", val, 4); + if (ret) { + tcpm_log(port, "Failed to parse pd-revision, ret:(%d)", ret); + return; + } + + port->pd_rev.rev_major = val[0]; + port->pd_rev.rev_minor = val[1]; + port->pd_rev.ver_major = val[2]; + port->pd_rev.ver_minor = val[3]; +} + /* Power Supply access to expose source power information */ enum tcpm_psy_online_states { TCPM_PSY_OFFLINE = 0, @@ -7669,11 +7704,18 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) goto out_destroy_wq; tcpm_fw_get_timings(port, tcpc->fwnode); + tcpm_fw_get_pd_revision(port, tcpc->fwnode); port->try_role = port->typec_caps.prefer_role; port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ - port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ + + if (port->pd_rev.rev_major) + port->typec_caps.pd_revision = port->pd_rev.rev_major << 8 | + port->pd_rev.rev_minor; + else + port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ + port->typec_caps.svdm_version = SVDM_VER_2_0; port->typec_caps.driver_data = port; port->typec_caps.ops = &tcpm_ops; -- 2.47.0.338.g60cca15819-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] usb: typec: tcpm: Add new AMS for Get_Revision response 2024-12-06 7:46 [PATCH 0/3] Add support for responding to Get_Revision request Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 2/3] usb: typec: tcpm: Add support for parsing pd-revision DT property Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 ` Amit Sunil Dhamne via B4 Relay 2 siblings, 0 replies; 9+ messages in thread From: Amit Sunil Dhamne via B4 Relay @ 2024-12-06 7:46 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Greg Kroah-Hartman, Badhri Jagan Sridharan, Heikki Krogerus Cc: Kyle Tso, RD Babiera, devicetree, linux-kernel, linux-usb, Amit Sunil Dhamne From: Amit Sunil Dhamne <amitsd@google.com> This commit adds a new AMS for responding to a "Get_Revision" request. Revision message consists of the following fields: +----------------------------------------------------+ | Header | RMDO | | No. of data objects = 1 | | +----------------------------------------------------+ While RMDO consists of: * B31..28 Revision Major * B27..24 Revision Minor * B23..20 Version Major * B19..16 Version Minor * B15..0 Reserved, shall be set to zero. As per the PD spec ("8.3.3.16.2.1 PR_Give_Revision State"), a request is only expected when an explicit contract is established and the port is in ready state. This AMS is only supported for PD >= 3.0. Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> --- drivers/usb/typec/tcpm/tcpm.c | 41 ++++++++++++++++++++++++++++++++++++++++- include/linux/usb/pd.h | 22 ++++++++++++++++++++-- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 59621cfaee3d67a36f3ad6870bd1aa92d382f33a..460dbde9fe2239b10c43cfb12dce92c736b1cea9 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -185,7 +185,8 @@ S(UNSTRUCTURED_VDMS), \ S(STRUCTURED_VDMS), \ S(COUNTRY_INFO), \ - S(COUNTRY_CODES) + S(COUNTRY_CODES), \ + S(REVISION_INFORMATION) #define GENERATE_ENUM(e) e #define GENERATE_STRING(s) #s @@ -225,6 +226,7 @@ enum pd_msg_request { PD_MSG_CTRL_NOT_SUPP, PD_MSG_DATA_SINK_CAP, PD_MSG_DATA_SOURCE_CAP, + PD_MSG_DATA_REV, }; enum adev_actions { @@ -1244,6 +1246,24 @@ static u32 tcpm_forge_legacy_pdo(struct tcpm_port *port, u32 pdo, enum typec_rol } } +static int tcpm_pd_send_revision(struct tcpm_port *port) +{ + struct pd_message msg; + u32 rmdo; + + memset(&msg, 0, sizeof(msg)); + rmdo = RMDO(port->pd_rev.rev_major, port->pd_rev.rev_minor, + port->pd_rev.ver_major, port->pd_rev.ver_minor); + msg.payload[0] = cpu_to_le32(rmdo); + msg.header = PD_HEADER_LE(PD_DATA_REVISION, + port->pwr_role, + port->data_role, + port->negotiated_rev, + port->message_id, + 1); + return tcpm_pd_transmit(port, TCPC_TX_SOP, &msg); +} + static int tcpm_pd_send_source_caps(struct tcpm_port *port) { struct pd_message msg; @@ -3547,6 +3567,17 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS); break; + case PD_CTRL_GET_REVISION: + if (port->negotiated_rev >= PD_REV30 && port->pd_rev.rev_major) + tcpm_pd_handle_msg(port, PD_MSG_DATA_REV, + REVISION_INFORMATION); + else + tcpm_pd_handle_msg(port, + port->negotiated_rev < PD_REV30 ? + PD_MSG_CTRL_REJECT : + PD_MSG_CTRL_NOT_SUPP, + NONE_AMS); + break; default: tcpm_pd_handle_msg(port, port->negotiated_rev < PD_REV30 ? @@ -3791,6 +3822,14 @@ static bool tcpm_send_queued_message(struct tcpm_port *port) tcpm_ams_finish(port); } break; + case PD_MSG_DATA_REV: + ret = tcpm_pd_send_revision(port); + if (ret) + tcpm_log(port, + "Unable to send revision msg, ret=%d", + ret); + tcpm_ams_finish(port); + break; default: break; } diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index d50098fb16b5d2e2d9e39c55db4329224115e8b1..3068c3084eb6176d7d9184c3959a4110282a9fa0 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -33,7 +33,9 @@ enum pd_ctrl_msg_type { PD_CTRL_FR_SWAP = 19, PD_CTRL_GET_PPS_STATUS = 20, PD_CTRL_GET_COUNTRY_CODES = 21, - /* 22-31 Reserved */ + /* 22-23 Reserved */ + PD_CTRL_GET_REVISION = 24, + /* 25-31 Reserved */ }; enum pd_data_msg_type { @@ -46,7 +48,9 @@ enum pd_data_msg_type { PD_DATA_ALERT = 6, PD_DATA_GET_COUNTRY_INFO = 7, PD_DATA_ENTER_USB = 8, - /* 9-14 Reserved */ + /* 9-11 Reserved */ + PD_DATA_REVISION = 12, + /* 13-14 Reserved */ PD_DATA_VENDOR_DEF = 15, /* 16-31 Reserved */ }; @@ -453,6 +457,20 @@ static inline unsigned int rdo_max_power(u32 rdo) #define EUDO_TBT_SUPPORT BIT(14) #define EUDO_HOST_PRESENT BIT(13) +/* + * Request Message Data Object (PD Revision 3.1+ only) + * -------- + * <31:28> :: Revision Major + * <27:24> :: Revision Minor + * <23:20> :: Version Major + * <19:16> :: Version Minor + * <15:0> :: Reserved, Shall be set to zero + */ + +#define RMDO(rev_maj, rev_min, ver_maj, ver_min) \ + (((rev_maj) & 0xf) << 28 | ((rev_min) & 0xf) << 24 | \ + ((ver_maj) & 0xf) << 20 | ((ver_min) & 0xf) << 16) + /* USB PD timers and counters */ #define PD_T_NO_RESPONSE 5000 /* 4.5 - 5.5 seconds */ #define PD_T_DB_DETECT 10000 /* 10 - 15 seconds */ -- 2.47.0.338.g60cca15819-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-15 15:38 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-06 7:46 [PATCH 0/3] Add support for responding to Get_Revision request Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 1/3] dt-bindings: connector: Add pd-revision property Amit Sunil Dhamne via B4 Relay 2024-12-06 16:52 ` Conor Dooley 2024-12-07 0:43 ` Amit Sunil Dhamne 2024-12-15 15:37 ` Conor Dooley 2024-12-10 23:06 ` Rob Herring 2024-12-11 2:55 ` Amit Sunil Dhamne 2024-12-06 7:46 ` [PATCH 2/3] usb: typec: tcpm: Add support for parsing pd-revision DT property Amit Sunil Dhamne via B4 Relay 2024-12-06 7:46 ` [PATCH 3/3] usb: typec: tcpm: Add new AMS for Get_Revision response Amit Sunil Dhamne via B4 Relay
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).