aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>2017-10-17 07:36:13 -0400
committerEduardo Valentin <edubezval@gmail.com>2017-10-31 22:32:14 -0400
commitd668c807aa6ef3c3eef57b4e9e785ec0cfab4f6d (patch)
tree44110a20b5cc4ae254652ac2992195e916550da4
parent0cf3a1ac3e10a5920531e38cf2ae99fa1e4d45a2 (diff)
thermal: rcar_gen3_thermal: fix initialization sequence for H3 ES2.0
The initialization sequence for H3 (r8a7795) ES1.x and ES2.0 is different. H3 ES2.0 and later uses the same sequence as M3 (r8a7796) ES1.0. Fix this by not looking at compatible strings and instead defaulting to the r8a7796 initialization sequence and use soc_device_match() to check for H3 ES1.x. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r--drivers/thermal/rcar_gen3_thermal.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
index 203aca44a2bb..561a0a332208 100644
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -24,6 +24,7 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/sys_soc.h>
27#include <linux/thermal.h> 28#include <linux/thermal.h>
28 29
29#include "thermal_core.h" 30#include "thermal_core.h"
@@ -90,10 +91,6 @@ struct rcar_gen3_thermal_priv {
90 struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; 91 struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
91 unsigned int num_tscs; 92 unsigned int num_tscs;
92 spinlock_t lock; /* Protect interrupts on and off */ 93 spinlock_t lock; /* Protect interrupts on and off */
93 const struct rcar_gen3_thermal_data *data;
94};
95
96struct rcar_gen3_thermal_data {
97 void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); 94 void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
98}; 95};
99 96
@@ -278,7 +275,12 @@ static irqreturn_t rcar_gen3_thermal_irq_thread(int irq, void *data)
278 return IRQ_HANDLED; 275 return IRQ_HANDLED;
279} 276}
280 277
281static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc) 278static const struct soc_device_attribute r8a7795es1[] = {
279 { .soc_id = "r8a7795", .revision = "ES1.*" },
280 { /* sentinel */ }
281};
282
283static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc)
282{ 284{
283 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); 285 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
284 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); 286 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0);
@@ -303,7 +305,7 @@ static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
303 usleep_range(1000, 2000); 305 usleep_range(1000, 2000);
304} 306}
305 307
306static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc) 308static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
307{ 309{
308 u32 reg_val; 310 u32 reg_val;
309 311
@@ -324,17 +326,9 @@ static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
324 usleep_range(1000, 2000); 326 usleep_range(1000, 2000);
325} 327}
326 328
327static const struct rcar_gen3_thermal_data r8a7795_data = {
328 .thermal_init = r8a7795_thermal_init,
329};
330
331static const struct rcar_gen3_thermal_data r8a7796_data = {
332 .thermal_init = r8a7796_thermal_init,
333};
334
335static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { 329static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
336 { .compatible = "renesas,r8a7795-thermal", .data = &r8a7795_data}, 330 { .compatible = "renesas,r8a7795-thermal", },
337 { .compatible = "renesas,r8a7796-thermal", .data = &r8a7796_data}, 331 { .compatible = "renesas,r8a7796-thermal", },
338 {}, 332 {},
339}; 333};
340MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids); 334MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
@@ -371,7 +365,9 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
371 if (!priv) 365 if (!priv)
372 return -ENOMEM; 366 return -ENOMEM;
373 367
374 priv->data = of_device_get_match_data(dev); 368 priv->thermal_init = rcar_gen3_thermal_init;
369 if (soc_device_match(r8a7795es1))
370 priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1;
375 371
376 spin_lock_init(&priv->lock); 372 spin_lock_init(&priv->lock);
377 373
@@ -423,7 +419,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
423 419
424 priv->tscs[i] = tsc; 420 priv->tscs[i] = tsc;
425 421
426 priv->data->thermal_init(tsc); 422 priv->thermal_init(tsc);
427 rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]); 423 rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]);
428 424
429 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, 425 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
@@ -476,7 +472,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev)
476 for (i = 0; i < priv->num_tscs; i++) { 472 for (i = 0; i < priv->num_tscs; i++) {
477 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; 473 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
478 474
479 priv->data->thermal_init(tsc); 475 priv->thermal_init(tsc);
480 rcar_gen3_thermal_set_trips(tsc, tsc->low, tsc->high); 476 rcar_gen3_thermal_set_trips(tsc, tsc->low, tsc->high);
481 } 477 }
482 478