summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-07-28 10:22:48 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:27:46 +0800
commitfc04c156c625ed0fb4aa4736211535e0368b78d1 (patch)
treeb094aefcf968a65412595dba667f307620d88e24 /drivers/thermal
parent6af35904042d6cf9bda595a7365976842e578c95 (diff)
MLK-16093-2 thermal: qoriq: add necessary callbacks for cooling support
Add get_trend and set_trip_temp to support i.MX8MQ cooling device, get_trend is to customize cooling governor behavior, once temperature exceeds passive trip, cooling device will work at full function, and set_trip_temp is for updating trip temp when do thermal test via modifying trip temp from sysfs. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/qoriq_thermal.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
index 1bd85e030c88..1c132fa35060 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -78,6 +78,14 @@ struct qoriq_tmu_data {
struct qoriq_tmu_regs __iomem *regs;
int sensor_id;
bool little_endian;
+ int temp_passive;
+ int temp_critical;
+};
+
+enum tmu_trip {
+ TMU_TRIP_PASSIVE,
+ TMU_TRIP_CRITICAL,
+ TMU_TRIP_NUM,
};
static void tmu_write(struct qoriq_tmu_data *p, u32 val, void __iomem *addr)
@@ -189,13 +197,50 @@ static void qoriq_tmu_init_device(struct qoriq_tmu_data *data)
tmu_write(data, TMR_DISABLE, &data->regs->tmr);
}
+static int tmu_get_trend(void *p,
+ int trip, enum thermal_trend *trend)
+{
+ int trip_temp;
+ struct qoriq_tmu_data *data = p;
+
+ if (!data->tz)
+ return 0;
+
+ trip_temp = (trip == TMU_TRIP_PASSIVE) ? data->temp_passive :
+ data->temp_critical;
+
+ if (data->tz->temperature >= trip_temp)
+ *trend = THERMAL_TREND_RAISE_FULL;
+ else
+ *trend = THERMAL_TREND_DROP_FULL;
+
+ return 0;
+}
+
+static int tmu_set_trip_temp(void *p, int trip,
+ int temp)
+{
+ struct qoriq_tmu_data *data = p;
+
+ if (trip == TMU_TRIP_CRITICAL)
+ data->temp_critical = temp;
+
+ if (trip == TMU_TRIP_PASSIVE)
+ data->temp_passive = temp;
+
+ return 0;
+}
+
static const struct thermal_zone_of_device_ops tmu_tz_ops = {
.get_temp = tmu_get_temp,
+ .get_trend = tmu_get_trend,
+ .set_trip_temp = tmu_set_trip_temp,
};
static int qoriq_tmu_probe(struct platform_device *pdev)
{
int ret;
+ const struct thermal_trip *trip;
struct qoriq_tmu_data *data;
struct device_node *np = pdev->dev.of_node;
u32 site = 0;
@@ -243,6 +288,10 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
goto err_tmu;
}
+ trip = of_thermal_get_trip_points(data->tz);
+ data->temp_passive = trip[0].temperature;
+ data->temp_critical = trip[1].temperature;
+
/* Enable monitoring */
site |= 0x1 << (15 - data->sensor_id);
tmu_write(data, site | TMR_ME | TMR_ALPF, &data->regs->tmr);