diff options
Diffstat (limited to 'drivers/clocksource/sh_cmt.c')
-rw-r--r-- | drivers/clocksource/sh_cmt.c | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 6b3e0c2f33e2..578595c4425d 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
@@ -40,7 +40,6 @@ struct sh_cmt_priv { | |||
40 | struct platform_device *pdev; | 40 | struct platform_device *pdev; |
41 | 41 | ||
42 | unsigned long flags; | 42 | unsigned long flags; |
43 | unsigned long flags_suspend; | ||
44 | unsigned long match_value; | 43 | unsigned long match_value; |
45 | unsigned long next_match_value; | 44 | unsigned long next_match_value; |
46 | unsigned long max_match_value; | 45 | unsigned long max_match_value; |
@@ -432,6 +431,11 @@ static void sh_cmt_clocksource_disable(struct clocksource *cs) | |||
432 | sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); | 431 | sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); |
433 | } | 432 | } |
434 | 433 | ||
434 | static void sh_cmt_clocksource_resume(struct clocksource *cs) | ||
435 | { | ||
436 | sh_cmt_start(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); | ||
437 | } | ||
438 | |||
435 | static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, | 439 | static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, |
436 | char *name, unsigned long rating) | 440 | char *name, unsigned long rating) |
437 | { | 441 | { |
@@ -442,6 +446,8 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, | |||
442 | cs->read = sh_cmt_clocksource_read; | 446 | cs->read = sh_cmt_clocksource_read; |
443 | cs->enable = sh_cmt_clocksource_enable; | 447 | cs->enable = sh_cmt_clocksource_enable; |
444 | cs->disable = sh_cmt_clocksource_disable; | 448 | cs->disable = sh_cmt_clocksource_disable; |
449 | cs->suspend = sh_cmt_clocksource_disable; | ||
450 | cs->resume = sh_cmt_clocksource_resume; | ||
445 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); | 451 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); |
446 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 452 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
447 | pr_info("sh_cmt: %s used as clock source\n", cs->name); | 453 | pr_info("sh_cmt: %s used as clock source\n", cs->name); |
@@ -603,18 +609,13 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
603 | p->irqaction.handler = sh_cmt_interrupt; | 609 | p->irqaction.handler = sh_cmt_interrupt; |
604 | p->irqaction.dev_id = p; | 610 | p->irqaction.dev_id = p; |
605 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; | 611 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; |
606 | ret = setup_irq(irq, &p->irqaction); | ||
607 | if (ret) { | ||
608 | pr_err("sh_cmt: failed to request irq %d\n", irq); | ||
609 | goto err1; | ||
610 | } | ||
611 | 612 | ||
612 | /* get hold of clock */ | 613 | /* get hold of clock */ |
613 | p->clk = clk_get(&p->pdev->dev, cfg->clk); | 614 | p->clk = clk_get(&p->pdev->dev, cfg->clk); |
614 | if (IS_ERR(p->clk)) { | 615 | if (IS_ERR(p->clk)) { |
615 | pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk); | 616 | pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk); |
616 | ret = PTR_ERR(p->clk); | 617 | ret = PTR_ERR(p->clk); |
617 | goto err2; | 618 | goto err1; |
618 | } | 619 | } |
619 | 620 | ||
620 | if (resource_size(res) == 6) { | 621 | if (resource_size(res) == 6) { |
@@ -627,14 +628,25 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
627 | p->clear_bits = ~0xc000; | 628 | p->clear_bits = ~0xc000; |
628 | } | 629 | } |
629 | 630 | ||
630 | return sh_cmt_register(p, cfg->name, | 631 | ret = sh_cmt_register(p, cfg->name, |
631 | cfg->clockevent_rating, | 632 | cfg->clockevent_rating, |
632 | cfg->clocksource_rating); | 633 | cfg->clocksource_rating); |
633 | err2: | 634 | if (ret) { |
634 | remove_irq(irq, &p->irqaction); | 635 | pr_err("sh_cmt: registration failed\n"); |
635 | err1: | 636 | goto err1; |
637 | } | ||
638 | |||
639 | ret = setup_irq(irq, &p->irqaction); | ||
640 | if (ret) { | ||
641 | pr_err("sh_cmt: failed to request irq %d\n", irq); | ||
642 | goto err1; | ||
643 | } | ||
644 | |||
645 | return 0; | ||
646 | |||
647 | err1: | ||
636 | iounmap(p->mapbase); | 648 | iounmap(p->mapbase); |
637 | err0: | 649 | err0: |
638 | return ret; | 650 | return ret; |
639 | } | 651 | } |
640 | 652 | ||
@@ -668,38 +680,11 @@ static int __devexit sh_cmt_remove(struct platform_device *pdev) | |||
668 | return -EBUSY; /* cannot unregister clockevent and clocksource */ | 680 | return -EBUSY; /* cannot unregister clockevent and clocksource */ |
669 | } | 681 | } |
670 | 682 | ||
671 | static int sh_cmt_suspend(struct device *dev) | ||
672 | { | ||
673 | struct platform_device *pdev = to_platform_device(dev); | ||
674 | struct sh_cmt_priv *p = platform_get_drvdata(pdev); | ||
675 | |||
676 | /* save flag state and stop CMT channel */ | ||
677 | p->flags_suspend = p->flags; | ||
678 | sh_cmt_stop(p, p->flags); | ||
679 | return 0; | ||
680 | } | ||
681 | |||
682 | static int sh_cmt_resume(struct device *dev) | ||
683 | { | ||
684 | struct platform_device *pdev = to_platform_device(dev); | ||
685 | struct sh_cmt_priv *p = platform_get_drvdata(pdev); | ||
686 | |||
687 | /* start CMT channel from saved state */ | ||
688 | sh_cmt_start(p, p->flags_suspend); | ||
689 | return 0; | ||
690 | } | ||
691 | |||
692 | static struct dev_pm_ops sh_cmt_dev_pm_ops = { | ||
693 | .suspend = sh_cmt_suspend, | ||
694 | .resume = sh_cmt_resume, | ||
695 | }; | ||
696 | |||
697 | static struct platform_driver sh_cmt_device_driver = { | 683 | static struct platform_driver sh_cmt_device_driver = { |
698 | .probe = sh_cmt_probe, | 684 | .probe = sh_cmt_probe, |
699 | .remove = __devexit_p(sh_cmt_remove), | 685 | .remove = __devexit_p(sh_cmt_remove), |
700 | .driver = { | 686 | .driver = { |
701 | .name = "sh_cmt", | 687 | .name = "sh_cmt", |
702 | .pm = &sh_cmt_dev_pm_ops, | ||
703 | } | 688 | } |
704 | }; | 689 | }; |
705 | 690 | ||