aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/dwc2/platform.c')
-rw-r--r--drivers/usb/dwc2/platform.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 121dbdafc06b..6a795aa2ff05 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -40,6 +40,7 @@
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/of_device.h> 42#include <linux/of_device.h>
43#include <linux/mutex.h>
43#include <linux/platform_device.h> 44#include <linux/platform_device.h>
44 45
45#include <linux/usb/of.h> 46#include <linux/usb/of.h>
@@ -121,6 +122,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
121 struct dwc2_hsotg *hsotg = platform_get_drvdata(dev); 122 struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
122 123
123 dwc2_hcd_remove(hsotg); 124 dwc2_hcd_remove(hsotg);
125 s3c_hsotg_remove(hsotg);
124 126
125 return 0; 127 return 0;
126} 128}
@@ -129,6 +131,7 @@ static const struct of_device_id dwc2_of_match_table[] = {
129 { .compatible = "brcm,bcm2835-usb", .data = &params_bcm2835 }, 131 { .compatible = "brcm,bcm2835-usb", .data = &params_bcm2835 },
130 { .compatible = "rockchip,rk3066-usb", .data = &params_rk3066 }, 132 { .compatible = "rockchip,rk3066-usb", .data = &params_rk3066 },
131 { .compatible = "snps,dwc2", .data = NULL }, 133 { .compatible = "snps,dwc2", .data = NULL },
134 { .compatible = "samsung,s3c6400-hsotg", .data = NULL},
132 {}, 135 {},
133}; 136};
134MODULE_DEVICE_TABLE(of, dwc2_of_match_table); 137MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
@@ -155,9 +158,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
155 int retval; 158 int retval;
156 int irq; 159 int irq;
157 160
158 if (usb_disabled())
159 return -ENODEV;
160
161 match = of_match_device(dwc2_of_match_table, &dev->dev); 161 match = of_match_device(dwc2_of_match_table, &dev->dev);
162 if (match && match->data) { 162 if (match && match->data) {
163 params = match->data; 163 params = match->data;
@@ -194,6 +194,14 @@ static int dwc2_driver_probe(struct platform_device *dev)
194 return irq; 194 return irq;
195 } 195 }
196 196
197 dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
198 irq);
199 retval = devm_request_irq(hsotg->dev, irq,
200 dwc2_handle_common_intr, IRQF_SHARED,
201 dev_name(hsotg->dev), hsotg);
202 if (retval)
203 return retval;
204
197 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 205 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
198 hsotg->regs = devm_ioremap_resource(&dev->dev, res); 206 hsotg->regs = devm_ioremap_resource(&dev->dev, res);
199 if (IS_ERR(hsotg->regs)) 207 if (IS_ERR(hsotg->regs))
@@ -204,6 +212,11 @@ static int dwc2_driver_probe(struct platform_device *dev)
204 212
205 hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node); 213 hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node);
206 214
215 spin_lock_init(&hsotg->lock);
216 mutex_init(&hsotg->init_mutex);
217 retval = dwc2_gadget_init(hsotg, irq);
218 if (retval)
219 return retval;
207 retval = dwc2_hcd_init(hsotg, irq, params); 220 retval = dwc2_hcd_init(hsotg, irq, params);
208 if (retval) 221 if (retval)
209 return retval; 222 return retval;
@@ -213,10 +226,35 @@ static int dwc2_driver_probe(struct platform_device *dev)
213 return retval; 226 return retval;
214} 227}
215 228
229static int __maybe_unused dwc2_suspend(struct device *dev)
230{
231 struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
232 int ret = 0;
233
234 if (dwc2_is_device_mode(dwc2))
235 ret = s3c_hsotg_suspend(dwc2);
236 return ret;
237}
238
239static int __maybe_unused dwc2_resume(struct device *dev)
240{
241 struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
242 int ret = 0;
243
244 if (dwc2_is_device_mode(dwc2))
245 ret = s3c_hsotg_resume(dwc2);
246 return ret;
247}
248
249static const struct dev_pm_ops dwc2_dev_pm_ops = {
250 SET_SYSTEM_SLEEP_PM_OPS(dwc2_suspend, dwc2_resume)
251};
252
216static struct platform_driver dwc2_platform_driver = { 253static struct platform_driver dwc2_platform_driver = {
217 .driver = { 254 .driver = {
218 .name = dwc2_driver_name, 255 .name = dwc2_driver_name,
219 .of_match_table = dwc2_of_match_table, 256 .of_match_table = dwc2_of_match_table,
257 .pm = &dwc2_dev_pm_ops,
220 }, 258 },
221 .probe = dwc2_driver_probe, 259 .probe = dwc2_driver_probe,
222 .remove = dwc2_driver_remove, 260 .remove = dwc2_driver_remove,