1 From 04216bedafb1b3992a6c2b7f1518281d2ba5fc7b Mon Sep 17 00:00:00 2001
2 From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
3 Date: Mon, 6 Aug 2012 18:08:39 -0700
4 Subject: [PATCH] usb: host: ehci-platform: add platform specific power callback
6 Commit 04216bedafb1b3992a6c2b7f1518281d2ba5fc7b upstream.
8 This patch enables to call platform specific power callback function.
10 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
11 Acked-by: Alan Stern <stern@rowland.harvard.edu>
12 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 drivers/usb/host/ehci-platform.c | 40 +++++++++++++++++++++++++++++++++++---
15 include/linux/usb/ehci_pdriver.h | 8 ++++++++
16 2 files changed, 45 insertions(+), 3 deletions(-)
18 --- a/drivers/usb/host/ehci-platform.c
19 +++ b/drivers/usb/host/ehci-platform.c
20 @@ -105,10 +105,18 @@ static int __devinit ehci_platform_probe
24 + if (pdata->power_on) {
25 + err = pdata->power_on(dev);
30 hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev,
39 hcd->rsrc_start = res_mem->start;
40 hcd->rsrc_len = resource_size(res_mem);
41 @@ -136,12 +144,17 @@ err_release_region:
42 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
46 + if (pdata->power_off)
47 + pdata->power_off(dev);
52 static int __devexit ehci_platform_remove(struct platform_device *dev)
54 struct usb_hcd *hcd = platform_get_drvdata(dev);
55 + struct usb_ehci_pdata *pdata = dev->dev.platform_data;
59 @@ -149,6 +162,9 @@ static int __devexit ehci_platform_remov
61 platform_set_drvdata(dev, NULL);
63 + if (pdata->power_off)
64 + pdata->power_off(dev);
69 @@ -157,14 +173,32 @@ static int __devexit ehci_platform_remov
70 static int ehci_platform_suspend(struct device *dev)
72 struct usb_hcd *hcd = dev_get_drvdata(dev);
73 + struct usb_ehci_pdata *pdata = dev->platform_data;
74 + struct platform_device *pdev =
75 + container_of(dev, struct platform_device, dev);
76 bool do_wakeup = device_may_wakeup(dev);
79 + ret = ehci_suspend(hcd, do_wakeup);
81 - return ehci_suspend(hcd, do_wakeup);
82 + if (pdata->power_suspend)
83 + pdata->power_suspend(pdev);
88 static int ehci_platform_resume(struct device *dev)
90 struct usb_hcd *hcd = dev_get_drvdata(dev);
91 + struct usb_ehci_pdata *pdata = dev->platform_data;
92 + struct platform_device *pdev =
93 + container_of(dev, struct platform_device, dev);
95 + if (pdata->power_on) {
96 + int err = pdata->power_on(pdev);
101 ehci_resume(hcd, false);
103 --- a/include/linux/usb/ehci_pdriver.h
104 +++ b/include/linux/usb/ehci_pdriver.h
105 @@ -41,6 +41,14 @@ struct usb_ehci_pdata {
106 unsigned big_endian_mmio:1;
107 unsigned port_power_on:1;
108 unsigned port_power_off:1;
110 + /* Turn on all power and clocks */
111 + int (*power_on)(struct platform_device *pdev);
112 + /* Turn off all power and clocks */
113 + void (*power_off)(struct platform_device *pdev);
114 + /* Turn on only VBUS suspend power and hotplug detection,
115 + * turn off everything else */
116 + void (*power_suspend)(struct platform_device *pdev);
119 #endif /* __USB_CORE_EHCI_PDRIVER_H */