mbox series

[00/16] ADD USB3.1 HOST, Peri and DRD support

Message ID 20221212172804.1277751-1-biju.das.jz@bp.renesas.com
Headers show
Series ADD USB3.1 HOST, Peri and DRD support | expand

Message

Biju Das Dec. 12, 2022, 5:27 p.m. UTC
This patch series aims to add USB3.1 HOST, Peri and DRD support
on RZ/V2M EVK platform.

The reset for both host and peri are located in USB3DRD block. The
USB3DRD registers are mapped in the AXI address space of the Peripheral
module.

RZ/V2M is similar to R-Car XHCI but it doesn't require any
firmware.

Patch#16 depend upon [1]
[1] https://lore.kernel.org/linux-renesas-soc/20221209171836.71610-1-biju.das.jz@bp.renesas.com/T/#t


Biju Das (16):
  clk: renesas: r9a09g011: Add USB clock and reset entries
  dt-bindings: usb: Add RZ/V2M USB3DRD binding
  usb: gadget: Add support for RZ/V2M USB3DRD driver
  dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support
  usb: host: xhci-plat: Improve clock handling in probe()
  usb: host: xhci-plat: Add reset support
  xhci: host: Add Renesas RZ/V2M SoC support
  dt-bindings: usb: renesas,usb3-peri: Update reset property
  dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings
  usb: gadget: udc: renesas_usb3: Remove drd_reset handling
  usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M
  arm64: dts: renesas: r9a09g011: Add USB3 DRD and host nodes
  arm64: dts: renesas: r9a09g011: Add USB3 peripheral node
  arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host
  arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral
  arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch

 .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++
 .../bindings/usb/renesas,usb-xhci.yaml        |  41 ++++-
 .../bindings/usb/renesas,usb3-peri.yaml       |  16 +-
 .../boot/dts/renesas/r9a09g011-v2mevk2.dts    |  76 +++++++++
 arch/arm64/boot/dts/renesas/r9a09g011.dtsi    |  46 ++++++
 drivers/clk/renesas/r9a09g011-cpg.c           |  21 +++
 drivers/usb/gadget/udc/Kconfig                |   7 +
 drivers/usb/gadget/udc/Makefile               |   1 +
 drivers/usb/gadget/udc/renesas_usb3.c         |  63 ++++----
 drivers/usb/gadget/udc/rzv2m_usb3drd.c        | 151 ++++++++++++++++++
 drivers/usb/host/Kconfig                      |   9 ++
 drivers/usb/host/Makefile                     |   3 +
 drivers/usb/host/xhci-plat.c                  |  36 ++++-
 drivers/usb/host/xhci-rzv2m.c                 |  38 +++++
 drivers/usb/host/xhci-rzv2m.h                 |  16 ++
 include/linux/soc/renesas/rzv2m_usb3drd.h     |  19 +++
 16 files changed, 615 insertions(+), 51 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
 create mode 100644 drivers/usb/gadget/udc/rzv2m_usb3drd.c
 create mode 100644 drivers/usb/host/xhci-rzv2m.c
 create mode 100644 drivers/usb/host/xhci-rzv2m.h
 create mode 100644 include/linux/soc/renesas/rzv2m_usb3drd.h

Comments

Biju Das Dec. 13, 2022, 6:43 a.m. UTC | #1
Hi Rob,

Looks like I missed to add dependency on later patch[1] on the same series for the below bot errors.

[1]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20221212172804.1277751-9-biju.das.jz@bp.renesas.com/

[2]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20221212172804.1277751-5-biju.das.jz@bp.renesas.com/

I will send next version by arranging [1] and [2] before this patch.

Cheers,
Biju

> Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> 
> 
> On Mon, 12 Dec 2022 17:27:50 +0000, Biju Das wrote:
> > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> >  1 file changed, 123 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> >
> 
> 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:
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb3peri:resets: [[4294967295, 29]] is
> too short
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb3peri: 'reset-names' is a required
> property
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000:compatible: 'oneOf'
> conditional failed, one must be fixed:
> 	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a7742',
> 'renesas,xhci-r8a7743', 'renesas,xhci-r8a7744', 'renesas,xhci-r8a7790',
> 'renesas,xhci-r8a7791', 'renesas,xhci-r8a7793']
> 	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a774a1',
> 'renesas,xhci-r8a774b1', 'renesas,xhci-r8a774c0', 'renesas,xhci-r8a774e1',
> 'renesas,xhci-r8a7795', 'renesas,xhci-r8a7796', 'renesas,xhci-r8a77961',
> 'renesas,xhci-r8a77965', 'renesas,xhci-r8a77990']
> 	'renesas,rcar-gen2-xhci' was expected
> 	'renesas,rcar-gen3-xhci' was expected
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000:clocks: [[4294967295, 1,
> 34], [4294967295, 1, 36]] is too long
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000: Unevaluated properties
> are not allowed ('clock-names', 'clocks', 'compatible' were unexpected)
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to
> match any schema with compatible: ['renesas,r9a09g011-xhci',
> 'renesas,rzv2m-xhci']
> Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to
> match any schema with compatible: ['renesas,r9a09g011-xhci',
> 'renesas,rzv2m-xhci']
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb3peri: resets: [[4294967295, 29]] is too short
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb3peri: 'reset-names' is a required property
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
> 
> doc reference errors (make refcheckdocs):
> 
> See
> https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwor
> k.ozlabs.org%2Fproject%2Fdevicetree-
> bindings%2Fpatch%2F20221212172804.1277751-3-
> biju.das.jz%40bp.renesas.com&amp;data=05%7C01%7Cbiju.das.jz%40bp.renesas.c
> om%7C847aa4858e704c2d03a708dadc864f81%7C53d82571da1947e49cb4625a166a4a2a%7
> C0%7C0%7C638064766653956032%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC
> JQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2F
> uKtm48%2Bzxnx0ha2ddRFLUNiYFXtesrXOIPt46UhJ7c%3D&amp;reserved=0
> 
> 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.
Rob Herring (Arm) Dec. 13, 2022, 2:29 p.m. UTC | #2
On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
>  1 file changed, 123 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> 
> diff --git a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> new file mode 100644
> index 000000000000..0c473c3398b3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> @@ -0,0 +1,123 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/usb/renesas,rzv2m-usb3drd.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Renesas RZ/V2M USB 3.1 DRD controller
> +
> +maintainers:
> +  - Biju Das <biju.das.jz@bp.renesas.com>
> +
> +description: |
> +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> +  * Role swapping function by the ID pin of the Micro-AB receptacle
> +  * Battery Charging Specification Revision 1.2
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> +      - const: renesas,rzv2m-usb3drd
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    items:
> +      - description: Peripheral AXI clock
> +      - description: APB clock
> +
> +  clock-names:
> +    items:
> +      - const: peri_axi
> +      - const: apb
> +
> +  power-domains:
> +    maxItems: 1
> +
> +  resets:
> +    items:
> +      - description: DRD reset
> +      - description: Peripheral reset
> +
> +  reset-names:
> +    items:
> +      - const: drd_reset
> +      - const: aresetn_p
> +
> +  ranges: true
> +
> +  '#address-cells':
> +    enum: [ 1, 2 ]
> +
> +  '#size-cells':
> +    enum: [ 1, 2 ]
> +
> +  usb3peri:
> +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> +
> +patternProperties:
> +  "^usb@[0-9a-f]+$":
> +    type: object
> +    $ref: renesas,usb-xhci.yaml#
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - power-domains
> +  - resets
> +  - reset-names
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    usb3drd: usb@85070000 {
> +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-usb3drd";
> +        reg = <0x85070000 0x1000>;
> +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +        clock-names = "peri_axi", "apb";
> +        power-domains = <&cpg>;
> +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> +                 <&cpg R9A09G011_USB_ARESETN_P>;
> +        reset-names = "drd_reset", "aresetn_p";
> +        ranges;
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +
> +        usb3host: usb@85060000 {
> +           compatible = "renesas,r9a09g011-xhci",
> +                        "renesas,rzv2m-xhci";
> +           reg = <0x85060000 0x2000>;
> +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +           clock-names = "host_axi", "reg";
> +           power-domains = <&cpg>;
> +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> +        };
> +
> +        usb3peri: usb3peri {
> +           compatible = "renesas,r9a09g011-usb3-peri",
> +                        "renesas,rzv2m-usb3-peri";
> +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> +           interrupt-names = "all_p", "drd", "bc", "gpi";
> +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +           clock-names = "aclk", "reg";
> +           power-domains = <&cpg>;
> +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> +        };

The USB device ctrlr doesn't have registers? It looks to me like you've 
created 3 nodes for instantiating drivers rather that because you have 3 
separate h/w blocks. Either you should split this to 2 independent nodes 
or move usb3peri resources to the parent node. That would only be 
interrupts because everything else is already there.

Rob
Biju Das Dec. 13, 2022, 3:01 p.m. UTC | #3
Hi Rob,

> Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> 
> On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> >  1 file changed, 123 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> >
> > diff --git
> > a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > new file mode 100644
> > index 000000000000..0c473c3398b3
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > @@ -0,0 +1,123 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
> > +---
> > +
> > +title: Renesas RZ/V2M USB 3.1 DRD controller
> > +
> > +maintainers:
> > +  - Biju Das <biju.das.jz@bp.renesas.com>
> > +
> > +description: |
> > +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> > +  * Role swapping function by the ID pin of the Micro-AB receptacle
> > +  * Battery Charging Specification Revision 1.2
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> > +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> > +      - const: renesas,rzv2m-usb3drd
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    items:
> > +      - description: Peripheral AXI clock
> > +      - description: APB clock
> > +
> > +  clock-names:
> > +    items:
> > +      - const: peri_axi
> > +      - const: apb
> > +
> > +  power-domains:
> > +    maxItems: 1
> > +
> > +  resets:
> > +    items:
> > +      - description: DRD reset
> > +      - description: Peripheral reset
> > +
> > +  reset-names:
> > +    items:
> > +      - const: drd_reset
> > +      - const: aresetn_p
> > +
> > +  ranges: true
> > +
> > +  '#address-cells':
> > +    enum: [ 1, 2 ]
> > +
> > +  '#size-cells':
> > +    enum: [ 1, 2 ]
> > +
> > +  usb3peri:
> > +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> > +
> > +patternProperties:
> > +  "^usb@[0-9a-f]+$":
> > +    type: object
> > +    $ref: renesas,usb-xhci.yaml#
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - power-domains
> > +  - resets
> > +  - reset-names
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > +
> > +    usb3drd: usb@85070000 {
> > +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-
> usb3drd";
> > +        reg = <0x85070000 0x1000>;
> > +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +        clock-names = "peri_axi", "apb";
> > +        power-domains = <&cpg>;
> > +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> > +                 <&cpg R9A09G011_USB_ARESETN_P>;
> > +        reset-names = "drd_reset", "aresetn_p";
> > +        ranges;
> > +        #address-cells = <1>;
> > +        #size-cells = <1>;
> > +
> > +        usb3host: usb@85060000 {
> > +           compatible = "renesas,r9a09g011-xhci",
> > +                        "renesas,rzv2m-xhci";
> > +           reg = <0x85060000 0x2000>;
> > +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +           clock-names = "host_axi", "reg";
> > +           power-domains = <&cpg>;
> > +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> > +        };
> > +
> > +        usb3peri: usb3peri {
> > +           compatible = "renesas,r9a09g011-usb3-peri",
> > +                        "renesas,rzv2m-usb3-peri";
> > +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> > +           interrupt-names = "all_p", "drd", "bc", "gpi";
> > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +           clock-names = "aclk", "reg";
> > +           power-domains = <&cpg>;
> > +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> > +        };
> 
> The USB device ctrlr doesn't have registers? It looks to me like you've
> created 3 nodes for instantiating drivers rather that because you have 3
> separate h/w blocks. Either you should split this to 2 independent nodes
> or move usb3peri resources to the parent node. That would only be
> interrupts because everything else is already there.

Address map of USB device controller is 0x85070000-0x85070400
Address map of USB3 DRD is 0x85070400-0x850704FF

The advantage of the current split is that, 

1) With this model, I can use USB3 storage device for booting and mounting rootFS 
as XHCI driver is built-in and USB3 device ctrlr is usually module.

2) To reuse the usb device controller code as much as possible.

