diff options
author | hongbo.zhang <hongbo.zhang@linaro.com> | 2012-11-15 05:56:42 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-11-15 07:50:34 -0500 |
commit | aa1acb0451bb27add173d9641d0b74c58889e693 (patch) | |
tree | e7118568c9722dc1dc69c5f19c6218be3185ab79 /drivers/thermal/db8500_cpufreq_cooling.c | |
parent | 445110e9d05e693c5e511717a010969175878754 (diff) |
Thermal: Add ST-Ericsson DB8500 thermal driver.
This driver is based on the thermal management framework in thermal_sys.c. A
thermal zone device is created with the trip points to which cooling devices
can be bound, the current cooling device is cpufreq, e.g. CPU frequency is
clipped down to cool the CPU, and other cooling devices can be added and bound
to the trip points dynamically. The platform specific PRCMU interrupts are
used to active thermal update when trip points are reached.
Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Francesco Lavra <francescolavra.fl@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/db8500_cpufreq_cooling.c')
-rw-r--r-- | drivers/thermal/db8500_cpufreq_cooling.c | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/drivers/thermal/db8500_cpufreq_cooling.c b/drivers/thermal/db8500_cpufreq_cooling.c new file mode 100644 index 000000000000..4cf8e72af90a --- /dev/null +++ b/drivers/thermal/db8500_cpufreq_cooling.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * db8500_cpufreq_cooling.c - DB8500 cpufreq works as cooling device. | ||
3 | * | ||
4 | * Copyright (C) 2012 ST-Ericsson | ||
5 | * Copyright (C) 2012 Linaro Ltd. | ||
6 | * | ||
7 | * Author: Hongbo Zhang <hongbo.zhang@linaro.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | #include <linux/cpu_cooling.h> | ||
21 | #include <linux/cpufreq.h> | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/slab.h> | ||
26 | |||
27 | static int db8500_cpufreq_cooling_probe(struct platform_device *pdev) | ||
28 | { | ||
29 | struct thermal_cooling_device *cdev; | ||
30 | struct cpumask mask_val; | ||
31 | |||
32 | /* make sure cpufreq driver has been initialized */ | ||
33 | if (!cpufreq_frequency_get_table(0)) | ||
34 | return -EPROBE_DEFER; | ||
35 | |||
36 | cpumask_set_cpu(0, &mask_val); | ||
37 | cdev = cpufreq_cooling_register(&mask_val); | ||
38 | |||
39 | if (IS_ERR_OR_NULL(cdev)) { | ||
40 | dev_err(&pdev->dev, "Failed to register cooling device\n"); | ||
41 | return PTR_ERR(cdev); | ||
42 | } | ||
43 | |||
44 | platform_set_drvdata(pdev, cdev); | ||
45 | |||
46 | dev_info(&pdev->dev, "Cooling device registered: %s\n", cdev->type); | ||
47 | |||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static int db8500_cpufreq_cooling_remove(struct platform_device *pdev) | ||
52 | { | ||
53 | struct thermal_cooling_device *cdev = platform_get_drvdata(pdev); | ||
54 | |||
55 | cpufreq_cooling_unregister(cdev); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static int db8500_cpufreq_cooling_suspend(struct platform_device *pdev, | ||
61 | pm_message_t state) | ||
62 | { | ||
63 | return -ENOSYS; | ||
64 | } | ||
65 | |||
66 | static int db8500_cpufreq_cooling_resume(struct platform_device *pdev) | ||
67 | { | ||
68 | return -ENOSYS; | ||
69 | } | ||
70 | |||
71 | #ifdef CONFIG_OF | ||
72 | static const struct of_device_id db8500_cpufreq_cooling_match[] = { | ||
73 | { .compatible = "stericsson,db8500-cpufreq-cooling" }, | ||
74 | {}, | ||
75 | }; | ||
76 | #else | ||
77 | #define db8500_cpufreq_cooling_match NULL | ||
78 | #endif | ||
79 | |||
80 | static struct platform_driver db8500_cpufreq_cooling_driver = { | ||
81 | .driver = { | ||
82 | .owner = THIS_MODULE, | ||
83 | .name = "db8500-cpufreq-cooling", | ||
84 | .of_match_table = db8500_cpufreq_cooling_match, | ||
85 | }, | ||
86 | .probe = db8500_cpufreq_cooling_probe, | ||
87 | .suspend = db8500_cpufreq_cooling_suspend, | ||
88 | .resume = db8500_cpufreq_cooling_resume, | ||
89 | .remove = db8500_cpufreq_cooling_remove, | ||
90 | }; | ||
91 | |||
92 | static int __init db8500_cpufreq_cooling_init(void) | ||
93 | { | ||
94 | return platform_driver_register(&db8500_cpufreq_cooling_driver); | ||
95 | } | ||
96 | |||
97 | static void __exit db8500_cpufreq_cooling_exit(void) | ||
98 | { | ||
99 | platform_driver_unregister(&db8500_cpufreq_cooling_driver); | ||
100 | } | ||
101 | |||
102 | /* Should be later than db8500_cpufreq_register */ | ||
103 | late_initcall(db8500_cpufreq_cooling_init); | ||
104 | module_exit(db8500_cpufreq_cooling_exit); | ||
105 | |||
106 | MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>"); | ||
107 | MODULE_DESCRIPTION("DB8500 cpufreq cooling driver"); | ||
108 | MODULE_LICENSE("GPL"); | ||