mbox series

[v6,0/5] USB: misc: Add onboard_usb_hub driver

Message ID 20210405201817.3977893-1-mka@chromium.org
Headers show
Series USB: misc: Add onboard_usb_hub driver | expand

Message

Matthias Kaehlcke April 5, 2021, 8:18 p.m. UTC
This series adds:
- the onboard_usb_hub_driver
- glue in the xhci-plat driver to create the onboard_usb_hub
  platform device if needed
- a device tree binding for the Realtek RTS5411 USB hub controller
- device tree changes that add RTS5411 entries for the QCA SC7180
  based boards trogdor and lazor
- a couple of stubs for platform device functions to avoid
  unresolved symbols with certain kernel configs

The main issue the driver addresses is that a USB hub needs to be
powered before it can be discovered. For discrete onboard hubs (an
example for such a hub is the Realtek RTS5411) this is often solved
by supplying the hub with an 'always-on' regulator, which is kind
of a hack. Some onboard hubs may require further initialization
steps, like changing the state of a GPIO or enabling a clock, which
requires even more hacks. This driver creates a platform device
representing the hub which performs the necessary initialization.
Currently it only supports switching on a single regulator, support
for multiple regulators or other actions can be added as needed.
Different initialization sequences can be supported based on the
compatible string.

Besides performing the initialization the driver can be configured
to power the hub off during system suspend. This can help to extend
battery life on battery powered devices which have no requirements
to keep the hub powered during suspend. The driver can also be
configured to leave the hub powered when a wakeup capable USB device
is connected when suspending, and power it off otherwise.

Changes in v7:
- series rebased on qcom/arm64-for-5.13

Changes in v6:
- updated summary

Changes in v5:
- cover letter added

Matthias Kaehlcke (5):
  dt-bindings: usb: Add binding for Realtek RTS5411 hub controller
  USB: misc: Add onboard_usb_hub driver
  of/platform: Add stubs for of_platform_device_create/destroy()
  usb: host: xhci-plat: Create platform device for onboard hubs in
    probe()
  arm64: dts: qcom: sc7180-trogdor: Add nodes for onboard USB hub

 .../sysfs-bus-platform-onboard-usb-hub        |   8 +
 .../bindings/usb/realtek,rts5411.yaml         |  59 +++
 MAINTAINERS                                   |   7 +
 .../boot/dts/qcom/sc7180-trogdor-lazor-r0.dts |  19 +-
 .../boot/dts/qcom/sc7180-trogdor-lazor-r1.dts |  11 +-
 .../arm64/boot/dts/qcom/sc7180-trogdor-r1.dts |  19 +-
 arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi  |  21 +-
 drivers/usb/host/xhci-plat.c                  |  16 +
 drivers/usb/misc/Kconfig                      |  17 +
 drivers/usb/misc/Makefile                     |   1 +
 drivers/usb/misc/onboard_usb_hub.c            | 415 ++++++++++++++++++
 include/linux/of_platform.h                   |  22 +-
 include/linux/usb/hcd.h                       |   2 +
 include/linux/usb/onboard_hub.h               |  15 +
 14 files changed, 596 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-platform-onboard-usb-hub
 create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
 create mode 100644 drivers/usb/misc/onboard_usb_hub.c
 create mode 100644 include/linux/usb/onboard_hub.h

Comments

Matthias Kaehlcke April 5, 2021, 8:22 p.m. UTC | #1
> Subject: [PATCH v6 0/5] USB: misc: Add onboard_usb_hub driver

Argh, that should have been v7 :/ Not sure if it's worth/required to
resend.

