mbox series

[00/18] dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema

Message ID 20201010224121.12672-1-Sergey.Semin@baikalelectronics.ru
Headers show
Series dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema | expand

Message

Serge Semin Oct. 10, 2020, 10:41 p.m. UTC
We've performed some work on the Generic USB HCD, xHCI and DWC USB3 DT
bindings in the framework of the Baikal-T1 SoC support integration into
the kernel. This patchset is a result of that work.

First of all we moved the generic USB properties from the legacy text
bindings into the USB HCD DT schema. So now the generic USB HCD-compatible
DT nodes are validated taking into account the optional properties like:
maximum-speed, dr_mode, otg-rev, usb-role-switch, etc. We've fixed these
properties a bit so they would correspond to what functionality kernel
currently supports.

Secondly we converted generic USB xHCI text bindings file into the DT
schema. It had to be split up into two bindings: DT schema with generic
xHCI properties and a generic xHCI device DT schema. The later will be
used to validate the pure xHCI-based nodes, while the former can be
utilized by some vendor-specific versions of xHCI.

Thirdly, what was primarily intended to be done for Baikal-T1 SoC USB we
converted the legacy text-based DWC USB3 bindings to DT schema and altered
the result a bit so it would be more coherent with what actually
controller and its driver support. Since we've now got the DWC USB3 DT
schema, we made it used to validate the sub-nodes of the Qualcom, TI and
Amlogic DWC3 DT nodes.

Alas the new DWC USB3 DT schema doesn't support all the DT nodes defined
as compatible with "snps,dwc3". There are next problems we've discovered
while were working on this patchset:

1) There are many "snps,dwc3"-compatible DT nodes, which names are defined
as "^usb[0-9](@.*)", "^dwc3(@.*)" and even "^dwusb(@.*)". It contradicts
to what usb-hcd.yaml requires. Since it's included into the allOf property
of the DWC USB3 DT binding, some USB DT nodes declared for Freescale,
Qualcomm, HiSilicon, Exynos, Allwinner, Omap, Stih and APM will fail the
dtbs_check validation. This is the main problem and currently I don't
really know how to fix it better. Ideally we should convert all the
problematic DT nodes to have "usb@"-prefixed names. But it will be very
painful due to having a lot of such nodes defined. On the other hand we
could just fix the usb-hcd.yaml file either by detaching the generic
properties into a separate DT schema and allOf-ing it in the HCDs with
non-standard node-names instead of using usb-hcd.yaml there, or just add
the non-standard node-names into the usb-hcd.yaml file. What do you think
would be better?

2) amlogic/meson-g12-common.dtsi has got a USB controller node defined
with boolean "snps,quirk-frame-length-adjustment", which actually is
supposed to have u32 type.

3) freescale/imx8mq.dtsi defines a USB controller node with unknown
"usb3-resume-missing-cas" property.

4) marvell/armada-37xx.dtsi defines a USB controller with unknown
"marvell,usb-misc-reg" property.

5) socionext/uniphier-pxs3.dtsi, uniphier-pxs2.dtsi define a USB
controller with too many PHYs.

