arm: tegra: soctherm: Add critical trip to hwmon with callback
Diwakar Tundlam [Thu, 14 Mar 2013 22:33:21 +0000 (15:33 -0700)]
Change-Id: I907debaa9ebfd8aa3f04cc6cdb50561803f5736d
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-on: http://git-master/r/215930
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>

arch/arm/mach-tegra/tegra11_soctherm.c

index 56506c6..2d23363 100644 (file)
@@ -1034,6 +1034,26 @@ static int soctherm_set_trip_temp(struct thermal_zone_device *thz,
        return 0;
 }
 
+static int soctherm_get_crit_temp(struct thermal_zone_device *thz,
+                                 unsigned long *temp)
+{
+       int i, index = ((int)thz->devdata) - TSENSE_SIZE;
+       struct thermal_trip_info *trip_state;
+
+       if (index < 0)
+               return -EINVAL;
+
+       for (i = 0; i < plat_data.therm[index].num_trips; i++) {
+               trip_state = &plat_data.therm[index].trips[i];
+               if (trip_state->trip_type != THERMAL_TRIP_CRITICAL)
+                       continue;
+               *temp = trip_state->trip_temp;
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
 static int soctherm_get_trend(struct thermal_zone_device *thz,
                                int trip,
                                enum thermal_trend *trend)
@@ -1074,6 +1094,7 @@ static struct thermal_zone_device_ops soctherm_ops = {
        .get_trip_type = soctherm_get_trip_type,
        .get_trip_temp = soctherm_get_trip_temp,
        .set_trip_temp = soctherm_set_trip_temp,
+       .get_crit_temp = soctherm_get_crit_temp,
        .get_trend = soctherm_get_trend,
 };