mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 06:49:52 +00:00
thermal: tegra: Introduce struct trip_temps for critical and hot trips
Introduce a helper structure, struct trip_temps, for storing the temperatures of the critical and hot trip points. This helps to make the code in tegra_tsensor_get_hw_channel_trips() somewhat cleaner and will be useful subsequently in eliminating iteration over trip indices from the driver. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/9333090.CDJkKcVGEf@rjwysocki.net
This commit is contained in:
parent
ab446887ea
commit
289a54f611
@ -303,8 +303,13 @@ stop_channel:
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct trip_temps {
|
||||
int hot_trip;
|
||||
int crit_trip;
|
||||
};
|
||||
|
||||
static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd,
|
||||
int *hot_trip, int *crit_trip)
|
||||
struct trip_temps *temps)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -312,8 +317,8 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd,
|
||||
* 90C is the maximal critical temperature of all Tegra30 SoC variants,
|
||||
* use it for the default trip if unspecified in a device-tree.
|
||||
*/
|
||||
*hot_trip = 85000;
|
||||
*crit_trip = 90000;
|
||||
temps->hot_trip = 85000;
|
||||
temps->crit_trip = 90000;
|
||||
|
||||
for (i = 0; i < thermal_zone_get_num_trips(tzd); i++) {
|
||||
|
||||
@ -322,14 +327,14 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd,
|
||||
thermal_zone_get_trip(tzd, i, &trip);
|
||||
|
||||
if (trip.type == THERMAL_TRIP_HOT)
|
||||
*hot_trip = trip.temperature;
|
||||
temps->hot_trip = trip.temperature;
|
||||
|
||||
if (trip.type == THERMAL_TRIP_CRITICAL)
|
||||
*crit_trip = trip.temperature;
|
||||
temps->crit_trip = trip.temperature;
|
||||
}
|
||||
|
||||
/* clamp hardware trips to the calibration limits */
|
||||
*hot_trip = clamp(*hot_trip, 25000, 90000);
|
||||
temps->hot_trip = clamp(temps->hot_trip, 25000, 90000);
|
||||
|
||||
/*
|
||||
* Kernel will perform a normal system shut down if it will
|
||||
@ -338,7 +343,7 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd,
|
||||
* shut down gracefully before sending signal to the Power
|
||||
* Management controller.
|
||||
*/
|
||||
*crit_trip = clamp(*crit_trip + 5000, 25000, 90000);
|
||||
temps->crit_trip = clamp(temps->crit_trip + 5000, 25000, 90000);
|
||||
}
|
||||
|
||||
static int tegra_tsensor_enable_hw_channel(const struct tegra_tsensor *ts,
|
||||
@ -346,7 +351,8 @@ static int tegra_tsensor_enable_hw_channel(const struct tegra_tsensor *ts,
|
||||
{
|
||||
const struct tegra_tsensor_channel *tsc = &ts->ch[id];
|
||||
struct thermal_zone_device *tzd = tsc->tzd;
|
||||
int err, hot_trip = 0, crit_trip = 0;
|
||||
struct trip_temps temps = { 0 };
|
||||
int err;
|
||||
u32 val;
|
||||
|
||||
if (!tzd) {
|
||||
@ -357,24 +363,24 @@ static int tegra_tsensor_enable_hw_channel(const struct tegra_tsensor *ts,
|
||||
return 0;
|
||||
}
|
||||
|
||||
tegra_tsensor_get_hw_channel_trips(tzd, &hot_trip, &crit_trip);
|
||||
tegra_tsensor_get_hw_channel_trips(tzd, &temps);
|
||||
|
||||
dev_info_once(ts->dev, "ch%u: PMC emergency shutdown trip set to %dC\n",
|
||||
id, DIV_ROUND_CLOSEST(crit_trip, 1000));
|
||||
id, DIV_ROUND_CLOSEST(temps.crit_trip, 1000));
|
||||
|
||||
hot_trip = tegra_tsensor_temp_to_counter(ts, hot_trip);
|
||||
crit_trip = tegra_tsensor_temp_to_counter(ts, crit_trip);
|
||||
temps.hot_trip = tegra_tsensor_temp_to_counter(ts, temps.hot_trip);
|
||||
temps.crit_trip = tegra_tsensor_temp_to_counter(ts, temps.crit_trip);
|
||||
|
||||
/* program LEVEL2 counter threshold */
|
||||
val = readl_relaxed(tsc->regs + TSENSOR_SENSOR0_CONFIG1);
|
||||
val &= ~TSENSOR_SENSOR0_CONFIG1_TH2;
|
||||
val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG1_TH2, hot_trip);
|
||||
val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG1_TH2, temps.hot_trip);
|
||||
writel_relaxed(val, tsc->regs + TSENSOR_SENSOR0_CONFIG1);
|
||||
|
||||
/* program LEVEL3 counter threshold */
|
||||
val = readl_relaxed(tsc->regs + TSENSOR_SENSOR0_CONFIG2);
|
||||
val &= ~TSENSOR_SENSOR0_CONFIG2_TH3;
|
||||
val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG2_TH3, crit_trip);
|
||||
val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG2_TH3, temps.crit_trip);
|
||||
writel_relaxed(val, tsc->regs + TSENSOR_SENSOR0_CONFIG2);
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user