From: Pascal Paillet <p.paillet@st.com>
To: <mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>,
<robh+dt@kernel.org>, <mark.rutland@arm.com>,
<rui.zhang@intel.com>, <edubezval@gmail.com>,
<daniel.lezcano@linaro.org>, <amit.kucheria@verdurent.com>,
<david.hernandezsanchez@st.com>,
<wsa+renesas@sang-engineering.com>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-pm@vger.kernel.org>
Cc: p.paillet@st.com
Subject: [PATCH 3/4] thermal: stm32: fix engineering calibration value
Date: Tue, 29 Oct 2019 17:45:36 +0100 [thread overview]
Message-ID: <20191029164537.1561-4-p.paillet@st.com> (raw)
In-Reply-To: <20191029164537.1561-1-p.paillet@st.com>
TS1_T0 is only used by engineering during calibration.
The temperature offset is actually fixed to 30 Celsius.
Signed-off-by: Pascal Paillet <p.paillet@st.com>
Change-Id: I83abea65ff3f58f8954256495f2d5d38f0d868d9
---
drivers/thermal/st/stm_thermal.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c
index 4bc1bbece0de..37abbdffe573 100644
--- a/drivers/thermal/st/stm_thermal.c
+++ b/drivers/thermal/st/stm_thermal.c
@@ -82,8 +82,7 @@
#define ONE_MHZ 1000000
#define POLL_TIMEOUT 5000
#define STARTUP_TIME 40
-#define TS1_T0_VAL0 30000 /* 30 celsius */
-#define TS1_T0_VAL1 130000 /* 130 celsius */
+#define T0 30000 /* 30 celsius */
#define NO_HW_TRIG 0
#define SAMPLING_TIME 15
@@ -94,7 +93,7 @@ struct stm_thermal_sensor {
struct clk *clk;
int irq;
void __iomem *base;
- int t0, fmt0, ramp_coeff;
+ int fmt0, ramp_coeff;
int low_en, high_en;
};
@@ -248,14 +247,6 @@ static int stm_thermal_calibration(struct stm_thermal_sensor *sensor)
/* Fill in DTS structure with factory sensor values */
static int stm_thermal_read_factory_settings(struct stm_thermal_sensor *sensor)
{
- /* Retrieve engineering calibration temperature */
- sensor->t0 = readl_relaxed(sensor->base + DTS_T0VALR1_OFFSET) &
- TS1_T0_MASK;
- if (!sensor->t0)
- sensor->t0 = TS1_T0_VAL0;
- else
- sensor->t0 = TS1_T0_VAL1;
-
/* Retrieve fmt0 and put it on Hz */
sensor->fmt0 = ADJUST * (readl_relaxed(sensor->base +
DTS_T0VALR1_OFFSET) & TS1_FMT0_MASK);
@@ -269,8 +260,8 @@ static int stm_thermal_read_factory_settings(struct stm_thermal_sensor *sensor)
return -EINVAL;
}
- dev_dbg(sensor->dev, "%s: T0 = %doC, FMT0 = %dHz, RAMP_COEFF = %dHz/oC",
- __func__, sensor->t0, sensor->fmt0, sensor->ramp_coeff);
+ dev_dbg(sensor->dev, "%s: FMT0 = %dHz, RAMP_COEFF = %dHz/oC",
+ __func__, sensor->fmt0, sensor->ramp_coeff);
return 0;
}
@@ -281,8 +272,7 @@ static int stm_thermal_calculate_threshold(struct stm_thermal_sensor *sensor,
int freqM;
/* Figure out the CLK_PTAT frequency for a given temperature */
- freqM = ((temp - sensor->t0) * sensor->ramp_coeff) / 1000 +
- sensor->fmt0;
+ freqM = ((temp - T0) * sensor->ramp_coeff) / 1000 + sensor->fmt0;
/* Figure out the threshold sample number */
*th = clk_get_rate(sensor->clk) * SAMPLING_TIME / freqM;
@@ -317,7 +307,7 @@ static int stm_thermal_get_temp(void *data, int *temp)
return -EINVAL;
/* Figure out the temperature in mili celsius */
- *temp = (freqM - sensor->fmt0) * 1000 / sensor->ramp_coeff + sensor->t0;
+ *temp = (freqM - sensor->fmt0) * 1000 / sensor->ramp_coeff + T0;
dev_dbg(sensor->dev, "periods=0x%x t=%d mC", periods, *temp);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-29 16:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 16:45 [PATCH 0/4] thermal: stm32: driver improvements Pascal Paillet
2019-10-29 16:45 ` [PATCH 1/4] thermal: stm32: implement set_trips callback Pascal Paillet
2019-10-29 17:34 ` Daniel Lezcano
2019-10-29 16:45 ` [PATCH 2/4] thermal: stm32: fix IRQ flood on low threshold Pascal Paillet
2019-10-29 17:11 ` Daniel Lezcano
2019-10-29 17:15 ` Joe Perches
2019-10-29 17:21 ` Daniel Lezcano
2019-10-29 17:24 ` Joe Perches
2019-10-29 17:34 ` Daniel Lezcano
2019-10-29 16:45 ` Pascal Paillet [this message]
2019-10-29 16:45 ` [PATCH 4/4] ARM: dts: stm32: remove thermal passive trip point on stm32mp157c Pascal Paillet
2019-10-29 17:36 ` 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=20191029164537.1561-4-p.paillet@st.com \
--to=p.paillet@st.com \
--cc=alexandre.torgue@st.com \
--cc=amit.kucheria@verdurent.com \
--cc=daniel.lezcano@linaro.org \
--cc=david.hernandezsanchez@st.com \
--cc=devicetree@vger.kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).