aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 06:13:09 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:31 -0500
commitfcd22e3b1f12e026dfefca20c97ff550a0e11b2b (patch)
treebbc97f1164cea1d37b110474c525c52b27ea5770 /drivers/usb
parent6f783e287c074afe1e9cf3f32ded9948e184b45e (diff)
usb: musb: blackfin: usb dev_pm_ops structure
instead of using musb_platform_suspend_resume, we can use dev_pm_ops and let platform_device core handle when to call musb_core's suspend and glue layer's suspend. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/musb/blackfin.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 8c9c5fc3a6ca..df0e906b1850 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -27,6 +27,7 @@ struct bfin_glue {
27 struct device *dev; 27 struct device *dev;
28 struct platform_device *musb; 28 struct platform_device *musb;
29}; 29};
30#define glue_to_musb(g) platform_get_drvdata(g->musb)
30 31
31/* 32/*
32 * Load an endpoint's FIFO 33 * Load an endpoint's FIFO
@@ -406,27 +407,6 @@ static int bfin_musb_init(struct musb *musb)
406 return 0; 407 return 0;
407} 408}
408 409
409static int bfin_musb_suspend(struct musb *musb)
410{
411 if (is_host_active(musb))
412 /*
413 * During hibernate gpio_vrsel will change from high to low
414 * low which will generate wakeup event resume the system
415 * immediately. Set it to 0 before hibernate to avoid this
416 * wakeup event.
417 */
418 gpio_set_value(musb->config->gpio_vrsel, 0);
419
420 return 0;
421}
422
423static int bfin_musb_resume(struct musb *musb)
424{
425 bfin_musb_reg_init(musb);
426
427 return 0;
428}
429
430static int bfin_musb_exit(struct musb *musb) 410static int bfin_musb_exit(struct musb *musb)
431{ 411{
432 gpio_free(musb->config->gpio_vrsel); 412 gpio_free(musb->config->gpio_vrsel);
@@ -446,9 +426,6 @@ static const struct musb_platform_ops bfin_ops = {
446 .set_mode = bfin_musb_set_mode, 426 .set_mode = bfin_musb_set_mode,
447 .try_idle = bfin_musb_try_idle, 427 .try_idle = bfin_musb_try_idle,
448 428
449 .suspend = bfin_musb_suspend,
450 .resume = bfin_musb_resume,
451
452 .vbus_status = bfin_musb_vbus_status, 429 .vbus_status = bfin_musb_vbus_status,
453 .set_vbus = bfin_musb_set_vbus, 430 .set_vbus = bfin_musb_set_vbus,
454}; 431};
@@ -528,10 +505,49 @@ static int __exit bfin_remove(struct platform_device *pdev)
528 return 0; 505 return 0;
529} 506}
530 507
508#ifdef CONFIG_PM
509static int bfin_suspend(struct device *dev)
510{
511 struct bfin_glue *glue = dev_get_drvdata(dev);
512 struct musb *musb = glue_to_musb(glue);
513
514 if (is_host_active(musb))
515 /*
516 * During hibernate gpio_vrsel will change from high to low
517 * low which will generate wakeup event resume the system
518 * immediately. Set it to 0 before hibernate to avoid this
519 * wakeup event.
520 */
521 gpio_set_value(musb->config->gpio_vrsel, 0);
522
523 return 0;
524}
525
526static int bfin_resume(struct device *dev)
527{
528 struct bfin_glue *glue = dev_get_drvdata(dev);
529 struct musb *musb = glue_to_musb(glue);
530
531 bfin_musb_reg_init(musb);
532
533 return 0;
534}
535
536static struct dev_pm_ops bfin_pm_ops = {
537 .suspend = bfin_suspend,
538 .resume = bfin_resume,
539};
540
541#define DEV_PM_OPS &bfin_pm_op,
542#else
543#define DEV_PM_OPS NULL
544#endif
545
531static struct platform_driver bfin_driver = { 546static struct platform_driver bfin_driver = {
532 .remove = __exit_p(bfin_remove), 547 .remove = __exit_p(bfin_remove),
533 .driver = { 548 .driver = {
534 .name = "musb-bfin", 549 .name = "musb-bfin",
550 .pm = DEV_PM_OPS,
535 }, 551 },
536}; 552};
537 553