ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Maksim Kiselev <bigunclemax@gmail.com>
Cc: Martin Botka <martin.botka@somainline.org>,
	Vasily Khoruzhick <anarsoul@gmail.com>,
	Yangtao Li <tiny.windzz@gmail.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>, Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	linux-pm@vger.kernel.org (open list:ALLWINNER THERMAL DRIVER),
	linux-arm-kernel@lists.infradead.org (moderated
	list:ARM/Allwinner sunXi SoC support),
	linux-sunxi@lists.linux.dev (open list:ARM/Allwinner sunXi SoC
	support), linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH v1] thermal: sun8i: extend H6 calibration function to support 4 sensors
Date: Mon, 18 Dec 2023 11:14:04 +0000	[thread overview]
Message-ID: <20231218111404.5f08a4c4@donnerap.manchester.arm.com> (raw)
In-Reply-To: <20231217133637.54773-1-bigunclemax@gmail.com>

On Sun, 17 Dec 2023 16:36:36 +0300
Maksim Kiselev <bigunclemax@gmail.com> wrote:

Hi Maksim,

many thanks for sending this!

> The H616 SoC resembles the H6 thermal sensor controller, with a few
> changes like four sensors.
> 
> Extend sun50i_h6_ths_calibrate() function to support calibration of
> these sensors.

Oh wow, I didn't expect that, but it's indeed that simple: we just need to
cater for the 4th sensor's data to be cramped into the other bits, the
rest is exactly the same! Well spotted!

> Signed-off-by: Martin Botka <martin.botka@somainline.org>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

I don't think the Signed-off-by:s are accurate here. Please replace those
two with just:
Co-developed-by: Martin Botka <martin.botka@somainline.org>
(I didn't really do anything in those parts)

> Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com>

I compared the two routines and came to the same solution as you, so:

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

I will incorporate this patch into the next submission of the H616 THS
series, so there is no need to merge this patch as is.

Cheers,
Andre

> ---
>  drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
> index f989b55a8aa8..9af95b4785be 100644
> --- a/drivers/thermal/sun8i_thermal.c
> +++ b/drivers/thermal/sun8i_thermal.c
> @@ -221,16 +221,21 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
>  	struct device *dev = tmdev->dev;
>  	int i, ft_temp;
>  
> -	if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num)
> +	if (!caldata[0])
>  		return -EINVAL;
>  
>  	/*
>  	 * efuse layout:
>  	 *
> -	 *	0   11  16	 32
> -	 *	+-------+-------+-------+
> -	 *	|temp|  |sensor0|sensor1|
> -	 *	+-------+-------+-------+
> +	 * 0      11  16     27   32     43   48    57
> +	 * +----------+-----------+-----------+-----------+
> +	 * |  temp |  |sensor0|   |sensor1|   |sensor2|   |
> +	 * +----------+-----------+-----------+-----------+
> +	 *                      ^           ^           ^
> +	 *                      |           |           |
> +	 *                      |           |           sensor3[11:8]
> +	 *                      |           sensor3[7:4]
> +	 *                      sensor3[3:0]
>  	 *
>  	 * The calibration data on the H6 is the ambient temperature and
>  	 * sensor values that are filled during the factory test stage.
> @@ -243,9 +248,16 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
>  	ft_temp = (caldata[0] & FT_TEMP_MASK) * 100;
>  
>  	for (i = 0; i < tmdev->chip->sensor_num; i++) {
> -		int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
> -		int cdata, offset;
> -		int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
> +		int sensor_reg, sensor_temp, cdata, offset;
> +
> +		if (i == 3)
> +			sensor_reg = (caldata[1] >> 12)
> +				     | ((caldata[2] >> 12) << 4)
> +				     | ((caldata[3] >> 12) << 8);
> +		else
> +			sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
> +
> +		sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
>  
>  		/*
>  		 * Calibration data is CALIBRATE_DEFAULT - (calculated


  reply	other threads:[~2023-12-18 11:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-17 13:36 [PATCH v1] thermal: sun8i: extend H6 calibration function to support 4 sensors Maksim Kiselev
2023-12-18 11:14 ` Andre Przywara [this message]
2023-12-27 13:25   ` Daniel Lezcano

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=20231218111404.5f08a4c4@donnerap.manchester.arm.com \
    --to=andre.przywara@arm.com \
    --cc=anarsoul@gmail.com \
    --cc=bigunclemax@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=lukasz.luba@arm.com \
    --cc=martin.botka@somainline.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=samuel@sholland.org \
    --cc=tiny.windzz@gmail.com \
    --cc=wens@csie.org \
    /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