* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-17 21:20 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Martin Blumenstingl
This series is the outcome of a discussion with Felipe Balbi,
see [0] and [1] as well as Mathias Nyman, see [7] and [8].
The quick-summary of this is:
- dwc3 already takes one USB2 and one USB3 PHY and initializes these
correct
- some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
ohci-platform.c) do not have a limitation on the number of PHYs - they
support one PHY per actual host port
- Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
or three USB2 ports enabled on the internal root-hub. The SoCs also
provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
internally "connected" to the dwc3 roothub) need to be powered on,
otherwise USB devices cannot be enumerated (even if just one PHY is
disabled and if the device is plugged into another, enabled port)
In my first attempt to get USB supported on the GXL and GXM SoCs I tried
to work-around the problem that I could not pass multiple PHYs to the
dwc3 controller.
This was rejected by Rob Herring (which was definitely the thing to do in
my opinion), see [2]
This series adds a new "roothub PHY wrapper". This can be configured
through devicetree by passing a child-node with "reg = <0>" (in other
words: it describes the roothub) to the USB controller.
Additionally there has to be a child-node for each port on
the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
property. This allows modeling the root-hub in devicetree similar to the
USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
This avoids and backwards-compatibility problems (which was a concern
regardless of the solution, see [3]) since the binding for the root-hub
was previously not specified (and we're not using the "phys" property of
the controller, which might have served different purposes before,
depending on the drivers).
Additionally this integrates the new roothub PHY wrapper into hcd.c
which automatically enables it for all USB controller drivers (tested
on an Amlogic Meson GXL SoC which uses a dwc3 controller).
Changes since RfC v5 at [10]:
- dropped RfC prefix
- removed noisy dev_err if no roothub node was found (spotted by
Xiaolong Ye's kbuild test robot - thank you for that!)
- moved the call to usb_phy_roothub_power_off() within
hcd_bus_suspend() to make sure that the PHYs are turned off
if the "race with a root-hub wakeup event" condition is met (in
this case the PHYs are turned on again, with the old code we did
break the PHYs internal ref-counting because we never turned the
PHYs off before turning them on again in case of that special
"race with a root-hub wakeup event").
additionally we're not handling the status returned by
usb_phy_roothub_power_off() anymore (the bus is already turned off
and we tried to turn off all PHYs as well - only the PHYs which
failed to power off will stay in the current state).
thanks to Alan Stern for the suggestion
- removed return value from usb_phy_roothub_power_off() because none
of my code uses it anymore. thanks to Alan Stern for the suggestion
Changes since v4 at [9]:
- renamed the subject of the cover-letter (old name was:
"initialize (multiple) PHYs in xhci-plat")
- back into RFC status (see below for the reasons)
- dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
- reworded cover-letter and commit messages from "platform-roothub"
to "roothub PHY wrapper"
- moved code from drivers/usb/host/platform-roothub.* to
drivers/usb/core/phy.* and the changes to
drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
by Mathias Nyman (as a benefit this will enable the new logic for
non-xHCI controllers as well - however this was not tested yet)
- rename the structs, function names, etc from platform_roothub_* to
usb_phy_roothub*
Changes since RFCv3 at [6]:
- moved the DT binding change from patch #3 to patch #1 as suggested
by Rob Herring (and slightly adjusted the commit message to account
for that)
- added Tested-by from Chunfeng Yun (who confirmed that the whole
concept and implementation works fine on Mediatek SoCs - many thanks
again!) to patch #2
- added Rob Herring's ACK to patches 1 and 3
- dropped RFC status (RFCv3 -> PATCH v4)
Changes since RFCv2 at [5]:
- split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
I called phy_init plus phy_power_on in platform_roothub_power_on and
phy_power_off plus phy_exit in platform_roothub_power_off. However,
Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
series and providing great feedback) reported that only using
phy_power_off (and omitting phy_exit) during system suspend fixes an
issue where USB devices would be re-enumerated when resuming. His
original problem description: "In order to keep link state on mt8173,
we just power off all phys(not exit) when system enter suspend, then
power on them again (needn't init, otherwise device will be
disconnected) when system resume, this can avoid re-enumerating
device.". This fix affects patch #2 and #3 as we now have
platform_roothub_init (which calls phy_init internally),
platform_roothub_power_on (which calls phy_power_on internally),
platform_roothub_power_off (which calls phy_power_off internally) and
platform_roothub_exit (which calls phy_exit internally). suspend and
resume only call platform_roothub_power_{on,off} to prevent the issue
described by Chunfeng Yun (unfortunately I cannot test this because
the Amlogic platform currently does not support system suspend).
- dropped two struct forward declarations from platform-roothub.h which
are not used in the header file (thanks to Chunfeng Yun for spotting
this)
Changes since RFCv1 at [4]:
- split the usb-xhci dt-binding documentation into a separate patch
- fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
- rebased to apply against latest usb-next
[0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
[1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
[2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
[3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
[4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
[5] https://www.spinics.net/lists/linux-usb/msg158967.html
[6] https://www.spinics.net/lists/devicetree/msg190426.html
[7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
[8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
[9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
[10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
Martin Blumenstingl (3):
dt-bindings: usb: add the documentation for USB root-hub
usb: core: add a wrapper for the USB PHYs on the root-hub
usb: core: hcd: integrate the PHY roothub wrapper
.../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
drivers/usb/core/Makefile | 2 +-
drivers/usb/core/hcd.c | 27 ++++
drivers/usb/core/phy.c | 176 +++++++++++++++++++++
drivers/usb/core/phy.h | 7 +
include/linux/usb/hcd.h | 1 +
7 files changed, 265 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
create mode 100644 drivers/usb/core/phy.c
create mode 100644 drivers/usb/core/phy.h
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-17 21:20 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linus-amlogic
This series is the outcome of a discussion with Felipe Balbi,
see [0] and [1] as well as Mathias Nyman, see [7] and [8].
The quick-summary of this is:
- dwc3 already takes one USB2 and one USB3 PHY and initializes these
correct
- some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
ohci-platform.c) do not have a limitation on the number of PHYs - they
support one PHY per actual host port
- Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
or three USB2 ports enabled on the internal root-hub. The SoCs also
provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
internally "connected" to the dwc3 roothub) need to be powered on,
otherwise USB devices cannot be enumerated (even if just one PHY is
disabled and if the device is plugged into another, enabled port)
In my first attempt to get USB supported on the GXL and GXM SoCs I tried
to work-around the problem that I could not pass multiple PHYs to the
dwc3 controller.
This was rejected by Rob Herring (which was definitely the thing to do in
my opinion), see [2]
This series adds a new "roothub PHY wrapper". This can be configured
through devicetree by passing a child-node with "reg = <0>" (in other
words: it describes the roothub) to the USB controller.
Additionally there has to be a child-node for each port on
the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
property. This allows modeling the root-hub in devicetree similar to the
USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
This avoids and backwards-compatibility problems (which was a concern
regardless of the solution, see [3]) since the binding for the root-hub
was previously not specified (and we're not using the "phys" property of
the controller, which might have served different purposes before,
depending on the drivers).
Additionally this integrates the new roothub PHY wrapper into hcd.c
which automatically enables it for all USB controller drivers (tested
on an Amlogic Meson GXL SoC which uses a dwc3 controller).
Changes since RfC v5 at [10]:
- dropped RfC prefix
- removed noisy dev_err if no roothub node was found (spotted by
Xiaolong Ye's kbuild test robot - thank you for that!)
- moved the call to usb_phy_roothub_power_off() within
hcd_bus_suspend() to make sure that the PHYs are turned off
if the "race with a root-hub wakeup event" condition is met (in
this case the PHYs are turned on again, with the old code we did
break the PHYs internal ref-counting because we never turned the
PHYs off before turning them on again in case of that special
"race with a root-hub wakeup event").
additionally we're not handling the status returned by
usb_phy_roothub_power_off() anymore (the bus is already turned off
and we tried to turn off all PHYs as well - only the PHYs which
failed to power off will stay in the current state).
thanks to Alan Stern for the suggestion
- removed return value from usb_phy_roothub_power_off() because none
of my code uses it anymore. thanks to Alan Stern for the suggestion
Changes since v4 at [9]:
- renamed the subject of the cover-letter (old name was:
"initialize (multiple) PHYs in xhci-plat")
- back into RFC status (see below for the reasons)
- dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
- reworded cover-letter and commit messages from "platform-roothub"
to "roothub PHY wrapper"
- moved code from drivers/usb/host/platform-roothub.* to
drivers/usb/core/phy.* and the changes to
drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
by Mathias Nyman (as a benefit this will enable the new logic for
non-xHCI controllers as well - however this was not tested yet)
- rename the structs, function names, etc from platform_roothub_* to
usb_phy_roothub*
Changes since RFCv3 at [6]:
- moved the DT binding change from patch #3 to patch #1 as suggested
by Rob Herring (and slightly adjusted the commit message to account
for that)
- added Tested-by from Chunfeng Yun (who confirmed that the whole
concept and implementation works fine on Mediatek SoCs - many thanks
again!) to patch #2
- added Rob Herring's ACK to patches 1 and 3
- dropped RFC status (RFCv3 -> PATCH v4)
Changes since RFCv2 at [5]:
- split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
I called phy_init plus phy_power_on in platform_roothub_power_on and
phy_power_off plus phy_exit in platform_roothub_power_off. However,
Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
series and providing great feedback) reported that only using
phy_power_off (and omitting phy_exit) during system suspend fixes an
issue where USB devices would be re-enumerated when resuming. His
original problem description: "In order to keep link state on mt8173,
we just power off all phys(not exit) when system enter suspend, then
power on them again (needn't init, otherwise device will be
disconnected) when system resume, this can avoid re-enumerating
device.". This fix affects patch #2 and #3 as we now have
platform_roothub_init (which calls phy_init internally),
platform_roothub_power_on (which calls phy_power_on internally),
platform_roothub_power_off (which calls phy_power_off internally) and
platform_roothub_exit (which calls phy_exit internally). suspend and
resume only call platform_roothub_power_{on,off} to prevent the issue
described by Chunfeng Yun (unfortunately I cannot test this because
the Amlogic platform currently does not support system suspend).
- dropped two struct forward declarations from platform-roothub.h which
are not used in the header file (thanks to Chunfeng Yun for spotting
this)
Changes since RFCv1 at [4]:
- split the usb-xhci dt-binding documentation into a separate patch
- fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
- rebased to apply against latest usb-next
[0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
[1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
[2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
[3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
[4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
[5] https://www.spinics.net/lists/linux-usb/msg158967.html
[6] https://www.spinics.net/lists/devicetree/msg190426.html
[7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
[8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
[9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
[10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
Martin Blumenstingl (3):
dt-bindings: usb: add the documentation for USB root-hub
usb: core: add a wrapper for the USB PHYs on the root-hub
usb: core: hcd: integrate the PHY roothub wrapper
.../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
drivers/usb/core/Makefile | 2 +-
drivers/usb/core/hcd.c | 27 ++++
drivers/usb/core/phy.c | 176 +++++++++++++++++++++
drivers/usb/core/phy.h | 7 +
include/linux/usb/hcd.h | 1 +
7 files changed, 265 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
create mode 100644 drivers/usb/core/phy.c
create mode 100644 drivers/usb/core/phy.h
--
2.14.2
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 1/3] dt-bindings: usb: add the documentation for USB root-hub
2017-10-17 21:20 ` Martin Blumenstingl
@ 2017-10-17 21:20 ` Martin Blumenstingl
-1 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Martin Blumenstingl
A USB root-hub may have several PHYs which need to be configured before
the root-hub starts working.
This adds the documentation for such a USB root-hub as well as a hint
regarding the child-nodes on XHCI controllers which can include the
roothub.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
.../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++++++++++++++++++
Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 ++++
2 files changed, 53 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
diff --git a/Documentation/devicetree/bindings/usb/usb-roothub.txt b/Documentation/devicetree/bindings/usb/usb-roothub.txt
new file mode 100644
index 000000000000..fc0797d7cee9
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-roothub.txt
@@ -0,0 +1,46 @@
+Generic USB root-hub Properties
+
+similar to the USB device bindings (documented in usb-device.txt from the
+current directory) this provides support for configuring the root-hub.
+
+Required properties:
+- compatible: should be at least one of "usb1d6b,3", "usb1d6b,2"
+- reg: must be 0.
+- address-cells: must be 1
+- size-cells: must be 0
+
+Required sub-nodes:
+a sub-node per actual USB port is required. each sub-node supports the
+following properties:
+ Required properties:
+ - reg: the port number on the root-hub (mandatory)
+ Optional properties:
+ - phys: optional, from the *Generic PHY* bindings (mandatory needed
+ when phy-names is given)
+ - phy-names: optional, from the *Generic PHY* bindings; supported names
+ are "usb2-phy" or "usb3-phy"
+
+Example:
+ &usb1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ roothub@0 {
+ compatible = "usb1d6b,3", "usb1d6b,2";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+
+ port@1 {
+ reg = <1>;
+ phys = <&usb2_phy1>, <&usb3_phy1>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+
+ port@2 {
+ reg = <2>;
+ phys = <&usb2_phy2>, <&usb3_phy2>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+ };
+ }
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index ae6e484a8d7c..5b49ba9f2f9a 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -30,6 +30,13 @@ Optional properties:
- usb3-lpm-capable: determines if platform is USB3 LPM capable
- quirk-broken-port-ped: set if the controller has broken port disable mechanism
+sub-nodes:
+- optionally there can be a node for the root-hub, see usb-roothub.txt in the
+ current directory
+- one or more nodes with reg 1-31 for each port to which a device is connected.
+ See usb-device.txt in the current directory for more information.
+
+
Example:
usb@f0931000 {
compatible = "generic-xhci";
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 1/3] dt-bindings: usb: add the documentation for USB root-hub
@ 2017-10-17 21:20 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linus-amlogic
A USB root-hub may have several PHYs which need to be configured before
the root-hub starts working.
This adds the documentation for such a USB root-hub as well as a hint
regarding the child-nodes on XHCI controllers which can include the
roothub.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Rob Herring <robh@kernel.org>
---
.../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++++++++++++++++++
Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 ++++
2 files changed, 53 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
diff --git a/Documentation/devicetree/bindings/usb/usb-roothub.txt b/Documentation/devicetree/bindings/usb/usb-roothub.txt
new file mode 100644
index 000000000000..fc0797d7cee9
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-roothub.txt
@@ -0,0 +1,46 @@
+Generic USB root-hub Properties
+
+similar to the USB device bindings (documented in usb-device.txt from the
+current directory) this provides support for configuring the root-hub.
+
+Required properties:
+- compatible: should be at least one of "usb1d6b,3", "usb1d6b,2"
+- reg: must be 0.
+- address-cells: must be 1
+- size-cells: must be 0
+
+Required sub-nodes:
+a sub-node per actual USB port is required. each sub-node supports the
+following properties:
+ Required properties:
+ - reg: the port number on the root-hub (mandatory)
+ Optional properties:
+ - phys: optional, from the *Generic PHY* bindings (mandatory needed
+ when phy-names is given)
+ - phy-names: optional, from the *Generic PHY* bindings; supported names
+ are "usb2-phy" or "usb3-phy"
+
+Example:
+ &usb1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ roothub at 0 {
+ compatible = "usb1d6b,3", "usb1d6b,2";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+
+ port at 1 {
+ reg = <1>;
+ phys = <&usb2_phy1>, <&usb3_phy1>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+
+ port at 2 {
+ reg = <2>;
+ phys = <&usb2_phy2>, <&usb3_phy2>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+ };
+ }
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index ae6e484a8d7c..5b49ba9f2f9a 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -30,6 +30,13 @@ Optional properties:
- usb3-lpm-capable: determines if platform is USB3 LPM capable
- quirk-broken-port-ped: set if the controller has broken port disable mechanism
+sub-nodes:
+- optionally there can be a node for the root-hub, see usb-roothub.txt in the
+ current directory
+- one or more nodes with reg 1-31 for each port to which a device is connected.
+ See usb-device.txt in the current directory for more information.
+
+
Example:
usb at f0931000 {
compatible = "generic-xhci";
--
2.14.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 2/3] usb: core: add a wrapper for the USB PHYs on the root-hub
2017-10-17 21:20 ` Martin Blumenstingl
@ 2017-10-17 21:20 ` Martin Blumenstingl
-1 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Martin Blumenstingl
Many SoC platforms have separate devices for the USB PHY which are
registered through the generic PHY framework. These PHYs have to be
enabled to make the USB controller actually work. They also have to be
disabled again on shutdown/suspend.
Currently (at least) the following HCI platform drivers are using custom
code to obtain all PHYs via devicetree for the roothub/controller and
disable/enable them when required:
- ehci-platform.c has ehci_platform_power_{on,off}
- xhci-mtk.c has xhci_mtk_phy_{init,exit,power_on,power_off}
- ohci-platform.c has ohci_platform_power_{on,off}
These drivers are not using the generic devicetree USB device bindings
(for the root-hub) yet which were only introduced recently (documentation
is available in devicetree/bindings/usb/usb-device.txt).
With this new wrapper the usb2-phy and usb3-phy can be specified directly
in the child-node of the corresponding port of the roothub via
devicetree.
This allows SoCs like the Amlogic Meson GXL family to operate correctly
because all USB PHYs are initialized (instead of the first USB PHY
only).
Signed-off-by: Martin Blumenstingl <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
---
drivers/usb/core/Makefile | 2 +-
drivers/usb/core/phy.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++
drivers/usb/core/phy.h | 7 ++
3 files changed, 184 insertions(+), 1 deletion(-)
create mode 100644 drivers/usb/core/phy.c
create mode 100644 drivers/usb/core/phy.h
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index 250ec1d662d9..b6e181d08bf6 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -5,7 +5,7 @@
usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-usbcore-y += port.o
+usbcore-y += phy.o port.o
usbcore-$(CONFIG_OF) += of.o
usbcore-$(CONFIG_USB_PCI) += hcd-pci.o
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
new file mode 100644
index 000000000000..31245b4abdbf
--- /dev/null
+++ b/drivers/usb/core/phy.c
@@ -0,0 +1,176 @@
+/*
+ * USB PHY roothub driver - a wrapper for multiple PHYs which passes all phy_*
+ * function calls to multiple (actual) PHY devices. This is comes handy when
+ * initializing all PHYs on a root-hub and to keep them all in the same state.
+ *
+ * Copyright (C) 2017 Martin Blumenstingl <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/phy/phy.h>
+#include <linux/of.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+#include <linux/usb/of.h>
+
+#include "phy.h"
+
+#define ROOTHUB_PORTNUM 0
+
+struct usb_phy_roothub {
+ struct phy *phy;
+ struct list_head list;
+};
+
+static struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+{
+ struct usb_phy_roothub *roothub_entry;
+
+ roothub_entry = devm_kzalloc(dev, sizeof(*roothub_entry), GFP_KERNEL);
+ if (!roothub_entry)
+ return ERR_PTR(-ENOMEM);
+
+ INIT_LIST_HEAD(&roothub_entry->list);
+
+ return roothub_entry;
+}
+
+static int usb_phy_roothub_add_phy(struct device *dev,
+ struct device_node *port_np,
+ const char *con_id, struct list_head *list)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct phy *phy = devm_of_phy_get(dev, port_np, con_id);
+
+ if (IS_ERR_OR_NULL(phy)) {
+ if (!phy || PTR_ERR(phy) == -ENODEV)
+ return 0;
+ else
+ return PTR_ERR(phy);
+ }
+
+ roothub_entry = usb_phy_roothub_alloc(dev);
+ if (IS_ERR(roothub_entry))
+ return PTR_ERR(roothub_entry);
+
+ roothub_entry->phy = phy;
+
+ list_add_tail(&roothub_entry->list, list);
+
+ return 0;
+}
+
+struct usb_phy_roothub *usb_phy_roothub_init(struct device *dev)
+{
+ struct device_node *roothub_np, *port_np;
+ struct usb_phy_roothub *phy_roothub;
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err;
+
+ roothub_np = usb_of_get_child_node(dev->of_node, ROOTHUB_PORTNUM);
+ if (!of_device_is_available(roothub_np))
+ return NULL;
+
+ phy_roothub = usb_phy_roothub_alloc(dev);
+ if (IS_ERR(phy_roothub))
+ return phy_roothub;
+
+ for_each_available_child_of_node(roothub_np, port_np) {
+ err = usb_phy_roothub_add_phy(dev, port_np, "usb2-phy",
+ &phy_roothub->list);
+ if (err)
+ goto err_out;
+
+ err = usb_phy_roothub_add_phy(dev, port_np, "usb3-phy",
+ &phy_roothub->list);
+ if (err)
+ goto err_out;
+ }
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_init(roothub_entry->phy);
+ if (err)
+ goto err_exit_phys;
+ }
+
+ return phy_roothub;
+
+err_exit_phys:
+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
+ phy_exit(roothub_entry->phy);
+
+err_out:
+ return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_init);
+
+int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err, ret = 0;
+
+ if (!phy_roothub)
+ return 0;
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_exit(roothub_entry->phy);
+ if (err)
+ ret = ret;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_exit);
+
+int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err;
+
+ if (!phy_roothub)
+ return 0;
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_power_on(roothub_entry->phy);
+ if (err)
+ goto err_out;
+ }
+
+ return 0;
+
+err_out:
+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
+ phy_power_off(roothub_entry->phy);
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_power_on);
+
+void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+
+ if (!phy_roothub)
+ return;
+
+ list_for_each_entry_reverse(roothub_entry, &phy_roothub->list, list)
+ phy_power_off(roothub_entry->phy);
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h
new file mode 100644
index 000000000000..6fde59bfbff8
--- /dev/null
+++ b/drivers/usb/core/phy.h
@@ -0,0 +1,7 @@
+struct usb_phy_roothub;
+
+struct usb_phy_roothub *usb_phy_roothub_init(struct device *dev);
+int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub);
+
+int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
+void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 2/3] usb: core: add a wrapper for the USB PHYs on the root-hub
@ 2017-10-17 21:20 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:20 UTC (permalink / raw)
To: linus-amlogic
Many SoC platforms have separate devices for the USB PHY which are
registered through the generic PHY framework. These PHYs have to be
enabled to make the USB controller actually work. They also have to be
disabled again on shutdown/suspend.
Currently (at least) the following HCI platform drivers are using custom
code to obtain all PHYs via devicetree for the roothub/controller and
disable/enable them when required:
- ehci-platform.c has ehci_platform_power_{on,off}
- xhci-mtk.c has xhci_mtk_phy_{init,exit,power_on,power_off}
- ohci-platform.c has ohci_platform_power_{on,off}
These drivers are not using the generic devicetree USB device bindings
(for the root-hub) yet which were only introduced recently (documentation
is available in devicetree/bindings/usb/usb-device.txt).
With this new wrapper the usb2-phy and usb3-phy can be specified directly
in the child-node of the corresponding port of the roothub via
devicetree.
This allows SoCs like the Amlogic Meson GXL family to operate correctly
because all USB PHYs are initialized (instead of the first USB PHY
only).
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/usb/core/Makefile | 2 +-
drivers/usb/core/phy.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++
drivers/usb/core/phy.h | 7 ++
3 files changed, 184 insertions(+), 1 deletion(-)
create mode 100644 drivers/usb/core/phy.c
create mode 100644 drivers/usb/core/phy.h
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index 250ec1d662d9..b6e181d08bf6 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -5,7 +5,7 @@
usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-usbcore-y += port.o
+usbcore-y += phy.o port.o
usbcore-$(CONFIG_OF) += of.o
usbcore-$(CONFIG_USB_PCI) += hcd-pci.o
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
new file mode 100644
index 000000000000..31245b4abdbf
--- /dev/null
+++ b/drivers/usb/core/phy.c
@@ -0,0 +1,176 @@
+/*
+ * USB PHY roothub driver - a wrapper for multiple PHYs which passes all phy_*
+ * function calls to multiple (actual) PHY devices. This is comes handy when
+ * initializing all PHYs on a root-hub and to keep them all in the same state.
+ *
+ * Copyright (C) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/phy/phy.h>
+#include <linux/of.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+#include <linux/usb/of.h>
+
+#include "phy.h"
+
+#define ROOTHUB_PORTNUM 0
+
+struct usb_phy_roothub {
+ struct phy *phy;
+ struct list_head list;
+};
+
+static struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+{
+ struct usb_phy_roothub *roothub_entry;
+
+ roothub_entry = devm_kzalloc(dev, sizeof(*roothub_entry), GFP_KERNEL);
+ if (!roothub_entry)
+ return ERR_PTR(-ENOMEM);
+
+ INIT_LIST_HEAD(&roothub_entry->list);
+
+ return roothub_entry;
+}
+
+static int usb_phy_roothub_add_phy(struct device *dev,
+ struct device_node *port_np,
+ const char *con_id, struct list_head *list)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct phy *phy = devm_of_phy_get(dev, port_np, con_id);
+
+ if (IS_ERR_OR_NULL(phy)) {
+ if (!phy || PTR_ERR(phy) == -ENODEV)
+ return 0;
+ else
+ return PTR_ERR(phy);
+ }
+
+ roothub_entry = usb_phy_roothub_alloc(dev);
+ if (IS_ERR(roothub_entry))
+ return PTR_ERR(roothub_entry);
+
+ roothub_entry->phy = phy;
+
+ list_add_tail(&roothub_entry->list, list);
+
+ return 0;
+}
+
+struct usb_phy_roothub *usb_phy_roothub_init(struct device *dev)
+{
+ struct device_node *roothub_np, *port_np;
+ struct usb_phy_roothub *phy_roothub;
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err;
+
+ roothub_np = usb_of_get_child_node(dev->of_node, ROOTHUB_PORTNUM);
+ if (!of_device_is_available(roothub_np))
+ return NULL;
+
+ phy_roothub = usb_phy_roothub_alloc(dev);
+ if (IS_ERR(phy_roothub))
+ return phy_roothub;
+
+ for_each_available_child_of_node(roothub_np, port_np) {
+ err = usb_phy_roothub_add_phy(dev, port_np, "usb2-phy",
+ &phy_roothub->list);
+ if (err)
+ goto err_out;
+
+ err = usb_phy_roothub_add_phy(dev, port_np, "usb3-phy",
+ &phy_roothub->list);
+ if (err)
+ goto err_out;
+ }
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_init(roothub_entry->phy);
+ if (err)
+ goto err_exit_phys;
+ }
+
+ return phy_roothub;
+
+err_exit_phys:
+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
+ phy_exit(roothub_entry->phy);
+
+err_out:
+ return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_init);
+
+int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err, ret = 0;
+
+ if (!phy_roothub)
+ return 0;
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_exit(roothub_entry->phy);
+ if (err)
+ ret = ret;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_exit);
+
+int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+ struct list_head *head;
+ int err;
+
+ if (!phy_roothub)
+ return 0;
+
+ head = &phy_roothub->list;
+
+ list_for_each_entry(roothub_entry, head, list) {
+ err = phy_power_on(roothub_entry->phy);
+ if (err)
+ goto err_out;
+ }
+
+ return 0;
+
+err_out:
+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
+ phy_power_off(roothub_entry->phy);
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_power_on);
+
+void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub)
+{
+ struct usb_phy_roothub *roothub_entry;
+
+ if (!phy_roothub)
+ return;
+
+ list_for_each_entry_reverse(roothub_entry, &phy_roothub->list, list)
+ phy_power_off(roothub_entry->phy);
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h
new file mode 100644
index 000000000000..6fde59bfbff8
--- /dev/null
+++ b/drivers/usb/core/phy.h
@@ -0,0 +1,7 @@
+struct usb_phy_roothub;
+
+struct usb_phy_roothub *usb_phy_roothub_init(struct device *dev);
+int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub);
+
+int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
+void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);
--
2.14.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 3/3] usb: core: hcd: integrate the PHY roothub wrapper
2017-10-17 21:20 ` Martin Blumenstingl
@ 2017-10-17 21:21 ` Martin Blumenstingl
-1 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:21 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Martin Blumenstingl
This integrates the PHY roothub wrapper into the core hcd
infrastructure. Multiple PHYs which are part of the roothub devicetree
node (which is a sub-node of the sysdev's node) are now managed
(= powered on/off when needed), by the new usb_phy_roothub code.
One example where this is required is the Amlogic GXL and GXM SoCs:
They are using a dwc3 USB controller with up to three ports enabled on
the internal roothub. Using only the top-level "phy" properties does not
work here since one can only specify one "usb2-phy" and one "usb3-phy",
while actually at least two "usb2-phy" have to be specified.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
---
drivers/usb/core/hcd.c | 27 +++++++++++++++++++++++++++
include/linux/usb/hcd.h | 1 +
2 files changed, 28 insertions(+)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 67aa3d039b9b..59bb8dac5264 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -50,6 +50,7 @@
#include <linux/usb/otg.h>
#include "usb.h"
+#include "phy.h"
/*-------------------------------------------------------------------------*/
@@ -2271,6 +2272,8 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
hcd->state = HC_STATE_SUSPENDED;
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+
/* Did we race with a root-hub wakeup event? */
if (rhdev->do_remote_wakeup) {
char buffer[6];
@@ -2292,6 +2295,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"suspend", status);
}
+
return status;
}
@@ -2307,6 +2311,11 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "resume");
return 0;
}
+
+ status = usb_phy_roothub_power_on(hcd->phy_roothub);
+ if (status)
+ return status;
+
if (!hcd->driver->bus_resume)
return -ENOENT;
if (HCD_RH_RUNNING(hcd))
@@ -2344,6 +2353,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
}
} else {
hcd->state = old_state;
+ usb_phy_roothub_power_off(hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2780,6 +2790,16 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
+ hcd->phy_roothub = usb_phy_roothub_init(hcd->self.sysdev);
+ if (IS_ERR(hcd->phy_roothub)) {
+ retval = PTR_ERR(hcd->phy_roothub);
+ goto err_phy_roothub_init;
+ }
+
+ retval = usb_phy_roothub_power_on(hcd->phy_roothub);
+ if (retval)
+ goto err_usb_phy_roothub_power_on;
+
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2944,6 +2964,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
err_register_bus:
hcd_buffer_destroy(hcd);
err_create_buf:
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+err_usb_phy_roothub_power_on:
+ usb_phy_roothub_exit(hcd->phy_roothub);
+err_phy_roothub_init:
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
@@ -3028,6 +3052,9 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(&hcd->self);
hcd_buffer_destroy(hcd);
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+ usb_phy_roothub_exit(hcd->phy_roothub);
+
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index a1f03ebfde47..6915b2afc209 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -103,6 +103,7 @@ struct usb_hcd {
*/
struct usb_phy *usb_phy;
struct phy *phy;
+ struct usb_phy_roothub *phy_roothub;
/* Flags that need to be manipulated atomically because they can
* change while the host controller is running. Always use
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 3/3] usb: core: hcd: integrate the PHY roothub wrapper
@ 2017-10-17 21:21 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-17 21:21 UTC (permalink / raw)
To: linus-amlogic
This integrates the PHY roothub wrapper into the core hcd
infrastructure. Multiple PHYs which are part of the roothub devicetree
node (which is a sub-node of the sysdev's node) are now managed
(= powered on/off when needed), by the new usb_phy_roothub code.
One example where this is required is the Amlogic GXL and GXM SoCs:
They are using a dwc3 USB controller with up to three ports enabled on
the internal roothub. Using only the top-level "phy" properties does not
work here since one can only specify one "usb2-phy" and one "usb3-phy",
while actually at least two "usb2-phy" have to be specified.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/usb/core/hcd.c | 27 +++++++++++++++++++++++++++
include/linux/usb/hcd.h | 1 +
2 files changed, 28 insertions(+)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 67aa3d039b9b..59bb8dac5264 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -50,6 +50,7 @@
#include <linux/usb/otg.h>
#include "usb.h"
+#include "phy.h"
/*-------------------------------------------------------------------------*/
@@ -2271,6 +2272,8 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
hcd->state = HC_STATE_SUSPENDED;
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+
/* Did we race with a root-hub wakeup event? */
if (rhdev->do_remote_wakeup) {
char buffer[6];
@@ -2292,6 +2295,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"suspend", status);
}
+
return status;
}
@@ -2307,6 +2311,11 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "resume");
return 0;
}
+
+ status = usb_phy_roothub_power_on(hcd->phy_roothub);
+ if (status)
+ return status;
+
if (!hcd->driver->bus_resume)
return -ENOENT;
if (HCD_RH_RUNNING(hcd))
@@ -2344,6 +2353,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
}
} else {
hcd->state = old_state;
+ usb_phy_roothub_power_off(hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2780,6 +2790,16 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
+ hcd->phy_roothub = usb_phy_roothub_init(hcd->self.sysdev);
+ if (IS_ERR(hcd->phy_roothub)) {
+ retval = PTR_ERR(hcd->phy_roothub);
+ goto err_phy_roothub_init;
+ }
+
+ retval = usb_phy_roothub_power_on(hcd->phy_roothub);
+ if (retval)
+ goto err_usb_phy_roothub_power_on;
+
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2944,6 +2964,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
err_register_bus:
hcd_buffer_destroy(hcd);
err_create_buf:
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+err_usb_phy_roothub_power_on:
+ usb_phy_roothub_exit(hcd->phy_roothub);
+err_phy_roothub_init:
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
@@ -3028,6 +3052,9 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(&hcd->self);
hcd_buffer_destroy(hcd);
+ usb_phy_roothub_power_off(hcd->phy_roothub);
+ usb_phy_roothub_exit(hcd->phy_roothub);
+
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index a1f03ebfde47..6915b2afc209 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -103,6 +103,7 @@ struct usb_hcd {
*/
struct usb_phy *usb_phy;
struct phy *phy;
+ struct usb_phy_roothub *phy_roothub;
/* Flags that need to be manipulated atomically because they can
* change while the host controller is running. Always use
--
2.14.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH usb-next v6 3/3] usb: core: hcd: integrate the PHY roothub wrapper
2017-10-17 21:21 ` Martin Blumenstingl
@ 2017-10-18 14:40 ` Alan Stern
-1 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2017-10-18 14:40 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w
On Tue, 17 Oct 2017, Martin Blumenstingl wrote:
> This integrates the PHY roothub wrapper into the core hcd
> infrastructure. Multiple PHYs which are part of the roothub devicetree
> node (which is a sub-node of the sysdev's node) are now managed
> (= powered on/off when needed), by the new usb_phy_roothub code.
>
> One example where this is required is the Amlogic GXL and GXM SoCs:
> They are using a dwc3 USB controller with up to three ports enabled on
> the internal roothub. Using only the top-level "phy" properties does not
> work here since one can only specify one "usb2-phy" and one "usb3-phy",
> while actually at least two "usb2-phy" have to be specified.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
> ---
> drivers/usb/core/hcd.c | 27 +++++++++++++++++++++++++++
> include/linux/usb/hcd.h | 1 +
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 67aa3d039b9b..59bb8dac5264 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -50,6 +50,7 @@
> #include <linux/usb/otg.h>
>
> #include "usb.h"
> +#include "phy.h"
>
>
> /*-------------------------------------------------------------------------*/
> @@ -2271,6 +2272,8 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
> usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
> hcd->state = HC_STATE_SUSPENDED;
>
> + usb_phy_roothub_power_off(hcd->phy_roothub);
> +
> /* Did we race with a root-hub wakeup event? */
> if (rhdev->do_remote_wakeup) {
> char buffer[6];
> @@ -2292,6 +2295,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
> dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
> "suspend", status);
> }
> +
> return status;
> }
Unnecessary whitespace change. Otherwise this is okay.
Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 3/3] usb: core: hcd: integrate the PHY roothub wrapper
@ 2017-10-18 14:40 ` Alan Stern
0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2017-10-18 14:40 UTC (permalink / raw)
To: linus-amlogic
On Tue, 17 Oct 2017, Martin Blumenstingl wrote:
> This integrates the PHY roothub wrapper into the core hcd
> infrastructure. Multiple PHYs which are part of the roothub devicetree
> node (which is a sub-node of the sysdev's node) are now managed
> (= powered on/off when needed), by the new usb_phy_roothub code.
>
> One example where this is required is the Amlogic GXL and GXM SoCs:
> They are using a dwc3 USB controller with up to three ports enabled on
> the internal roothub. Using only the top-level "phy" properties does not
> work here since one can only specify one "usb2-phy" and one "usb3-phy",
> while actually at least two "usb2-phy" have to be specified.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/usb/core/hcd.c | 27 +++++++++++++++++++++++++++
> include/linux/usb/hcd.h | 1 +
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 67aa3d039b9b..59bb8dac5264 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -50,6 +50,7 @@
> #include <linux/usb/otg.h>
>
> #include "usb.h"
> +#include "phy.h"
>
>
> /*-------------------------------------------------------------------------*/
> @@ -2271,6 +2272,8 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
> usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
> hcd->state = HC_STATE_SUSPENDED;
>
> + usb_phy_roothub_power_off(hcd->phy_roothub);
> +
> /* Did we race with a root-hub wakeup event? */
> if (rhdev->do_remote_wakeup) {
> char buffer[6];
> @@ -2292,6 +2295,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
> dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
> "suspend", status);
> }
> +
> return status;
> }
Unnecessary whitespace change. Otherwise this is okay.
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Alan Stern
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
2017-10-17 21:20 ` Martin Blumenstingl
@ 2017-10-19 9:55 ` Neil Armstrong
-1 siblings, 0 replies; 18+ messages in thread
From: Neil Armstrong @ 2017-10-19 9:55 UTC (permalink / raw)
To: Martin Blumenstingl, linux-usb-u79uwXL29TY76Z2rM5mHXA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w
Cc: mark.rutland-5wv7dgnIgG8, devicetree-u79uwXL29TY76Z2rM5mHXA,
arnd-r2nGTMty4D4, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w,
linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On 17/10/2017 23:20, Martin Blumenstingl wrote:
> This series is the outcome of a discussion with Felipe Balbi,
> see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> The quick-summary of this is:
> - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> correct
> - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> ohci-platform.c) do not have a limitation on the number of PHYs - they
> support one PHY per actual host port
> - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> or three USB2 ports enabled on the internal root-hub. The SoCs also
> provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> internally "connected" to the dwc3 roothub) need to be powered on,
> otherwise USB devices cannot be enumerated (even if just one PHY is
> disabled and if the device is plugged into another, enabled port)
>
> In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> to work-around the problem that I could not pass multiple PHYs to the
> dwc3 controller.
> This was rejected by Rob Herring (which was definitely the thing to do in
> my opinion), see [2]
>
> This series adds a new "roothub PHY wrapper". This can be configured
> through devicetree by passing a child-node with "reg = <0>" (in other
> words: it describes the roothub) to the USB controller.
> Additionally there has to be a child-node for each port on
> the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> property. This allows modeling the root-hub in devicetree similar to the
> USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> This avoids and backwards-compatibility problems (which was a concern
> regardless of the solution, see [3]) since the binding for the root-hub
> was previously not specified (and we're not using the "phys" property of
> the controller, which might have served different purposes before,
> depending on the drivers).
>
> Additionally this integrates the new roothub PHY wrapper into hcd.c
> which automatically enables it for all USB controller drivers (tested
> on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>
> Changes since RfC v5 at [10]:
> - dropped RfC prefix
> - removed noisy dev_err if no roothub node was found (spotted by
> Xiaolong Ye's kbuild test robot - thank you for that!)
> - moved the call to usb_phy_roothub_power_off() within
> hcd_bus_suspend() to make sure that the PHYs are turned off
> if the "race with a root-hub wakeup event" condition is met (in
> this case the PHYs are turned on again, with the old code we did
> break the PHYs internal ref-counting because we never turned the
> PHYs off before turning them on again in case of that special
> "race with a root-hub wakeup event").
> additionally we're not handling the status returned by
> usb_phy_roothub_power_off() anymore (the bus is already turned off
> and we tried to turn off all PHYs as well - only the PHYs which
> failed to power off will stay in the current state).
> thanks to Alan Stern for the suggestion
> - removed return value from usb_phy_roothub_power_off() because none
> of my code uses it anymore. thanks to Alan Stern for the suggestion
>
> Changes since v4 at [9]:
> - renamed the subject of the cover-letter (old name was:
> "initialize (multiple) PHYs in xhci-plat")
> - back into RFC status (see below for the reasons)
> - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> - reworded cover-letter and commit messages from "platform-roothub"
> to "roothub PHY wrapper"
> - moved code from drivers/usb/host/platform-roothub.* to
> drivers/usb/core/phy.* and the changes to
> drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> by Mathias Nyman (as a benefit this will enable the new logic for
> non-xHCI controllers as well - however this was not tested yet)
> - rename the structs, function names, etc from platform_roothub_* to
> usb_phy_roothub*
>
> Changes since RFCv3 at [6]:
> - moved the DT binding change from patch #3 to patch #1 as suggested
> by Rob Herring (and slightly adjusted the commit message to account
> for that)
> - added Tested-by from Chunfeng Yun (who confirmed that the whole
> concept and implementation works fine on Mediatek SoCs - many thanks
> again!) to patch #2
> - added Rob Herring's ACK to patches 1 and 3
> - dropped RFC status (RFCv3 -> PATCH v4)
>
> Changes since RFCv2 at [5]:
> - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> I called phy_init plus phy_power_on in platform_roothub_power_on and
> phy_power_off plus phy_exit in platform_roothub_power_off. However,
> Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> series and providing great feedback) reported that only using
> phy_power_off (and omitting phy_exit) during system suspend fixes an
> issue where USB devices would be re-enumerated when resuming. His
> original problem description: "In order to keep link state on mt8173,
> we just power off all phys(not exit) when system enter suspend, then
> power on them again (needn't init, otherwise device will be
> disconnected) when system resume, this can avoid re-enumerating
> device.". This fix affects patch #2 and #3 as we now have
> platform_roothub_init (which calls phy_init internally),
> platform_roothub_power_on (which calls phy_power_on internally),
> platform_roothub_power_off (which calls phy_power_off internally) and
> platform_roothub_exit (which calls phy_exit internally). suspend and
> resume only call platform_roothub_power_{on,off} to prevent the issue
> described by Chunfeng Yun (unfortunately I cannot test this because
> the Amlogic platform currently does not support system suspend).
> - dropped two struct forward declarations from platform-roothub.h which
> are not used in the header file (thanks to Chunfeng Yun for spotting
> this)
>
> Changes since RFCv1 at [4]:
> - split the usb-xhci dt-binding documentation into a separate patch
> - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> - rebased to apply against latest usb-next
>
>
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> [6] https://www.spinics.net/lists/devicetree/msg190426.html
> [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>
> Martin Blumenstingl (3):
> dt-bindings: usb: add the documentation for USB root-hub
> usb: core: add a wrapper for the USB PHYs on the root-hub
> usb: core: hcd: integrate the PHY roothub wrapper
>
> .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> drivers/usb/core/Makefile | 2 +-
> drivers/usb/core/hcd.c | 27 ++++
> drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> drivers/usb/core/phy.h | 7 +
> include/linux/usb/hcd.h | 1 +
> 7 files changed, 265 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> create mode 100644 drivers/usb/core/phy.c
> create mode 100644 drivers/usb/core/phy.h
>
On an Amlogic P212 (using roothub) and Odroid-C2 (not using roothub):
Tested-by: Neil Armstrong <narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-19 9:55 ` Neil Armstrong
0 siblings, 0 replies; 18+ messages in thread
From: Neil Armstrong @ 2017-10-19 9:55 UTC (permalink / raw)
To: linus-amlogic
On 17/10/2017 23:20, Martin Blumenstingl wrote:
> This series is the outcome of a discussion with Felipe Balbi,
> see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> The quick-summary of this is:
> - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> correct
> - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> ohci-platform.c) do not have a limitation on the number of PHYs - they
> support one PHY per actual host port
> - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> or three USB2 ports enabled on the internal root-hub. The SoCs also
> provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> internally "connected" to the dwc3 roothub) need to be powered on,
> otherwise USB devices cannot be enumerated (even if just one PHY is
> disabled and if the device is plugged into another, enabled port)
>
> In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> to work-around the problem that I could not pass multiple PHYs to the
> dwc3 controller.
> This was rejected by Rob Herring (which was definitely the thing to do in
> my opinion), see [2]
>
> This series adds a new "roothub PHY wrapper". This can be configured
> through devicetree by passing a child-node with "reg = <0>" (in other
> words: it describes the roothub) to the USB controller.
> Additionally there has to be a child-node for each port on
> the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> property. This allows modeling the root-hub in devicetree similar to the
> USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> This avoids and backwards-compatibility problems (which was a concern
> regardless of the solution, see [3]) since the binding for the root-hub
> was previously not specified (and we're not using the "phys" property of
> the controller, which might have served different purposes before,
> depending on the drivers).
>
> Additionally this integrates the new roothub PHY wrapper into hcd.c
> which automatically enables it for all USB controller drivers (tested
> on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>
> Changes since RfC v5 at [10]:
> - dropped RfC prefix
> - removed noisy dev_err if no roothub node was found (spotted by
> Xiaolong Ye's kbuild test robot - thank you for that!)
> - moved the call to usb_phy_roothub_power_off() within
> hcd_bus_suspend() to make sure that the PHYs are turned off
> if the "race with a root-hub wakeup event" condition is met (in
> this case the PHYs are turned on again, with the old code we did
> break the PHYs internal ref-counting because we never turned the
> PHYs off before turning them on again in case of that special
> "race with a root-hub wakeup event").
> additionally we're not handling the status returned by
> usb_phy_roothub_power_off() anymore (the bus is already turned off
> and we tried to turn off all PHYs as well - only the PHYs which
> failed to power off will stay in the current state).
> thanks to Alan Stern for the suggestion
> - removed return value from usb_phy_roothub_power_off() because none
> of my code uses it anymore. thanks to Alan Stern for the suggestion
>
> Changes since v4 at [9]:
> - renamed the subject of the cover-letter (old name was:
> "initialize (multiple) PHYs in xhci-plat")
> - back into RFC status (see below for the reasons)
> - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> - reworded cover-letter and commit messages from "platform-roothub"
> to "roothub PHY wrapper"
> - moved code from drivers/usb/host/platform-roothub.* to
> drivers/usb/core/phy.* and the changes to
> drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> by Mathias Nyman (as a benefit this will enable the new logic for
> non-xHCI controllers as well - however this was not tested yet)
> - rename the structs, function names, etc from platform_roothub_* to
> usb_phy_roothub*
>
> Changes since RFCv3 at [6]:
> - moved the DT binding change from patch #3 to patch #1 as suggested
> by Rob Herring (and slightly adjusted the commit message to account
> for that)
> - added Tested-by from Chunfeng Yun (who confirmed that the whole
> concept and implementation works fine on Mediatek SoCs - many thanks
> again!) to patch #2
> - added Rob Herring's ACK to patches 1 and 3
> - dropped RFC status (RFCv3 -> PATCH v4)
>
> Changes since RFCv2 at [5]:
> - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> I called phy_init plus phy_power_on in platform_roothub_power_on and
> phy_power_off plus phy_exit in platform_roothub_power_off. However,
> Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> series and providing great feedback) reported that only using
> phy_power_off (and omitting phy_exit) during system suspend fixes an
> issue where USB devices would be re-enumerated when resuming. His
> original problem description: "In order to keep link state on mt8173,
> we just power off all phys(not exit) when system enter suspend, then
> power on them again (needn't init, otherwise device will be
> disconnected) when system resume, this can avoid re-enumerating
> device.". This fix affects patch #2 and #3 as we now have
> platform_roothub_init (which calls phy_init internally),
> platform_roothub_power_on (which calls phy_power_on internally),
> platform_roothub_power_off (which calls phy_power_off internally) and
> platform_roothub_exit (which calls phy_exit internally). suspend and
> resume only call platform_roothub_power_{on,off} to prevent the issue
> described by Chunfeng Yun (unfortunately I cannot test this because
> the Amlogic platform currently does not support system suspend).
> - dropped two struct forward declarations from platform-roothub.h which
> are not used in the header file (thanks to Chunfeng Yun for spotting
> this)
>
> Changes since RFCv1 at [4]:
> - split the usb-xhci dt-binding documentation into a separate patch
> - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> - rebased to apply against latest usb-next
>
>
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> [6] https://www.spinics.net/lists/devicetree/msg190426.html
> [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>
> Martin Blumenstingl (3):
> dt-bindings: usb: add the documentation for USB root-hub
> usb: core: add a wrapper for the USB PHYs on the root-hub
> usb: core: hcd: integrate the PHY roothub wrapper
>
> .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> drivers/usb/core/Makefile | 2 +-
> drivers/usb/core/hcd.c | 27 ++++
> drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> drivers/usb/core/phy.h | 7 +
> include/linux/usb/hcd.h | 1 +
> 7 files changed, 265 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> create mode 100644 drivers/usb/core/phy.c
> create mode 100644 drivers/usb/core/phy.h
>
On an Amlogic P212 (using roothub) and Odroid-C2 (not using roothub):
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
2017-10-17 21:20 ` Martin Blumenstingl
@ 2017-10-19 21:32 ` Martin Blumenstingl
-1 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-19 21:32 UTC (permalink / raw)
To: chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Martin Blumenstingl,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA
Hi Chunfeng Yun,
many thanks for your efforts (testing and explaining the Mediatek SoC
implementatino) on the earlier versions of this series!
On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
<martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> This series is the outcome of a discussion with Felipe Balbi,
> see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> The quick-summary of this is:
> - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> correct
> - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> ohci-platform.c) do not have a limitation on the number of PHYs - they
> support one PHY per actual host port
> - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> or three USB2 ports enabled on the internal root-hub. The SoCs also
> provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> internally "connected" to the dwc3 roothub) need to be powered on,
> otherwise USB devices cannot be enumerated (even if just one PHY is
> disabled and if the device is plugged into another, enabled port)
>
> In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> to work-around the problem that I could not pass multiple PHYs to the
> dwc3 controller.
> This was rejected by Rob Herring (which was definitely the thing to do in
> my opinion), see [2]
>
> This series adds a new "roothub PHY wrapper". This can be configured
> through devicetree by passing a child-node with "reg = <0>" (in other
> words: it describes the roothub) to the USB controller.
> Additionally there has to be a child-node for each port on
> the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> property. This allows modeling the root-hub in devicetree similar to the
> USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> This avoids and backwards-compatibility problems (which was a concern
> regardless of the solution, see [3]) since the binding for the root-hub
> was previously not specified (and we're not using the "phys" property of
> the controller, which might have served different purposes before,
> depending on the drivers).
>
> Additionally this integrates the new roothub PHY wrapper into hcd.c
> which automatically enables it for all USB controller drivers (tested
> on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>
> Changes since RfC v5 at [10]:
> - dropped RfC prefix
> - removed noisy dev_err if no roothub node was found (spotted by
> Xiaolong Ye's kbuild test robot - thank you for that!)
> - moved the call to usb_phy_roothub_power_off() within
> hcd_bus_suspend() to make sure that the PHYs are turned off
> if the "race with a root-hub wakeup event" condition is met (in
> this case the PHYs are turned on again, with the old code we did
> break the PHYs internal ref-counting because we never turned the
> PHYs off before turning them on again in case of that special
> "race with a root-hub wakeup event").
> additionally we're not handling the status returned by
> usb_phy_roothub_power_off() anymore (the bus is already turned off
> and we tried to turn off all PHYs as well - only the PHYs which
> failed to power off will stay in the current state).
> thanks to Alan Stern for the suggestion
> - removed return value from usb_phy_roothub_power_off() because none
> of my code uses it anymore. thanks to Alan Stern for the suggestion
>
> Changes since v4 at [9]:
> - renamed the subject of the cover-letter (old name was:
> "initialize (multiple) PHYs in xhci-plat")
> - back into RFC status (see below for the reasons)
> - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> - reworded cover-letter and commit messages from "platform-roothub"
> to "roothub PHY wrapper"
is there a chance you can test v6 of this series on the Mediatek SoCs
one more time?
in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
which should even enable it on non-xHCI controllers.
however, I cannot test suspend/resume support on my Meson GXL SoCs -
and in addition to that it would be awesome to have confirmation from
you that the latest version still works fine on the Mediatek SoCs
thank you in advance!
> - moved code from drivers/usb/host/platform-roothub.* to
> drivers/usb/core/phy.* and the changes to
> drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> by Mathias Nyman (as a benefit this will enable the new logic for
> non-xHCI controllers as well - however this was not tested yet)
> - rename the structs, function names, etc from platform_roothub_* to
> usb_phy_roothub*
>
> Changes since RFCv3 at [6]:
> - moved the DT binding change from patch #3 to patch #1 as suggested
> by Rob Herring (and slightly adjusted the commit message to account
> for that)
> - added Tested-by from Chunfeng Yun (who confirmed that the whole
> concept and implementation works fine on Mediatek SoCs - many thanks
> again!) to patch #2
> - added Rob Herring's ACK to patches 1 and 3
> - dropped RFC status (RFCv3 -> PATCH v4)
>
> Changes since RFCv2 at [5]:
> - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> I called phy_init plus phy_power_on in platform_roothub_power_on and
> phy_power_off plus phy_exit in platform_roothub_power_off. However,
> Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> series and providing great feedback) reported that only using
> phy_power_off (and omitting phy_exit) during system suspend fixes an
> issue where USB devices would be re-enumerated when resuming. His
> original problem description: "In order to keep link state on mt8173,
> we just power off all phys(not exit) when system enter suspend, then
> power on them again (needn't init, otherwise device will be
> disconnected) when system resume, this can avoid re-enumerating
> device.". This fix affects patch #2 and #3 as we now have
> platform_roothub_init (which calls phy_init internally),
> platform_roothub_power_on (which calls phy_power_on internally),
> platform_roothub_power_off (which calls phy_power_off internally) and
> platform_roothub_exit (which calls phy_exit internally). suspend and
> resume only call platform_roothub_power_{on,off} to prevent the issue
> described by Chunfeng Yun (unfortunately I cannot test this because
> the Amlogic platform currently does not support system suspend).
> - dropped two struct forward declarations from platform-roothub.h which
> are not used in the header file (thanks to Chunfeng Yun for spotting
> this)
>
> Changes since RFCv1 at [4]:
> - split the usb-xhci dt-binding documentation into a separate patch
> - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> - rebased to apply against latest usb-next
>
>
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> [6] https://www.spinics.net/lists/devicetree/msg190426.html
> [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>
> Martin Blumenstingl (3):
> dt-bindings: usb: add the documentation for USB root-hub
> usb: core: add a wrapper for the USB PHYs on the root-hub
> usb: core: hcd: integrate the PHY roothub wrapper
>
> .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> drivers/usb/core/Makefile | 2 +-
> drivers/usb/core/hcd.c | 27 ++++
> drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> drivers/usb/core/phy.h | 7 +
> include/linux/usb/hcd.h | 1 +
> 7 files changed, 265 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> create mode 100644 drivers/usb/core/phy.c
> create mode 100644 drivers/usb/core/phy.h
>
> --
> 2.14.2
>
Regards,
Martin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-19 21:32 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-19 21:32 UTC (permalink / raw)
To: linus-amlogic
Hi Chunfeng Yun,
many thanks for your efforts (testing and explaining the Mediatek SoC
implementatino) on the earlier versions of this series!
On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
> This series is the outcome of a discussion with Felipe Balbi,
> see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> The quick-summary of this is:
> - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> correct
> - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> ohci-platform.c) do not have a limitation on the number of PHYs - they
> support one PHY per actual host port
> - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> or three USB2 ports enabled on the internal root-hub. The SoCs also
> provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> internally "connected" to the dwc3 roothub) need to be powered on,
> otherwise USB devices cannot be enumerated (even if just one PHY is
> disabled and if the device is plugged into another, enabled port)
>
> In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> to work-around the problem that I could not pass multiple PHYs to the
> dwc3 controller.
> This was rejected by Rob Herring (which was definitely the thing to do in
> my opinion), see [2]
>
> This series adds a new "roothub PHY wrapper". This can be configured
> through devicetree by passing a child-node with "reg = <0>" (in other
> words: it describes the roothub) to the USB controller.
> Additionally there has to be a child-node for each port on
> the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> property. This allows modeling the root-hub in devicetree similar to the
> USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> This avoids and backwards-compatibility problems (which was a concern
> regardless of the solution, see [3]) since the binding for the root-hub
> was previously not specified (and we're not using the "phys" property of
> the controller, which might have served different purposes before,
> depending on the drivers).
>
> Additionally this integrates the new roothub PHY wrapper into hcd.c
> which automatically enables it for all USB controller drivers (tested
> on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>
> Changes since RfC v5 at [10]:
> - dropped RfC prefix
> - removed noisy dev_err if no roothub node was found (spotted by
> Xiaolong Ye's kbuild test robot - thank you for that!)
> - moved the call to usb_phy_roothub_power_off() within
> hcd_bus_suspend() to make sure that the PHYs are turned off
> if the "race with a root-hub wakeup event" condition is met (in
> this case the PHYs are turned on again, with the old code we did
> break the PHYs internal ref-counting because we never turned the
> PHYs off before turning them on again in case of that special
> "race with a root-hub wakeup event").
> additionally we're not handling the status returned by
> usb_phy_roothub_power_off() anymore (the bus is already turned off
> and we tried to turn off all PHYs as well - only the PHYs which
> failed to power off will stay in the current state).
> thanks to Alan Stern for the suggestion
> - removed return value from usb_phy_roothub_power_off() because none
> of my code uses it anymore. thanks to Alan Stern for the suggestion
>
> Changes since v4 at [9]:
> - renamed the subject of the cover-letter (old name was:
> "initialize (multiple) PHYs in xhci-plat")
> - back into RFC status (see below for the reasons)
> - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> - reworded cover-letter and commit messages from "platform-roothub"
> to "roothub PHY wrapper"
is there a chance you can test v6 of this series on the Mediatek SoCs
one more time?
in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
which should even enable it on non-xHCI controllers.
however, I cannot test suspend/resume support on my Meson GXL SoCs -
and in addition to that it would be awesome to have confirmation from
you that the latest version still works fine on the Mediatek SoCs
thank you in advance!
> - moved code from drivers/usb/host/platform-roothub.* to
> drivers/usb/core/phy.* and the changes to
> drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> by Mathias Nyman (as a benefit this will enable the new logic for
> non-xHCI controllers as well - however this was not tested yet)
> - rename the structs, function names, etc from platform_roothub_* to
> usb_phy_roothub*
>
> Changes since RFCv3 at [6]:
> - moved the DT binding change from patch #3 to patch #1 as suggested
> by Rob Herring (and slightly adjusted the commit message to account
> for that)
> - added Tested-by from Chunfeng Yun (who confirmed that the whole
> concept and implementation works fine on Mediatek SoCs - many thanks
> again!) to patch #2
> - added Rob Herring's ACK to patches 1 and 3
> - dropped RFC status (RFCv3 -> PATCH v4)
>
> Changes since RFCv2 at [5]:
> - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> I called phy_init plus phy_power_on in platform_roothub_power_on and
> phy_power_off plus phy_exit in platform_roothub_power_off. However,
> Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> series and providing great feedback) reported that only using
> phy_power_off (and omitting phy_exit) during system suspend fixes an
> issue where USB devices would be re-enumerated when resuming. His
> original problem description: "In order to keep link state on mt8173,
> we just power off all phys(not exit) when system enter suspend, then
> power on them again (needn't init, otherwise device will be
> disconnected) when system resume, this can avoid re-enumerating
> device.". This fix affects patch #2 and #3 as we now have
> platform_roothub_init (which calls phy_init internally),
> platform_roothub_power_on (which calls phy_power_on internally),
> platform_roothub_power_off (which calls phy_power_off internally) and
> platform_roothub_exit (which calls phy_exit internally). suspend and
> resume only call platform_roothub_power_{on,off} to prevent the issue
> described by Chunfeng Yun (unfortunately I cannot test this because
> the Amlogic platform currently does not support system suspend).
> - dropped two struct forward declarations from platform-roothub.h which
> are not used in the header file (thanks to Chunfeng Yun for spotting
> this)
>
> Changes since RFCv1 at [4]:
> - split the usb-xhci dt-binding documentation into a separate patch
> - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> - rebased to apply against latest usb-next
>
>
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> [6] https://www.spinics.net/lists/devicetree/msg190426.html
> [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>
> Martin Blumenstingl (3):
> dt-bindings: usb: add the documentation for USB root-hub
> usb: core: add a wrapper for the USB PHYs on the root-hub
> usb: core: hcd: integrate the PHY roothub wrapper
>
> .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> drivers/usb/core/Makefile | 2 +-
> drivers/usb/core/hcd.c | 27 ++++
> drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> drivers/usb/core/phy.h | 7 +
> include/linux/usb/hcd.h | 1 +
> 7 files changed, 265 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> create mode 100644 drivers/usb/core/phy.c
> create mode 100644 drivers/usb/core/phy.h
>
> --
> 2.14.2
>
Regards,
Martin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
2017-10-19 21:32 ` Martin Blumenstingl
@ 2017-10-22 3:16 ` Chunfeng Yun
-1 siblings, 0 replies; 18+ messages in thread
From: Chunfeng Yun @ 2017-10-22 3:16 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
arnd-r2nGTMty4D4, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA
Hi,
On Thu, 2017-10-19 at 23:32 +0200, Martin Blumenstingl wrote:
> Hi Chunfeng Yun,
>
> many thanks for your efforts (testing and explaining the Mediatek SoC
> implementatino) on the earlier versions of this series!
>
> On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
> <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> > This series is the outcome of a discussion with Felipe Balbi,
> > see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> > The quick-summary of this is:
> > - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> > correct
> > - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> > ohci-platform.c) do not have a limitation on the number of PHYs - they
> > support one PHY per actual host port
> > - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> > or three USB2 ports enabled on the internal root-hub. The SoCs also
> > provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> > internally "connected" to the dwc3 roothub) need to be powered on,
> > otherwise USB devices cannot be enumerated (even if just one PHY is
> > disabled and if the device is plugged into another, enabled port)
> >
> > In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> > to work-around the problem that I could not pass multiple PHYs to the
> > dwc3 controller.
> > This was rejected by Rob Herring (which was definitely the thing to do in
> > my opinion), see [2]
> >
> > This series adds a new "roothub PHY wrapper". This can be configured
> > through devicetree by passing a child-node with "reg = <0>" (in other
> > words: it describes the roothub) to the USB controller.
> > Additionally there has to be a child-node for each port on
> > the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> > property. This allows modeling the root-hub in devicetree similar to the
> > USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> > This avoids and backwards-compatibility problems (which was a concern
> > regardless of the solution, see [3]) since the binding for the root-hub
> > was previously not specified (and we're not using the "phys" property of
> > the controller, which might have served different purposes before,
> > depending on the drivers).
> >
> > Additionally this integrates the new roothub PHY wrapper into hcd.c
> > which automatically enables it for all USB controller drivers (tested
> > on an Amlogic Meson GXL SoC which uses a dwc3 controller).
> >
> > Changes since RfC v5 at [10]:
> > - dropped RfC prefix
> > - removed noisy dev_err if no roothub node was found (spotted by
> > Xiaolong Ye's kbuild test robot - thank you for that!)
> > - moved the call to usb_phy_roothub_power_off() within
> > hcd_bus_suspend() to make sure that the PHYs are turned off
> > if the "race with a root-hub wakeup event" condition is met (in
> > this case the PHYs are turned on again, with the old code we did
> > break the PHYs internal ref-counting because we never turned the
> > PHYs off before turning them on again in case of that special
> > "race with a root-hub wakeup event").
> > additionally we're not handling the status returned by
> > usb_phy_roothub_power_off() anymore (the bus is already turned off
> > and we tried to turn off all PHYs as well - only the PHYs which
> > failed to power off will stay in the current state).
> > thanks to Alan Stern for the suggestion
> > - removed return value from usb_phy_roothub_power_off() because none
> > of my code uses it anymore. thanks to Alan Stern for the suggestion
> >
> > Changes since v4 at [9]:
> > - renamed the subject of the cover-letter (old name was:
> > "initialize (multiple) PHYs in xhci-plat")
> > - back into RFC status (see below for the reasons)
> > - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> > - reworded cover-letter and commit messages from "platform-roothub"
> > to "roothub PHY wrapper"
> is there a chance you can test v6 of this series on the Mediatek SoCs
> one more time?
> in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
> which should even enable it on non-xHCI controllers.
> however, I cannot test suspend/resume support on my Meson GXL SoCs -
> and in addition to that it would be awesome to have confirmation from
> you that the latest version still works fine on the Mediatek SoCs
>
Sorry for the late reply.
I tested it last week.
It works well, and will consume less power than the current way of
xhci-mtk's, because when no devices are attached, hcd_bus_suspend is
also called and power off phys even though the system doesn't enter
suspend mode.
And is there any side effect if the phys are powered off/on on runtime
for other Vendor platform?
I find a problem, xhci adds a usb2 hcd and a usb3 hcd, each one will
parse all phys, including usb2-phys and usb3-phys, but in fact, ideally,
usb2 hcd only needs usb2-phys, and usb3 one only needs usb3-phys too,
that's right? so is it necessary to separate those phys into proper hcd?
> thank you in advance!
>
> > - moved code from drivers/usb/host/platform-roothub.* to
> > drivers/usb/core/phy.* and the changes to
> > drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> > by Mathias Nyman (as a benefit this will enable the new logic for
> > non-xHCI controllers as well - however this was not tested yet)
> > - rename the structs, function names, etc from platform_roothub_* to
> > usb_phy_roothub*
> >
> > Changes since RFCv3 at [6]:
> > - moved the DT binding change from patch #3 to patch #1 as suggested
> > by Rob Herring (and slightly adjusted the commit message to account
> > for that)
> > - added Tested-by from Chunfeng Yun (who confirmed that the whole
> > concept and implementation works fine on Mediatek SoCs - many thanks
> > again!) to patch #2
> > - added Rob Herring's ACK to patches 1 and 3
> > - dropped RFC status (RFCv3 -> PATCH v4)
> >
> > Changes since RFCv2 at [5]:
> > - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> > I called phy_init plus phy_power_on in platform_roothub_power_on and
> > phy_power_off plus phy_exit in platform_roothub_power_off. However,
> > Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> > series and providing great feedback) reported that only using
> > phy_power_off (and omitting phy_exit) during system suspend fixes an
> > issue where USB devices would be re-enumerated when resuming. His
> > original problem description: "In order to keep link state on mt8173,
> > we just power off all phys(not exit) when system enter suspend, then
> > power on them again (needn't init, otherwise device will be
> > disconnected) when system resume, this can avoid re-enumerating
> > device.". This fix affects patch #2 and #3 as we now have
> > platform_roothub_init (which calls phy_init internally),
> > platform_roothub_power_on (which calls phy_power_on internally),
> > platform_roothub_power_off (which calls phy_power_off internally) and
> > platform_roothub_exit (which calls phy_exit internally). suspend and
> > resume only call platform_roothub_power_{on,off} to prevent the issue
> > described by Chunfeng Yun (unfortunately I cannot test this because
> > the Amlogic platform currently does not support system suspend).
> > - dropped two struct forward declarations from platform-roothub.h which
> > are not used in the header file (thanks to Chunfeng Yun for spotting
> > this)
> >
> > Changes since RFCv1 at [4]:
> > - split the usb-xhci dt-binding documentation into a separate patch
> > - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> > - rebased to apply against latest usb-next
> >
> >
> > [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> > [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> > [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> > [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> > [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> > [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> > [6] https://www.spinics.net/lists/devicetree/msg190426.html
> > [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> > [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> > [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> > [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
> >
> > Martin Blumenstingl (3):
> > dt-bindings: usb: add the documentation for USB root-hub
> > usb: core: add a wrapper for the USB PHYs on the root-hub
> > usb: core: hcd: integrate the PHY roothub wrapper
> >
> > .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> > Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> > drivers/usb/core/Makefile | 2 +-
> > drivers/usb/core/hcd.c | 27 ++++
> > drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> > drivers/usb/core/phy.h | 7 +
> > include/linux/usb/hcd.h | 1 +
> > 7 files changed, 265 insertions(+), 1 deletion(-)
> > create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> > create mode 100644 drivers/usb/core/phy.c
> > create mode 100644 drivers/usb/core/phy.h
> >
> > --
> > 2.14.2
> >
>
> Regards,
> Martin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-22 3:16 ` Chunfeng Yun
0 siblings, 0 replies; 18+ messages in thread
From: Chunfeng Yun @ 2017-10-22 3:16 UTC (permalink / raw)
To: linus-amlogic
Hi,
On Thu, 2017-10-19 at 23:32 +0200, Martin Blumenstingl wrote:
> Hi Chunfeng Yun,
>
> many thanks for your efforts (testing and explaining the Mediatek SoC
> implementatino) on the earlier versions of this series!
>
> On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
> <martin.blumenstingl@googlemail.com> wrote:
> > This series is the outcome of a discussion with Felipe Balbi,
> > see [0] and [1] as well as Mathias Nyman, see [7] and [8].
> > The quick-summary of this is:
> > - dwc3 already takes one USB2 and one USB3 PHY and initializes these
> > correct
> > - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
> > ohci-platform.c) do not have a limitation on the number of PHYs - they
> > support one PHY per actual host port
> > - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
> > or three USB2 ports enabled on the internal root-hub. The SoCs also
> > provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
> > internally "connected" to the dwc3 roothub) need to be powered on,
> > otherwise USB devices cannot be enumerated (even if just one PHY is
> > disabled and if the device is plugged into another, enabled port)
> >
> > In my first attempt to get USB supported on the GXL and GXM SoCs I tried
> > to work-around the problem that I could not pass multiple PHYs to the
> > dwc3 controller.
> > This was rejected by Rob Herring (which was definitely the thing to do in
> > my opinion), see [2]
> >
> > This series adds a new "roothub PHY wrapper". This can be configured
> > through devicetree by passing a child-node with "reg = <0>" (in other
> > words: it describes the roothub) to the USB controller.
> > Additionally there has to be a child-node for each port on
> > the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
> > property. This allows modeling the root-hub in devicetree similar to the
> > USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
> > This avoids and backwards-compatibility problems (which was a concern
> > regardless of the solution, see [3]) since the binding for the root-hub
> > was previously not specified (and we're not using the "phys" property of
> > the controller, which might have served different purposes before,
> > depending on the drivers).
> >
> > Additionally this integrates the new roothub PHY wrapper into hcd.c
> > which automatically enables it for all USB controller drivers (tested
> > on an Amlogic Meson GXL SoC which uses a dwc3 controller).
> >
> > Changes since RfC v5 at [10]:
> > - dropped RfC prefix
> > - removed noisy dev_err if no roothub node was found (spotted by
> > Xiaolong Ye's kbuild test robot - thank you for that!)
> > - moved the call to usb_phy_roothub_power_off() within
> > hcd_bus_suspend() to make sure that the PHYs are turned off
> > if the "race with a root-hub wakeup event" condition is met (in
> > this case the PHYs are turned on again, with the old code we did
> > break the PHYs internal ref-counting because we never turned the
> > PHYs off before turning them on again in case of that special
> > "race with a root-hub wakeup event").
> > additionally we're not handling the status returned by
> > usb_phy_roothub_power_off() anymore (the bus is already turned off
> > and we tried to turn off all PHYs as well - only the PHYs which
> > failed to power off will stay in the current state).
> > thanks to Alan Stern for the suggestion
> > - removed return value from usb_phy_roothub_power_off() because none
> > of my code uses it anymore. thanks to Alan Stern for the suggestion
> >
> > Changes since v4 at [9]:
> > - renamed the subject of the cover-letter (old name was:
> > "initialize (multiple) PHYs in xhci-plat")
> > - back into RFC status (see below for the reasons)
> > - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
> > - reworded cover-letter and commit messages from "platform-roothub"
> > to "roothub PHY wrapper"
> is there a chance you can test v6 of this series on the Mediatek SoCs
> one more time?
> in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
> which should even enable it on non-xHCI controllers.
> however, I cannot test suspend/resume support on my Meson GXL SoCs -
> and in addition to that it would be awesome to have confirmation from
> you that the latest version still works fine on the Mediatek SoCs
>
Sorry for the late reply.
I tested it last week.
It works well, and will consume less power than the current way of
xhci-mtk's, because when no devices are attached, hcd_bus_suspend is
also called and power off phys even though the system doesn't enter
suspend mode.
And is there any side effect if the phys are powered off/on on runtime
for other Vendor platform?
I find a problem, xhci adds a usb2 hcd and a usb3 hcd, each one will
parse all phys, including usb2-phys and usb3-phys, but in fact, ideally,
usb2 hcd only needs usb2-phys, and usb3 one only needs usb3-phys too,
that's right? so is it necessary to separate those phys into proper hcd?
> thank you in advance!
>
> > - moved code from drivers/usb/host/platform-roothub.* to
> > drivers/usb/core/phy.* and the changes to
> > drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
> > by Mathias Nyman (as a benefit this will enable the new logic for
> > non-xHCI controllers as well - however this was not tested yet)
> > - rename the structs, function names, etc from platform_roothub_* to
> > usb_phy_roothub*
> >
> > Changes since RFCv3 at [6]:
> > - moved the DT binding change from patch #3 to patch #1 as suggested
> > by Rob Herring (and slightly adjusted the commit message to account
> > for that)
> > - added Tested-by from Chunfeng Yun (who confirmed that the whole
> > concept and implementation works fine on Mediatek SoCs - many thanks
> > again!) to patch #2
> > - added Rob Herring's ACK to patches 1 and 3
> > - dropped RFC status (RFCv3 -> PATCH v4)
> >
> > Changes since RFCv2 at [5]:
> > - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
> > I called phy_init plus phy_power_on in platform_roothub_power_on and
> > phy_power_off plus phy_exit in platform_roothub_power_off. However,
> > Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
> > series and providing great feedback) reported that only using
> > phy_power_off (and omitting phy_exit) during system suspend fixes an
> > issue where USB devices would be re-enumerated when resuming. His
> > original problem description: "In order to keep link state on mt8173,
> > we just power off all phys(not exit) when system enter suspend, then
> > power on them again (needn't init, otherwise device will be
> > disconnected) when system resume, this can avoid re-enumerating
> > device.". This fix affects patch #2 and #3 as we now have
> > platform_roothub_init (which calls phy_init internally),
> > platform_roothub_power_on (which calls phy_power_on internally),
> > platform_roothub_power_off (which calls phy_power_off internally) and
> > platform_roothub_exit (which calls phy_exit internally). suspend and
> > resume only call platform_roothub_power_{on,off} to prevent the issue
> > described by Chunfeng Yun (unfortunately I cannot test this because
> > the Amlogic platform currently does not support system suspend).
> > - dropped two struct forward declarations from platform-roothub.h which
> > are not used in the header file (thanks to Chunfeng Yun for spotting
> > this)
> >
> > Changes since RFCv1 at [4]:
> > - split the usb-xhci dt-binding documentation into a separate patch
> > - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
> > - rebased to apply against latest usb-next
> >
> >
> > [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
> > [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
> > [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
> > [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
> > [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
> > [5] https://www.spinics.net/lists/linux-usb/msg158967.html
> > [6] https://www.spinics.net/lists/devicetree/msg190426.html
> > [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
> > [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
> > [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
> > [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
> >
> > Martin Blumenstingl (3):
> > dt-bindings: usb: add the documentation for USB root-hub
> > usb: core: add a wrapper for the USB PHYs on the root-hub
> > usb: core: hcd: integrate the PHY roothub wrapper
> >
> > .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
> > Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
> > drivers/usb/core/Makefile | 2 +-
> > drivers/usb/core/hcd.c | 27 ++++
> > drivers/usb/core/phy.c | 176 +++++++++++++++++++++
> > drivers/usb/core/phy.h | 7 +
> > include/linux/usb/hcd.h | 1 +
> > 7 files changed, 265 insertions(+), 1 deletion(-)
> > create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
> > create mode 100644 drivers/usb/core/phy.c
> > create mode 100644 drivers/usb/core/phy.h
> >
> > --
> > 2.14.2
> >
>
> Regards,
> Martin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
2017-10-22 3:16 ` Chunfeng Yun
@ 2017-10-23 21:45 ` Martin Blumenstingl
-1 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-23 21:45 UTC (permalink / raw)
To: Chunfeng Yun
Cc: mark.rutland-5wv7dgnIgG8, devicetree-u79uwXL29TY76Z2rM5mHXA,
mathias.nyman-ral2JQCrhuEAvxtiuMwx3w, arnd-r2nGTMty4D4,
felipe.balbi-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Hi,
On Sun, Oct 22, 2017 at 5:16 AM, Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> wrote:
> Hi,
>
> On Thu, 2017-10-19 at 23:32 +0200, Martin Blumenstingl wrote:
>> Hi Chunfeng Yun,
>>
>> many thanks for your efforts (testing and explaining the Mediatek SoC
>> implementatino) on the earlier versions of this series!
>>
>> On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
>> <martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
>> > This series is the outcome of a discussion with Felipe Balbi,
>> > see [0] and [1] as well as Mathias Nyman, see [7] and [8].
>> > The quick-summary of this is:
>> > - dwc3 already takes one USB2 and one USB3 PHY and initializes these
>> > correct
>> > - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
>> > ohci-platform.c) do not have a limitation on the number of PHYs - they
>> > support one PHY per actual host port
>> > - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
>> > or three USB2 ports enabled on the internal root-hub. The SoCs also
>> > provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
>> > internally "connected" to the dwc3 roothub) need to be powered on,
>> > otherwise USB devices cannot be enumerated (even if just one PHY is
>> > disabled and if the device is plugged into another, enabled port)
>> >
>> > In my first attempt to get USB supported on the GXL and GXM SoCs I tried
>> > to work-around the problem that I could not pass multiple PHYs to the
>> > dwc3 controller.
>> > This was rejected by Rob Herring (which was definitely the thing to do in
>> > my opinion), see [2]
>> >
>> > This series adds a new "roothub PHY wrapper". This can be configured
>> > through devicetree by passing a child-node with "reg = <0>" (in other
>> > words: it describes the roothub) to the USB controller.
>> > Additionally there has to be a child-node for each port on
>> > the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
>> > property. This allows modeling the root-hub in devicetree similar to the
>> > USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
>> > This avoids and backwards-compatibility problems (which was a concern
>> > regardless of the solution, see [3]) since the binding for the root-hub
>> > was previously not specified (and we're not using the "phys" property of
>> > the controller, which might have served different purposes before,
>> > depending on the drivers).
>> >
>> > Additionally this integrates the new roothub PHY wrapper into hcd.c
>> > which automatically enables it for all USB controller drivers (tested
>> > on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>> >
>> > Changes since RfC v5 at [10]:
>> > - dropped RfC prefix
>> > - removed noisy dev_err if no roothub node was found (spotted by
>> > Xiaolong Ye's kbuild test robot - thank you for that!)
>> > - moved the call to usb_phy_roothub_power_off() within
>> > hcd_bus_suspend() to make sure that the PHYs are turned off
>> > if the "race with a root-hub wakeup event" condition is met (in
>> > this case the PHYs are turned on again, with the old code we did
>> > break the PHYs internal ref-counting because we never turned the
>> > PHYs off before turning them on again in case of that special
>> > "race with a root-hub wakeup event").
>> > additionally we're not handling the status returned by
>> > usb_phy_roothub_power_off() anymore (the bus is already turned off
>> > and we tried to turn off all PHYs as well - only the PHYs which
>> > failed to power off will stay in the current state).
>> > thanks to Alan Stern for the suggestion
>> > - removed return value from usb_phy_roothub_power_off() because none
>> > of my code uses it anymore. thanks to Alan Stern for the suggestion
>> >
>> > Changes since v4 at [9]:
>> > - renamed the subject of the cover-letter (old name was:
>> > "initialize (multiple) PHYs in xhci-plat")
>> > - back into RFC status (see below for the reasons)
>> > - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
>> > - reworded cover-letter and commit messages from "platform-roothub"
>> > to "roothub PHY wrapper"
>> is there a chance you can test v6 of this series on the Mediatek SoCs
>> one more time?
>> in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
>> which should even enable it on non-xHCI controllers.
>> however, I cannot test suspend/resume support on my Meson GXL SoCs -
>> and in addition to that it would be awesome to have confirmation from
>> you that the latest version still works fine on the Mediatek SoCs
>>
> Sorry for the late reply.
we are all busy - no need to be sorry
> I tested it last week.
many thanks for that again!
> It works well, and will consume less power than the current way of
> xhci-mtk's, because when no devices are attached, hcd_bus_suspend is
> also called and power off phys even though the system doesn't enter
> suspend mode.
interesting, I didn't even think about this. it looks like Mathias
Nyman's suggestion brings lots of benefits!
> And is there any side effect if the phys are powered off/on on runtime
> for other Vendor platform?
not that I'm aware of - however, linux-usb is CC'ed, so it would be
great if other vendors could share some feedback!
> I find a problem, xhci adds a usb2 hcd and a usb3 hcd, each one will
> parse all phys, including usb2-phys and usb3-phys, but in fact, ideally,
> usb2 hcd only needs usb2-phys, and usb3 one only needs usb3-phys too,
> that's right? so is it necessary to separate those phys into proper hcd?
indeed - you're doing a great job at reviewing my code (I really like
*proper* code-reviews)!
Mathias and I spotted this (potential) loophole as well: [0]
when implementing the patch I found it hard to detect whether the HCD
is USB2 or USB3 (because on xHCI both, the USB2 and USB3 HCD, are
initially registered as USB3 HCDs and only after registering it the
speed of the hub is changed)
however, apart from a bit of memory overhead I could not find any
issues with this so far - we can still improve this later on (what do
you think?)
once you're fine with the state of my patchset, would you mind sending
a Tested-by/Acked-by (I'm going to send a v7 in a few minutes)?
>
>> thank you in advance!
>>
>> > - moved code from drivers/usb/host/platform-roothub.* to
>> > drivers/usb/core/phy.* and the changes to
>> > drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
>> > by Mathias Nyman (as a benefit this will enable the new logic for
>> > non-xHCI controllers as well - however this was not tested yet)
>> > - rename the structs, function names, etc from platform_roothub_* to
>> > usb_phy_roothub*
>> >
>> > Changes since RFCv3 at [6]:
>> > - moved the DT binding change from patch #3 to patch #1 as suggested
>> > by Rob Herring (and slightly adjusted the commit message to account
>> > for that)
>> > - added Tested-by from Chunfeng Yun (who confirmed that the whole
>> > concept and implementation works fine on Mediatek SoCs - many thanks
>> > again!) to patch #2
>> > - added Rob Herring's ACK to patches 1 and 3
>> > - dropped RFC status (RFCv3 -> PATCH v4)
>> >
>> > Changes since RFCv2 at [5]:
>> > - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
>> > I called phy_init plus phy_power_on in platform_roothub_power_on and
>> > phy_power_off plus phy_exit in platform_roothub_power_off. However,
>> > Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
>> > series and providing great feedback) reported that only using
>> > phy_power_off (and omitting phy_exit) during system suspend fixes an
>> > issue where USB devices would be re-enumerated when resuming. His
>> > original problem description: "In order to keep link state on mt8173,
>> > we just power off all phys(not exit) when system enter suspend, then
>> > power on them again (needn't init, otherwise device will be
>> > disconnected) when system resume, this can avoid re-enumerating
>> > device.". This fix affects patch #2 and #3 as we now have
>> > platform_roothub_init (which calls phy_init internally),
>> > platform_roothub_power_on (which calls phy_power_on internally),
>> > platform_roothub_power_off (which calls phy_power_off internally) and
>> > platform_roothub_exit (which calls phy_exit internally). suspend and
>> > resume only call platform_roothub_power_{on,off} to prevent the issue
>> > described by Chunfeng Yun (unfortunately I cannot test this because
>> > the Amlogic platform currently does not support system suspend).
>> > - dropped two struct forward declarations from platform-roothub.h which
>> > are not used in the header file (thanks to Chunfeng Yun for spotting
>> > this)
>> >
>> > Changes since RFCv1 at [4]:
>> > - split the usb-xhci dt-binding documentation into a separate patch
>> > - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
>> > - rebased to apply against latest usb-next
>> >
>> >
>> > [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
>> > [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
>> > [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
>> > [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
>> > [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
>> > [5] https://www.spinics.net/lists/linux-usb/msg158967.html
>> > [6] https://www.spinics.net/lists/devicetree/msg190426.html
>> > [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
>> > [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
>> > [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
>> > [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>> >
>> > Martin Blumenstingl (3):
>> > dt-bindings: usb: add the documentation for USB root-hub
>> > usb: core: add a wrapper for the USB PHYs on the root-hub
>> > usb: core: hcd: integrate the PHY roothub wrapper
>> >
>> > .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
>> > Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
>> > drivers/usb/core/Makefile | 2 +-
>> > drivers/usb/core/hcd.c | 27 ++++
>> > drivers/usb/core/phy.c | 176 +++++++++++++++++++++
>> > drivers/usb/core/phy.h | 7 +
>> > include/linux/usb/hcd.h | 1 +
>> > 7 files changed, 265 insertions(+), 1 deletion(-)
>> > create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
>> > create mode 100644 drivers/usb/core/phy.c
>> > create mode 100644 drivers/usb/core/phy.h
>> >
>> > --
>> > 2.14.2
>> >
>>
>> Regards,
>> Martin
>
>
>
> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic
Regards
Mart
[0] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub
@ 2017-10-23 21:45 ` Martin Blumenstingl
0 siblings, 0 replies; 18+ messages in thread
From: Martin Blumenstingl @ 2017-10-23 21:45 UTC (permalink / raw)
To: linus-amlogic
Hi,
On Sun, Oct 22, 2017 at 5:16 AM, Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> Hi,
>
> On Thu, 2017-10-19 at 23:32 +0200, Martin Blumenstingl wrote:
>> Hi Chunfeng Yun,
>>
>> many thanks for your efforts (testing and explaining the Mediatek SoC
>> implementatino) on the earlier versions of this series!
>>
>> On Tue, Oct 17, 2017 at 11:20 PM, Martin Blumenstingl
>> <martin.blumenstingl@googlemail.com> wrote:
>> > This series is the outcome of a discussion with Felipe Balbi,
>> > see [0] and [1] as well as Mathias Nyman, see [7] and [8].
>> > The quick-summary of this is:
>> > - dwc3 already takes one USB2 and one USB3 PHY and initializes these
>> > correct
>> > - some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
>> > ohci-platform.c) do not have a limitation on the number of PHYs - they
>> > support one PHY per actual host port
>> > - Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
>> > or three USB2 ports enabled on the internal root-hub. The SoCs also
>> > provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
>> > internally "connected" to the dwc3 roothub) need to be powered on,
>> > otherwise USB devices cannot be enumerated (even if just one PHY is
>> > disabled and if the device is plugged into another, enabled port)
>> >
>> > In my first attempt to get USB supported on the GXL and GXM SoCs I tried
>> > to work-around the problem that I could not pass multiple PHYs to the
>> > dwc3 controller.
>> > This was rejected by Rob Herring (which was definitely the thing to do in
>> > my opinion), see [2]
>> >
>> > This series adds a new "roothub PHY wrapper". This can be configured
>> > through devicetree by passing a child-node with "reg = <0>" (in other
>> > words: it describes the roothub) to the USB controller.
>> > Additionally there has to be a child-node for each port on
>> > the root-hub. Each of the child-nodes takes a "phys" and "phy-names"
>> > property. This allows modeling the root-hub in devicetree similar to the
>> > USB device binding (documented in devicetree/bindings/usb/usb-device.txt)
>> > This avoids and backwards-compatibility problems (which was a concern
>> > regardless of the solution, see [3]) since the binding for the root-hub
>> > was previously not specified (and we're not using the "phys" property of
>> > the controller, which might have served different purposes before,
>> > depending on the drivers).
>> >
>> > Additionally this integrates the new roothub PHY wrapper into hcd.c
>> > which automatically enables it for all USB controller drivers (tested
>> > on an Amlogic Meson GXL SoC which uses a dwc3 controller).
>> >
>> > Changes since RfC v5 at [10]:
>> > - dropped RfC prefix
>> > - removed noisy dev_err if no roothub node was found (spotted by
>> > Xiaolong Ye's kbuild test robot - thank you for that!)
>> > - moved the call to usb_phy_roothub_power_off() within
>> > hcd_bus_suspend() to make sure that the PHYs are turned off
>> > if the "race with a root-hub wakeup event" condition is met (in
>> > this case the PHYs are turned on again, with the old code we did
>> > break the PHYs internal ref-counting because we never turned the
>> > PHYs off before turning them on again in case of that special
>> > "race with a root-hub wakeup event").
>> > additionally we're not handling the status returned by
>> > usb_phy_roothub_power_off() anymore (the bus is already turned off
>> > and we tried to turn off all PHYs as well - only the PHYs which
>> > failed to power off will stay in the current state).
>> > thanks to Alan Stern for the suggestion
>> > - removed return value from usb_phy_roothub_power_off() because none
>> > of my code uses it anymore. thanks to Alan Stern for the suggestion
>> >
>> > Changes since v4 at [9]:
>> > - renamed the subject of the cover-letter (old name was:
>> > "initialize (multiple) PHYs in xhci-plat")
>> > - back into RFC status (see below for the reasons)
>> > - dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
>> > - reworded cover-letter and commit messages from "platform-roothub"
>> > to "roothub PHY wrapper"
>> is there a chance you can test v6 of this series on the Mediatek SoCs
>> one more time?
>> in v5 the code was moved from xhci-plat.c to drivers/usb/core/hub.c
>> which should even enable it on non-xHCI controllers.
>> however, I cannot test suspend/resume support on my Meson GXL SoCs -
>> and in addition to that it would be awesome to have confirmation from
>> you that the latest version still works fine on the Mediatek SoCs
>>
> Sorry for the late reply.
we are all busy - no need to be sorry
> I tested it last week.
many thanks for that again!
> It works well, and will consume less power than the current way of
> xhci-mtk's, because when no devices are attached, hcd_bus_suspend is
> also called and power off phys even though the system doesn't enter
> suspend mode.
interesting, I didn't even think about this. it looks like Mathias
Nyman's suggestion brings lots of benefits!
> And is there any side effect if the phys are powered off/on on runtime
> for other Vendor platform?
not that I'm aware of - however, linux-usb is CC'ed, so it would be
great if other vendors could share some feedback!
> I find a problem, xhci adds a usb2 hcd and a usb3 hcd, each one will
> parse all phys, including usb2-phys and usb3-phys, but in fact, ideally,
> usb2 hcd only needs usb2-phys, and usb3 one only needs usb3-phys too,
> that's right? so is it necessary to separate those phys into proper hcd?
indeed - you're doing a great job at reviewing my code (I really like
*proper* code-reviews)!
Mathias and I spotted this (potential) loophole as well: [0]
when implementing the patch I found it hard to detect whether the HCD
is USB2 or USB3 (because on xHCI both, the USB2 and USB3 HCD, are
initially registered as USB3 HCDs and only after registering it the
speed of the hub is changed)
however, apart from a bit of memory overhead I could not find any
issues with this so far - we can still improve this later on (what do
you think?)
once you're fine with the state of my patchset, would you mind sending
a Tested-by/Acked-by (I'm going to send a v7 in a few minutes)?
>
>> thank you in advance!
>>
>> > - moved code from drivers/usb/host/platform-roothub.* to
>> > drivers/usb/core/phy.* and the changes to
>> > drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
>> > by Mathias Nyman (as a benefit this will enable the new logic for
>> > non-xHCI controllers as well - however this was not tested yet)
>> > - rename the structs, function names, etc from platform_roothub_* to
>> > usb_phy_roothub*
>> >
>> > Changes since RFCv3 at [6]:
>> > - moved the DT binding change from patch #3 to patch #1 as suggested
>> > by Rob Herring (and slightly adjusted the commit message to account
>> > for that)
>> > - added Tested-by from Chunfeng Yun (who confirmed that the whole
>> > concept and implementation works fine on Mediatek SoCs - many thanks
>> > again!) to patch #2
>> > - added Rob Herring's ACK to patches 1 and 3
>> > - dropped RFC status (RFCv3 -> PATCH v4)
>> >
>> > Changes since RFCv2 at [5]:
>> > - split phy_{init,exit} and phy_power_{on,off} handling. up until RFCv2
>> > I called phy_init plus phy_power_on in platform_roothub_power_on and
>> > phy_power_off plus phy_exit in platform_roothub_power_off. However,
>> > Chunfeng Yun (a Mediatek SoC developer - many thanks for testing my
>> > series and providing great feedback) reported that only using
>> > phy_power_off (and omitting phy_exit) during system suspend fixes an
>> > issue where USB devices would be re-enumerated when resuming. His
>> > original problem description: "In order to keep link state on mt8173,
>> > we just power off all phys(not exit) when system enter suspend, then
>> > power on them again (needn't init, otherwise device will be
>> > disconnected) when system resume, this can avoid re-enumerating
>> > device.". This fix affects patch #2 and #3 as we now have
>> > platform_roothub_init (which calls phy_init internally),
>> > platform_roothub_power_on (which calls phy_power_on internally),
>> > platform_roothub_power_off (which calls phy_power_off internally) and
>> > platform_roothub_exit (which calls phy_exit internally). suspend and
>> > resume only call platform_roothub_power_{on,off} to prevent the issue
>> > described by Chunfeng Yun (unfortunately I cannot test this because
>> > the Amlogic platform currently does not support system suspend).
>> > - dropped two struct forward declarations from platform-roothub.h which
>> > are not used in the header file (thanks to Chunfeng Yun for spotting
>> > this)
>> >
>> > Changes since RFCv1 at [4]:
>> > - split the usb-xhci dt-binding documentation into a separate patch
>> > - fixed a typo ("usb-phy" -> "phys" in the dt-binding example)
>> > - rebased to apply against latest usb-next
>> >
>> >
>> > [0] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001945.html
>> > [1] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001947.html
>> > [2] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001818.html
>> > [3] http://lists.infradead.org/pipermail/linux-amlogic/2017-January/001948.html
>> > [4] http://marc.info/?l=linux-usb&m=148414866303604&w=2
>> > [5] https://www.spinics.net/lists/linux-usb/msg158967.html
>> > [6] https://www.spinics.net/lists/devicetree/msg190426.html
>> > [7] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004881.html
>> > [8] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
>> > [9] http://lists.infradead.org/pipermail/linux-amlogic/2017-September/004685.html
>> > [10] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004924.html
>> >
>> > Martin Blumenstingl (3):
>> > dt-bindings: usb: add the documentation for USB root-hub
>> > usb: core: add a wrapper for the USB PHYs on the root-hub
>> > usb: core: hcd: integrate the PHY roothub wrapper
>> >
>> > .../devicetree/bindings/usb/usb-roothub.txt | 46 ++++++
>> > Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +
>> > drivers/usb/core/Makefile | 2 +-
>> > drivers/usb/core/hcd.c | 27 ++++
>> > drivers/usb/core/phy.c | 176 +++++++++++++++++++++
>> > drivers/usb/core/phy.h | 7 +
>> > include/linux/usb/hcd.h | 1 +
>> > 7 files changed, 265 insertions(+), 1 deletion(-)
>> > create mode 100644 Documentation/devicetree/bindings/usb/usb-roothub.txt
>> > create mode 100644 drivers/usb/core/phy.c
>> > create mode 100644 drivers/usb/core/phy.h
>> >
>> > --
>> > 2.14.2
>> >
>>
>> Regards,
>> Martin
>
>
>
> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic
Regards
Mart
[0] http://lists.infradead.org/pipermail/linux-amlogic/2017-October/004920.html
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2017-10-23 21:45 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17 21:20 [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub Martin Blumenstingl
2017-10-17 21:20 ` Martin Blumenstingl
[not found] ` <20171017212100.10544-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-10-17 21:20 ` [PATCH usb-next v6 1/3] dt-bindings: usb: add the documentation for USB root-hub Martin Blumenstingl
2017-10-17 21:20 ` Martin Blumenstingl
2017-10-17 21:20 ` [PATCH usb-next v6 2/3] usb: core: add a wrapper for the USB PHYs on the root-hub Martin Blumenstingl
2017-10-17 21:20 ` Martin Blumenstingl
2017-10-17 21:21 ` [PATCH usb-next v6 3/3] usb: core: hcd: integrate the PHY roothub wrapper Martin Blumenstingl
2017-10-17 21:21 ` Martin Blumenstingl
[not found] ` <20171017212100.10544-4-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-10-18 14:40 ` Alan Stern
2017-10-18 14:40 ` Alan Stern
2017-10-19 9:55 ` [PATCH usb-next v6 0/3] initialize (multiple) PHYs on the roothub Neil Armstrong
2017-10-19 9:55 ` Neil Armstrong
2017-10-19 21:32 ` Martin Blumenstingl
2017-10-19 21:32 ` Martin Blumenstingl
[not found] ` <CAFBinCCMxdg=P3ods02mweetykQvgmmaL+GtKmuYEdivTZUofw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-22 3:16 ` Chunfeng Yun
2017-10-22 3:16 ` Chunfeng Yun
2017-10-23 21:45 ` Martin Blumenstingl
2017-10-23 21:45 ` Martin Blumenstingl
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.