On Mon, Apr 05, 2021 at 01:18:12PM -0700, Matthias Kaehlcke wrote:
> This series adds:
> - the onboard_usb_hub_driver
> - glue in the xhci-plat driver to create the onboard_usb_hub
>   platform device if needed
> - a device tree binding for the Realtek RTS5411 USB hub controller
> - device tree changes that add RTS5411 entries for the QCA SC7180
>   based boards trogdor and lazor
> - a couple of stubs for platform device functions to avoid
>   unresolved symbols with certain kernel configs
> 
> The main issue the driver addresses is that a USB hub needs to be
> powered before it can be discovered. For discrete onboard hubs (an
> example for such a hub is the Realtek RTS5411) this is often solved
> by supplying the hub with an 'always-on' regulator, which is kind
> of a hack. Some onboard hubs may require further initialization
> steps, like changing the state of a GPIO or enabling a clock, which
> requires even more hacks. This driver creates a platform device
> representing the hub which performs the necessary initialization.
> Currently it only supports switching on a single regulator, support
> for multiple regulators or other actions can be added as needed.
> Different initialization sequences can be supported based on the
> compatible string.
> 
> Besides performing the initialization the driver can be configured
> to power the hub off during system suspend. This can help to extend
> battery life on battery powered devices which have no requirements
> to keep the hub powered during suspend. The driver can also be
> configured to leave the hub powered when a wakeup capable USB device
> is connected when suspending, and power it off otherwise.
> 
> Changes in v7:
> - series rebased on qcom/arm64-for-5.13
> 
> Changes in v6:
> - updated summary
> 
> Changes in v5:
> - cover letter added
> 
> Matthias Kaehlcke (5):
>   dt-bindings: usb: Add binding for Realtek RTS5411 hub controller
>   USB: misc: Add onboard_usb_hub driver
>   of/platform: Add stubs for of_platform_device_create/destroy()
>   usb: host: xhci-plat: Create platform device for onboard hubs in
>     probe()
>   arm64: dts: qcom: sc7180-trogdor: Add nodes for onboard USB hub
> 
>  .../sysfs-bus-platform-onboard-usb-hub        |   8 +
>  .../bindings/usb/realtek,rts5411.yaml         |  59 +++
>  MAINTAINERS                                   |   7 +
>  .../boot/dts/qcom/sc7180-trogdor-lazor-r0.dts |  19 +-
>  .../boot/dts/qcom/sc7180-trogdor-lazor-r1.dts |  11 +-
>  .../arm64/boot/dts/qcom/sc7180-trogdor-r1.dts |  19 +-
>  arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi  |  21 +-
>  drivers/usb/host/xhci-plat.c                  |  16 +
>  drivers/usb/misc/Kconfig                      |  17 +
>  drivers/usb/misc/Makefile                     |   1 +
>  drivers/usb/misc/onboard_usb_hub.c            | 415 ++++++++++++++++++
>  include/linux/of_platform.h                   |  22 +-
>  include/linux/usb/hcd.h                       |   2 +
>  include/linux/usb/onboard_hub.h               |  15 +
>  14 files changed, 596 insertions(+), 36 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-bus-platform-onboard-usb-hub
>  create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
>  create mode 100644 drivers/usb/misc/onboard_usb_hub.c
>  create mode 100644 include/linux/usb/onboard_hub.h
> 
> -- 
> 2.31.0.208.g409f899ff0-goog
>
Rob Herring April 6, 2021, 1:24 p.m. UTC | #2
On Mon, 05 Apr 2021 13:18:13 -0700, Matthias Kaehlcke wrote:
> The Realtek RTS5411 is a USB 3.0 hub controller with 4 ports.

> 

> This initial version of the binding only describes USB related

> aspects of the RTS5411, it does not cover the option of

> connecting the controller as an i2c slave.

> 

> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

> ---

> 

> Changes in v7:

> - added type ref for 'companion-hub' property

> 

> Changes in v6:

> - Realtek binding instead of generic onboard_usb_hub

> - added 'companion-hub' property

> - added reference to 'usb-device.yaml'

> - 'fixed' indentation of compatible entries to keep yamllint happy

> - added 'additionalProperties' entry

> - updated commit message

> 

> Changes in v5:

> - updated 'title'

> - only use standard USB compatible strings

> - deleted 'usb_hub' node

> - renamed 'usb_controller' node to 'usb-controller'

> - removed labels from USB nodes

> - added 'vdd-supply' to USB nodes

> 

> Changes in v4:

> - none

> 

> Changes in v3:

> - updated commit message

> - removed recursive reference to $self

> - adjusted 'compatible' definition to support multiple entries

> - changed USB controller phandle to be a node

> 

> Changes in v2:

> - removed 'wakeup-source' and 'power-off-in-suspend' properties

