diff options
author | Wei Ni <wni@nvidia.com> | 2016-03-29 06:29:22 -0400 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2016-05-17 10:28:29 -0400 |
commit | f09d698494289cdf1f0afc0baddbac8db30f195d (patch) | |
tree | 3645f1e8687424b89b40c1e787d0486bbd3d764d | |
parent | 1ed895c2a27ebc862241926945f4adcbc88c6cd6 (diff) |
thermal: tegra: add PM support
Add suspend/resume function in soctherm driver.
Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/tegra/soctherm.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index d2b7c255d71f..559c74279eb8 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c | |||
@@ -88,6 +88,7 @@ struct tegra_soctherm { | |||
88 | struct clk *clock_tsensor; | 88 | struct clk *clock_tsensor; |
89 | struct clk *clock_soctherm; | 89 | struct clk *clock_soctherm; |
90 | void __iomem *regs; | 90 | void __iomem *regs; |
91 | struct thermal_zone_device **thermctl_tzs; | ||
91 | 92 | ||
92 | u32 *calib; | 93 | u32 *calib; |
93 | struct tegra_soctherm_soc *soc; | 94 | struct tegra_soctherm_soc *soc; |
@@ -566,6 +567,12 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
566 | return err; | 567 | return err; |
567 | } | 568 | } |
568 | 569 | ||
570 | tegra->thermctl_tzs = devm_kzalloc(&pdev->dev, | ||
571 | sizeof(*z) * soc->num_ttgs, | ||
572 | GFP_KERNEL); | ||
573 | if (!tegra->thermctl_tzs) | ||
574 | return -ENOMEM; | ||
575 | |||
569 | err = soctherm_clk_enable(pdev, true); | 576 | err = soctherm_clk_enable(pdev, true); |
570 | if (err) | 577 | if (err) |
571 | return err; | 578 | return err; |
@@ -595,6 +602,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
595 | } | 602 | } |
596 | 603 | ||
597 | zone->tz = z; | 604 | zone->tz = z; |
605 | tegra->thermctl_tzs[soc->ttgs[i]->id] = z; | ||
598 | 606 | ||
599 | /* Configure hw trip points */ | 607 | /* Configure hw trip points */ |
600 | tegra_soctherm_set_hwtrips(&pdev->dev, soc->ttgs[i], z); | 608 | tegra_soctherm_set_hwtrips(&pdev->dev, soc->ttgs[i], z); |
@@ -621,11 +629,49 @@ static int tegra_soctherm_remove(struct platform_device *pdev) | |||
621 | return 0; | 629 | return 0; |
622 | } | 630 | } |
623 | 631 | ||
632 | static int soctherm_suspend(struct device *dev) | ||
633 | { | ||
634 | struct platform_device *pdev = to_platform_device(dev); | ||
635 | |||
636 | soctherm_clk_enable(pdev, false); | ||
637 | |||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static int soctherm_resume(struct device *dev) | ||
642 | { | ||
643 | struct platform_device *pdev = to_platform_device(dev); | ||
644 | struct tegra_soctherm *tegra = platform_get_drvdata(pdev); | ||
645 | struct tegra_soctherm_soc *soc = tegra->soc; | ||
646 | int err, i; | ||
647 | |||
648 | err = soctherm_clk_enable(pdev, true); | ||
649 | if (err) { | ||
650 | dev_err(&pdev->dev, | ||
651 | "Resume failed: enable clocks failed\n"); | ||
652 | return err; | ||
653 | } | ||
654 | |||
655 | soctherm_init(pdev); | ||
656 | |||
657 | for (i = 0; i < soc->num_ttgs; ++i) { | ||
658 | struct thermal_zone_device *tz; | ||
659 | |||
660 | tz = tegra->thermctl_tzs[soc->ttgs[i]->id]; | ||
661 | tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz); | ||
662 | } | ||
663 | |||
664 | return 0; | ||
665 | } | ||
666 | |||
667 | static SIMPLE_DEV_PM_OPS(tegra_soctherm_pm, soctherm_suspend, soctherm_resume); | ||
668 | |||
624 | static struct platform_driver tegra_soctherm_driver = { | 669 | static struct platform_driver tegra_soctherm_driver = { |
625 | .probe = tegra_soctherm_probe, | 670 | .probe = tegra_soctherm_probe, |
626 | .remove = tegra_soctherm_remove, | 671 | .remove = tegra_soctherm_remove, |
627 | .driver = { | 672 | .driver = { |
628 | .name = "tegra_soctherm", | 673 | .name = "tegra_soctherm", |
674 | .pm = &tegra_soctherm_pm, | ||
629 | .of_match_table = tegra_soctherm_of_match, | 675 | .of_match_table = tegra_soctherm_of_match, |
630 | }, | 676 | }, |
631 | }; | 677 | }; |