From: Louis Adamian <adamianlouis@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: Louis Adamian <adamianlouis@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 5/5] iio: pressure: ms5637: Add per-variant compensation
Date: Thu, 20 Aug 2026 10:12:20 -0400 [thread overview]
Message-ID: <20260820141224.23730-6-adamianlouis@gmail.com> (raw)
In-Reply-To: <20260820141224.23730-1-adamianlouis@gmail.com>
Previously, all sensors used the compensation for the MS5637-02BA. Add
correct temperature compensation for MS5637-30BA, MS5803-01BA,
MS5803-02BA, MS5803-05BA, MS5803-14BA, MS5803-30BA, MS5805, MS5837-02BA
and MS5837-30BA.
The deprecated meas,ms5803, meas,ms5637 and meas,ms5837 compatibles
resolve to the -02BA variants. This changes the values that meas,ms5803
and meas,ms5837 report.
meas,ms5805 now uses its own constants, correcting its readings. MS8607
gets its own constants struct. The values match the MS5637-02BA ones it
previously shared, so its readings are unchanged.
Signed-off-by: Louis Adamian <adamianlouis@gmail.com>
---
drivers/iio/pressure/ms5637.c | 376 ++++++++++++++++++++++++++++++++--
1 file changed, 360 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c
index 359f3a8e79b2..81b87b79e011 100644
--- a/drivers/iio/pressure/ms5637.c
+++ b/drivers/iio/pressure/ms5637.c
@@ -223,51 +223,395 @@ static const struct ms_tp_comp_consts ms5637_02_consts = {
.press_shift = 15,
};
-static const struct ms_tp_data ms5637_data = {
- .name = "ms5637",
+static const struct ms_tp_data ms5637_02_data = {
+ .name = "ms5637-02ba",
.hw = &ms5637_hw_data,
.comp_consts = &ms5637_02_consts,
};
-static const struct ms_tp_data ms5803_data = {
- .name = "ms5803",
+/*
+ * MS5637-30BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=showdoc&DocId=Data+Sheet%7FMS5637-30BA%7FA3%7Fpdf%7FEnglish%7FENG_DS_MS5637-30BA_A3.pdf
+ * Pages: 8-9
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5637_30_consts = {
+ .press_scale = 100,
+ .high_t2_multiplier = 2,
+ .high_t2_shift = 37,
+ .high_off2_multiplier = 1,
+ .high_off2_shift = 4,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 1,
+ .low_sens2_multiplier = 5,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 7,
+ .vlow_sens2_multiplier = 4,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 16,
+ .off_shift = 7,
+ .sens_t1_shift = 15,
+ .sens_shift = 8,
+ .press_sens_shift = 21,
+ .press_shift = 13,
+};
+
+static const struct ms_tp_data ms5637_30_data = {
+ .name = "ms5637-30ba",
+ .hw = &ms5637_hw_data,
+ .comp_consts = &ms5637_30_consts,
+};
+
+/*
+ * MS5803-01BA compensation Constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5803-01BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf
+ * Pages: 13-14
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5803_01_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 0,
+ .high_t2_shift = 0,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 1,
+ .low_t2_shift = 31,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 0,
+ .low_sens2_multiplier = 7,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 0,
+ .vlow_sens2_multiplier = 2,
+ .has_vhigh_temp = true,
+ .off_t1_shift = 16,
+ .off_shift = 7,
+ .sens_t1_shift = 15,
+ .sens_shift = 8,
+ .press_sens_shift = 21,
+ .press_shift = 15,
+};
+
+static const struct ms_tp_data ms5803_01_data = {
+ .name = "ms5803-01ba",
.hw = &ms5803_hw_data,
- .comp_consts = &ms5637_02_consts,
+ .comp_consts = &ms5803_01_consts,
+};
+
+/*
+ * MS5803-02BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5803-02BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf
+ * Pages: 13-14
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5803_02_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 0,
+ .high_t2_shift = 0,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 1,
+ .low_t2_shift = 31,
+ .low_off2_multiplier = 61,
+ .low_off2_shift = 4,
+ .low_sens2_multiplier = 2,
+ .low_sens2_shift = 0,
+ .vlow_off2_multiplier = 20,
+ .vlow_sens2_multiplier = 12,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 17,
+ .off_shift = 6,
+ .sens_t1_shift = 16,
+ .sens_shift = 7,
+ .press_sens_shift = 21,
+ .press_shift = 15,
+};
+
+static const struct ms_tp_data ms5803_02_data = {
+ .name = "ms5803-02ba",
+ .hw = &ms5803_hw_data,
+ .comp_consts = &ms5803_02_consts,
+};
+
+/*
+ * MS5803-05BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5803-05BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=MS580305BA01-00
+ * Pages: 13-14
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5803_05_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 0,
+ .high_t2_shift = 0,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 3,
+ .low_sens2_multiplier = 7,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 0,
+ .vlow_sens2_multiplier = 3,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 18,
+ .off_shift = 5,
+ .sens_t1_shift = 17,
+ .sens_shift = 7,
+ .press_sens_shift = 21,
+ .press_shift = 15,
+};
+
+static const struct ms_tp_data ms5803_05_data = {
+ .name = "ms5803-05ba",
+ .hw = &ms5803_hw_data,
+ .comp_consts = &ms5803_05_consts,
+};
+
+/*
+ * MS5803-14BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5803-14BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=MS580314BA01-50
+ * Pages: 13-14
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5803_14_consts = {
+ .press_scale = 100,
+ .high_t2_multiplier = 7,
+ .high_t2_shift = 37,
+ .high_off2_multiplier = 1,
+ .high_off2_shift = 4,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 1,
+ .low_sens2_multiplier = 5,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 7,
+ .vlow_sens2_multiplier = 4,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 16,
+ .off_shift = 7,
+ .sens_t1_shift = 15,
+ .sens_shift = 8,
+ .press_sens_shift = 21,
+ .press_shift = 15,
+};
+
+static const struct ms_tp_data ms5803_14_data = {
+ .name = "ms5803-14ba",
+ .hw = &ms5803_hw_data,
+ .comp_consts = &ms5803_14_consts,
+};
+
+/*
+ * MS5803-30BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5803-30BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=MS580330BA01-00
+ * Pages: 13-14
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5803_30_consts = {
+ .press_scale = 100,
+ .high_t2_multiplier = 7,
+ .high_t2_shift = 37,
+ .high_off2_multiplier = 1,
+ .high_off2_shift = 4,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 1,
+ .low_sens2_multiplier = 5,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 7,
+ .vlow_sens2_multiplier = 4,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 16,
+ .off_shift = 7,
+ .sens_t1_shift = 15,
+ .sens_shift = 8,
+ .press_sens_shift = 21,
+ .press_shift = 13,
+};
+
+static const struct ms_tp_data ms5803_30_data = {
+ .name = "ms5803-30ba",
+ .hw = &ms5803_hw_data,
+ .comp_consts = &ms5803_30_consts,
+};
+
+/*
+ * MS5805-02BA01 compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5805-02BA01&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=MS580502BA01-50
+ * Pages: 8-9
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5805_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 0,
+ .high_t2_shift = 0,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 11,
+ .low_t2_shift = 35,
+ .low_off2_multiplier = 31,
+ .low_off2_shift = 3,
+ .low_sens2_multiplier = 63,
+ .low_sens2_shift = 5,
+ .vlow_off2_multiplier = 0,
+ .vlow_sens2_multiplier = 0,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 17,
+ .off_shift = 6,
+ .sens_t1_shift = 16,
+ .sens_shift = 7,
+ .press_sens_shift = 21,
+ .press_shift = 15,
};
static const struct ms_tp_data ms5805_data = {
.name = "ms5805",
.hw = &ms5637_hw_data,
- .comp_consts = &ms5637_02_consts,
+ .comp_consts = &ms5805_consts,
+};
+
+/*
+ * MS5837-02BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5837-02BA01&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=20000979-00
+ * Pages: 7-8
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5837_02_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 0,
+ .high_t2_shift = 0,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 11,
+ .low_t2_shift = 35,
+ .low_off2_multiplier = 31,
+ .low_off2_shift = 3,
+ .low_sens2_multiplier = 63,
+ .low_sens2_shift = 5,
+ .vlow_off2_multiplier = 0,
+ .vlow_sens2_multiplier = 0,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 17,
+ .off_shift = 6,
+ .sens_t1_shift = 16,
+ .sens_shift = 7,
+ .press_sens_shift = 21,
+ .press_shift = 15,
};
-static const struct ms_tp_data ms5837_data = {
- .name = "ms5837",
+static const struct ms_tp_data ms5837_02_data = {
+ .name = "ms5837-02ba",
.hw = &ms5637_hw_data,
- .comp_consts = &ms5637_02_consts,
+ .comp_consts = &ms5837_02_consts,
+};
+
+/*
+ * MS5837-30BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5837-30BA&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=MS583730BA01-50
+ * Pages: 11-12
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms5837_30_consts = {
+ .press_scale = 100,
+ .high_t2_multiplier = 2,
+ .high_t2_shift = 37,
+ .high_off2_multiplier = 1,
+ .high_off2_shift = 4,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 3,
+ .low_off2_shift = 1,
+ .low_sens2_multiplier = 5,
+ .low_sens2_shift = 3,
+ .vlow_off2_multiplier = 7,
+ .vlow_sens2_multiplier = 4,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 16,
+ .off_shift = 7,
+ .sens_t1_shift = 15,
+ .sens_shift = 8,
+ .press_sens_shift = 21,
+ .press_shift = 13,
+};
+
+static const struct ms_tp_data ms5837_30_data = {
+ .name = "ms5837-30ba",
+ .hw = &ms5637_hw_data,
+ .comp_consts = &ms5837_30_consts,
+};
+
+/*
+ * MS8607-02BA compensation constants
+ * Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS8607-02BA01&DocType=Data%20Sheet&DocLang=English&DocFormat=pdf&PartCntxt=CAT-BLPS0018
+ * Pages: 9-10
+ * Sections: Pressure and Temperature Calculation, Second Order Temperature Compensation
+ */
+static const struct ms_tp_comp_consts ms8607_consts = {
+ .press_scale = 1000,
+ .high_t2_multiplier = 5,
+ .high_t2_shift = 38,
+ .high_off2_multiplier = 0,
+ .high_off2_shift = 0,
+ .low_t2_multiplier = 3,
+ .low_t2_shift = 33,
+ .low_off2_multiplier = 61,
+ .low_off2_shift = 4,
+ .low_sens2_multiplier = 29,
+ .low_sens2_shift = 4,
+ .vlow_off2_multiplier = 17,
+ .vlow_sens2_multiplier = 9,
+ .has_vhigh_temp = false,
+ .off_t1_shift = 17,
+ .off_shift = 6,
+ .sens_t1_shift = 16,
+ .sens_shift = 7,
+ .press_sens_shift = 21,
+ .press_shift = 15,
};
static const struct ms_tp_data ms8607_data = {
.name = "ms8607-temppressure",
.hw = &ms5637_hw_data,
- .comp_consts = &ms5637_02_consts,
+ .comp_consts = &ms8607_consts,
};
static const struct i2c_device_id ms5637_id[] = {
- { .name = "ms5637", .driver_data = (kernel_ulong_t)&ms5637_data },
- { .name = "ms5803", .driver_data = (kernel_ulong_t)&ms5803_data },
+ { .name = "ms5637", .driver_data = (kernel_ulong_t)&ms5637_02_data },
+ { .name = "ms5637-02ba", .driver_data = (kernel_ulong_t)&ms5637_02_data },
+ { .name = "ms5637-30ba", .driver_data = (kernel_ulong_t)&ms5637_30_data },
+ { .name = "ms5803", .driver_data = (kernel_ulong_t)&ms5803_02_data },
+ { .name = "ms5803-01ba", .driver_data = (kernel_ulong_t)&ms5803_01_data },
+ { .name = "ms5803-02ba", .driver_data = (kernel_ulong_t)&ms5803_02_data },
+ { .name = "ms5803-05ba", .driver_data = (kernel_ulong_t)&ms5803_05_data },
+ { .name = "ms5803-14ba", .driver_data = (kernel_ulong_t)&ms5803_14_data },
+ { .name = "ms5803-30ba", .driver_data = (kernel_ulong_t)&ms5803_30_data },
{ .name = "ms5805", .driver_data = (kernel_ulong_t)&ms5805_data },
- { .name = "ms5837", .driver_data = (kernel_ulong_t)&ms5837_data },
+ { .name = "ms5837", .driver_data = (kernel_ulong_t)&ms5837_02_data },
+ { .name = "ms5837-02ba", .driver_data = (kernel_ulong_t)&ms5837_02_data },
+ { .name = "ms5837-30ba", .driver_data = (kernel_ulong_t)&ms5837_30_data },
{ .name = "ms8607-temppressure", .driver_data = (kernel_ulong_t)&ms8607_data },
{ }
};
MODULE_DEVICE_TABLE(i2c, ms5637_id);
static const struct of_device_id ms5637_of_match[] = {
- { .compatible = "meas,ms5637", .data = &ms5637_data },
- { .compatible = "meas,ms5803", .data = &ms5803_data },
+ { .compatible = "meas,ms5637", .data = &ms5637_02_data },
+ { .compatible = "meas,ms5637-02ba", .data = &ms5637_02_data },
+ { .compatible = "meas,ms5637-30ba", .data = &ms5637_30_data },
+ { .compatible = "meas,ms5803", .data = &ms5803_02_data },
+ { .compatible = "meas,ms5803-01ba", .data = &ms5803_01_data },
+ { .compatible = "meas,ms5803-02ba", .data = &ms5803_02_data },
+ { .compatible = "meas,ms5803-05ba", .data = &ms5803_05_data },
+ { .compatible = "meas,ms5803-14ba", .data = &ms5803_14_data },
+ { .compatible = "meas,ms5803-30ba", .data = &ms5803_30_data },
{ .compatible = "meas,ms5805", .data = &ms5805_data },
- { .compatible = "meas,ms5837", .data = &ms5837_data },
+ { .compatible = "meas,ms5837", .data = &ms5837_02_data },
+ { .compatible = "meas,ms5837-02ba", .data = &ms5837_02_data },
+ { .compatible = "meas,ms5837-30ba", .data = &ms5837_30_data },
{ .compatible = "meas,ms8607-temppressure", .data = &ms8607_data },
{ }
};
--
2.55.0
next prev parent reply other threads:[~2026-08-20 14:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260820141224.23730-1-adamianlouis@gmail.com>
2026-08-20 14:12 ` [PATCH v3 1/5] iio: pressure: ms5637: Add missing ms5803 I2C device ID Louis Adamian
2026-08-21 0:41 ` Jonathan Cameron
2026-08-20 14:12 ` [PATCH v3 2/5] iio: pressure: ms5637: Move device data struct to header Louis Adamian
2026-08-21 0:48 ` Jonathan Cameron
2026-08-20 14:12 ` [PATCH v3 3/5] dt-bindings: iio: pressure: Add MS5637 Louis Adamian
2026-08-20 18:13 ` Conor Dooley
2026-08-20 14:12 ` [PATCH v3 4/5] iio: pressure: ms5637: Parameterise second order temperature compensation Louis Adamian
2026-08-20 14:12 ` Louis Adamian [this message]
2026-08-21 1:01 ` [PATCH v3 5/5] iio: pressure: ms5637: Add per-variant compensation Jonathan Cameron
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=20260820141224.23730-6-adamianlouis@gmail.com \
--to=adamianlouis@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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).