aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/am35x.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 05:53:22 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:30 -0500
commit6f783e287c074afe1e9cf3f32ded9948e184b45e (patch)
tree01b0ba48afb04591e1131ad630866914c57d5b7e /drivers/usb/musb/am35x.c
parentc20aebb92796cf54ae8171ad7f53a8fa7c61d2d8 (diff)
usb: musb: am35x: 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/musb/am35x.c')
-rw-r--r--drivers/usb/musb/am35x.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index eacf1e09b495..fdc7c8878f8b 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -88,6 +88,7 @@ struct am35x_glue {
88 struct clk *phy_clk; 88 struct clk *phy_clk;
89 struct clk *clk; 89 struct clk *clk;
90}; 90};
91#define glue_to_musb(g) platform_get_drvdata(g->musb)
91 92
92static inline void phy_on(void) 93static inline void phy_on(void)
93{ 94{
@@ -462,20 +463,6 @@ static int am35x_musb_exit(struct musb *musb)
462 return 0; 463 return 0;
463} 464}
464 465
465static int am35x_musb_suspend(struct musb *musb)
466{
467 phy_off();
468
469 return 0;
470}
471
472static int am35x_musb_resume(struct musb *musb)
473{
474 phy_on();
475
476 return 0;
477}
478
479/* AM35x supports only 32bit read operation */ 466/* AM35x supports only 32bit read operation */
480void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) 467void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
481{ 468{
@@ -516,9 +503,6 @@ static const struct musb_platform_ops am35x_ops = {
516 .set_mode = am35x_musb_set_mode, 503 .set_mode = am35x_musb_set_mode,
517 .try_idle = am35x_musb_try_idle, 504 .try_idle = am35x_musb_try_idle,
518 505
519 .suspend = am35x_musb_suspend,
520 .resume = am35x_musb_resume,
521
522 .set_vbus = am35x_musb_set_vbus, 506 .set_vbus = am35x_musb_set_vbus,
523}; 507};
524 508
@@ -644,10 +628,54 @@ static int __exit am35x_remove(struct platform_device *pdev)
644 return 0; 628 return 0;
645} 629}
646 630
631#ifdef CONFIG_PM
632static int am35x_suspend(struct device *dev)
633{
634 struct am35x_glue *glue = dev_get_drvdata(dev);
635
636 phy_off();
637 clk_disable(glue->phy_clk);
638 clk_disable(glue->clk);
639
640 return 0;
641}
642
643static int am35x_resume(struct device *dev)
644{
645 struct am35x_glue *glue = dev_get_drvdata(dev);
646 int ret;
647
648 phy_on();
649 ret = clk_enable(glue->phy_clk);
650 if (ret) {
651 dev_err(dev, "failed to enable PHY clock\n");
652 return ret;
653 }
654
655 ret = clk_enable(glue->clk);
656 if (ret) {
657 dev_err(dev, "failed to enable clock\n");
658 return ret;
659 }
660
661 return 0;
662}
663
664static struct dev_pm_ops am35x_pm_ops = {
665 .suspend = am35x_suspend,
666 .resume = am35x_resume,
667};
668
669#define DEV_PM_OPS &am35x_pm_ops
670#else
671#define DEV_PM_OPS NULL
672#endif
673
647static struct platform_driver am35x_driver = { 674static struct platform_driver am35x_driver = {
648 .remove = __exit_p(am35x_remove), 675 .remove = __exit_p(am35x_remove),
649 .driver = { 676 .driver = {
650 .name = "musb-am35x", 677 .name = "musb-am35x",
678 .pm = DEV_PM_OPS,
651 }, 679 },
652}; 680};
653 681