msm: thermal: Maintain state in the mitigation device monitor

If KTM get a trip threshold trigger notification and if the
temperature stays the same as the recent trip threshold, KTM will
re-activate the recently triggered threshold, resulting in back to
back interrupts. To avoid this add support in KTM to maintain the
recently triggered threshold state and then re-active the threshold
based on the last threshold trip.
This state is updated for mitigation features like VDD MX retention,
CX phase control, VDD restriction, OCR monitor and external clients
like CPR low temperature monitor etc.

CRs-Fixed: 969112 972634
Change-Id: I44c0a93e1507a9f0b8a65e5c2ce5a98962bb335b
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi 2016-02-03 16:23:58 +05:30 committed by Gerrit - the friendly Code Review server
parent 59ecba3a9d
commit 54a36422d8
4 changed files with 38 additions and 13 deletions

View File

@ -3536,8 +3536,11 @@ static void thermal_monitor_notify(struct therm_threshold *trig_thres)
break;
}
sensor_mgr_set_threshold(trig_thres->sensor_id,
if (trig_thres->cur_state != trig_thres->trip_triggered) {
sensor_mgr_set_threshold(trig_thres->sensor_id,
trig_thres->threshold);
trig_thres->cur_state = trig_thres->trip_triggered;
}
}
static int clock_check_tsens(void)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -5092,10 +5092,16 @@ static void tsens_threshold_notify(struct therm_threshold *tsens_cb_data)
break;
}
rc = sensor_mgr_set_threshold(tsens_cb_data->sensor_id,
tsens_cb_data->threshold);
if (rc < 0)
cpr_err(cpr_vreg, "Failed to set temp. threshold, rc=%d\n", rc);
if (tsens_cb_data->cur_state != tsens_cb_data->trip_triggered) {
rc = sensor_mgr_set_threshold(tsens_cb_data->sensor_id,
tsens_cb_data->threshold);
if (rc < 0)
cpr_err(cpr_vreg,
"Failed to set temp. threshold, rc=%d\n", rc);
else
tsens_cb_data->cur_state =
tsens_cb_data->trip_triggered;
}
}
static int cpr_check_tsens(struct cpr_regulator *cpr_vreg)

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -2601,8 +2601,12 @@ static void vdd_mx_notify(struct therm_threshold *trig_thresh)
pr_err("Failed to remove vdd mx restriction\n");
}
mutex_unlock(&vdd_mx_mutex);
sensor_mgr_set_threshold(trig_thresh->sensor_id,
if (trig_thresh->cur_state != trig_thresh->trip_triggered) {
sensor_mgr_set_threshold(trig_thresh->sensor_id,
trig_thresh->threshold);
trig_thresh->cur_state = trig_thresh->trip_triggered;
}
}
static void msm_thermal_bite(int zone_id, long temp)
@ -4036,8 +4040,11 @@ static void cx_phase_ctrl_notify(struct therm_threshold *trig_thresh)
cx_phase_unlock_exit:
mutex_unlock(&cx_mutex);
cx_phase_ctrl_exit:
sensor_mgr_set_threshold(trig_thresh->sensor_id,
if (trig_thresh->cur_state != trig_thresh->trip_triggered) {
sensor_mgr_set_threshold(trig_thresh->sensor_id,
trig_thresh->threshold);
trig_thresh->cur_state = trig_thresh->trip_triggered;
}
return;
}
@ -4260,8 +4267,11 @@ static void vdd_restriction_notify(struct therm_threshold *trig_thresh)
unlock_and_exit:
mutex_unlock(&vdd_rstr_mutex);
set_and_exit:
sensor_mgr_set_threshold(trig_thresh->sensor_id,
if (trig_thresh->cur_state != trig_thresh->trip_triggered) {
sensor_mgr_set_threshold(trig_thresh->sensor_id,
trig_thresh->threshold);
trig_thresh->cur_state = trig_thresh->trip_triggered;
}
return;
}
@ -4309,8 +4319,11 @@ static void ocr_notify(struct therm_threshold *trig_thresh)
unlock_and_exit:
mutex_unlock(&ocr_mutex);
set_and_exit:
sensor_mgr_set_threshold(trig_thresh->sensor_id,
trig_thresh->threshold);
if (trig_thresh->cur_state != trig_thresh->trip_triggered) {
sensor_mgr_set_threshold(trig_thresh->sensor_id,
trig_thresh->threshold);
trig_thresh->cur_state = trig_thresh->trip_triggered;
}
return;
}
@ -4654,6 +4667,7 @@ int sensor_mgr_init_threshold(struct device *dev,
thresh_ptr[i].notify = callback;
thresh_ptr[i].trip_triggered = -1;
thresh_ptr[i].parent = thresh_inp;
thresh_ptr[i].cur_state = -1;
thresh_ptr[i].threshold[0].temp =
high_temp * tsens_scaling_factor;
thresh_ptr[i].threshold[0].trip =
@ -4677,6 +4691,7 @@ int sensor_mgr_init_threshold(struct device *dev,
thresh_ptr->notify = callback;
thresh_ptr->trip_triggered = -1;
thresh_ptr->parent = thresh_inp;
thresh_ptr->cur_state = -1;
thresh_ptr->threshold[0].temp = high_temp * tsens_scaling_factor;
thresh_ptr->threshold[0].trip =
THERMAL_TRIP_CONFIGURABLE_HI;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -105,6 +105,7 @@ struct therm_threshold {
struct threshold_info *parent;
enum msm_therm_progressive_state prog_state;
bool prog_trip_clear;
int32_t cur_state;
};
struct threshold_info {