dwc2 patches to allow wakeup on Rockchip rk3288
Subsystems (4)
cover dwc2 patches to allow wakeup on Rockchip rk3288
This series of patches, together with
<https://patchwork.kernel.org/patch/6652341/> from Chris Zhong and a dts change allow us to wake up from a USB device on rk3288 boards. The patches were tested on rk3288-jerry in the chromeos-3.14 kernel. The chromeos-3.14 kernel tested included a full set of dwc2 backports from upstream, so this is expected to function upstream once we get everything setup there.
Douglas Anderson (3):
USB: Export usb_wakeup_enabled_descendants()
Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
USB: dwc2: Don't turn off the usbphy in suspend if wakeup is enabled
Documentation/devicetree/bindings/usb/dwc2.txt | 4 +++ drivers/usb/core/hub.c | 7 ++-- drivers/usb/dwc2/core.h | 2 ++ drivers/usb/dwc2/platform.c | 45 ++++++++++++++++++++++++-- include/linux/usb/hcd.h | 5 +++ 5 files changed, 58 insertions(+), 5 deletions(-)
Signature · 4 lines
2.4.3.573.g4eafbef -- To unsubscribe from this list: send the line "unsubscribe devicetree" in
PATCH 1/3 USB: Export usb_wakeup_enabled_descendants()
In (e583d9d USB: global suspend and remote wakeup don't mix) we introduced wakeup_enabled_descendants() as a static function. We'd like to use this function in USB controller drivers to know if we should keep the controller on during suspend time, since doing so has a power impact.
--- drivers/usb/core/hub.c | 7 ++++--- include/linux/usb/hcd.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/usb/core/hub.c +4 -3
@@ -3034,13 +3034,14 @@ static int usb_disable_remote_wakeup(struct usb_device *udev) }/* Count of wakeup-enabled devices at or below udev */ -static unsigned wakeup_enabled_descendants (struct usb_device *udev) +unsigned usb_wakeup_enabled_descendants (struct usb_device *udev) {struct usb_hub *hub =usb_hub_to_struct_hub (udev);return udev->do_remote_wakeup + (hub ? hub->wakeup_enabled_descendants :0 ); } +EXPORT_SYMBOL_GPL (usb_wakeup_enabled_descendants);/* * usb_port_suspend - suspend a usb device's upstream port
@@ -3149,7 +3150,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)* Therefore we will turn on the suspend feature if udev or any of its * descendants is enabled for remote wakeup. */ - else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0) + else if (PMSG_IS_AUTO(msg) || usb_wakeup_enabled_descendants(udev) > 0) status =set_port_feature (hub->hdev, port1,USB_PORT_FEAT_SUSPEND ); else {
@@ -3548,7 +3549,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) }if (udev) hub->wakeup_enabled_descendants += -wakeup_enabled_descendants (udev); +usb_wakeup_enabled_descendants (udev); }if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
include/linux/usb/hcd.h +5 -0
@@ -626,11 +626,16 @@ extern wait_queue_head_t usb_kill_urb_queue;#define usb_endpoint_out (ep_dir) (!((ep_dir) & USB_DIR_IN))#ifdef CONFIG_PM +extern unsigned usb_wakeup_enabled_descendants (struct usb_device *udev);extern void usb_root_hub_lost_power (struct usb_device *rhdev);extern int hcd_bus_suspend (struct usb_device *rhdev,pm_message_t msg);extern int hcd_bus_resume (struct usb_device *rhdev,pm_message_t msg);extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);#else +static inline unsigned usb_wakeup_enabled_descendants (struct usb_device *udev) +{ +return 0 ; +}static inline void usb_hcd_resume_root_hub (struct usb_hcd *hcd) {return ;
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 2/3 Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
In reply to Douglas AndersonSome SoCs with a dwc2 USB controller may need to keep the PHY on to support remote wakeup. Allow specifying this as a device tree property.
--- Documentation/devicetree/bindings/usb/dwc2.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/dwc2.txt +4 -0
@@ -17,6 +17,9 @@ Refer to clk/clock-bindings.txt for generic clock consumer properties Optional properties: - phys: phy provider specifier - phy-names: shall be "usb2-phy" +- snps,need-phy-for-wake: if present indicates that the phy needs to be left + on for remote wakeup during suspend. + Refer to phy/phy-bindings.txt for generic phy consumer properties - dr_mode: shall be one of "host", "peripheral" and "otg" Refer to usb/generic.txt
@@ -35,4 +38,5 @@ Example: clock-names = "otg"; phys = <&usbphy>; phy-names = "usb2-phy"; + snps,need-phy-for-wake; };
Signature · 4 lines
2.4.3.573.g4eafbef -- To unsubscribe from this list: send the line "unsubscribe devicetree" in
Re: [PATCH 2/3] Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
Quoted 3 lines · Douglas Anderson
Some SoCs with a dwc2 USB controller may need to keep the PHY on to support remote wakeup. Allow specifying this as a device tree property.
I find it hard to believe that any host can support wake-up without the PHY. Does this really need to be conditional? Perhaps other cases are just always-on or remote wake-up has not been tested.
Assuming the PHY was provided with the knowledge that remote wakeup is enabled, it would be able to figure out within its driver how to support that. Unfortunately the generic PHY framework is a completely lacking in its ability to support protocol specific features like this or other USB PHY features like Vbus detect or charger detection.
Rob
Quoted 29 lines
Signed-off-by Douglas Anderson <[email protected]>--- Documentation/devicetree/bindings/usb/dwc2.txt | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/usb/dwc2.txt +4
-1@@ -17,6 +17,9 @@ Refer to clk/clock-bindings.txt for generic clock consumer properties Optional properties: - phys: phy provider specifier - phy-names: shall be "usb2-phy" +- snps,need-phy-for-wake: if present indicates that the phy needs to be left + on for remote wakeup during suspend. + Refer to phy/phy-bindings.txt for generic phy consumer properties - dr_mode: shall be one of "host", "peripheral" and "otg" Refer to usb/generic.txt@@ -35,4 +38,5 @@ Example: clock-names = "otg"; phys = <&usbphy>; phy-names = "usb2-phy"; + snps,need-phy-for-wake; }; --2.4.3.573.g4eafbef
Re: [PATCH 2/3] Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
Rob,
Quoted 7 lines · Rob Herring
Quoted 3 lines · Douglas Anderson
Some SoCs with a dwc2 USB controller may need to keep the PHY on to support remote wakeup. Allow specifying this as a device tree property.
I find it hard to believe that any host can support wake-up without the PHY.
I am told by Andrew Bresticker that on tegra there is complicated logic in the PMU that allows USB wakeup while powering off the PHY. If I hadn't been aware of such a feature I probably would have called the property "wakeup-supported" or something like that.
Quoted 2 lines
Does this really need to be conditional? Perhaps other cases are just always-on or remote wake-up has not been tested.
When I worked on exynos products I was told by Samsung that USB wakeup was simply not possible. True that they have a different USB controller, but I can certainly believe that someone could design a system with dwc2 where USB wakeup was not possible.
Specifically, in order to get USB wakeup we had to switch on the 24MHz clock at suspend time. Had that not been possible (or had the 24MHz clock not been able to be a clock source for the USB controller) then USB wakeup would not be possible on rk3288 even if we left the phy on.
So to me the three states are:
1. USB wake not possible
2. USB wake possible, don't need PHY
3. USB wake possible, do need PHY
I don't know of any dwc2 users that are in #2 (so I didn't add a property now), but I figure that when they exist someone should add a property then.
-Doug
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 USB: dwc2: Don't turn off the usbphy in suspend if wakeup is enabled
In reply to Douglas AndersonIf the 'snps,need-phy-for-wake' is set in the device tree then:
- We know that we can wakeup, so call device_set_wakeup_capable(). The USB core will use this knowledge to enable wakeup by default.
- We know that we should keep the PHY on during suspend if something on our root hub needs remote wakeup. This requires the patch (USB:
Export usb_wakeup_enabled_descendants()). Note that we don't keep the PHY on at suspend time if it's not needed because it would be a power draw.
If we later find some users of dwc2 that can support wakeup without keeping the PHY on we may want to add a way to call device_set_wakeup_capable() without keeping the PHY on at suspend time.
--- drivers/usb/dwc2/core.h | 2 ++ drivers/usb/dwc2/platform.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-)
drivers/usb/dwc2/core.h +2 -0
@@ -687,6 +687,8 @@ struct dwc2_hsotg {enum usb_dr_mode dr_mode; unsigned int hcd_enabled:1; unsigned int gadget_enabled:1; + unsigned int need_phy_for_wake:1; + unsigned int phy_off_for_suspend:1;struct phy *phy;struct usb_phy *uphy;
drivers/usb/dwc2/platform.c +42 -1
80 lines not on this page · raw message
Quoted 9 lines · Douglas Anderson
This series of patches, together with
<https://patchwork.kernel.org/patch/6652341/> from Chris Zhong and a dts change allow us to wake up from a USB device on rk3288 boards. The patches were tested on rk3288-jerry in the chromeos-3.14 kernel. The chromeos-3.14 kernel tested included a full set of dwc2 backports from upstream, so this is expected to function upstream once we get everything setup there.
Quoted 3 lines
Douglas Anderson (3):
USB: Exportusb_wakeup_enabled_descendants()
Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
I didn't get 2/3 :-(
Signature · 1 line
balbi
_______________________________________________
Linux-rockchip mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Felipe,
Quoted 10 lines · Felipe Balbi
Quoted 9 lines · Douglas Anderson
This series of patches, together with
<https://patchwork.kernel.org/patch/6652341/> from Chris Zhong and a dts change allow us to wake up from a USB device on rk3288 boards. The patches were tested on rk3288-jerry in the chromeos-3.14 kernel. The chromeos-3.14 kernel tested included a full set of dwc2 backports from upstream, so this is expected to function upstream once we get everything setup there.
Quoted 5 lines
Quoted 3 lines
Douglas Anderson (3):
USB: Exportusb_wakeup_enabled_descendants()
Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USBI didn't get 2/3 :-(
Odd. I'm happy to repost the series, but you were certainly on the "To" for the whole series. You can see the Headers at
<https://patchwork.kernel.org/patch/6658421/>
...please let me know if you'd like me to repost and we can hope the email system works better next time...
-Doug
Quoted 17 lines · Doug Anderson
Felipe,
Quoted 14 lines · Felipe Balbi
Quoted 12 lines · Douglas Anderson
This series of patches, together with
<https://patchwork.kernel.org/patch/6652341/> from Chris Zhong and a dts change allow us to wake up from a USB device on rk3288 boards. The patches were tested on rk3288-jerry in the chromeos-3.14 kernel. The chromeos-3.14 kernel tested included a full set of dwc2 backports from upstream, so this is expected to function upstream once we get everything setup there.Douglas Anderson (3):
USB: Exportusb_wakeup_enabled_descendants()
Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB
Quoted 8 lines
Quoted 1 line
I didn't get 2/3 :-(
Odd. I'm happy to repost the series, but you were certainly on the "To" for the whole series. You can see the Headers at
<https://patchwork.kernel.org/patch/6658421/>...please let me know if you'd like me to repost and we can hope the email system works better next time...
If you can, that would help me. Just make sure to Cc linux-usb on all patches, since that's where I tend to get my patches from.
Thanks and sorry for the extra step resending this.
ps: dropping Paul Z as he's not in SNPS anymore
Signature · 1 line
balbi
_______________________________________________
Linux-rockchip mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip