#include <linux/thermal.h>
#include <soc/imx8/sc/sci.h>
+#include "thermal_core.h"
+
struct imx_sc_sensor {
struct thermal_zone_device *tzd;
+ struct thermal_cooling_device *cdev;
sc_rsrc_t hw_id;
+ int temp_passive;
+ int temp_critical;
};
struct imx_sc_tsens_device {
static int imx_sc_tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
{
+ int trip_temp;
+ struct imx_sc_sensor *sensor = p;
+
+ if (!sensor->tzd)
+ return 0;
+
+ trip_temp = (trip == IMX_TRIP_PASSIVE) ? sensor->temp_passive :
+ sensor->temp_critical;
+
+ if (sensor->tzd->temperature >= trip_temp)
+ *trend = THERMAL_TREND_RAISE_FULL;
+ else
+ *trend = THERMAL_TREND_DROP_FULL;
+
return 0;
}
+static int imx_sc_set_trip_temp(void *p, int trip,
+ int temp)
+{
+ struct imx_sc_sensor *sensor = p;
+
+ if (trip == IMX_TRIP_CRITICAL)
+ sensor->temp_critical = temp;
+
+ if (trip == IMX_TRIP_PASSIVE)
+ sensor->temp_passive = temp;
+
+ return 0;
+}
static const struct thermal_zone_of_device_ops imx_sc_tsens_ops = {
.get_temp = imx_sc_tsens_get_temp,
.get_trend = imx_sc_tsens_get_trend,
+ .set_trip_temp = imx_sc_set_trip_temp,
};
static const struct of_device_id imx_sc_tsens_table[] = {
struct device_node *np = pdev->dev.of_node;
struct imx_sc_tsens_device *tsens_dev;
struct imx_sc_sensor *sensor;
+ const struct thermal_trip *trip;
struct thermal_zone_device *tzd;
sc_err_t sciErr;
uint32_t mu_id;
goto failed;
}
sensor->tzd = tzd;
+ trip = of_thermal_get_trip_points(sensor->tzd);
+ sensor->temp_passive = trip[0].temperature;
+ sensor->temp_critical = trip[1].temperature;
}
return 0;