Skip to content

Commit 6c7f87f

Browse files
Demon000dlezcano
authored andcommitted
thermal: renesas: rzg3e: make min and max temperature per-chip
The Renesas RZ/T2H (R9A09G077) and RZ/N2H (R9A09G087) SoCs have different minimum and maximum temperatures compared to the already supported RZ/G3E. Prepare for them by moving these into a chip-specific struct. Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: John Madieu <john.madieu.xa@bp.renesas.com> Tested-by: John Madieu <john.madieu.xa@bp.renesas.com> Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com> Link: https://patch.msgid.link/20260108195223.193531-3-cosmin-gabriel.tanislav.xa@renesas.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 671d315 commit 6c7f87f

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

drivers/thermal/renesas/rzg3e_thermal.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
#define TSU_SICR_CMPCLR BIT(1)
6363

6464
/* Temperature calculation constants from datasheet */
65-
#define TSU_TEMP_D (-41)
66-
#define TSU_TEMP_E 126
6765
#define TSU_CODE_MAX 0xFFF
6866

6967
/* Timing specifications from datasheet */
@@ -72,13 +70,19 @@
7270
#define TSU_POLL_DELAY_US 10 /* Polling interval */
7371
#define TSU_MIN_CLOCK_RATE 24000000 /* TSU_PCLK minimum 24MHz */
7472

73+
struct rzg3e_thermal_info {
74+
int temp_d_mc;
75+
int temp_e_mc;
76+
};
77+
7578
/**
7679
* struct rzg3e_thermal_priv - RZ/G3E TSU private data
7780
* @base: TSU register base
7881
* @dev: device pointer
7982
* @syscon: regmap for calibration values
8083
* @zone: thermal zone device
8184
* @rstc: reset control
85+
* @info: chip type specific information
8286
* @trmval0: calibration value 0 (b)
8387
* @trmval1: calibration value 1 (c)
8488
* @trim_offset: offset for trim registers in syscon
@@ -90,6 +94,7 @@ struct rzg3e_thermal_priv {
9094
struct regmap *syscon;
9195
struct thermal_zone_device *zone;
9296
struct reset_control *rstc;
97+
const struct rzg3e_thermal_info *info;
9398
u16 trmval0;
9499
u16 trmval1;
95100
u32 trim_offset;
@@ -161,17 +166,17 @@ static void rzg3e_thermal_power_off(struct rzg3e_thermal_priv *priv)
161166
*/
162167
static int rzg3e_thermal_code_to_temp(struct rzg3e_thermal_priv *priv, u16 code)
163168
{
164-
int temp_e_mc = TSU_TEMP_E * MILLIDEGREE_PER_DEGREE;
165-
int temp_d_mc = TSU_TEMP_D * MILLIDEGREE_PER_DEGREE;
169+
const struct rzg3e_thermal_info *info = priv->info;
166170
s64 numerator, denominator;
167171
int temp_mc;
168172

169-
numerator = (temp_e_mc - temp_d_mc) * (s64)(code - priv->trmval0);
173+
numerator = (info->temp_e_mc - info->temp_d_mc) *
174+
(s64)(code - priv->trmval0);
170175
denominator = priv->trmval1 - priv->trmval0;
171176

172-
temp_mc = div64_s64(numerator, denominator) + temp_d_mc;
177+
temp_mc = div64_s64(numerator, denominator) + info->temp_d_mc;
173178

174-
return clamp(temp_mc, temp_d_mc, temp_e_mc);
179+
return clamp(temp_mc, info->temp_d_mc, info->temp_e_mc);
175180
}
176181

177182
/*
@@ -180,13 +185,12 @@ static int rzg3e_thermal_code_to_temp(struct rzg3e_thermal_priv *priv, u16 code)
180185
*/
181186
static u16 rzg3e_thermal_temp_to_code(struct rzg3e_thermal_priv *priv, int temp_mc)
182187
{
183-
int temp_e_mc = TSU_TEMP_E * MILLIDEGREE_PER_DEGREE;
184-
int temp_d_mc = TSU_TEMP_D * MILLIDEGREE_PER_DEGREE;
188+
const struct rzg3e_thermal_info *info = priv->info;
185189
s64 numerator, denominator;
186190
s64 code;
187191

188-
numerator = (temp_mc - temp_d_mc) * (priv->trmval1 - priv->trmval0);
189-
denominator = temp_e_mc - temp_d_mc;
192+
numerator = (temp_mc - info->temp_d_mc) * (priv->trmval1 - priv->trmval0);
193+
denominator = info->temp_e_mc - info->temp_d_mc;
190194

191195
code = div64_s64(numerator, denominator) + priv->trmval0;
192196

@@ -392,6 +396,8 @@ static int rzg3e_thermal_probe(struct platform_device *pdev)
392396
return ret;
393397
platform_set_drvdata(pdev, priv);
394398

399+
priv->info = device_get_match_data(dev);
400+
395401
priv->base = devm_platform_ioremap_resource(pdev, 0);
396402
if (IS_ERR(priv->base))
397403
return PTR_ERR(priv->base);
@@ -526,8 +532,13 @@ static const struct dev_pm_ops rzg3e_thermal_pm_ops = {
526532
SYSTEM_SLEEP_PM_OPS(rzg3e_thermal_suspend, rzg3e_thermal_resume)
527533
};
528534

535+
static const struct rzg3e_thermal_info rzg3e_thermal_info = {
536+
.temp_d_mc = -41000,
537+
.temp_e_mc = 126000,
538+
};
539+
529540
static const struct of_device_id rzg3e_thermal_dt_ids[] = {
530-
{ .compatible = "renesas,r9a09g047-tsu" },
541+
{ .compatible = "renesas,r9a09g047-tsu", .data = &rzg3e_thermal_info },
531542
{ /* sentinel */ }
532543
};
533544
MODULE_DEVICE_TABLE(of, rzg3e_thermal_dt_ids);

0 commit comments

Comments
 (0)