kernel: bcma: update to wireless-testing master-2013-10-01
[openwrt.git] / target / linux / generic / patches-3.6 / 003-usb-host-ehci-platform-add-platform-specific-power-c.patch
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
5
6 Commit 04216bedafb1b3992a6c2b7f1518281d2ba5fc7b upstream.
7
8 This patch enables to call platform specific power callback function.
9
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>
13 ---
14  drivers/usb/host/ehci-platform.c |   40 +++++++++++++++++++++++++++++++++++---
15  include/linux/usb/ehci_pdriver.h |    8 ++++++++
16  2 files changed, 45 insertions(+), 3 deletions(-)
17
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
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(&ehci_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 @@ -136,12 +144,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 ehci_platform_remove(struct platform_device *dev)
53  {
54         struct usb_hcd *hcd = platform_get_drvdata(dev);
55 +       struct usb_ehci_pdata *pdata = dev->dev.platform_data;
56  
57         usb_remove_hcd(hcd);
58         iounmap(hcd->regs);
59 @@ -149,6 +162,9 @@ static int __devexit ehci_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 @@ -157,14 +173,32 @@ static int __devexit ehci_platform_remov
70  static int ehci_platform_suspend(struct device *dev)
71  {
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);
77 +       int ret;
78 +
79 +       ret = ehci_suspend(hcd, do_wakeup);
80  
81 -       return ehci_suspend(hcd, do_wakeup);
82 +       if (pdata->power_suspend)
83 +               pdata->power_suspend(pdev);
84 +
85 +       return ret;
86  }
87  
88  static int ehci_platform_resume(struct device *dev)
89  {
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);
94 +
95 +       if (pdata->power_on) {
96 +               int err = pdata->power_on(pdev);
97 +               if (err < 0)
98 +                       return err;
99 +       }
100  
101         ehci_resume(hcd, false);
102         return 0;
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;
109 +
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);
117  };
118  
119  #endif /* __USB_CORE_EHCI_PDRIVER_H */