diff options
author | Ram Chandrasekar <rkumbako@codeaurora.org> | 2017-01-13 11:54:28 -0700 |
---|---|---|
committer | Ram Chandrasekar <rkumbako@codeaurora.org> | 2017-01-16 10:33:00 -0700 |
commit | 823b91650d883c89459e3015c717fdcc8fa597d2 (patch) | |
tree | 19b1c63fe56bba489c346126f13bcbe34c6ae399 /drivers | |
parent | 8bd88623ccc8149ca2b1ce657a8c1c867bbe8353 (diff) |
drivers: thermal: lmh_dcvs: Update Low threshold with high threshold
LMH DCVS driver doesn't change the low threshold from HLOS. When there is
new request to lower the high threshold, the low threshold will be
modified if the new high threshold is lower than the existing low
threshold. But the low threshold is not increased when the high
threshold is moved back again.
Update the LMH DCVSh driver to always update the low threshold value
when there is a new high threshold request. The new low threshold will
be 0.5C less than the high threshold.
Change-Id: I356e47de585ae81bd27859f790f673b31ae5ba72
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/msm_lmh_dcvs.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/drivers/thermal/msm_lmh_dcvs.c b/drivers/thermal/msm_lmh_dcvs.c index ac1da854ab32..7758750516f8 100644 --- a/drivers/thermal/msm_lmh_dcvs.c +++ b/drivers/thermal/msm_lmh_dcvs.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2017, 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 @@ -48,6 +48,7 @@ #define MSM_LIMITS_ALGO_MODE_ENABLE 0x454E424C #define MSM_LIMITS_HI_THRESHOLD 0x48494748 +#define MSM_LIMITS_LOW_THRESHOLD 0x4C4F5700 #define MSM_LIMITS_ARM_THRESHOLD 0x41524D00 #define MSM_LIMITS_CLUSTER_0 0x6370302D @@ -57,6 +58,7 @@ #define MSM_LIMITS_HIGH_THRESHOLD_VAL 95000 #define MSM_LIMITS_ARM_THRESHOLD_VAL 65000 +#define MSM_LIMITS_LOW_THRESHOLD_OFFSET 500 #define MSM_LIMITS_POLLING_DELAY_MS 10 #define MSM_LIMITS_CLUSTER_0_REQ 0x179C1B04 #define MSM_LIMITS_CLUSTER_1_REQ 0x179C3B04 @@ -227,7 +229,8 @@ static int lmh_activate_trip(struct thermal_zone_device *dev, int trip, enum thermal_trip_activation_mode mode) { struct msm_lmh_dcvs_hw *hw = dev->devdata; - uint32_t enable, temp, thresh; + uint32_t enable, temp; + int ret = 0; enable = (mode == THERMAL_TRIP_ACTIVATION_ENABLED) ? 1 : 0; if (!enable) { @@ -240,12 +243,35 @@ static int lmh_activate_trip(struct thermal_zone_device *dev, hw->temp_limits[LIMITS_TRIP_HI]) return -EINVAL; - thresh = (trip == LIMITS_TRIP_LO) ? MSM_LIMITS_ARM_THRESHOLD : - MSM_LIMITS_HI_THRESHOLD; temp = hw->temp_limits[trip]; + switch (trip) { + case LIMITS_TRIP_LO: + ret = msm_lmh_dcvs_write(hw->affinity, + MSM_LIMITS_SUB_FN_THERMAL, + MSM_LIMITS_ARM_THRESHOLD, temp); + break; + case LIMITS_TRIP_HI: + /* + * The high threshold should be atleast greater than the + * low threshold offset + */ + if (temp < MSM_LIMITS_LOW_THRESHOLD_OFFSET) + return -EINVAL; + ret = msm_lmh_dcvs_write(hw->affinity, + MSM_LIMITS_SUB_FN_THERMAL, + MSM_LIMITS_HI_THRESHOLD, temp); + if (ret) + break; + ret = msm_lmh_dcvs_write(hw->affinity, + MSM_LIMITS_SUB_FN_THERMAL, + MSM_LIMITS_LOW_THRESHOLD, temp - + MSM_LIMITS_LOW_THRESHOLD_OFFSET); + break; + default: + return -EINVAL; + } - return msm_lmh_dcvs_write(hw->affinity, MSM_LIMITS_SUB_FN_THERMAL, - thresh, temp); + return ret; } static int lmh_get_trip_temp(struct thermal_zone_device *dev, |