2023-05-11 19:36:24

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH RFT v3 0/3] drivers/thermal/rcar_gen3_thermal: add Gen4 fuse support

R-Car Gen4 has the fuse registers at different locations and with
different names, but with the same purpose. So, first refactor IP core
differences into a 'info' struct, then add the fuse_read callback to it.

Changes since RFT v2:
* In patch 3, I mixed up the PTAT and THCODE registers. Fixed now.
(Thanks, Shimoda-san!)
* patches are rebased to 6.4-rc1

They have been tested on R-Car H3 ES2.0 and M3-N against regressions.
Actual testing of the new fuses on Gen4 still needs to be done because I
don't have access to such HW.

@Shimoda-san: maybe the BSP team or Test team can test these patches?
A branch for testing can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/for-thermal

Looking forward to other review comments, too, of course.

Happy hacking,

Wolfram


Wolfram Sang (3):
drivers/thermal/rcar_gen3_thermal: introduce 'info' structure
drivers/thermal/rcar_gen3_thermal: refactor reading fuses into
seprarate function
drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4

drivers/thermal/rcar_gen3_thermal.c | 141 ++++++++++++++++++++--------
1 file changed, 102 insertions(+), 39 deletions(-)

--
2.35.1



2023-05-11 19:38:17

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH RFT v3 3/3] drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4

The registers are differently named and at different offsets, but their
functionality is the same as for Gen3.

Signed-off-by: Wolfram Sang <[email protected]>
Reviewed-by: Niklas Söderlund <[email protected]>
---
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..9029d01e029b 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_THSFMON16) &
+ GEN4_FUSE_MASK;
+ priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON17) &
+ GEN4_FUSE_MASK;
+ priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON15) &
+ GEN4_FUSE_MASK;
+
+ 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_THSFMON01) &
+ GEN4_FUSE_MASK;
+ tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON02) &
+ GEN4_FUSE_MASK;
+ tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON00) &
+ GEN4_FUSE_MASK;
+ }
+}
+
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.35.1


2023-05-12 12:28:16

by Yoshihiro Shimoda

[permalink] [raw]
Subject: RE: [PATCH RFT v3 0/3] drivers/thermal/rcar_gen3_thermal: add Gen4 fuse support

Hello Wolfram-san,

> From: Wolfram Sang, Sent: Friday, May 12, 2023 4:22 AM
>
> R-Car Gen4 has the fuse registers at different locations and with
> different names, but with the same purpose. So, first refactor IP core
> differences into a 'info' struct, then add the fuse_read callback to it.
>
> Changes since RFT v2:
> * In patch 3, I mixed up the PTAT and THCODE registers. Fixed now.
> (Thanks, Shimoda-san!)
> * patches are rebased to 6.4-rc1
>
> They have been tested on R-Car H3 ES2.0 and M3-N against regressions.
> Actual testing of the new fuses on Gen4 still needs to be done because I
> don't have access to such HW.
>
> @Shimoda-san: maybe the BSP team or Test team can test these patches?
> A branch for testing can be found here:
> git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/for-thermal
>
> Looking forward to other review comments, too, of course.

Thank you for the patches!
I checked the patches. So:

Reviewed-by: Yoshihiro Shimoda <[email protected]>

And, I tested on R-Car H3 ES3.0 and R-Car S4 and it worked. So,

Tested-by: Yoshihiro Shimoda <[email protected]>

Best regards,
Yoshihiro Shimoda

> Happy hacking,
>
> Wolfram
>
>
> Wolfram Sang (3):
> drivers/thermal/rcar_gen3_thermal: introduce 'info' structure
> drivers/thermal/rcar_gen3_thermal: refactor reading fuses into
> seprarate function
> drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4
>
> drivers/thermal/rcar_gen3_thermal.c | 141 ++++++++++++++++++++--------
> 1 file changed, 102 insertions(+), 39 deletions(-)
>
> --
> 2.35.1

2023-05-12 12:51:35

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH RFT v3 0/3] drivers/thermal/rcar_gen3_thermal: add Gen4 fuse support


> Thank you for the patches!
> I checked the patches. So:
>
> Reviewed-by: Yoshihiro Shimoda <[email protected]>
>
> And, I tested on R-Car H3 ES3.0 and R-Car S4 and it worked. So,
>
> Tested-by: Yoshihiro Shimoda <[email protected]>

Awesome, thank you Shimoda-san!


Attachments:
(No filename) (314.00 B)
signature.asc (849.00 B)
Download all attachments

2023-06-05 14:50:19

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH RFT v3 0/3] drivers/thermal/rcar_gen3_thermal: add Gen4 fuse support

On 12/05/2023 14:39, Wolfram Sang wrote:
>
>> Thank you for the patches!
>> I checked the patches. So:
>>
>> Reviewed-by: Yoshihiro Shimoda <[email protected]>
>>
>> And, I tested on R-Car H3 ES3.0 and R-Car S4 and it worked. So,
>>
>> Tested-by: Yoshihiro Shimoda <[email protected]>
>
> Awesome, thank you Shimoda-san!

Applied, thanks


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog