Commit d668c807 authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Eduardo Valentin

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: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Acked-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent 0cf3a1ac
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sys_soc.h>
#include <linux/thermal.h> #include <linux/thermal.h>
#include "thermal_core.h" #include "thermal_core.h"
...@@ -90,10 +91,6 @@ struct rcar_gen3_thermal_priv { ...@@ -90,10 +91,6 @@ struct rcar_gen3_thermal_priv {
struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
unsigned int num_tscs; unsigned int num_tscs;
spinlock_t lock; /* Protect interrupts on and off */ spinlock_t lock; /* Protect interrupts on and off */
const struct rcar_gen3_thermal_data *data;
};
struct rcar_gen3_thermal_data {
void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
}; };
...@@ -278,7 +275,12 @@ static irqreturn_t rcar_gen3_thermal_irq_thread(int irq, void *data) ...@@ -278,7 +275,12 @@ static irqreturn_t rcar_gen3_thermal_irq_thread(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc) static const struct soc_device_attribute r8a7795es1[] = {
{ .soc_id = "r8a7795", .revision = "ES1.*" },
{ /* sentinel */ }
};
static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc)
{ {
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); 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,7 +305,7 @@ static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
usleep_range(1000, 2000); usleep_range(1000, 2000);
} }
static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc) static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
{ {
u32 reg_val; u32 reg_val;
...@@ -324,17 +326,9 @@ static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc) ...@@ -324,17 +326,9 @@ static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
usleep_range(1000, 2000); usleep_range(1000, 2000);
} }
static const struct rcar_gen3_thermal_data r8a7795_data = {
.thermal_init = r8a7795_thermal_init,
};
static const struct rcar_gen3_thermal_data r8a7796_data = {
.thermal_init = r8a7796_thermal_init,
};
static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
{ .compatible = "renesas,r8a7795-thermal", .data = &r8a7795_data}, { .compatible = "renesas,r8a7795-thermal", },
{ .compatible = "renesas,r8a7796-thermal", .data = &r8a7796_data}, { .compatible = "renesas,r8a7796-thermal", },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids); MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
...@@ -371,7 +365,9 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) ...@@ -371,7 +365,9 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->data = of_device_get_match_data(dev); priv->thermal_init = rcar_gen3_thermal_init;
if (soc_device_match(r8a7795es1))
priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1;
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
...@@ -423,7 +419,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) ...@@ -423,7 +419,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
priv->tscs[i] = tsc; priv->tscs[i] = tsc;
priv->data->thermal_init(tsc); priv->thermal_init(tsc);
rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]); rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]);
zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, 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,7 +472,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev)
for (i = 0; i < priv->num_tscs; i++) { for (i = 0; i < priv->num_tscs; i++) {
struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
priv->data->thermal_init(tsc); priv->thermal_init(tsc);
rcar_gen3_thermal_set_trips(tsc, tsc->low, tsc->high); rcar_gen3_thermal_set_trips(tsc, tsc->low, tsc->high);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment