Root/target/linux/generic/patches-3.6/004-usb-host-ohci-platform-add-platform-specific-power-c.patch

1From e4d37aeb373a5edceecc1dadc76fabbe8bc18e44 Mon Sep 17 00:00:00 2001
2From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
3Date: Mon, 6 Aug 2012 18:09:10 -0700
4Subject: [PATCH] usb: host: ohci-platform: add platform specific power callback
5
6Commit e4d37aeb373a5edceecc1dadc76fabbe8bc18e44 upstream.
7
8This patch enables to call platform specific power callback function.
9
10Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
11Acked-by: Alan Stern <stern@rowland.harvard.edu>
12Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13---
14 drivers/usb/host/ohci-platform.c | 36 ++++++++++++++++++++++++++++++++++--
15 include/linux/usb/ohci_pdriver.h | 8 ++++++++
16 2 files changed, 42 insertions(+), 2 deletions(-)
17
18--- a/drivers/usb/host/ohci-platform.c
19+++ b/drivers/usb/host/ohci-platform.c
20@@ -107,10 +107,18 @@ static int __devinit ohci_platform_probe
21         return -ENXIO;
22     }
23 
24+ if (pdata->power_on) {
25+ err = pdata->power_on(dev);
26+ if (err < 0)
27+ return err;
28+ }
29+
30     hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
31             dev_name(&dev->dev));
32- if (!hcd)
33- return -ENOMEM;
34+ if (!hcd) {
35+ err = -ENOMEM;
36+ goto err_power;
37+ }
38 
39     hcd->rsrc_start = res_mem->start;
40     hcd->rsrc_len = resource_size(res_mem);
41@@ -138,12 +146,17 @@ err_release_region:
42     release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
43 err_put_hcd:
44     usb_put_hcd(hcd);
45+err_power:
46+ if (pdata->power_off)
47+ pdata->power_off(dev);
48+
49     return err;
50 }
51 
52 static int __devexit ohci_platform_remove(struct platform_device *dev)
53 {
54     struct usb_hcd *hcd = platform_get_drvdata(dev);
55+ struct usb_ohci_pdata *pdata = dev->dev.platform_data;
56 
57     usb_remove_hcd(hcd);
58     iounmap(hcd->regs);
59@@ -151,6 +164,9 @@ static int __devexit ohci_platform_remov
60     usb_put_hcd(hcd);
61     platform_set_drvdata(dev, NULL);
62 
63+ if (pdata->power_off)
64+ pdata->power_off(dev);
65+
66     return 0;
67 }
68 
69@@ -158,12 +174,28 @@ static int __devexit ohci_platform_remov
70 
71 static int ohci_platform_suspend(struct device *dev)
72 {
73+ struct usb_ohci_pdata *pdata = dev->platform_data;
74+ struct platform_device *pdev =
75+ container_of(dev, struct platform_device, dev);
76+
77+ if (pdata->power_suspend)
78+ pdata->power_suspend(pdev);
79+
80     return 0;
81 }
82 
83 static int ohci_platform_resume(struct device *dev)
84 {
85     struct usb_hcd *hcd = dev_get_drvdata(dev);
86+ struct usb_ohci_pdata *pdata = dev->platform_data;
87+ struct platform_device *pdev =
88+ container_of(dev, struct platform_device, dev);
89+
90+ if (pdata->power_on) {
91+ int err = pdata->power_on(pdev);
92+ if (err < 0)
93+ return err;
94+ }
95 
96     ohci_finish_controller_resume(hcd);
97     return 0;
98--- a/include/linux/usb/ohci_pdriver.h
99+++ b/include/linux/usb/ohci_pdriver.h
100@@ -33,6 +33,14 @@ struct usb_ohci_pdata {
101     unsigned big_endian_desc:1;
102     unsigned big_endian_mmio:1;
103     unsigned no_big_frame_no:1;
104+
105+ /* Turn on all power and clocks */
106+ int (*power_on)(struct platform_device *pdev);
107+ /* Turn off all power and clocks */
108+ void (*power_off)(struct platform_device *pdev);
109+ /* Turn on only VBUS suspend power and hotplug detection,
110+ * turn off everything else */
111+ void (*power_suspend)(struct platform_device *pdev);
112 };
113 
114 #endif /* __USB_CORE_OHCI_PDRIVER_H */
115

Archive Download this file



interactive