diff mbox series

[v2,1/4] dt-bindings: usb: gpio-sbu-mux: add support for ss-data lanes mux

Message ID 20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-1-3889b1b2050c@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series Add i.MX8MP-EVK USB Gadget Support | expand

Commit Message

Marco Felsch May 4, 2023, 1:46 p.m. UTC
This adds the support for GPIO based USB-C SS data lane muxing.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 .../devicetree/bindings/usb/gpio-sbu-mux.yaml      | 82 +++++++++++++++++++---
 1 file changed, 71 insertions(+), 11 deletions(-)

Comments

Rob Herring (Arm) May 4, 2023, 2:08 p.m. UTC | #1
On Thu, 04 May 2023 15:46:50 +0200, Marco Felsch wrote:
> This adds the support for GPIO based USB-C SS data lane muxing.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  .../devicetree/bindings/usb/gpio-sbu-mux.yaml      | 82 +++++++++++++++++++---
>  1 file changed, 71 insertions(+), 11 deletions(-)
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dts:96.47-98.27: ERROR (duplicate_label): /example-1/tcpm/connector/ports/port@0/endpoint: Duplicate label 'tcpm_hs_out' on /example-1/tcpm/connector/ports/port@0/endpoint and /example-0/tcpm/connector/ports/port@0/endpoint
Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dts:103.47-105.27: ERROR (duplicate_label): /example-1/tcpm/connector/ports/port@1/endpoint: Duplicate label 'tcpm_ss_out' on /example-1/tcpm/connector/ports/port@1/endpoint and /example-0/tcpm/connector/ports/port@1/endpoint
ERROR: Input tree has errors, aborting (use -f to force output)
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dtb] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-1-3889b1b2050c@pengutronix.de

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Marco Felsch May 4, 2023, 2:29 p.m. UTC | #2
On 23-05-04, Rob Herring wrote:
> 
> On Thu, 04 May 2023 15:46:50 +0200, Marco Felsch wrote:
> > This adds the support for GPIO based USB-C SS data lane muxing.
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  .../devicetree/bindings/usb/gpio-sbu-mux.yaml      | 82 +++++++++++++++++++---
> >  1 file changed, 71 insertions(+), 11 deletions(-)
> > 
> 
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dts:96.47-98.27: ERROR (duplicate_label): /example-1/tcpm/connector/ports/port@0/endpoint: Duplicate label 'tcpm_hs_out' on /example-1/tcpm/connector/ports/port@0/endpoint and /example-0/tcpm/connector/ports/port@0/endpoint
> Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dts:103.47-105.27: ERROR (duplicate_label): /example-1/tcpm/connector/ports/port@1/endpoint: Duplicate label 'tcpm_ss_out' on /example-1/tcpm/connector/ports/port@1/endpoint and /example-0/tcpm/connector/ports/port@1/endpoint
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/usb/gpio-sbu-mux.example.dtb] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make: *** [Makefile:1512: dt_binding_check] Error 2

While adding the example I thought about the need for it. Is it okay for
you if I drop the example since most of it is just copy'n'paste.

Regards,
  Marco
Rob Herring (Arm) May 4, 2023, 7:47 p.m. UTC | #3
On Thu, May 04, 2023 at 03:46:50PM +0200, Marco Felsch wrote:
> This adds the support for GPIO based USB-C SS data lane muxing.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  .../devicetree/bindings/usb/gpio-sbu-mux.yaml      | 82 +++++++++++++++++++---
>  1 file changed, 71 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
> index bf4b1d016e1f..796f3283ac02 100644
> --- a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
> +++ b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
> @@ -4,24 +4,26 @@
>  $id: "http://devicetree.org/schemas/usb/gpio-sbu-mux.yaml#"
>  $schema: "http://devicetree.org/meta-schemas/core.yaml#"
>  
> -title: GPIO-based SBU mux
> +title: GPIO-based SS/SBU mux
>  
>  maintainers:
>    - Bjorn Andersson <andersson@kernel.org>
>  
>  description:
> -  In USB Type-C applications the SBU lines needs to be connected, disconnected
> -  and swapped depending on the altmode and orientation. This binding describes
> -  a family of hardware solutions which switches between these modes using GPIO
> -  signals.
> +  In USB Type-C applications the SS/SBU lines needs to be connected,
> +  disconnected and swapped depending on the altmode and orientation. This
> +  binding describes a family of hardware solutions which switches between these
> +  modes using GPIO signals.

Consider whether the mux-control binding would work for this purpose. 
Then what controls the muxing can be anything.

