MLK-11705 thermal: imx: make the critical trip temp changable for test
authorBai Ping <b51503@freescale.com>
Tue, 13 Oct 2015 18:46:13 +0000 (02:46 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:57 +0000 (14:48 -0500)
In order to test the critical trip point funtion, the
critical trip point temp should be writable from userspace.

Signed-off-by: Bai Ping <b51503@freescale.com>
drivers/thermal/imx_thermal.c

index 29c83d4..1ae06c5 100644 (file)
@@ -453,17 +453,18 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
 {
        struct imx_thermal_data *data = tz->devdata;
 
-       /* do not allow changing critical threshold */
-       if (trip == IMX_TRIP_CRITICAL)
-               return -EPERM;
-
-       /* do not allow passive to be set higher than critical */
-       if (temp < 0 || temp > data->temp_critical)
-               return -EINVAL;
-
-       data->temp_passive = temp;
+       if (trip == IMX_TRIP_CRITICAL) {
+               data->temp_critical = temp;
+               if (data->socdata->version == TEMPMON_IMX6SX)
+                       imx_set_panic_temp(data, temp);
+       }
 
-       imx_set_alarm_temp(data, temp);
+       if (trip == IMX_TRIP_PASSIVE) {
+               if (temp > IMX_TRIP_PASSIVE)
+                       return -EINVAL;
+               data->temp_passive = temp;
+               imx_set_alarm_temp(data, temp);
+       }
 
        return 0;
 }
@@ -841,7 +842,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
        mutex_init(&data->mutex);
        data->tz = thermal_zone_device_register("imx_thermal_zone",
                                                IMX_TRIP_NUM,
-                                               BIT(IMX_TRIP_PASSIVE), data,
+                                               (1 << IMX_TRIP_NUM) - 1, data,
                                                &imx_tz_ops, NULL,
                                                IMX_PASSIVE_DELAY,
                                                IMX_POLLING_DELAY);