Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eb3c5a2 authored by Manaf Meethalavalappu Pallikunhi's avatar Manaf Meethalavalappu Pallikunhi
Browse files

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: default avatarManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
parent 55cb63cb
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -5166,10 +5166,16 @@ static void tsens_threshold_notify(struct therm_threshold *tsens_cb_data)
		break;
	}

	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);
			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)
+21 −6
Original line number Diff line number Diff line
/* 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
@@ -2695,8 +2695,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);

	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)
@@ -4065,8 +4069,11 @@ static void cx_phase_ctrl_notify(struct therm_threshold *trig_thresh)
cx_phase_unlock_exit:
	mutex_unlock(&cx_mutex);
cx_phase_ctrl_exit:
	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;
}

@@ -4194,8 +4201,11 @@ static void vdd_restriction_notify(struct therm_threshold *trig_thresh)
unlock_and_exit:
	mutex_unlock(&vdd_rstr_mutex);
set_and_exit:
	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;
}

@@ -4243,8 +4253,11 @@ static void ocr_notify(struct therm_threshold *trig_thresh)
unlock_and_exit:
	mutex_unlock(&ocr_mutex);
set_and_exit:
	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;
}

@@ -4479,6 +4492,7 @@ int sensor_mgr_init_threshold(struct threshold_info *thresh_inp,
			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 =
@@ -4499,6 +4513,7 @@ int sensor_mgr_init_threshold(struct threshold_info *thresh_inp,
		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;
+2 −1
Original line number Diff line number Diff line
/*
 * 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
@@ -91,6 +91,7 @@ struct therm_threshold {
	int32_t                     trip_triggered;
	void (*notify)(struct therm_threshold *);
	struct threshold_info       *parent;
	int32_t                     cur_state;
};

struct threshold_info {