2019-02-28 18:57:57

by Måns Rullgård

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: usb: add non-removable-ports hub property

Add a non-removable-ports property that lists the hardwired downstream
ports of a hub. Although hubs can provide this information, they are
not always configured correctly. An alternate means of indicating this
for built-in USB devices is thus useful.

Signed-off-by: Mans Rullgard <[email protected]>
---
Documentation/devicetree/bindings/usb/usb-device.txt | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/usb-device.txt b/Documentation/devicetree/bindings/usb/usb-device.txt
index 036be172b1ae..92d863cc96b6 100644
--- a/Documentation/devicetree/bindings/usb/usb-device.txt
+++ b/Documentation/devicetree/bindings/usb/usb-device.txt
@@ -66,6 +66,10 @@ Required properties for host-controller nodes with device nodes:
- #size-cells: shall be 0


+Optional properties for hub and host-controller nodes:
+- non-removable-ports: list of hardwired downstream ports
+
+
Example:

&usb1 { /* host controller */
--
2.20.1



2019-02-28 18:57:41

by Måns Rullgård

[permalink] [raw]
Subject: [PATCH 2/2] usb: hub: use non-removable-ports DT property

Mark any ports listed in the non-removable-ports DT property as
hardwired. This is useful for boards with built-in USB devices
that cannot be (or have not been) marked as fixed in hardware.

Signed-off-by: Mans Rullgard <[email protected]>
---
drivers/usb/core/hub.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 3adff4da2ee1..44ac49a30be1 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1328,6 +1328,9 @@ static int hub_configure(struct usb_hub *hub,
unsigned unit_load;
unsigned full_load;
unsigned maxchild;
+ struct property *prop;
+ const __be32 *cur;
+ u32 val;

hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
if (!hub->buffer) {
@@ -1629,6 +1632,17 @@ static int hub_configure(struct usb_hub *hub,
}
}

+ of_property_for_each_u32(hub_dev->of_node, "non-removable-ports",
+ prop, cur, val) {
+ if (val < 1 || val > hdev->maxchild) {
+ dev_warn(hub_dev, "port number %u out of range\n", val);
+ continue;
+ }
+
+ hub->ports[val - 1]->connect_type =
+ USB_PORT_CONNECT_TYPE_HARD_WIRED;
+ }
+
usb_hub_adjust_deviceremovable(hdev, hub->descriptor);

hub_activate(hub, HUB_INIT);
--
2.20.1


2019-03-18 14:40:00

by Måns Rullgård

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: hub: use non-removable-ports DT property

Mans Rullgard <[email protected]> writes:

> Mark any ports listed in the non-removable-ports DT property as
> hardwired. This is useful for boards with built-in USB devices
> that cannot be (or have not been) marked as fixed in hardware.
>
> Signed-off-by: Mans Rullgard <[email protected]>
> ---
> drivers/usb/core/hub.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)

Any comments on these patches?

> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 3adff4da2ee1..44ac49a30be1 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -1328,6 +1328,9 @@ static int hub_configure(struct usb_hub *hub,
> unsigned unit_load;
> unsigned full_load;
> unsigned maxchild;
> + struct property *prop;
> + const __be32 *cur;
> + u32 val;
>
> hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
> if (!hub->buffer) {
> @@ -1629,6 +1632,17 @@ static int hub_configure(struct usb_hub *hub,
> }
> }
>
> + of_property_for_each_u32(hub_dev->of_node, "non-removable-ports",
> + prop, cur, val) {
> + if (val < 1 || val > hdev->maxchild) {
> + dev_warn(hub_dev, "port number %u out of range\n", val);
> + continue;
> + }
> +
> + hub->ports[val - 1]->connect_type =
> + USB_PORT_CONNECT_TYPE_HARD_WIRED;
> + }
> +
> usb_hub_adjust_deviceremovable(hdev, hub->descriptor);
>
> hub_activate(hub, HUB_INIT);
> --
> 2.20.1
>

--
M?ns Rullg?rd

2019-03-18 15:01:12

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: hub: use non-removable-ports DT property

On Mon, 18 Mar 2019, [iso-8859-1] M?ns Rullg?rd wrote:

> Mans Rullgard <[email protected]> writes:
>
> > Mark any ports listed in the non-removable-ports DT property as
> > hardwired. This is useful for boards with built-in USB devices
> > that cannot be (or have not been) marked as fixed in hardware.
> >
> > Signed-off-by: Mans Rullgard <[email protected]>
> > ---
> > drivers/usb/core/hub.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
>
> Any comments on these patches?
>
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index 3adff4da2ee1..44ac49a30be1 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -1328,6 +1328,9 @@ static int hub_configure(struct usb_hub *hub,
> > unsigned unit_load;
> > unsigned full_load;
> > unsigned maxchild;
> > + struct property *prop;
> > + const __be32 *cur;
> > + u32 val;
> >
> > hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
> > if (!hub->buffer) {
> > @@ -1629,6 +1632,17 @@ static int hub_configure(struct usb_hub *hub,
> > }
> > }
> >
> > + of_property_for_each_u32(hub_dev->of_node, "non-removable-ports",
> > + prop, cur, val) {
> > + if (val < 1 || val > hdev->maxchild) {
> > + dev_warn(hub_dev, "port number %u out of range\n", val);
> > + continue;
> > + }
> > +
> > + hub->ports[val - 1]->connect_type =
> > + USB_PORT_CONNECT_TYPE_HARD_WIRED;
> > + }
> > +
> > usb_hub_adjust_deviceremovable(hdev, hub->descriptor);
> >
> > hub_activate(hub, HUB_INIT);
> > --
> > 2.20.1

This seems like a reasonable thing to do. However, you should improve
the warning message; people who encounter it will have no idea what it
refers to.

Alan Stern


2019-03-27 19:34:36

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: usb: add non-removable-ports hub property

On Thu, 28 Feb 2019 18:45:39 +0000, Mans Rullgard wrote:
> Add a non-removable-ports property that lists the hardwired downstream
> ports of a hub. Although hubs can provide this information, they are
> not always configured correctly. An alternate means of indicating this
> for built-in USB devices is thus useful.
>
> Signed-off-by: Mans Rullgard <[email protected]>
> ---
> Documentation/devicetree/bindings/usb/usb-device.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>

Reviewed-by: Rob Herring <[email protected]>