From c753075f1d8c57580e968616ad97b08c134978ee Mon Sep 17 00:00:00 2001 From: "kuninori.morimoto.gx@renesas.com" Date: Sun, 2 Dec 2012 18:48:41 -0800 Subject: [PATCH] --- yaml --- r: 359757 b: refs/heads/master c: d2a73e225d113fdccd80373ad9aeb2b58b32a30b h: refs/heads/master i: 359755: d11c068207e3bdef0af1c36e2e9f0c04935edbbc v: v3 --- [refs] | 2 +- trunk/drivers/thermal/rcar_thermal.c | 68 ++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 5090cc6db6b7..653c61086b23 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bbf63be4f331358173da26b888a10583fcc92ec0 +refs/heads/master: d2a73e225d113fdccd80373ad9aeb2b58b32a30b diff --git a/trunk/drivers/thermal/rcar_thermal.c b/trunk/drivers/thermal/rcar_thermal.c index 90db951725da..89979ff10e27 100644 --- a/trunk/drivers/thermal/rcar_thermal.c +++ b/trunk/drivers/thermal/rcar_thermal.c @@ -22,10 +22,13 @@ #include #include #include +#include #include #include #include +#define IDLE_INTERVAL 5000 + #define THSCR 0x2c #define THSSR 0x30 @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, return 0; } +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, + int trip, enum thermal_trip_type *type) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + /* see rcar_thermal_get_temp() */ + switch (trip) { + case 0: /* +90 <= temp */ + *type = THERMAL_TRIP_CRITICAL; + break; + default: + dev_err(priv->dev, "rcar driver trip error\n"); + return -EINVAL; + } + + return 0; +} + +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, + int trip, unsigned long *temp) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + /* see rcar_thermal_get_temp() */ + switch (trip) { + case 0: /* +90 <= temp */ + *temp = MCELSIUS(90); + break; + default: + dev_err(priv->dev, "rcar driver trip error\n"); + return -EINVAL; + } + + return 0; +} + +static int rcar_thermal_notify(struct thermal_zone_device *zone, + int trip, enum thermal_trip_type type) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + switch (type) { + case THERMAL_TRIP_CRITICAL: + /* FIXME */ + dev_warn(priv->dev, + "Thermal reached to critical temperature\n"); + machine_power_off(); + break; + default: + break; + } + + return 0; +} + static struct thermal_zone_device_ops rcar_thermal_zone_ops = { - .get_temp = rcar_thermal_get_temp, + .get_temp = rcar_thermal_get_temp, + .get_trip_type = rcar_thermal_get_trip_type, + .get_trip_temp = rcar_thermal_get_trip_temp, + .notify = rcar_thermal_notify, }; /* @@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev) return -ENOMEM; } - zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv, - &rcar_thermal_zone_ops, NULL, 0, 0); + zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv, + &rcar_thermal_zone_ops, NULL, 0, + IDLE_INTERVAL); if (IS_ERR(zone)) { dev_err(&pdev->dev, "thermal zone device is NULL\n"); return PTR_ERR(zone);