1 From e4d37aeb373a5edceecc1dadc76fabbe8bc18e44 Mon Sep 17 00:00:00 2001
2 From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
3 Date: Mon, 6 Aug 2012 18:09:10 -0700
4 Subject: [PATCH] usb: host: ohci-platform: add platform specific power callback
6 Commit e4d37aeb373a5edceecc1dadc76fabbe8bc18e44 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/ohci-platform.c | 36 ++++++++++++++++++++++++++++++++++--
15 include/linux/usb/ohci_pdriver.h | 8 ++++++++
16 2 files changed, 42 insertions(+), 2 deletions(-)
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
24 + if (pdata->power_on) {
25 + err = pdata->power_on(dev);
30 hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
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);
46 + if (pdata->power_off)
47 + pdata->power_off(dev);
52 static int __devexit ohci_platform_remove(struct platform_device *dev)
54 struct usb_hcd *hcd = platform_get_drvdata(dev);
55 + struct usb_ohci_pdata *pdata = dev->dev.platform_data;
59 @@ -151,6 +164,9 @@ static int __devexit ohci_platform_remov
61 platform_set_drvdata(dev, NULL);
63 + if (pdata->power_off)
64 + pdata->power_off(dev);
69 @@ -158,12 +174,28 @@ static int __devexit ohci_platform_remov
71 static int ohci_platform_suspend(struct device *dev)
73 + struct usb_ohci_pdata *pdata = dev->platform_data;
74 + struct platform_device *pdev =
75 + container_of(dev, struct platform_device, dev);
77 + if (pdata->power_suspend)
78 + pdata->power_suspend(pdev);
83 static int ohci_platform_resume(struct device *dev)
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);
90 + if (pdata->power_on) {
91 + int err = pdata->power_on(pdev);
96 ohci_finish_controller_resume(hcd);
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;
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);
114 #endif /* __USB_CORE_OHCI_PDRIVER_H */