* [PATCH/RFC 0/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume
@ 2017-02-20 7:35 Yoshihiro Shimoda
2017-02-20 7:35 ` [PATCH/RFC 1/2] usb: of: add functions to bind a companion controller Yoshihiro Shimoda
2017-02-20 7:35 ` [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda
0 siblings, 2 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2017-02-20 7:35 UTC (permalink / raw)
To: stern, gregkh, robh+dt, mark.rutland
Cc: linux-usb, devicetree, linux-renesas-soc, Yoshihiro Shimoda
This patch set is based on Greg's usb.git / usb-next branch
(the commit id = 0df8a3dbacb585bb9c8b2e55de43c6aac9d86488).
This patch set is related to the following email threads:
http://marc.info/?t=148653514200001&r=1&w=2
http://marc.info/?t=148712534300005&r=1&w=2
Since I'm not sure the helper functions can be in core/of.c,
I sent the patch set as RFC. I guess if these functions are not needed
to other codes, the functions should be into ehci-platform.c.
Yoshihiro Shimoda (2):
usb: of: add functions to bind a companion controller
usb: host: ehci-platform: fix usb 1.1 device is not connected in
system resume
Documentation/devicetree/bindings/usb/generic.txt | 1 +
drivers/usb/core/of.c | 36 +++++++++++++++++++++++
drivers/usb/host/ehci-platform.c | 8 +++++
include/linux/usb/of.h | 10 +++++++
4 files changed, 55 insertions(+)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH/RFC 1/2] usb: of: add functions to bind a companion controller 2017-02-20 7:35 [PATCH/RFC 0/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda @ 2017-02-20 7:35 ` Yoshihiro Shimoda 2017-02-20 7:35 ` [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda 1 sibling, 0 replies; 5+ messages in thread From: Yoshihiro Shimoda @ 2017-02-20 7:35 UTC (permalink / raw) To: stern, gregkh, robh+dt, mark.rutland Cc: linux-usb, devicetree, linux-renesas-soc, Yoshihiro Shimoda EHCI controllers will have a companion controller. However, on platform bus, there was difficult to bind them in previous code. So, this patch adds helper functions to bind them using a "companion" property. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- Documentation/devicetree/bindings/usb/generic.txt | 1 + drivers/usb/core/of.c | 36 +++++++++++++++++++++++ include/linux/usb/of.h | 10 +++++++ 3 files changed, 47 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index bfadeb1..0a74ab8 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -22,6 +22,7 @@ Optional properties: property is used if any real OTG features(HNP/SRP/ADP) is enabled, if ADP is required, otg-rev should be 0x0200 or above. + - companion: phandle of a companion - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP is the basic function of real OTG except you want it to be a srp-capable only B device. diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c index 3de4f88..033530b 100644 --- a/drivers/usb/core/of.c +++ b/drivers/usb/core/of.c @@ -18,6 +18,7 @@ */ #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/usb/of.h> /** @@ -46,3 +47,38 @@ struct device_node *usb_of_get_child_node(struct device_node *parent, } EXPORT_SYMBOL_GPL(usb_of_get_child_node); +/** + * usb_of_has_companion - To get if the device has a companion device + * @dev: the device pointer to get if it has a companion + * + * This function gets if the device has a companion property. + * + */ +bool usb_of_has_companion(struct device *dev) +{ + return !!of_find_property(dev->of_node, "companion", NULL); +} +EXPORT_SYMBOL_GPL(usb_of_has_companion); + +/** + * usb_of_get_companion_dev - Find the companion device + * @dev: the device pointer to find a companion + * + * Find the companion device from platform bus. + * + * Return: On success, a pointer to the companion device, %NULL on failure. + */ +struct device *usb_of_get_companion_dev(struct device *dev) +{ + struct device_node *node; + struct platform_device *pdev = NULL; + + node = of_parse_phandle(dev->of_node, "companion", 0); + if (node) + pdev = of_find_device_by_node(node); + + of_node_put(node); + + return pdev ? &pdev->dev : NULL; +} +EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index 5ff9032..a5c7885 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -18,6 +18,8 @@ int of_usb_update_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps); struct device_node *usb_of_get_child_node(struct device_node *parent, int portnum); +bool usb_of_has_companion(struct device *dev); +struct device *usb_of_get_companion_dev(struct device *dev); #else static inline enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0) @@ -38,6 +40,14 @@ static inline int of_usb_update_otg_caps(struct device_node *np, { return NULL; } +static inline bool usb_of_has_companion(struct device *dev) +{ + return false; +} +static inline struct device *usb_of_get_companion_dev(struct device *dev) +{ + return NULL; +} #endif #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume 2017-02-20 7:35 [PATCH/RFC 0/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda 2017-02-20 7:35 ` [PATCH/RFC 1/2] usb: of: add functions to bind a companion controller Yoshihiro Shimoda @ 2017-02-20 7:35 ` Yoshihiro Shimoda [not found] ` <1487576111-29287-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 1 sibling, 1 reply; 5+ messages in thread From: Yoshihiro Shimoda @ 2017-02-20 7:35 UTC (permalink / raw) To: stern, gregkh, robh+dt, mark.rutland Cc: linux-usb, devicetree, linux-renesas-soc, Yoshihiro Shimoda This patch fixes an issue that a usb 1.1 device is not connected in system resume and then the following message appeared if debug messages are enabled: usb 2-1: Waited 2000ms for CONNECT To resolve this issue, the EHCI controller must be resumed after its companion controllers. So, this patch adds such code on the driver. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/usb/host/ehci-platform.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index a268d9e..65a7725 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -34,6 +34,7 @@ #include <linux/usb.h> #include <linux/usb/hcd.h> #include <linux/usb/ehci_pdriver.h> +#include <linux/usb/of.h> #include "ehci.h" @@ -297,6 +298,8 @@ static int ehci_platform_probe(struct platform_device *dev) goto err_power; device_wakeup_enable(hcd->self.controller); + if (usb_of_has_companion(hcd->self.controller)) + device_enable_async_suspend(hcd->self.controller); platform_set_drvdata(dev, hcd); return err; @@ -370,6 +373,7 @@ static int ehci_platform_resume(struct device *dev) struct usb_ehci_pdata *pdata = dev_get_platdata(dev); struct platform_device *pdev = to_platform_device(dev); struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); + struct device *companion_dev; if (pdata->power_on) { int err = pdata->power_on(pdev); @@ -377,6 +381,10 @@ static int ehci_platform_resume(struct device *dev) return err; } + companion_dev = usb_of_get_companion_dev(hcd->self.controller); + if (companion_dev) + device_pm_wait_for_dev(hcd->self.controller, companion_dev); + ehci_resume(hcd, priv->reset_on_resume); return 0; } -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1487576111-29287-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume [not found] ` <1487576111-29287-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> @ 2017-02-21 8:51 ` Peter Chen 2017-02-21 10:18 ` Yoshihiro Shimoda 0 siblings, 1 reply; 5+ messages in thread From: Peter Chen @ 2017-02-21 8:51 UTC (permalink / raw) To: Yoshihiro Shimoda Cc: stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, linux-usb-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA On Mon, Feb 20, 2017 at 04:35:11PM +0900, Yoshihiro Shimoda wrote: > This patch fixes an issue that a usb 1.1 device is not connected in > system resume and then the following message appeared if debug messages > are enabled: > usb 2-1: Waited 2000ms for CONNECT > > To resolve this issue, the EHCI controller must be resumed after its > companion controllers. So, this patch adds such code on the driver. > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> > --- > drivers/usb/host/ehci-platform.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c > index a268d9e..65a7725 100644 > --- a/drivers/usb/host/ehci-platform.c > +++ b/drivers/usb/host/ehci-platform.c > @@ -34,6 +34,7 @@ > #include <linux/usb.h> > #include <linux/usb/hcd.h> > #include <linux/usb/ehci_pdriver.h> > +#include <linux/usb/of.h> > > #include "ehci.h" > > @@ -297,6 +298,8 @@ static int ehci_platform_probe(struct platform_device *dev) > goto err_power; > > device_wakeup_enable(hcd->self.controller); > + if (usb_of_has_companion(hcd->self.controller)) According to Alan's comments, all USB ehci platform device can be async device, so this API can be skipped. > + device_enable_async_suspend(hcd->self.controller); > platform_set_drvdata(dev, hcd); > > return err; > @@ -370,6 +373,7 @@ static int ehci_platform_resume(struct device *dev) > struct usb_ehci_pdata *pdata = dev_get_platdata(dev); > struct platform_device *pdev = to_platform_device(dev); > struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); > + struct device *companion_dev; > > if (pdata->power_on) { > int err = pdata->power_on(pdev); > @@ -377,6 +381,10 @@ static int ehci_platform_resume(struct device *dev) > return err; > } > > + companion_dev = usb_of_get_companion_dev(hcd->self.controller); Maybe other EHCI controller has companion controller too, so it is ok for you to let it as a common API. > + if (companion_dev) > + device_pm_wait_for_dev(hcd->self.controller, companion_dev); > + > ehci_resume(hcd, priv->reset_on_resume); > return 0; > } You can send formal patch next time. -- Best Regards, Peter Chen -- 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] 5+ messages in thread
* RE: [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume 2017-02-21 8:51 ` Peter Chen @ 2017-02-21 10:18 ` Yoshihiro Shimoda 0 siblings, 0 replies; 5+ messages in thread From: Yoshihiro Shimoda @ 2017-02-21 10:18 UTC (permalink / raw) To: Peter Chen Cc: stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, mark.rutland-5wv7dgnIgG8@public.gmane.org, linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Hi Peter, > From: Peter Chen > Sent: Tuesday, February 21, 2017 5:51 PM > > On Mon, Feb 20, 2017 at 04:35:11PM +0900, Yoshihiro Shimoda wrote: < snip > > > @@ -297,6 +298,8 @@ static int ehci_platform_probe(struct platform_device *dev) > > goto err_power; > > > > device_wakeup_enable(hcd->self.controller); > > + if (usb_of_has_companion(hcd->self.controller)) > > According to Alan's comments, all USB ehci platform device can be async > device, so this API can be skipped. I got it. I will remove this API. > > + device_enable_async_suspend(hcd->self.controller); > > platform_set_drvdata(dev, hcd); > > > > return err; > > @@ -370,6 +373,7 @@ static int ehci_platform_resume(struct device *dev) > > struct usb_ehci_pdata *pdata = dev_get_platdata(dev); > > struct platform_device *pdev = to_platform_device(dev); > > struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); > > + struct device *companion_dev; > > > > if (pdata->power_on) { > > int err = pdata->power_on(pdev); > > @@ -377,6 +381,10 @@ static int ehci_platform_resume(struct device *dev) > > return err; > > } > > > > + companion_dev = usb_of_get_companion_dev(hcd->self.controller); > > Maybe other EHCI controller has companion controller too, so it is ok > for you to let it as a common API. I got it. > > + if (companion_dev) > > + device_pm_wait_for_dev(hcd->self.controller, companion_dev); > > + > > ehci_resume(hcd, priv->reset_on_resume); > > return 0; > > } > > You can send formal patch next time. Thank you for your review! I will send v2 patch set without RFC. Best regards, Yoshihiro Shimoda > -- > > Best Regards, > Peter Chen -- 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] 5+ messages in thread
end of thread, other threads:[~2017-02-21 10:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-20 7:35 [PATCH/RFC 0/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda
2017-02-20 7:35 ` [PATCH/RFC 1/2] usb: of: add functions to bind a companion controller Yoshihiro Shimoda
2017-02-20 7:35 ` [PATCH/RFC 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda
[not found] ` <1487576111-29287-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-02-21 8:51 ` Peter Chen
2017-02-21 10:18 ` Yoshihiro Shimoda
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).