From: Hao Wu <[email protected]>

This patch adds transceiver driver interface for runtime pm, in order to
support OTG case.

Signed-off-by: Hao Wu <[email protected]>
---
 drivers/usb/host/ehci-langwell-pci.c |   47 +++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-langwell-pci.c 
b/drivers/usb/host/ehci-langwell-pci.c
index ee2a56f..e08aa98 100644
--- a/drivers/usb/host/ehci-langwell-pci.c
+++ b/drivers/usb/host/ehci-langwell-pci.c
@@ -225,18 +225,61 @@ static int ehci_mid_stop_host(struct intel_mid_otg_xceiv 
*iotg)
        return 0;
 }
 
+#ifdef CONFIG_PM_RUNTIME
+static int ehci_mid_runtime_suspend_host(struct intel_mid_otg_xceiv *iotg)
+{
+       int             retval;
+
+       if (iotg == NULL)
+               return -EINVAL;
+
+       if (ehci_otg_driver.driver.pm == NULL)
+               return -EINVAL;
+
+       retval = ehci_otg_driver.driver.pm->runtime_suspend(iotg->otg.dev);
+       if (retval)
+               dev_warn(iotg->otg.dev, "runtime suspend failed\n");
+
+       return retval;
+}
+
+static int ehci_mid_runtime_resume_host(struct intel_mid_otg_xceiv *iotg)
+{
+       int             retval;
+
+       if (iotg == NULL)
+               return -EINVAL;
+
+       if (ehci_otg_driver.driver.pm == NULL)
+               return -EINVAL;
+
+       retval = ehci_otg_driver.driver.pm->runtime_resume(iotg->otg.dev);
+       if (retval)
+               dev_warn(iotg->otg.dev, "runtime suspend failed\n");
+
+       return retval;
+}
+#else
+
+#define ehci_mid_runtime_suspend_host NULL
+#define ehci_mid_runtime_resume_host NULL
+
+#endif
+
 static int intel_mid_ehci_driver_register(struct pci_driver *host_driver)
 {
        struct otg_transceiver          *otg;
        struct intel_mid_otg_xceiv      *iotg;
 
        otg = otg_get_transceiver();
-       if (otg == NULL)
+       if (otg == NULL || host_driver == NULL)
                return -EINVAL;
 
        iotg = otg_to_mid_xceiv(otg);
        iotg->start_host = ehci_mid_start_host;
        iotg->stop_host = ehci_mid_stop_host;
+       iotg->runtime_suspend_host = ehci_mid_runtime_suspend_host;
+       iotg->runtime_resume_host = ehci_mid_runtime_resume_host;
 
        /* notify host driver is registered */
        atomic_notifier_call_chain(&iotg->iotg_notifier,
@@ -259,6 +302,8 @@ static void intel_mid_ehci_driver_unregister(struct 
pci_driver *host_driver)
        iotg = otg_to_mid_xceiv(otg);
        iotg->start_host = NULL;
        iotg->stop_host = NULL;
+       iotg->runtime_suspend_host = NULL;
+       iotg->runtime_resume_host = NULL;
 
        /* notify host driver is unregistered */
        atomic_notifier_call_chain(&iotg->iotg_notifier,
-- 
1.6.0.6

Attachment: 0002-usb-ehci-langwell-pci-add-transceiver-driver-inter.patch
Description: 0002-usb-ehci-langwell-pci-add-transceiver-driver-inter.patch

_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to