diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-10-11 00:58:19 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-10-13 13:40:00 -0400 |
commit | ca8a282a5373f96d0ea002d97a168211448e8526 (patch) | |
tree | 1e5d8b1e4d8352d5e26a2c801dfeae7206506209 /drivers | |
parent | 4bb99b7c82bac1488a0228d2363db1f68d90f6f3 (diff) |
usb: gadget: renesas_usbhs: add suspend/resume support
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/renesas_usbhs/common.c | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index d8239e5efa66..319ed47153d7 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -203,13 +203,10 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) | |||
203 | } | 203 | } |
204 | 204 | ||
205 | /* | 205 | /* |
206 | * notify hotplug | 206 | * hotplug |
207 | */ | 207 | */ |
208 | static void usbhsc_notify_hotplug(struct work_struct *work) | 208 | static void usbhsc_hotplug(struct usbhs_priv *priv) |
209 | { | 209 | { |
210 | struct usbhs_priv *priv = container_of(work, | ||
211 | struct usbhs_priv, | ||
212 | notify_hotplug_work.work); | ||
213 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); | 210 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); |
214 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); | 211 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); |
215 | int id; | 212 | int id; |
@@ -257,6 +254,17 @@ static void usbhsc_notify_hotplug(struct work_struct *work) | |||
257 | } | 254 | } |
258 | } | 255 | } |
259 | 256 | ||
257 | /* | ||
258 | * notify hotplug | ||
259 | */ | ||
260 | static void usbhsc_notify_hotplug(struct work_struct *work) | ||
261 | { | ||
262 | struct usbhs_priv *priv = container_of(work, | ||
263 | struct usbhs_priv, | ||
264 | notify_hotplug_work.work); | ||
265 | usbhsc_hotplug(priv); | ||
266 | } | ||
267 | |||
260 | int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) | 268 | int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) |
261 | { | 269 | { |
262 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); | 270 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); |
@@ -443,9 +451,60 @@ static int __devexit usbhs_remove(struct platform_device *pdev) | |||
443 | return 0; | 451 | return 0; |
444 | } | 452 | } |
445 | 453 | ||
454 | static int usbhsc_suspend(struct device *dev) | ||
455 | { | ||
456 | struct usbhs_priv *priv = dev_get_drvdata(dev); | ||
457 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); | ||
458 | |||
459 | if (mod) { | ||
460 | usbhs_mod_call(priv, stop, priv); | ||
461 | usbhs_mod_change(priv, -1); | ||
462 | } | ||
463 | |||
464 | if (mod || !usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) | ||
465 | usbhsc_power_ctrl(priv, 0); | ||
466 | |||
467 | return 0; | ||
468 | } | ||
469 | |||
470 | static int usbhsc_resume(struct device *dev) | ||
471 | { | ||
472 | struct usbhs_priv *priv = dev_get_drvdata(dev); | ||
473 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); | ||
474 | |||
475 | usbhs_platform_call(priv, phy_reset, pdev); | ||
476 | |||
477 | if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) | ||
478 | usbhsc_power_ctrl(priv, 1); | ||
479 | |||
480 | usbhsc_hotplug(priv); | ||
481 | |||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | static int usbhsc_runtime_nop(struct device *dev) | ||
486 | { | ||
487 | /* Runtime PM callback shared between ->runtime_suspend() | ||
488 | * and ->runtime_resume(). Simply returns success. | ||
489 | * | ||
490 | * This driver re-initializes all registers after | ||
491 | * pm_runtime_get_sync() anyway so there is no need | ||
492 | * to save and restore registers here. | ||
493 | */ | ||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | static const struct dev_pm_ops usbhsc_pm_ops = { | ||
498 | .suspend = usbhsc_suspend, | ||
499 | .resume = usbhsc_resume, | ||
500 | .runtime_suspend = usbhsc_runtime_nop, | ||
501 | .runtime_resume = usbhsc_runtime_nop, | ||
502 | }; | ||
503 | |||
446 | static struct platform_driver renesas_usbhs_driver = { | 504 | static struct platform_driver renesas_usbhs_driver = { |
447 | .driver = { | 505 | .driver = { |
448 | .name = "renesas_usbhs", | 506 | .name = "renesas_usbhs", |
507 | .pm = &usbhsc_pm_ops, | ||
449 | }, | 508 | }, |
450 | .probe = usbhs_probe, | 509 | .probe = usbhs_probe, |
451 | .remove = __devexit_p(usbhs_remove), | 510 | .remove = __devexit_p(usbhs_remove), |