mbox series

[v5,0/2] mutiple selectable capabilities in tcpm

Message ID 20231205030114.1349089-1-kyletso@google.com
Headers show
Series mutiple selectable capabilities in tcpm | expand

Message

Kyle Tso Dec. 5, 2023, 3:01 a.m. UTC
updates in v5

dt-bindings: connector: Add child nodes for multiple PD capabilities
  - Fixed DT_CHECK errors

usb: typec: tcpm: Support multiple capabilities
  - no change

---
updates in v4

dt-bindings: connector: Add child nodes for multiple PD capabilities
  - Modified the structure as corrected in v2
  - Modified the commit message

usb: typec: tcpm: Support multiple capabilities
  - no change

---
updates in v3

dt-bindings: connector: Add child nodes for multiple PD capabilities
  - Updated the commit message
  - Remain unchanged for the comments about the property/node
    refactor

usb: typec: tcpm: Support multiple capabilities
  - Changed the error handling and the usage of the APIs
  - Updated the commit message

---
updates in v2

dt-bindings: connector: Add child nodes for multiple PD capabilities
  - revised the dt-bindings

usb: typec: tcpm: Support multiple capabilities
  - Added missing cleanups in the function tcpm_port_unregister_pd

---
Original cover letter:

In commit a7cff92f0635 ("usb: typec: USB Power Delivery helpers for
ports and partners"), typec_operations has two new ops .pd_get and
.pd_set providing selection of different PD capabilities. This commit
implements these two ops in tcpm.

To support multiple capabilities, new dt-binding properties need to be
defined to create a tree structure for the driver to get each set of
capabilities one by one. The first tier of the child node under
connector is called "capabilities". Under this child node lies several
2nd tier of child nodes whose names are in the pattern of ^caps[0-9]+$.
And the source and sink capabilities are placed in these nodes.

Kyle Tso (2):
  dt-bindings: connector: Add child nodes for multiple PD capabilities
  usb: typec: tcpm: Support multiple capabilities

 .../bindings/connector/usb-connector.yaml     |  88 ++--
 drivers/usb/typec/tcpm/tcpm.c                 | 389 ++++++++++++++----
 2 files changed, 362 insertions(+), 115 deletions(-)

Comments

Rob Herring Dec. 8, 2023, 4:50 p.m. UTC | #1
On Tue, Dec 05, 2023 at 11:01:13AM +0800, Kyle Tso wrote:
> Commit 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB
> Type-C") allows userspace to configure the PD of a port by selecting
> different set of predefined PD capabilities. Define the PD capability
> sets in DT for better configurability in device modules.
> 
> Define an optional child node "capabilities" to contain multiple USB
> Power Delivery capabilities.
> 
> Define child nodes with pattern (e.g. caps-0, caps-1) under
> "capabilities". Each node contains PDO data of a selectable Power
> Delivery capability.
> 
> Also define common properties for source-pdos, sink-pdos, and
> op-sink-microwatt that can be referenced.
> 
> Signed-off-by: Kyle Tso <kyletso@google.com>
> ---
> v4 -> v5:
> - Fixed DT_CHECK errors
> 
>  .../bindings/connector/usb-connector.yaml     | 88 +++++++++++++------
>  1 file changed, 59 insertions(+), 29 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> index 7c8a3e8430d3..7945d09d1f59 100644
> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> @@ -14,6 +14,8 @@ description:
>    of a USB interface controller or a separate node when it is attached to both
>    MUX and USB interface controller.
>  
> +$ref: "#/$defs/capabilities"
> +
>  properties:
>    compatible:
>      oneOf:
> @@ -67,6 +69,15 @@ properties:
>        model it as a regulator. See bindings/regulator/fixed-regulator.yaml
>  
>    # The following are optional properties for "usb-c-connector".
> +  source-pdos:
> +    $ref: "#/$defs/capabilities/properties/source-pdos"
> +
> +  sink-pdos:
> +    $ref: "#/$defs/capabilities/properties/sink-pdos"
> +
> +  op-sink-microwatt:
> +    $ref: "#/$defs/capabilities/properties/op-sink-microwatt"

With the $ref above, these aren't needed. But you have to use 
unevaluatedProperties instead of additionalProperties.

I fixed this up and applied.

Rob
Kyle Tso Dec. 11, 2023, 2:49 a.m. UTC | #2
On Sat, Dec 9, 2023 at 12:50 AM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Dec 05, 2023 at 11:01:13AM +0800, Kyle Tso wrote:
> > Commit 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB
> > Type-C") allows userspace to configure the PD of a port by selecting
> > different set of predefined PD capabilities. Define the PD capability
> > sets in DT for better configurability in device modules.
> >
> > Define an optional child node "capabilities" to contain multiple USB
> > Power Delivery capabilities.
> >
> > Define child nodes with pattern (e.g. caps-0, caps-1) under
> > "capabilities". Each node contains PDO data of a selectable Power
> > Delivery capability.
> >
> > Also define common properties for source-pdos, sink-pdos, and
> > op-sink-microwatt that can be referenced.
> >
> > Signed-off-by: Kyle Tso <kyletso@google.com>
> > ---
> > v4 -> v5:
> > - Fixed DT_CHECK errors
> >
> >  .../bindings/connector/usb-connector.yaml     | 88 +++++++++++++------
> >  1 file changed, 59 insertions(+), 29 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > index 7c8a3e8430d3..7945d09d1f59 100644
> > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > @@ -14,6 +14,8 @@ description:
> >    of a USB interface controller or a separate node when it is attached to both
> >    MUX and USB interface controller.
> >
> > +$ref: "#/$defs/capabilities"
> > +
> >  properties:
> >    compatible:
> >      oneOf:
> > @@ -67,6 +69,15 @@ properties:
> >        model it as a regulator. See bindings/regulator/fixed-regulator.yaml
> >
> >    # The following are optional properties for "usb-c-connector".
> > +  source-pdos:
> > +    $ref: "#/$defs/capabilities/properties/source-pdos"
> > +
> > +  sink-pdos:
> > +    $ref: "#/$defs/capabilities/properties/sink-pdos"
> > +
> > +  op-sink-microwatt:
> > +    $ref: "#/$defs/capabilities/properties/op-sink-microwatt"
>
> With the $ref above, these aren't needed. But you have to use
> unevaluatedProperties instead of additionalProperties.
>
> I fixed this up and applied.
>
> Rob

Thank you, Rob!

--
Kyle