We haven't fixed the problems denoted above in this patchset for now.
So any help, suggestions on how they (especially #1) could be fixed,
following up fixup patches would be appropriate.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Manu Gautam <mgautam@codeaurora.org>
Cc: Roger Quadros <rogerq@ti.com>
Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-usb@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

Serge Semin (18):
  dt-bindings: usb: usb-hcd: Convert generic USB properties to DT schema
  dt-bindings: usb: usb-hcd: Add "wireless" maximum-speed property value
  dt-bindings: usb: usb-hcd: Add "otg-rev" property restriction
  dt-bindings: usb: usb-hcd: Add "ulpi/serial/hsic" PHY types
  dt-bindings: usb: usb-hcd: Add "tpl-support" property
  dt-bindings: usb: usb-hcd: Add generic "usb-phy" property
  dt-bindings: usb: Convert xHCI bindings to DT schema
  dt-bindings: usb: xhci: Add Broadcom STB v2 compatible device
  dt-bindings: usb: renesas-xhci: Refer to the usb-xhci.yaml file
  dt-bindings: usb: Convert DWC USB3 bindings to DT schema
  dt-bindings: usb: dwc3: Add interrupt-names property support
  dt-bindings: usb: dwc3: Add synopsys,dwc3 compatible string
  dt-bindings: usb: dwc3: Add Tx De-emphasis restrictions
  dt-bindings: usb: dwc3: Add Frame Length Adj restrictions
  dt-bindings: usb: meson-g12a-usb: Discard FL-adj property
  dt-bindings: usb: meson-g12a-usb: Validate DWC2/DWC3 sub-nodes
  dt-bindings: usb: keystone-dwc3: Validate DWC3 sub-node
  dt-bindings: usb: qcom,dwc3: Validate DWC3 sub-node

 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      |  16 +-
 .../devicetree/bindings/usb/dwc3.txt          | 125 -------
 .../devicetree/bindings/usb/generic-xhci.yaml |  65 ++++
 .../devicetree/bindings/usb/generic.txt       |  57 ----
 .../devicetree/bindings/usb/qcom,dwc3.yaml    |   9 +-
 .../bindings/usb/renesas,usb-xhci.yaml        |   4 +-
 .../devicetree/bindings/usb/snps,dwc3.yaml    | 315 ++++++++++++++++++
 .../bindings/usb/ti,keystone-dwc3.yaml        |   4 +-
 .../devicetree/bindings/usb/usb-hcd.yaml      | 100 ++++++
 .../devicetree/bindings/usb/usb-xhci.txt      |  41 ---
 .../devicetree/bindings/usb/usb-xhci.yaml     |  40 +++
 11 files changed, 540 insertions(+), 236 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/dwc3.txt
 create mode 100644 Documentation/devicetree/bindings/usb/generic-xhci.yaml
 delete mode 100644 Documentation/devicetree/bindings/usb/generic.txt
 create mode 100644 Documentation/devicetree/bindings/usb/snps,dwc3.yaml
 delete mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.yaml

Comments

Sergei Shtylyov Oct. 11, 2020, 8:53 a.m. UTC | #1
On 11.10.2020 1:41, Serge Semin wrote:

> The controller driver supports two types of DWC USB3 devices: with a
> common interrupt lane and with individual interrupts for each mode. Add
> both of these cases support to the DWC USB3 DT schema.

    Add support for both these cases?

> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
[...]

MBR, Sergei
Serge Semin Oct. 11, 2020, 6:09 p.m. UTC | #2
On Sun, Oct 11, 2020 at 11:53:07AM +0300, Sergei Shtylyov wrote:
> On 11.10.2020 1:41, Serge Semin wrote:
> 
> > The controller driver supports two types of DWC USB3 devices: with a
> > common interrupt lane and with individual interrupts for each mode. Add
> > both of these cases support to the DWC USB3 DT schema.
> 

>    Add support for both these cases?

Ok. Thanks.

-Sergey

> 
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> [...]
> 
> MBR, Sergei
Neil Armstrong Oct. 12, 2020, 7:38 a.m. UTC | #3
On 11/10/2020 00:41, Serge Semin wrote:
> Amlogic G12A USB DT sub-nodes are supposed to be compatible with the
> generic DWC USB2 and USB3 devices. Since now we've got DT schemas for
> both of the later IP cores let's make sure that the Amlogic G12A USB
> DT nodes are fully evaluated including the DWC sub-nodes.
> 
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> ---
>  .../bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> index 88184d7e26cc..3e8ac0ff90de 100644
> --- a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> +++ b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> @@ -78,7 +78,20 @@ properties:
>  
>  patternProperties:
>    "^usb@[0-9a-f]+$":
> -    type: object
> +    allOf:
> +      - if:
> +          properties:
> +            compatible:
> +              contains:
> +                const: snps,dwc2
> +        then:
> +          $ref: dwc2.yaml#
> +      - if:
> +          properties:
> +            compatible:
> +              const: snps,dwc3
> +        then:
> +          $ref: snps,dwc3.yaml#
>  
>  additionalProperties: false
>  
> 

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Rob Herring Oct. 13, 2020, 12:42 p.m. UTC | #4
On Sun, Oct 11, 2020 at 01:41:19AM +0300, Serge Semin wrote:
> Amlogic G12A USB DT sub-nodes are supposed to be compatible with the
> generic DWC USB2 and USB3 devices. Since now we've got DT schemas for
> both of the later IP cores let's make sure that the Amlogic G12A USB
> DT nodes are fully evaluated including the DWC sub-nodes.
> 
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> ---
>  .../bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> index 88184d7e26cc..3e8ac0ff90de 100644
> --- a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> +++ b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> @@ -78,7 +78,20 @@ properties:
>  
>  patternProperties:
>    "^usb@[0-9a-f]+$":
> -    type: object
> +    allOf:
> +      - if:
> +          properties:
> +            compatible:
> +              contains:
> +                const: snps,dwc2
> +        then:
> +          $ref: dwc2.yaml#
> +      - if:
> +          properties:
> +            compatible:
> +              const: snps,dwc3
> +        then:
> +          $ref: snps,dwc3.yaml#

It should be enough to do just:

oneOf:
  - $ref: dwc2.yaml#
  - $ref: snps,dwc3.yaml#
Serge Semin Oct. 13, 2020, 3:45 p.m. UTC | #5
On Tue, Oct 13, 2020 at 07:38:59AM -0500, Rob Herring wrote:
> On Sun, Oct 11, 2020 at 01:41:17AM +0300, Serge Semin wrote:
> > In accordance with the IP core databook the
> > snps,quirk-frame-length-adjustment property can be set within [0, 0x3F].
> > Let's make sure the DT schema applies a correct restriction on the
> > property.
> > 
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> > ---
> >  Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
> > index 36d4b8060d7c..f1e6c3dab1ff 100644
> > --- a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
> > +++ b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
> > @@ -226,6 +226,8 @@ properties:
> >        length adjustment when the fladj_30mhz_sdbnd signal is invalid or
> >        incorrect.
> >      $ref: /schemas/types.yaml#/definitions/uint32
> > +    minimum: 0
> > +    maximum: 0x3f
> 

> It's fine if you add the constraints during the conversion.

Ok. I'll keep it in mind next time.)

-Sergey

> 
> >  
> >    snps,rx-thr-num-pkt-prd:
> >      description: |
> > -- 
> > 2.27.0
> >
Serge Semin Oct. 13, 2020, 3:50 p.m. UTC | #6
On Tue, Oct 13, 2020 at 07:42:03AM -0500, Rob Herring wrote:
> On Sun, Oct 11, 2020 at 01:41:19AM +0300, Serge Semin wrote:
> > Amlogic G12A USB DT sub-nodes are supposed to be compatible with the
> > generic DWC USB2 and USB3 devices. Since now we've got DT schemas for
> > both of the later IP cores let's make sure that the Amlogic G12A USB
> > DT nodes are fully evaluated including the DWC sub-nodes.
> > 
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> > ---
> >  .../bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> > index 88184d7e26cc..3e8ac0ff90de 100644
> > --- a/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> > +++ b/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
> > @@ -78,7 +78,20 @@ properties:
> >  
> >  patternProperties:
> >    "^usb@[0-9a-f]+$":
> > -    type: object
> > +    allOf:
> > +      - if:
> > +          properties:
> > +            compatible:
> > +              contains:
> > +                const: snps,dwc2
> > +        then:
> > +          $ref: dwc2.yaml#
> > +      - if:
> > +          properties:
> > +            compatible:
> > +              const: snps,dwc3
> > +        then:
> > +          $ref: snps,dwc3.yaml#
> 

> It should be enough to do just:
> 
> oneOf:
>   - $ref: dwc2.yaml#
>   - $ref: snps,dwc3.yaml#

Ah, good point! Thanks.

-Sergey