RE: Re : [PATCH v5 3/5] thermal: renesas: rzg3e: Add thermal driver for the Renesas RZ/G3E SoC

From: Biju Das
Date: Mon Mar 31 2025 - 14:21:29 EST


Hi Alok,

> -----Original Message-----
> From: ALOK TIWARI <alok.a.tiwari@xxxxxxxxxx>
> Sent: 31 March 2025 19:11
> Subject: Re : [PATCH v5 3/5] thermal: renesas: rzg3e: Add thermal driver for the Renesas RZ/G3E SoC
>
>
>
> On 31-03-2025 03:19, John Madieu wrote:
> > The RZ/G3E SoC integrates a Temperature Sensor Unit (TSU) block
> > designed to monitor the chip's junction temperature. This sensor is
> > connected to channel 1 of the APB port clock/reset and provides temperature measurements.
> >
> > It also requires calibration values stored in the system controller
> > registers for accurate temperature measurement. Add a driver for the Renesas RZ/G3E TSU.
> >
> > Signed-off-by: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>
> > ---
> > v1 -> v2: fixes IRQ names
> > v2 -> v3: no changes
> > v3 -> v4: no changes
> > v5: removes curly braces arround single-line protected scoped guards
> >
> > MAINTAINERS | 7 +
> > drivers/thermal/renesas/Kconfig | 7 +
> > drivers/thermal/renesas/Makefile | 1 +
> > drivers/thermal/renesas/rzg3e_thermal.c | 443 ++++++++++++++++++++++++
> > 4 files changed, 458 insertions(+)
> > create mode 100644 drivers/thermal/renesas/rzg3e_thermal.c
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS index
> > b9f7d2115b57..ba7c95146f01 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -20289,6 +20289,13 @@ S: Maintained
> > F: Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml
> > F: drivers/iio/potentiometer/x9250.c
> >
> > +RENESAS RZ/G3E THERMAL SENSOR UNIT DRIVER
> > +M: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>
> > +L: linux-pm@xxxxxxxxxxxxxxx
> > +S: Maintained
> > +F: Documentation/devicetree/bindings/thermal/renesas,r9a09g047-tsu.yaml
> > +F: drivers/thermal/renesas/rzg3e_thermal.c
> > +
> > RESET CONTROLLER FRAMEWORK
> > M: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
> > S: Maintained
> > diff --git a/drivers/thermal/renesas/Kconfig
> > b/drivers/thermal/renesas/Kconfig index dcf5fc5ae08e..10cf90fc4bfa
> > 100644
> > --- a/drivers/thermal/renesas/Kconfig
> > +++ b/drivers/thermal/renesas/Kconfig
> > @@ -26,3 +26,10 @@ config RZG2L_THERMAL
> > help
> > Enable this to plug the RZ/G2L thermal sensor driver into the Linux
> > thermal framework.
> > +
> > +config RZG3E_THERMAL
> > + tristate "Renesas RZ/G3E thermal driver"
> > + depends on ARCH_RENESAS || COMPILE_TEST
> > + help
> > + Enable this to plug the RZ/G3E thermal sensor driver into the Linux
> > + thermal framework.
> > diff --git a/drivers/thermal/renesas/Makefile
> > b/drivers/thermal/renesas/Makefile
> > index bf9cb3cb94d6..5a3eba0dedd0 100644
> > --- a/drivers/thermal/renesas/Makefile
> > +++ b/drivers/thermal/renesas/Makefile
> > @@ -3,3 +3,4 @@
> > obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o
> > obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
> > obj-$(CONFIG_RZG2L_THERMAL) += rzg2l_thermal.o
> > +obj-$(CONFIG_RZG3E_THERMAL) += rzg3e_thermal.o
> > diff --git a/drivers/thermal/renesas/rzg3e_thermal.c
> > b/drivers/thermal/renesas/rzg3e_thermal.c
> > new file mode 100644
> > index 000000000000..fe50df057b74
> > --- /dev/null
> > +++ b/drivers/thermal/renesas/rzg3e_thermal.c
> > @@ -0,0 +1,443 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Renesas RZ/G3E TSU Temperature Sensor Unit
> > + *
> > + * Copyright (C) 2025 Renesas Electronics Corporation */ #include
> > +<linux/clk.h> #include <linux/delay.h> #include <linux/err.h>
> > +#include <linux/interrupt.h> #include <linux/io.h> #include
> > +<linux/iopoll.h> #include <linux/kernel.h> #include
> > +<linux/mfd/syscon.h> #include <linux/module.h> #include
> > +<linux/of_device.h> #include <linux/platform_device.h> #include
> > +<linux/regmap.h> #include <linux/reset.h> #include <linux/thermal.h>
> > +#include <linux/units.h>
> > +
> > +#include "../thermal_hwmon.h"

<snip>
> > +static int rzg3e_thermal_change_mode(struct thermal_zone_device *tz,
> > + enum thermal_device_mode mode) {
> > + struct rzg3e_thermal_priv *priv = thermal_zone_device_priv(tz);
> > +
> > + if (mode == THERMAL_DEVICE_DISABLED)
> > + rzg3e_thermal_hw_disable(priv);
> > + else
> > + rzg3e_thermal_hw_enable(priv);
> > +
> > + priv->mode = mode;
> > + return 0;
> > +}
> > +
> always return 0 here ? what, if (!priv) return -EINVAL; ?

priv cannot be NULL as it is checked in probe().
Maybe replace static int rzg3e_thermal_change_mode->
static void rzg3e_thermal_change_mode().

Cheers,
Biju


Cheers,
Biju

>