mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Cc: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Daniel Lezcano" <daniel.lezcano@linaro.org>,
	"Amit Kucheria" <amitk@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH RFT v2 3/3] drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4
Date: Fri, 21 Apr 2023 08:02:27 +0000	[thread overview]
Message-ID: <TYBPR01MB53413B97CCBAC486C2CF7085D8609@TYBPR01MB5341.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20230420092128.6073-4-wsa+renesas@sang-engineering.com>

Hello Wolfram-san,

> From: Wolfram Sang, Sent: Thursday, April 20, 2023 6:21 PM
> 
> The registers are differently named and at different offsets, but their
> functionality is the same as for Gen3.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Thank you for the patch!

> ---
>  drivers/thermal/rcar_gen3_thermal.c | 44 +++++++++++++++++++++++++++--
>  1 file changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
> index 39b382ee08c8..e01e27903e44 100644
> --- a/drivers/thermal/rcar_gen3_thermal.c
> +++ b/drivers/thermal/rcar_gen3_thermal.c
> @@ -35,6 +35,12 @@
>  #define REG_GEN3_PTAT2		0x60
>  #define REG_GEN3_PTAT3		0x64
>  #define REG_GEN3_THSCP		0x68
> +#define REG_GEN4_THSFMON00	0x180
> +#define REG_GEN4_THSFMON01	0x184
> +#define REG_GEN4_THSFMON02	0x188
> +#define REG_GEN4_THSFMON15	0x1BC
> +#define REG_GEN4_THSFMON16	0x1C0
> +#define REG_GEN4_THSFMON17	0x1C4
> 
>  /* IRQ{STR,MSK,EN} bits */
>  #define IRQ_TEMP1		BIT(0)
> @@ -55,6 +61,7 @@
> 
>  #define MCELSIUS(temp)	((temp) * 1000)
>  #define GEN3_FUSE_MASK	0xFFF
> +#define GEN4_FUSE_MASK	0xFFF
> 
>  #define TSC_MAX_NUM	5
> 
> @@ -272,6 +279,34 @@ static void rcar_gen3_thermal_read_fuses_gen3(struct rcar_gen3_thermal_priv *pri
>  	}
>  }
> 
> +static void rcar_gen3_thermal_read_fuses_gen4(struct rcar_gen3_thermal_priv *priv)
> +{
> +	unsigned int i;
> +
> +	/*
> +	 * Set the pseudo calibration points with fused values.
> +	 * PTAT is shared between all TSCs but only fused for the first
> +	 * TSC while THCODEs are fused for each TSC.
> +	 */
> +	priv->ptat[0] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON01) &
> +		GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON01/REG_GEN4_THSFMON16/

According to the table in 13.3.3.4 of R-Car {S4,V4H} Hardware manuals:

PTAT1	PTAT_PF_U_SR1 bits (of THSFMON16 register)
PTAT2	PTAT_PF_R_SR1 bits (of THSFMON17 register)
PTAT3	PTAT_PF_L_SR1 bits (of THSFMON15 register)
THCODE1	THCODE_U_SR1 bits (of THSFMON01 register)
THCODE2	THCODE_R_SR1 bits (of THSFMON02 register)
THCODE3	THCODE_L_SR1 bits (of THSFMON00 register)

Otherwise, calculated the temperature value was incorrect.

> +	priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON02) &
> +		GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON02/THSFMON17/

> +	priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON00) &
> +		GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON00/THSFMON15/

> +
> +	for (i = 0; i < priv->num_tscs; i++) {
> +		struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
> +
> +		tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON16) &
> +			GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON16/THSFMON01/

> +		tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON17) &
> +			GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON17/THSFMON02/

> +		tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON15) &
> +			GEN4_FUSE_MASK;

s/REG_GEN4_THSFMON15/THSFMON00/

Best regards,
Yoshihiro Shimoda

> +	}
> +}
> +
>  static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv)
>  {
>  	unsigned int i;
> @@ -343,6 +378,11 @@ static const struct rcar_thermal_info rcar_gen3_thermal_info = {
>  	.read_fuses = rcar_gen3_thermal_read_fuses_gen3,
>  };
> 
> +static const struct rcar_thermal_info rcar_gen4_thermal_info = {
> +	.ths_tj_1 = 126,
> +	.read_fuses = rcar_gen3_thermal_read_fuses_gen4,
> +};
> +
>  static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
>  	{
>  		.compatible = "renesas,r8a774a1-thermal",
> @@ -382,11 +422,11 @@ static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
>  	},
>  	{
>  		.compatible = "renesas,r8a779f0-thermal",
> -		.data = &rcar_gen3_thermal_info,
> +		.data = &rcar_gen4_thermal_info,
>  	},
>  	{
>  		.compatible = "renesas,r8a779g0-thermal",
> -		.data = &rcar_gen3_thermal_info,
> +		.data = &rcar_gen4_thermal_info,
>  	},
>  	{},
>  };
> --
> 2.30.2


  reply	other threads:[~2023-04-21  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20  9:21 [PATCH RFT v2 0/3] drivers/thermal/rcar_gen3_thermal: add Gen4 fuse support Wolfram Sang
2023-04-20  9:21 ` [PATCH RFT v2 1/3] drivers/thermal/rcar_gen3_thermal: introduce 'info' structure Wolfram Sang
2023-04-20  9:21 ` [PATCH RFT v2 2/3] drivers/thermal/rcar_gen3_thermal: refactor reading fuses into seprarate function Wolfram Sang
2023-04-20  9:21 ` [PATCH RFT v2 3/3] drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4 Wolfram Sang
2023-04-21  8:02   ` Yoshihiro Shimoda [this message]
2023-05-11 19:12     ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TYBPR01MB53413B97CCBAC486C2CF7085D8609@TYBPR01MB5341.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®