1
0
Fork 0

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>
pull/10/head
Anson Huang 2017-07-28 10:22:48 +08:00 committed by Jason Liu
parent 79fb241dba
commit ad1f676e04
1 changed files with 49 additions and 0 deletions

View File

@ -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);