From bf15badbff75cfbea007c5b02d016a0d22da5f5c Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Mon, 8 Jan 2018 23:22:16 +0530 Subject: [PATCH] msm: thermal: Add support to monitor only one tsens for VDD restriction Currently VDD restriction feature monitors all tsens for low temperature condition. There can be interrupt storm due to temperature oscillation between trigger and clear thresholds of all these sensors. It may lead to power issues due to frequent tsens interrupt wake up. Add support to monitor only one sensor for VDD restriction feature. It helps to configure one optimal sensor for this feature if above mentioned scenario is a concern. Add an optional devicetree property "qcom,vdd-restriction-sensor-id" to specify sensor id to monitor. If not defined, monitor all tsens for VDD restriction. Change-Id: I9a36952cbcb40ebca4de5e8357529842b2f77187 Signed-off-by: Manaf Meethalavalappu Pallikunhi --- .../devicetree/bindings/arm/msm/msm_thermal.txt | 4 ++++ drivers/thermal/msm_thermal.c | 13 ++++++++++++- include/linux/msm_thermal.h | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/msm/msm_thermal.txt b/Documentation/devicetree/bindings/arm/msm/msm_thermal.txt index c2bc68a57bc7..c99bd2f349c0 100644 --- a/Documentation/devicetree/bindings/arm/msm/msm_thermal.txt +++ b/Documentation/devicetree/bindings/arm/msm/msm_thermal.txt @@ -55,6 +55,9 @@ Optional properties key voltage rails, in degC. - qcom,vdd-restriction-temp-hysteresis: When temperature is above this threshold will disable vdd restriction on key rails, in degC. +- qcom,vdd-restriction-sensor-id: sensor id, which needs to be monitored for vdd restriction. + If this optional property is defined, msm_thermal will monitor only this + sensor, otherwise by default it will monitor all TSENS for this feature. - qcom,pmic-sw-mode-temp: Threshold temperature to disable auto mode on the rail, in degC. If this property exists, qcom,pmic-sw-mode-temp-hysteresis and @@ -273,6 +276,7 @@ Example: qcom,pmic-sw-mode-regs = "vdd-dig"; qcom,vdd-restriction-temp = <5>; qcom,vdd-restriction-temp-hysteresis = <10>; + qcom,vdd-restriction-sensor-id = <0>; vdd-dig-supply=<&pm8841_s2_floor_corner> qcom,mx-restriction-temp = <5>; qcom,mx-restriction-temp-hysteresis = <10>; diff --git a/drivers/thermal/msm_thermal.c b/drivers/thermal/msm_thermal.c index 990a4161038e..0a3ff5791488 100644 --- a/drivers/thermal/msm_thermal.c +++ b/drivers/thermal/msm_thermal.c @@ -6102,6 +6102,13 @@ static int probe_vdd_rstr(struct device_node *node, if (ret) goto read_node_fail; + /* + * Monitor only this sensor if defined, otherwise monitor all tsens + */ + key = "qcom,vdd-restriction-sensor-id"; + if (of_property_read_u32(node, key, &data->vdd_rstr_sensor_id)) + data->vdd_rstr_sensor_id = MONITOR_ALL_TSENS; + for_each_child_of_node(node, child_node) { rails_cnt++; } @@ -6174,7 +6181,7 @@ static int probe_vdd_rstr(struct device_node *node, goto read_node_fail; } ret = sensor_mgr_init_threshold(&thresh[MSM_VDD_RESTRICTION], - MONITOR_ALL_TSENS, + data->vdd_rstr_sensor_id, data->vdd_rstr_temp_hyst_degC, data->vdd_rstr_temp_degC, vdd_restriction_notify); if (ret) { @@ -7110,6 +7117,10 @@ static void thermal_vdd_config_read(struct seq_file *m, void *data) msm_thermal_info.vdd_rstr_temp_degC); seq_printf(m, "threshold clear:%d degC\n", msm_thermal_info.vdd_rstr_temp_hyst_degC); + if (msm_thermal_info.vdd_rstr_sensor_id != MONITOR_ALL_TSENS) + seq_printf(m, "tsens sensor:tsens_tz_sensor%d\n", + msm_thermal_info.vdd_rstr_sensor_id); + for (i = 0; i < rails_cnt; i++) { if (!strcmp(rails[i].name, "vdd-dig") && rails[i].num_levels) diff --git a/include/linux/msm_thermal.h b/include/linux/msm_thermal.h index 33286c2d81fc..1098a0c9afaa 100644 --- a/include/linux/msm_thermal.h +++ b/include/linux/msm_thermal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2016,2018, 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 @@ -54,6 +54,7 @@ struct msm_thermal_data { uint32_t freq_limit; int32_t vdd_rstr_temp_degC; int32_t vdd_rstr_temp_hyst_degC; + int32_t vdd_rstr_sensor_id; int32_t vdd_mx_min; int32_t vdd_cx_min; int32_t psm_temp_degC;