If I create 2 independent nodes, then there will be more exported API's
between USB3 peri and USB3 drd driver.

If I move usb3peri resources to the parent node, then I won't be able to
achieve 1)

Please let me know, what is the best way to move forward?

Cheers,
Biju
Rob Herring (Arm) Dec. 13, 2022, 3:54 p.m. UTC | #4
On Tue, Dec 13, 2022 at 03:01:34PM +0000, Biju Das wrote:
> Hi Rob,
> 
> > Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> > 
> > On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> > > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> > >  1 file changed, 123 insertions(+)
> > >  create mode 100644
> > > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > >
> > > diff --git
> > > a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > new file mode 100644
> > > index 000000000000..0c473c3398b3
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > @@ -0,0 +1,123 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
> > > +---
> > > +
> > > +title: Renesas RZ/V2M USB 3.1 DRD controller
> > > +
> > > +maintainers:
> > > +  - Biju Das <biju.das.jz@bp.renesas.com>
> > > +
> > > +description: |
> > > +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> > > +  * Role swapping function by the ID pin of the Micro-AB receptacle
> > > +  * Battery Charging Specification Revision 1.2
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> > > +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> > > +      - const: renesas,rzv2m-usb3drd
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  clocks:
> > > +    items:
> > > +      - description: Peripheral AXI clock
> > > +      - description: APB clock
> > > +
> > > +  clock-names:
> > > +    items:
> > > +      - const: peri_axi
> > > +      - const: apb
> > > +
> > > +  power-domains:
> > > +    maxItems: 1
> > > +
> > > +  resets:
> > > +    items:
> > > +      - description: DRD reset
> > > +      - description: Peripheral reset
> > > +
> > > +  reset-names:
> > > +    items:
> > > +      - const: drd_reset
> > > +      - const: aresetn_p
> > > +
> > > +  ranges: true
> > > +
> > > +  '#address-cells':
> > > +    enum: [ 1, 2 ]
> > > +
> > > +  '#size-cells':
> > > +    enum: [ 1, 2 ]
> > > +
> > > +  usb3peri:
> > > +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> > > +
> > > +patternProperties:
> > > +  "^usb@[0-9a-f]+$":
> > > +    type: object
> > > +    $ref: renesas,usb-xhci.yaml#
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - clocks
> > > +  - clock-names
> > > +  - power-domains
> > > +  - resets
> > > +  - reset-names
> > > +
> > > +additionalProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> > > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > > +
> > > +    usb3drd: usb@85070000 {
> > > +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-
> > usb3drd";
> > > +        reg = <0x85070000 0x1000>;
> > > +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +        clock-names = "peri_axi", "apb";
> > > +        power-domains = <&cpg>;
> > > +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> > > +                 <&cpg R9A09G011_USB_ARESETN_P>;
> > > +        reset-names = "drd_reset", "aresetn_p";
> > > +        ranges;
> > > +        #address-cells = <1>;
> > > +        #size-cells = <1>;
> > > +
> > > +        usb3host: usb@85060000 {
> > > +           compatible = "renesas,r9a09g011-xhci",
> > > +                        "renesas,rzv2m-xhci";
> > > +           reg = <0x85060000 0x2000>;
> > > +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +           clock-names = "host_axi", "reg";
> > > +           power-domains = <&cpg>;
> > > +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> > > +        };
> > > +
> > > +        usb3peri: usb3peri {
> > > +           compatible = "renesas,r9a09g011-usb3-peri",
> > > +                        "renesas,rzv2m-usb3-peri";
> > > +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> > > +           interrupt-names = "all_p", "drd", "bc", "gpi";
> > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +           clock-names = "aclk", "reg";
> > > +           power-domains = <&cpg>;
> > > +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> > > +        };
> > 
> > The USB device ctrlr doesn't have registers? It looks to me like you've
> > created 3 nodes for instantiating drivers rather that because you have 3
> > separate h/w blocks. Either you should split this to 2 independent nodes
> > or move usb3peri resources to the parent node. That would only be
> > interrupts because everything else is already there.
> 
> Address map of USB device controller is 0x85070000-0x85070400
> Address map of USB3 DRD is 0x85070400-0x850704FF

Then your DT should reflect that with 'reg' in usb3peri.

Why does the device ctrlr have a DRD interrupt?

> The advantage of the current split is that, 
> 
> 1) With this model, I can use USB3 storage device for booting and mounting rootFS 
> as XHCI driver is built-in and USB3 device ctrlr is usually module.

Sounds like a Linux problem. What does that have to do with the binding?

> 
> 2) To reuse the usb device controller code as much as possible.
> 
> If I create 2 independent nodes, then there will be more exported API's
> between USB3 peri and USB3 drd driver.

Why if that's a common split, then doesn't Linux have a defined 
interface?

There is no reason you can spawn 2 drivers from 1 DT node if that's what 
you need. Describe h/w blocks, not nodes for drivers. Sometimes the h/w 
isn't partitioned just like Linux would like. That's a Linux problem, 
not something to 'fix' in DT.

Rob
Geert Uytterhoeven Dec. 15, 2022, 10:20 a.m. UTC | #5
Hi Biju,

CC Justin

On Mon, Dec 12, 2022 at 6:28 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Add optional reset support. This is in preparation to adding USB xHCI
> support for RZ/V2M SoC.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>\

Thanks for your patch!

> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -19,6 +19,7 @@
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
>  #include <linux/usb/of.h>
> +#include <linux/reset.h>
>
>  #include "xhci.h"
>  #include "xhci-plat.h"
> @@ -263,10 +264,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
>                 goto put_hcd;
>         }
>
> -       ret = clk_prepare_enable(xhci->reg_clk);
> +       xhci->reset = devm_reset_control_array_get_optional_shared(&pdev->dev);
> +       if (IS_ERR(xhci->reset)) {
> +               ret = PTR_ERR(xhci->reset);
> +               goto put_hcd;
> +       }
> +
> +       ret = reset_control_deassert(xhci->reset);
>         if (ret)
>                 goto put_hcd;
>
> +       ret = clk_prepare_enable(xhci->reg_clk);
> +       if (ret)
> +               goto err_reset;
> +
>         ret = clk_prepare_enable(xhci->clk);
>         if (ret)
>                 goto disable_reg_clk;
> @@ -377,6 +388,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  disable_reg_clk:
>         clk_disable_unprepare(xhci->reg_clk);
>
> +err_reset:
> +       reset_control_assert(xhci->reset);
> +
>  put_hcd:
>         usb_put_hcd(hcd);
>
> @@ -412,6 +426,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>
>         clk_disable_unprepare(clk);
>         clk_disable_unprepare(reg_clk);
> +       reset_control_assert(xhci->reset);
>         usb_put_hcd(hcd);
>
>         pm_runtime_disable(&dev->dev);

LGTM, so
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Just wondering if the reset should be (de)asserted in the suspend/resume
path, too.  But that can only affect the Broadcom STB platforms, which
probably don't have the resets property.  I can't check as there no users
in upstream DTS.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds