aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorkuninori.morimoto.gx@renesas.com <kuninori.morimoto.gx@renesas.com>2012-12-02 21:48:41 -0500
committerZhang Rui <rui.zhang@intel.com>2013-01-04 02:37:45 -0500
commitd2a73e225d113fdccd80373ad9aeb2b58b32a30b (patch)
treeaf255ad70f782ef6a32cde24df5f94522414f531 /drivers/thermal
parentbbf63be4f331358173da26b888a10583fcc92ec0 (diff)
thermal: rcar: add .get_trip_type/temp and .notify support
This patch adds .get_trip_type(), .get_trip_temp(), and .notify() on rcar_thermal_zone_ops. Driver will try platform power OFF if it reached to critical temperature. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/rcar_thermal.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 90db951725da..89979ff10e27 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -22,10 +22,13 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/reboot.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27#include <linux/thermal.h> 28#include <linux/thermal.h>
28 29
30#define IDLE_INTERVAL 5000
31
29#define THSCR 0x2c 32#define THSCR 0x2c
30#define THSSR 0x30 33#define THSSR 0x30
31 34
@@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
176 return 0; 179 return 0;
177} 180}
178 181
182static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
183 int trip, enum thermal_trip_type *type)
184{
185 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
186
187 /* see rcar_thermal_get_temp() */
188 switch (trip) {
189 case 0: /* +90 <= temp */
190 *type = THERMAL_TRIP_CRITICAL;
191 break;
192 default:
193 dev_err(priv->dev, "rcar driver trip error\n");
194 return -EINVAL;
195 }
196
197 return 0;
198}
199
200static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
201 int trip, unsigned long *temp)
202{
203 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
204
205 /* see rcar_thermal_get_temp() */
206 switch (trip) {
207 case 0: /* +90 <= temp */
208 *temp = MCELSIUS(90);
209 break;
210 default:
211 dev_err(priv->dev, "rcar driver trip error\n");
212 return -EINVAL;
213 }
214
215 return 0;
216}
217
218static int rcar_thermal_notify(struct thermal_zone_device *zone,
219 int trip, enum thermal_trip_type type)
220{
221 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
222
223 switch (type) {
224 case THERMAL_TRIP_CRITICAL:
225 /* FIXME */
226 dev_warn(priv->dev,
227 "Thermal reached to critical temperature\n");
228 machine_power_off();
229 break;
230 default:
231 break;
232 }
233
234 return 0;
235}
236
179static struct thermal_zone_device_ops rcar_thermal_zone_ops = { 237static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
180 .get_temp = rcar_thermal_get_temp, 238 .get_temp = rcar_thermal_get_temp,
239 .get_trip_type = rcar_thermal_get_trip_type,
240 .get_trip_temp = rcar_thermal_get_trip_temp,
241 .notify = rcar_thermal_notify,
181}; 242};
182 243
183/* 244/*
@@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
211 return -ENOMEM; 272 return -ENOMEM;
212 } 273 }
213 274
214 zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv, 275 zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
215 &rcar_thermal_zone_ops, NULL, 0, 0); 276 &rcar_thermal_zone_ops, NULL, 0,
277 IDLE_INTERVAL);
216 if (IS_ERR(zone)) { 278 if (IS_ERR(zone)) {
217 dev_err(&pdev->dev, "thermal zone device is NULL\n"); 279 dev_err(&pdev->dev, "thermal zone device is NULL\n");
218 return PTR_ERR(zone); 280 return PTR_ERR(zone);