Re: [PATCH] Adds power management support to the atmel ehci driver.

2014-04-16 Thread Michael Welling
On Wed, Apr 16, 2014 at 10:54:26AM -0400, Alan Stern wrote:
 On Tue, 15 Apr 2014, Michael Welling wrote:
 
  Allows the driver to turn off the clock during suspend for additional power 
  savings.
  
  Signed-off-by: Michael Welling mwell...@ieee.org
 
  @@ -181,6 +182,40 @@ static int ehci_atmel_drv_remove(struct 
  platform_device *pdev)
  return 0;
   }
   
  +#ifdef CONFIG_PM
  +static int
  +ehci_atmel_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
  +{
  +   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
  +
  +   if (device_may_wakeup(pdev-dev))
  +   enable_irq_wake(hcd-irq);
 
 This is peculiar.  Wny isn't the IRQ enabled all the time?  As I 
 understand it, the proper way to disable wakeups is to tell the 
 controller not to issue any wakeup signal at all.  Not to tell the 
 kernel that the IRQ shouldn't be used for wakeups.  That sort of 
 approach fails when shared IRQs are used.

I was just following the lead of the at91 ohci driver. I have cc'd
the author of the driver to see if he has an insight as to why the
wake is being turned on and off for the Atmel processors.

After a little feedback I will update the patch as necessary.

 
 Otherwise the patch looks okay.
 
 Alan Stern
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Adds power management support to the atmel ehci driver.

2014-04-15 Thread Michael Welling
Allows the driver to turn off the clock during suspend for additional power 
savings.

Signed-off-by: Michael Welling mwell...@ieee.org
---
 drivers/usb/host/ehci-atmel.c |   37 +
 1 file changed, 37 insertions(+)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index ec9f7b7..004858d 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -19,6 +19,7 @@
 #include linux/of.h
 #include linux/of_platform.h
 #include linux/platform_device.h
+#include linux/platform_data/atmel.h
 #include linux/usb.h
 #include linux/usb/hcd.h
 
@@ -181,6 +182,40 @@ static int ehci_atmel_drv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int
+ehci_atmel_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
+{
+   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+
+   if (device_may_wakeup(pdev-dev))
+   enable_irq_wake(hcd-irq);
+
+   if (at91_suspend_entering_slow_clock())
+   atmel_stop_clock();
+
+   ehci_suspend(hcd, (bool) device_may_wakeup(pdev-dev));
+   return 0;
+}
+
+static int ehci_atmel_drv_resume(struct platform_device *pdev)
+{
+   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+
+   if (device_may_wakeup(pdev-dev))
+   disable_irq_wake(hcd-irq);
+
+   if (!clocked)
+   atmel_start_clock();
+
+   ehci_resume(hcd, false);
+   return 0;
+}
+#else
+#define ehci_atmel_drv_suspend NULL
+#define ehci_atmel_drv_resume  NULL
+#endif
+
 #ifdef CONFIG_OF
 static const struct of_device_id atmel_ehci_dt_ids[] = {
{ .compatible = atmel,at91sam9g45-ehci },
@@ -193,6 +228,8 @@ MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
 static struct platform_driver ehci_atmel_driver = {
.probe  = ehci_atmel_drv_probe,
.remove = ehci_atmel_drv_remove,
+   .suspend= ehci_atmel_drv_suspend,
+   .resume = ehci_atmel_drv_resume,
.shutdown   = usb_hcd_platform_shutdown,
.driver = {
.name   = atmel-ehci,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html