aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2018-04-16 06:11:52 -0400
committerEduardo Valentin <edubezval@gmail.com>2018-04-27 09:17:30 -0400
commit88fc6f73fddf64eb507b04f7b2bd01d7291db514 (patch)
treecd81900d41dddba5ec2186798c1d02fdb3251a60
parent6d08b06e67cd117f6992c46611dfb4ce267cd71e (diff)
thermal: exynos: Reading temperature makes sense only when TMU is turned on
When thermal sensor is not yet enabled, reading temperature might return random value. This might even result in stopping system booting when such temperature is higher than the critical value. Fix this by checking if TMU has been actually enabled before reading the temperature. This change fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Fixes: 9e4249b40340 ("thermal: exynos: Fix first temperature read after registering sensor") CC: stable@vger.kernel.org # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ed805c7c5ace..986cbd01aaaa 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -185,6 +185,7 @@
185 * @regulator: pointer to the TMU regulator structure. 185 * @regulator: pointer to the TMU regulator structure.
186 * @reg_conf: pointer to structure to register with core thermal. 186 * @reg_conf: pointer to structure to register with core thermal.
187 * @ntrip: number of supported trip points. 187 * @ntrip: number of supported trip points.
188 * @enabled: current status of TMU device
188 * @tmu_initialize: SoC specific TMU initialization method 189 * @tmu_initialize: SoC specific TMU initialization method
189 * @tmu_control: SoC specific TMU control method 190 * @tmu_control: SoC specific TMU control method
190 * @tmu_read: SoC specific TMU temperature read method 191 * @tmu_read: SoC specific TMU temperature read method
@@ -205,6 +206,7 @@ struct exynos_tmu_data {
205 struct regulator *regulator; 206 struct regulator *regulator;
206 struct thermal_zone_device *tzd; 207 struct thermal_zone_device *tzd;
207 unsigned int ntrip; 208 unsigned int ntrip;
209 bool enabled;
208 210
209 int (*tmu_initialize)(struct platform_device *pdev); 211 int (*tmu_initialize)(struct platform_device *pdev);
210 void (*tmu_control)(struct platform_device *pdev, bool on); 212 void (*tmu_control)(struct platform_device *pdev, bool on);
@@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
398 mutex_lock(&data->lock); 400 mutex_lock(&data->lock);
399 clk_enable(data->clk); 401 clk_enable(data->clk);
400 data->tmu_control(pdev, on); 402 data->tmu_control(pdev, on);
403 data->enabled = on;
401 clk_disable(data->clk); 404 clk_disable(data->clk);
402 mutex_unlock(&data->lock); 405 mutex_unlock(&data->lock);
403} 406}
@@ -890,7 +893,7 @@ static int exynos_get_temp(void *p, int *temp)
890{ 893{
891 struct exynos_tmu_data *data = p; 894 struct exynos_tmu_data *data = p;
892 895
893 if (!data || !data->tmu_read) 896 if (!data || !data->tmu_read || !data->enabled)
894 return -EINVAL; 897 return -EINVAL;
895 898
896 mutex_lock(&data->lock); 899 mutex_lock(&data->lock);