>  
>  properties:
>    compatible:
> -    items:
> -      - enum:
> -          - onnn,fsusb43l10x
> -          - pericom,pi3usb102
> -      - const: gpio-sbu-mux
> +    oneOf:
> +      - items:
> +          - enum:
> +              - onnn,fsusb43l10x
> +              - pericom,pi3usb102
> +          - const: gpio-sbu-mux
> +      - const: gpio-ss-mux
>  
>    enable-gpios:
>      description: Switch enable GPIO
> @@ -50,10 +52,18 @@ required:
>    - compatible
>    - enable-gpios
>    - select-gpios
> -  - mode-switch
>    - orientation-switch
>    - port
>  
> +if:
> +  properties:
> +    compatible:
> +      contains:
> +        const: gpio-sbu-mux
> +then:
> +  required:
> +    - mode-switch
> +
>  additionalProperties: false
>  
>  examples:
> @@ -107,4 +117,54 @@ examples:
>              };
>          };
>      };
> +
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    tcpm {
> +        connector {
> +            compatible = "usb-c-connector";
> +
> +            ports {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                port@0 {
> +                    reg = <0>;
> +                    tcpm_hs_out: endpoint {
> +                        remote-endpoint = <&usb_hs_phy_in>;
> +                    };
> +                };
> +
> +                port@1 {
> +                    reg = <1>;
> +                    tcpm_ss_out: endpoint {
> +                        remote-endpoint = <&usb_ss_phy_in>;
> +                    };
> +                };
> +
> +                port@2 {
> +                    reg = <2>;
> +                    tcpm_ss_mux_out: endpoint {
> +                        remote-endpoint = <&ss_mux_in>;
> +                    };
> +                };

port@2 already has a defined use for SBU signals. You can't use it. 
port@1 corresponds to the SS signals.

> +            };
> +        };
> +    };
> +
> +    usb-ss-mux {
> +        compatible = "gpio-ss-mux";
> +
> +        enable-gpios = <&tlmm 101 GPIO_ACTIVE_LOW>;
> +        select-gpios = <&tlmm 164 GPIO_ACTIVE_HIGH>;
> +
> +        orientation-switch;
> +
> +        port {

This is a mux device. It needs an output port and N input ports.

Please present a complete picture of your USB-C related h/w. It's hard 
to review with just 'I have a GPIO controlling the SS muxing'.

Rob
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
index bf4b1d016e1f..796f3283ac02 100644
--- a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
+++ b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
@@ -4,24 +4,26 @@ 
 $id: "http://devicetree.org/schemas/usb/gpio-sbu-mux.yaml#"
 $schema: "http://devicetree.org/meta-schemas/core.yaml#"
 
-title: GPIO-based SBU mux
+title: GPIO-based SS/SBU mux
 
 maintainers:
   - Bjorn Andersson <andersson@kernel.org>
 
 description:
-  In USB Type-C applications the SBU lines needs to be connected, disconnected
-  and swapped depending on the altmode and orientation. This binding describes
-  a family of hardware solutions which switches between these modes using GPIO
-  signals.
+  In USB Type-C applications the SS/SBU lines needs to be connected,
+  disconnected and swapped depending on the altmode and orientation. This
+  binding describes a family of hardware solutions which switches between these
+  modes using GPIO signals.
 
 properties:
   compatible:
-    items:
-      - enum:
-          - onnn,fsusb43l10x
-          - pericom,pi3usb102
-      - const: gpio-sbu-mux
+    oneOf:
+      - items:
+          - enum:
+              - onnn,fsusb43l10x
+              - pericom,pi3usb102
+          - const: gpio-sbu-mux
+      - const: gpio-ss-mux
 
   enable-gpios:
     description: Switch enable GPIO
@@ -50,10 +52,18 @@  required:
   - compatible
   - enable-gpios
   - select-gpios
-  - mode-switch
   - orientation-switch
   - port
 
+if:
+  properties:
+    compatible:
+      contains:
+        const: gpio-sbu-mux
+then:
+  required:
+    - mode-switch
+
 additionalProperties: false
 
 examples:
@@ -107,4 +117,54 @@  examples:
             };
         };
     };
+
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    tcpm {
+        connector {
+            compatible = "usb-c-connector";
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    tcpm_hs_out: endpoint {
+                        remote-endpoint = <&usb_hs_phy_in>;
+                    };
+                };
+
+                port@1 {
+                    reg = <1>;
+                    tcpm_ss_out: endpoint {
+                        remote-endpoint = <&usb_ss_phy_in>;
+                    };
+                };
+
+                port@2 {
+                    reg = <2>;
+                    tcpm_ss_mux_out: endpoint {
+                        remote-endpoint = <&ss_mux_in>;
+                    };
+                };
+            };
+        };
+    };
+
+    usb-ss-mux {
+        compatible = "gpio-ss-mux";
+
+        enable-gpios = <&tlmm 101 GPIO_ACTIVE_LOW>;
+        select-gpios = <&tlmm 164 GPIO_ACTIVE_HIGH>;
+
+        orientation-switch;
+
+        port {
+            ss_mux_in: endpoint {
+                remote-endpoint = <&tcpm_ss_mux_out>;
+            };
+        };
+    };
 ...