All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car
@ 2017-03-17 10:02 Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 1/3] usb: host: xhci-plat: enable clk in resume timing Yoshihiro Shimoda
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-17 10:02 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch adds support suspend/resume for R-Car controllers.
The controllers need firmware downloading and the current code has
such process only when probe timing. After suspend the system and
the power of controller down, the driver needs to re-download the firmware
in resume timing. This patch adds such a process.
Also, since previous xhci-plat code didnn't handle the clk in suspend/resume,
this patch set has such process.

Yoshihiro Shimoda (3):
  usb: host: xhci-plat: enable clk in resume timing
  usb: host: xhci-plat: add resume_quirk()
  usb: host: xhci-plat: set resume_quirk() for R-Car controllers

 drivers/usb/host/xhci-plat.c | 29 ++++++++++++++++++++++++++++-
 drivers/usb/host/xhci-plat.h |  1 +
 drivers/usb/host/xhci-rcar.c | 11 +++++++++++
 drivers/usb/host/xhci-rcar.h |  6 ++++++
 4 files changed, 46 insertions(+), 1 deletion(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] usb: host: xhci-plat: enable clk in resume timing
  2017-03-17 10:02 [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
@ 2017-03-17 10:02 ` Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 2/3] usb: host: xhci-plat: add resume_quirk() Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-17 10:02 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch enables the clk in resume timing when device_may_wakeup()
is false. Otherwise, kernel panic happens when R-Car resumes the system
from Suspend-to-RAM because the clk is disabled.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/host/xhci-plat.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index bd02a6c..3528de3 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -306,6 +306,7 @@ static int xhci_plat_suspend(struct device *dev)
 {
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
+	int ret;
 
 	/*
 	 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
@@ -315,7 +316,12 @@ static int xhci_plat_suspend(struct device *dev)
 	 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
 	 * also applies to runtime suspend.
 	 */
-	return xhci_suspend(xhci, device_may_wakeup(dev));
+	ret = xhci_suspend(xhci, device_may_wakeup(dev));
+
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+		clk_disable_unprepare(xhci->clk);
+
+	return ret;
 }
 
 static int xhci_plat_resume(struct device *dev)
@@ -323,6 +329,9 @@ static int xhci_plat_resume(struct device *dev)
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+		clk_prepare_enable(xhci->clk);
+
 	return xhci_resume(xhci, 0);
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] usb: host: xhci-plat: add resume_quirk()
  2017-03-17 10:02 [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 1/3] usb: host: xhci-plat: enable clk in resume timing Yoshihiro Shimoda
@ 2017-03-17 10:02 ` Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers Yoshihiro Shimoda
  2017-04-12  0:46 ` [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
  3 siblings, 0 replies; 7+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-17 10:02 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch adds resume_quirk() to do platform specific process in
resume timing.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/host/xhci-plat.c | 15 +++++++++++++++
 drivers/usb/host/xhci-plat.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 3528de3..ceb7413 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -54,6 +54,16 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 	return priv->init_quirk(hcd);
 }
 
+static int xhci_priv_resume_quirk(struct usb_hcd *hcd)
+{
+	struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+
+	if (!priv->resume_quirk)
+		return 0;
+
+	return priv->resume_quirk(hcd);
+}
+
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
 	/*
@@ -328,10 +338,15 @@ static int xhci_plat_resume(struct device *dev)
 {
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
+	int ret;
 
 	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
 		clk_prepare_enable(xhci->clk);
 
+	ret = xhci_priv_resume_quirk(hcd);
+	if (ret)
+		return ret;
+
 	return xhci_resume(xhci, 0);
 }
 
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index 9af0cb4..29b2278 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -17,6 +17,7 @@ struct xhci_plat_priv {
 	const char *firmware_name;
 	void (*plat_start)(struct usb_hcd *);
 	int (*init_quirk)(struct usb_hcd *);
+	int (*resume_quirk)(struct usb_hcd *);
 };
 
 #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers
  2017-03-17 10:02 [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 1/3] usb: host: xhci-plat: enable clk in resume timing Yoshihiro Shimoda
  2017-03-17 10:02 ` [PATCH 2/3] usb: host: xhci-plat: add resume_quirk() Yoshihiro Shimoda
@ 2017-03-17 10:02 ` Yoshihiro Shimoda
  2017-04-18 10:28   ` Mathias Nyman
  2017-04-12  0:46 ` [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
  3 siblings, 1 reply; 7+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-17 10:02 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch sets resume_quirk() for R-Car controllers to re-download
the firmware in resume timing. Otherwise, if the controller's power
is down in suspend timing, the firmware in the controller goes away,
and then the controller doesn't work after resume.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/host/xhci-plat.c |  3 +++
 drivers/usb/host/xhci-rcar.c | 11 +++++++++++
 drivers/usb/host/xhci-rcar.h |  6 ++++++
 3 files changed, 20 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ceb7413..a285595 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -102,18 +102,21 @@ static int xhci_plat_start(struct usb_hcd *hcd)
 	.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
 	.init_quirk = xhci_rcar_init_quirk,
 	.plat_start = xhci_rcar_start,
+	.resume_quirk = xhci_rcar_resume_quirk,
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
 	.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2,
 	.init_quirk = xhci_rcar_init_quirk,
 	.plat_start = xhci_rcar_start,
+	.resume_quirk = xhci_rcar_resume_quirk,
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_r8a7796 = {
 	.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V3,
 	.init_quirk = xhci_rcar_init_quirk,
 	.plat_start = xhci_rcar_start,
+	.resume_quirk = xhci_rcar_resume_quirk,
 };
 
 static const struct of_device_id usb_xhci_of_match[] = {
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index d28df38..0727822 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -198,3 +198,14 @@ int xhci_rcar_init_quirk(struct usb_hcd *hcd)
 
 	return xhci_rcar_download_firmware(hcd);
 }
+
+int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
+{
+	int ret;
+
+	ret = xhci_rcar_download_firmware(hcd);
+	if (!ret)
+		xhci_rcar_start(hcd);
+
+	return ret;
+}
diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h
index d2ffe20..d247951 100644
--- a/drivers/usb/host/xhci-rcar.h
+++ b/drivers/usb/host/xhci-rcar.h
@@ -18,6 +18,7 @@
 #if IS_ENABLED(CONFIG_USB_XHCI_RCAR)
 void xhci_rcar_start(struct usb_hcd *hcd);
 int xhci_rcar_init_quirk(struct usb_hcd *hcd);
+int xhci_rcar_resume_quirk(struct usb_hcd *hcd);
 #else
 static inline void xhci_rcar_start(struct usb_hcd *hcd)
 {
@@ -27,5 +28,10 @@ static inline int xhci_rcar_init_quirk(struct usb_hcd *hcd)
 {
 	return 0;
 }
+
+static inline int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
+{
+	return 0;
+}
 #endif
 #endif /* _XHCI_RCAR_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car
  2017-03-17 10:02 [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2017-03-17 10:02 ` [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers Yoshihiro Shimoda
@ 2017-04-12  0:46 ` Yoshihiro Shimoda
  2017-04-13  8:15   ` Mathias Nyman
  3 siblings, 1 reply; 7+ messages in thread
From: Yoshihiro Shimoda @ 2017-04-12  0:46 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc

Hi Mathias,

> From: Yoshihiro Shimoda, Sent: Friday, March 17, 2017 7:03 PM
> 
> This patch adds support suspend/resume for R-Car controllers.
> The controllers need firmware downloading and the current code has
> such process only when probe timing. After suspend the system and
> the power of controller down, the driver needs to re-download the firmware
> in resume timing. This patch adds such a process.
> Also, since previous xhci-plat code didnn't handle the clk in suspend/resume,
> this patch set has such process.

I'm afraid but would you review this patch set?
This can be applied on the latest Greg's usb.git / usb-next branch at the moment.

Best regards,
Yoshihiro Shimoda

> Yoshihiro Shimoda (3):
>   usb: host: xhci-plat: enable clk in resume timing
>   usb: host: xhci-plat: add resume_quirk()
>   usb: host: xhci-plat: set resume_quirk() for R-Car controllers
> 
>  drivers/usb/host/xhci-plat.c | 29 ++++++++++++++++++++++++++++-
>  drivers/usb/host/xhci-plat.h |  1 +
>  drivers/usb/host/xhci-rcar.c | 11 +++++++++++
>  drivers/usb/host/xhci-rcar.h |  6 ++++++
>  4 files changed, 46 insertions(+), 1 deletion(-)
> 
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car
  2017-04-12  0:46 ` [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
@ 2017-04-13  8:15   ` Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2017-04-13  8:15 UTC (permalink / raw)
  To: Yoshihiro Shimoda, mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc

On 12.04.2017 03:46, Yoshihiro Shimoda wrote:
> Hi Mathias,
>
>> From: Yoshihiro Shimoda, Sent: Friday, March 17, 2017 7:03 PM
>>
>> This patch adds support suspend/resume for R-Car controllers.
>> The controllers need firmware downloading and the current code has
>> such process only when probe timing. After suspend the system and
>> the power of controller down, the driver needs to re-download the firmware
>> in resume timing. This patch adds such a process.
>> Also, since previous xhci-plat code didnn't handle the clk in suspend/resume,
>> this patch set has such process.
>
> I'm afraid but would you review this patch set?
> This can be applied on the latest Greg's usb.git / usb-next branch at the moment.
>

Sorry about the delay, I'll start looking at these.

-Mathias

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers
  2017-03-17 10:02 ` [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers Yoshihiro Shimoda
@ 2017-04-18 10:28   ` Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2017-04-18 10:28 UTC (permalink / raw)
  To: Yoshihiro Shimoda, mathias.nyman, gregkh; +Cc: linux-usb, linux-renesas-soc

On 17.03.2017 12:02, Yoshihiro Shimoda wrote:
> This patch sets resume_quirk() for R-Car controllers to re-download
> the firmware in resume timing. Otherwise, if the controller's power
> is down in suspend timing, the firmware in the controller goes away,
> and then the controller doesn't work after resume.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---

Added to queue for usb next

-Mathias

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-04-18 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 10:02 [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
2017-03-17 10:02 ` [PATCH 1/3] usb: host: xhci-plat: enable clk in resume timing Yoshihiro Shimoda
2017-03-17 10:02 ` [PATCH 2/3] usb: host: xhci-plat: add resume_quirk() Yoshihiro Shimoda
2017-03-17 10:02 ` [PATCH 3/3] usb: host: xhci-plat: set resume_quirk() for R-Car controllers Yoshihiro Shimoda
2017-04-18 10:28   ` Mathias Nyman
2017-04-12  0:46 ` [PATCH 0/3] usb: host: xhci-plat: add support suspend/resume for R-Car Yoshihiro Shimoda
2017-04-13  8:15   ` Mathias Nyman

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.