> - consistently use spaces for indentation in example

> 

>  .../bindings/usb/realtek,rts5411.yaml         | 59 +++++++++++++++++++

>  1 file changed, 59 insertions(+)

>  create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5411.yaml

> 


My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/realtek,rts5411.example.dt.yaml: hub@1: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/realtek,rts5411.example.dt.yaml: hub@2: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml

See https://patchwork.ozlabs.org/patch/1462533

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

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.
Rob Herring April 6, 2021, 4:30 p.m. UTC | #3
On Mon, Apr 05, 2021 at 01:18:13PM -0700, Matthias Kaehlcke wrote:
> The Realtek RTS5411 is a USB 3.0 hub controller with 4 ports.

> 

> This initial version of the binding only describes USB related

> aspects of the RTS5411, it does not cover the option of

> connecting the controller as an i2c slave.

> 

> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

> ---

> 

> Changes in v7:

> - added type ref for 'companion-hub' property

> 

> Changes in v6:

> - Realtek binding instead of generic onboard_usb_hub

> - added 'companion-hub' property

> - added reference to 'usb-device.yaml'

> - 'fixed' indentation of compatible entries to keep yamllint happy

> - added 'additionalProperties' entry

> - updated commit message

> 

> Changes in v5:

> - updated 'title'

> - only use standard USB compatible strings

> - deleted 'usb_hub' node

> - renamed 'usb_controller' node to 'usb-controller'

> - removed labels from USB nodes

> - added 'vdd-supply' to USB nodes

> 

> Changes in v4:

> - none

> 

> Changes in v3:

> - updated commit message

> - removed recursive reference to $self

> - adjusted 'compatible' definition to support multiple entries

> - changed USB controller phandle to be a node

> 

> Changes in v2:

> - removed 'wakeup-source' and 'power-off-in-suspend' properties

> - consistently use spaces for indentation in example

> 

>  .../bindings/usb/realtek,rts5411.yaml         | 59 +++++++++++++++++++

>  1 file changed, 59 insertions(+)

>  create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5411.yaml

> 

> diff --git a/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml b/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml

> new file mode 100644

> index 000000000000..b59001972749

> --- /dev/null

> +++ b/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml

> @@ -0,0 +1,59 @@

> +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause

> +%YAML 1.2

> +---

> +$id: http://devicetree.org/schemas/usb/realtek,rts5411.yaml#

> +$schema: http://devicetree.org/meta-schemas/core.yaml#

> +

> +title: Binding for the Realtek RTS5411 USB 3.0 hub controller

> +

> +maintainers:

> +  - Matthias Kaehlcke <mka@chromium.org>

> +

> +allOf:

> +  - $ref: usb-device.yaml#

> +

> +properties:

> +  compatible:

> +    items:

> +      - enum:

> +          - usbbda,5411

> +          - usbbda,411

> +


reg: true

to fix the error.

> +  vdd-supply:

> +    description:

> +      phandle to the regulator that provides power to the hub.

> +

> +  companion-hub:

> +    $ref: '/schemas/types.yaml#/definitions/phandle'

> +    description:

> +      phandle to the companion hub on the controller.


This should be required I think. I suppose you could only hook up 2.0 
ports, but why. And 3.0 only wouldn't be USB compliant, would it?

> +

> +required:

> +  - compatible

> +  - reg

> +

> +additionalProperties: false

> +

> +examples:

> +  - |

> +    usb-controller {


'usb' is the standard name.

> +        dr_mode = "host";

> +        #address-cells = <1>;

> +        #size-cells = <0>;

> +

> +        /* 2.0 hub on port 1 */

> +        hub_2_0: hub@1 {

> +            compatible = "usbbda,5411";

> +            reg = <1>;

> +            vdd-supply = <&pp3300_hub>;

> +            companion-hub = <&hub_3_0>;

> +        };

> +

> +        /* 3.0 hub on port 2 */

> +        hub_3_0: hub@2 {

> +            compatible = "usbbda,411";

> +            reg = <2>;

> +            vdd-supply = <&pp3300_hub>;

> +            companion-hub = <&hub_2_0>;

> +        };

> +    };

> -- 

> 2.31.0.208.g409f899ff0-goog

>