mirror of
https://github.com/torvalds/linux.git
synced 2026-08-01 20:22:08 +02:00
drivers: thermal: tsens: Cache the trip temperature
Cache the trip temperature for the thermal framework to read. Once the trip occurs the temperature at which the trip or trip clear is cached till the thermal framework sets a new trip value. This will ensure that the thermal framework will read the exact temperature as the driver and it cannot go out of sync. Change-Id: Ie44ee0e1e7e4acf3a08f47f1204e6d2ab1a8100f Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
This commit is contained in:
parent
70627fa6e2
commit
8f25da0261
|
|
@ -466,7 +466,7 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
|
|||
|
||||
for (i = 0; i < priv->num_sensors; i++) {
|
||||
bool trigger = false;
|
||||
const struct tsens_sensor *s = &priv->sensor[i];
|
||||
struct tsens_sensor *s = &priv->sensor[i];
|
||||
u32 hw_id = s->hw_id;
|
||||
|
||||
if (!s->tzd)
|
||||
|
|
@ -511,6 +511,7 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
|
|||
spin_unlock_irqrestore(&priv->ul_lock, flags);
|
||||
|
||||
if (trigger) {
|
||||
s->cached_temp = temp;
|
||||
dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
|
||||
hw_id, __func__, temp);
|
||||
thermal_zone_device_update(s->tzd,
|
||||
|
|
@ -564,6 +565,7 @@ static int tsens_set_trips(void *_sensor, int low, int high)
|
|||
|
||||
tsens_read_irq_state(priv, hw_id, s, &d);
|
||||
|
||||
s->cached_temp = INT_MIN;
|
||||
/* Write the new thresholds and clear the status */
|
||||
regmap_field_write(priv->rf[LOW_THRESH_0 + hw_id], low_val);
|
||||
regmap_field_write(priv->rf[UP_THRESH_0 + hw_id], high_val);
|
||||
|
|
@ -605,6 +607,11 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)
|
|||
u32 valid;
|
||||
int ret;
|
||||
|
||||
if (s->cached_temp != INT_MIN) {
|
||||
*temp = s->cached_temp;
|
||||
goto dump_and_exit;
|
||||
}
|
||||
|
||||
/* VER_0 doesn't have VALID bit */
|
||||
if (tsens_version(priv) == VER_0)
|
||||
goto get_temp;
|
||||
|
|
@ -624,6 +631,7 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)
|
|||
/* Valid bit is set, OK to read the temperature */
|
||||
*temp = tsens_hw_to_mC(s, temp_idx);
|
||||
|
||||
dump_and_exit:
|
||||
TSENS_DBG(priv, "Sensor_id: %d temp: %d", hw_id, *temp);
|
||||
|
||||
return 0;
|
||||
|
|
@ -1150,6 +1158,7 @@ static int tsens_probe(struct platform_device *pdev)
|
|||
priv->sensor[i].hw_id = data->hw_ids[i];
|
||||
else
|
||||
priv->sensor[i].hw_id = i;
|
||||
priv->sensor[i].cached_temp = INT_MIN;
|
||||
}
|
||||
priv->feat = data->feat;
|
||||
priv->fields = data->fields;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ struct tsens_sensor {
|
|||
unsigned int hw_id;
|
||||
int slope;
|
||||
u32 status;
|
||||
int cached_temp;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user