Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: =Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, srv_heupstream@mediatek.com,
	linux-pm@vger.kernel.org,
	=Daniel Lezcano <daniel.lezcano@linaro.org>,
	linux-kernel@vger.kernel.org, michael.kao@mediatek.com,
	=Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	=Zhang Rui <rui.zhang@intel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/7] thermal: mediatek: add calibration item
Date: Tue, 5 Feb 2019 16:48:51 -0800
Message-ID: <20190206004837.GC19687@localhost.localdomain> (raw)
In-Reply-To: <dcc04c1e-eb7d-024e-abc8-7b75504947c2@gmail.com>

On Mon, Feb 04, 2019 at 06:31:41PM +0100, Matthias Brugger wrote:
> 
> 
> On 01/02/2019 08:38, michael.kao@mediatek.com wrote:
> > From: Michael Kao <michael.kao@mediatek.com>
> > 
> > Add calibration item in thermal_data to support
> > the project with different calibration coefficient.
> > 
> > Signed-off-by: Michael Kao <michael.kao@mediatek.com>
> > ---
> >  drivers/thermal/mtk_thermal.c | 19 ++++++++++++++++++-
> >  1 file changed, 18 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > index 07f8ad7..45c6587 100644
> > --- a/drivers/thermal/mtk_thermal.c
> > +++ b/drivers/thermal/mtk_thermal.c
> > @@ -105,6 +105,9 @@
> >  /* The number of sensing points per bank */
> >  #define MT8173_NUM_SENSORS_PER_ZONE	4
> >  
> > +/* The calibration coefficient of sensor  */
> > +#define MT8173_CALIBRATION	165
> > +
> 
> Calibration value is the same for all SoCs (including mt8183), we can define it
> once and use it in all mtk_thermal structs.

Well, on patch 7 we have:

+#define MT8183_CALIBRATION	153

> 
> Regards,
> Matthias
> 
> 
> >  /*
> >   * Layout of the fuses providing the calibration data
> >   * These macros could be used for MT8173, MT2701, and MT2712.
> > @@ -147,6 +150,9 @@ enum {
> >  /* The number of sensing points per bank */
> >  #define MT2701_NUM_SENSORS_PER_ZONE	3
> >  
> > +/* The calibration coefficient of sensor  */
> > +#define MT2701_CALIBRATION	165
> > +
> >  /* MT2712 thermal sensors */
> >  #define MT2712_TS1	0
> >  #define MT2712_TS2	1
> > @@ -162,12 +168,18 @@ enum {
> >  /* The number of sensing points per bank */
> >  #define MT2712_NUM_SENSORS_PER_ZONE	4
> >  
> > +/* The calibration coefficient of sensor  */
> > +#define MT2712_CALIBRATION	165
> > +
> >  #define MT7622_TEMP_AUXADC_CHANNEL	11
> >  #define MT7622_NUM_SENSORS		1
> >  #define MT7622_NUM_ZONES		1
> >  #define MT7622_NUM_SENSORS_PER_ZONE	1
> >  #define MT7622_TS1	0
> >  
> > +/* The calibration coefficient of sensor  */
> > +#define MT7622_CALIBRATION	165
> > +
> >  struct mtk_thermal;
> >  
> >  struct thermal_bank_cfg {
> > @@ -188,6 +200,7 @@ struct mtk_thermal_data {
> >  	const int *sensor_mux_values;
> >  	const int *msr;
> >  	const int *adcpnp;
> > +	const int cali_val;
> >  	struct thermal_bank_cfg bank_data[];
> >  };
> >  
> > @@ -295,6 +308,7 @@ struct mtk_thermal {
> >  	.num_banks = MT8173_NUM_ZONES,
> >  	.num_sensors = MT8173_NUM_SENSORS,
> >  	.vts_index = mt8173_vts_index,
> > +	.cali_val = MT8173_CALIBRATION,
> >  	.bank_data = {
> >  		{
> >  			.num_sensors = 2,
> > @@ -330,6 +344,7 @@ struct mtk_thermal {
> >  	.num_banks = 1,
> >  	.num_sensors = MT2701_NUM_SENSORS,
> >  	.vts_index = mt2701_vts_index,
> > +	.cali_val = MT2701_CALIBRATION,
> >  	.bank_data = {
> >  		{
> >  			.num_sensors = 3,
> > @@ -356,6 +371,7 @@ struct mtk_thermal {
> >  	.num_banks = 1,
> >  	.num_sensors = MT2712_NUM_SENSORS,
> >  	.vts_index = mt2712_vts_index,
> > +	.cali_val = MT2712_CALIBRATION,
> >  	.bank_data = {
> >  		{
> >  			.num_sensors = 4,
> > @@ -376,6 +392,7 @@ struct mtk_thermal {
> >  	.num_banks = MT7622_NUM_ZONES,
> >  	.num_sensors = MT7622_NUM_SENSORS,
> >  	.vts_index = mt7622_vts_index,
> > +	.cali_val = MT7622_CALIBRATION,
> >  	.bank_data = {
> >  		{
> >  			.num_sensors = 1,
> > @@ -402,7 +419,7 @@ static int raw_to_mcelsius(struct mtk_thermal *mt, int sensno, s32 raw)
> >  	raw &= 0xfff;
> >  
> >  	tmp = 203450520 << 3;
> > -	tmp /= 165 + mt->o_slope;
> > +	tmp /= mt->conf->cali_val + mt->o_slope;
> >  	tmp /= 10000 + mt->adc_ge;
> >  	tmp *= raw - mt->vts[sensno] - 3350;
> >  	tmp >>= 3;
> > 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01  7:38 [PATCH 0/7] Add Mediatek thermal dirver for mt8183 michael.kao
2019-02-01  7:38 ` [PATCH 1/7] thermal: mediatek: fix register index error michael.kao
2019-02-04 17:24   ` Matthias Brugger
2019-02-12  8:20     ` Michael Kao
2019-02-01  7:38 ` [PATCH 2/7] thermal: mediatek: add common index of vts settings michael.kao
2019-02-01  7:38 ` [PATCH 3/7] thermal: mediatek: add calibration item michael.kao
2019-02-04 17:31   ` Matthias Brugger
2019-02-06  0:48     ` Eduardo Valentin [this message]
2019-02-01  7:38 ` [PATCH 4/7] thermal: mediatek: add thermal controller offset michael.kao
2019-02-06  0:53   ` Eduardo Valentin
2019-02-12  9:55     ` Michael Kao
2019-02-01  7:38 ` [PATCH 5/7] thermal: mediatek: add flag for bank selection michael.kao
2019-02-01  7:38 ` [PATCH 6/7] dt-bindings: thermal: add binding document for mt8183 thermal controller michael.kao
2019-02-01  7:38 ` [PATCH 7/7] thermal: mediatek: add support for MT8183 michael.kao

Reply instructions:

You may reply publically 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=20190206004837.GC19687@localhost.localdomain \
    --to=edubezval@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=michael.kao@mediatek.com \
    --cc=robh+dt@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srv_heupstream@mediatek.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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox