thermal/drivers/renesas/rzg3s: Convert calibration defaults to per-SoC match data

Move the default (software) calibration values SW_CALIB0_VAL and
SW_CALIB1_VAL, used when FUSE values are missing, into a new
struct rzg3s_thermal_info retrieved via of_device_get_match_data().

This allows different SoCs sharing this driver to provide their own
default calibration constants, which is needed as RZ/G3L uses
different values than RZ/G3S.

No functional change intended for RZ/G3S.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260925061617.127349-3-biju.das.jz@bp.renesas.com
This commit is contained in:
Biju Das 2026-09-25 07:16:00 +01:00 committed by Daniel Lezcano
parent 6b7f5abb48
commit 91e5a33675

View File

@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/reset.h>
#include <linux/thermal.h>
#include <linux/units.h>
@ -27,10 +28,6 @@
#define TSU_READ_STEPS 8
/* Default calibration values, if FUSE values are missing. */
#define SW_CALIB0_VAL 1297
#define SW_CALIB1_VAL 751
#define MCELSIUS(temp) ((temp) * MILLIDEGREE_PER_DEGREE)
/**
@ -55,6 +52,16 @@ struct rzg3s_thermal_priv {
u16 calib1;
};
/**
* struct rzg3s_thermal_info - RZ/G3S thermal information
* @calib0: calibration value if FUSE value is missing
* @calib1: calibration value if FUSE value is missing
*/
struct rzg3s_thermal_info {
u16 calib0;
u16 calib1;
};
static int rzg3s_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
struct rzg3s_thermal_priv *priv = thermal_zone_device_priv(tz);
@ -149,7 +156,8 @@ static const struct thermal_zone_device_ops rzg3s_tz_of_ops = {
.change_mode = rzg3s_thermal_change_mode,
};
static int rzg3s_thermal_read_calib(struct rzg3s_thermal_priv *priv)
static int rzg3s_thermal_read_calib(struct rzg3s_thermal_priv *priv,
const struct rzg3s_thermal_info *info)
{
struct device *dev = priv->dev;
u32 val;
@ -163,13 +171,13 @@ static int rzg3s_thermal_read_calib(struct rzg3s_thermal_priv *priv)
if (val & OTPTSUTRIM_EN_MASK)
priv->calib0 = FIELD_GET(OTPTSUTRIM_MASK, val);
else
priv->calib0 = SW_CALIB0_VAL;
priv->calib0 = info->calib0;
val = readl(priv->base + OTPTSUTRIM_REG(1));
if (val & OTPTSUTRIM_EN_MASK)
priv->calib1 = FIELD_GET(OTPTSUTRIM_MASK, val);
else
priv->calib1 = SW_CALIB1_VAL;
priv->calib1 = info->calib1;
pm_runtime_put_autosuspend(dev);
@ -178,6 +186,7 @@ static int rzg3s_thermal_read_calib(struct rzg3s_thermal_priv *priv)
static int rzg3s_thermal_probe(struct platform_device *pdev)
{
const struct rzg3s_thermal_info *info = device_get_match_data(&pdev->dev);
struct rzg3s_thermal_priv *priv;
struct device *dev = &pdev->dev;
int ret;
@ -208,7 +217,7 @@ static int rzg3s_thermal_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "Failed to enable runtime PM!\n");
ret = rzg3s_thermal_read_calib(priv);
ret = rzg3s_thermal_read_calib(priv, info);
if (ret)
return dev_err_probe(dev, ret, "Failed to read calibration data!\n");
@ -251,8 +260,13 @@ static const struct dev_pm_ops rzg3s_thermal_pm_ops = {
SYSTEM_SLEEP_PM_OPS(rzg3s_thermal_suspend, rzg3s_thermal_resume)
};
static const struct rzg3s_thermal_info rzg3s_info = {
.calib0 = 1297,
.calib1 = 751,
};
static const struct of_device_id rzg3s_thermal_dt_ids[] = {
{ .compatible = "renesas,r9a08g045-tsu" },
{ .compatible = "renesas,r9a08g045-tsu", .data = &rzg3s_info },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, rzg3s_thermal_dt_ids);