-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
hongbo.zhang
authored and
Zhang Rui
committed
Nov 15, 2012
1 parent
445110e
commit aa1acb0
Showing
6 changed files
with
743 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Documentation/devicetree/bindings/thermal/db8500-thermal.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
* ST-Ericsson DB8500 Thermal | ||
|
||
** Thermal node properties: | ||
|
||
- compatible : "stericsson,db8500-thermal"; | ||
- reg : address range of the thermal sensor registers; | ||
- interrupts : interrupts generated from PRCMU; | ||
- interrupt-names : "IRQ_HOTMON_LOW" and "IRQ_HOTMON_HIGH"; | ||
- num-trips : number of total trip points, this is required, set it 0 if none, | ||
if greater than 0, the following properties must be defined; | ||
- tripN-temp : temperature of trip point N, should be in ascending order; | ||
- tripN-type : type of trip point N, should be one of "active" "passive" "hot" | ||
"critical"; | ||
- tripN-cdev-num : number of the cooling devices which can be bound to trip | ||
point N, this is required if trip point N is defined, set it 0 if none, | ||
otherwise the following cooling device names must be defined; | ||
- tripN-cdev-nameM : name of the No. M cooling device of trip point N; | ||
|
||
Usually the num-trips and tripN-*** are separated in board related dts files. | ||
|
||
Example: | ||
thermal@801573c0 { | ||
compatible = "stericsson,db8500-thermal"; | ||
reg = <0x801573c0 0x40>; | ||
interrupts = <21 0x4>, <22 0x4>; | ||
interrupt-names = "IRQ_HOTMON_LOW", "IRQ_HOTMON_HIGH"; | ||
|
||
num-trips = <3>; | ||
|
||
trip0-temp = <75000>; | ||
trip0-type = "active"; | ||
trip0-cdev-num = <1>; | ||
trip0-cdev-name0 = "thermal-cpufreq-0"; | ||
|
||
trip1-temp = <80000>; | ||
trip1-type = "active"; | ||
trip1-cdev-num = <2>; | ||
trip1-cdev-name0 = "thermal-cpufreq-0"; | ||
trip1-cdev-name1 = "thermal-fan"; | ||
|
||
trip2-temp = <85000>; | ||
trip2-type = "critical"; | ||
trip2-cdev-num = <0>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* db8500_cpufreq_cooling.c - DB8500 cpufreq works as cooling device. | ||
* | ||
* Copyright (C) 2012 ST-Ericsson | ||
* Copyright (C) 2012 Linaro Ltd. | ||
* | ||
* Author: Hongbo Zhang <hongbo.zhang@linaro.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
#include <linux/cpu_cooling.h> | ||
#include <linux/cpufreq.h> | ||
#include <linux/err.h> | ||
#include <linux/module.h> | ||
#include <linux/platform_device.h> | ||
#include <linux/slab.h> | ||
|
||
static int db8500_cpufreq_cooling_probe(struct platform_device *pdev) | ||
{ | ||
struct thermal_cooling_device *cdev; | ||
struct cpumask mask_val; | ||
|
||
/* make sure cpufreq driver has been initialized */ | ||
if (!cpufreq_frequency_get_table(0)) | ||
return -EPROBE_DEFER; | ||
|
||
cpumask_set_cpu(0, &mask_val); | ||
cdev = cpufreq_cooling_register(&mask_val); | ||
|
||
if (IS_ERR_OR_NULL(cdev)) { | ||
dev_err(&pdev->dev, "Failed to register cooling device\n"); | ||
return PTR_ERR(cdev); | ||
} | ||
|
||
platform_set_drvdata(pdev, cdev); | ||
|
||
dev_info(&pdev->dev, "Cooling device registered: %s\n", cdev->type); | ||
|
||
return 0; | ||
} | ||
|
||
static int db8500_cpufreq_cooling_remove(struct platform_device *pdev) | ||
{ | ||
struct thermal_cooling_device *cdev = platform_get_drvdata(pdev); | ||
|
||
cpufreq_cooling_unregister(cdev); | ||
|
||
return 0; | ||
} | ||
|
||
static int db8500_cpufreq_cooling_suspend(struct platform_device *pdev, | ||
pm_message_t state) | ||
{ | ||
return -ENOSYS; | ||
} | ||
|
||
static int db8500_cpufreq_cooling_resume(struct platform_device *pdev) | ||
{ | ||
return -ENOSYS; | ||
} | ||
|
||
#ifdef CONFIG_OF | ||
static const struct of_device_id db8500_cpufreq_cooling_match[] = { | ||
{ .compatible = "stericsson,db8500-cpufreq-cooling" }, | ||
{}, | ||
}; | ||
#else | ||
#define db8500_cpufreq_cooling_match NULL | ||
#endif | ||
|
||
static struct platform_driver db8500_cpufreq_cooling_driver = { | ||
.driver = { | ||
.owner = THIS_MODULE, | ||
.name = "db8500-cpufreq-cooling", | ||
.of_match_table = db8500_cpufreq_cooling_match, | ||
}, | ||
.probe = db8500_cpufreq_cooling_probe, | ||
.suspend = db8500_cpufreq_cooling_suspend, | ||
.resume = db8500_cpufreq_cooling_resume, | ||
.remove = db8500_cpufreq_cooling_remove, | ||
}; | ||
|
||
static int __init db8500_cpufreq_cooling_init(void) | ||
{ | ||
return platform_driver_register(&db8500_cpufreq_cooling_driver); | ||
} | ||
|
||
static void __exit db8500_cpufreq_cooling_exit(void) | ||
{ | ||
platform_driver_unregister(&db8500_cpufreq_cooling_driver); | ||
} | ||
|
||
/* Should be later than db8500_cpufreq_register */ | ||
late_initcall(db8500_cpufreq_cooling_init); | ||
module_exit(db8500_cpufreq_cooling_exit); | ||
|
||
MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>"); | ||
MODULE_DESCRIPTION("DB8500 cpufreq cooling driver"); | ||
MODULE_LICENSE("GPL"); |
Oops, something went wrong.