Skip to contentSkip to conversation

iio: pressure: ms5637: Add missing ms5803 I2C device ID

PATCH In review Louis Adamian 4 participants 11 messages Aug 20 – Aug 31 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/5 iio: pressure: ms5637: Add missing ms5803 I2C device ID

meas,ms5803 is in the OF match table with no corresponding entry in ms5637_id.

Fixes 649ef114a0a0 ("iio:pressure:ms5637: add ms5803 support")
---
 drivers/iio/pressure/ms5637.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/pressure/ms5637.c +1 -0
index be8921644558..4f9f556bd123 100644
@@ -215,6 +215,7 @@ static const struct ms_tp_data ms8607_data = {
 
 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 = "ms5805", .driver_data = (kernel_ulong_t)&ms5805_data },
 	{ .name = "ms5837", .driver_data = (kernel_ulong_t)&ms5837_data },
 	{ .name = "ms8607-temppressure", .driver_data = (kernel_ulong_t)&ms8607_data },
Signature · 1 line
2.55.0
maintainer
#2 lore raw
Quoted 4 lines · On Thu, 20 Aug 2026 10:12:16 -0400 Louis Adamian <[email protected]> wrote:

meas,ms5803 is in the OF match table with no corresponding entry in ms5637_id.

Fixes 649ef114a0a0 ("iio:pressure:ms5637: add ms5803 support")

Hi Louis,

What is the result of this entry not being there? We need
a reason that this is a fix rather than simply a cleanup / consistency improvement.

Quoted 1 line

Please make sure that a series has a cover letter in future --cover-letter to git will provide you with one to fill in.

The rest of the thread will end up in reply to that. Brings the advantage of a place to provide a short overview of what the whole series is up to; somewhere for comments; and a useful name in tools like patchwork.

Otherwise this looks good to me.

Quoted 16 lines
---
 drivers/iio/pressure/ms5637.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/pressure/ms5637.c +1 -0
index be8921644558..4f9f556bd123 100644
@@ -215,6 +215,7 @@ static const struct ms_tp_data ms8607_data = {
 
 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 = "ms5805", .driver_data = (kernel_ulong_t)&ms5805_data },
 	{ .name = "ms5837", .driver_data = (kernel_ulong_t)&ms5837_data },
 	{ .name = "ms8607-temppressure", .driver_data = (kernel_ulong_t)&ms8607_data },
#3 lore raw

PATCH v3 2/5 iio: pressure: ms5637: Move device data struct to header

In reply to a message not in the archive

ms_tp_dev duplicated the hw pointer already in ms_tp_data. This stores a pointer to ms_tp_data instead which requires moving the struct definition from ms5637.c to ms_sensors_i2c.h.

No functional change intended

---
 drivers/iio/common/ms_sensors/ms_sensors_i2c.c |  4 ++--
 drivers/iio/common/ms_sensors/ms_sensors_i2c.h | 13 ++++++++++++-
 drivers/iio/pressure/ms5637.c                  |  9 ++-------
 3 files changed, 16 insertions(+), 10 deletions(-)
drivers/iio/common/ms_sensors/ms_sensors_i2c.c +2 -2
index 1960a2ce82a8..f9dc7c7468c1 100644
@@ -579,7 +579,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 	int i, ret;
 	bool valid;
 
-	for (i = 0; i < dev_data->hw->prom_len; i++) {
+	for (i = 0; i < dev_data->data->hw->prom_len; i++) {
 		ret = ms_sensors_read_prom_word(
 			dev_data->client,
 			MS_SENSORS_TP_PROM_READ + (i << 1),
@@ -589,7 +589,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 			return ret;
 	}
 
-	if (dev_data->hw->prom_len == 8)
+	if (dev_data->data->hw->prom_len == 8)
 		valid = ms_sensors_tp_crc_valid_128(dev_data->prom);
 	else
 		valid = ms_sensors_tp_crc_valid_112(dev_data->prom);
drivers/iio/common/ms_sensors/ms_sensors_i2c.h +12 -1
index f15b973f27c6..d9898098c066 100644
@@ -35,6 +35,16 @@ struct ms_tp_hw_data {
 	u8 max_res_index;
 };
 
+/**
+ * struct ms_tp_data - Temperature/Pressure sensor data
+ * @name: Device name
+ * @hw: Sensor hardware data
+ */
+struct ms_tp_data {
+	const char *name;
+	const struct ms_tp_hw_data *hw;
+};
+
 /**
  * struct ms_tp_dev - Temperature/Pressure sensor device structure
  * @client:	i2c client
@@ -42,11 +52,12 @@ struct ms_tp_hw_data {
  * @prom:	array of PROM coefficients used for conversion. Added element
  *              for CRC computation
  * @res_index:	index to selected sensor resolution
+ * @data:	Temperature/Pressure sensor data
  */
 struct ms_tp_dev {
 	struct i2c_client *client;
 	struct mutex lock;
-	const struct ms_tp_hw_data *hw;
+	const struct ms_tp_data *data;
 	u16 prom[MS_SENSORS_TP_PROM_WORDS_NB];
 	u8 res_index;
 };
drivers/iio/pressure/ms5637.c +2 -7
index 4f9f556bd123..6009d87f3d4c 100644
@@ -29,11 +29,6 @@
 
 #include "../common/ms_sensors/ms_sensors_i2c.h"
 
-struct ms_tp_data {
-	const char *name;
-	const struct ms_tp_hw_data *hw;
-};
-
 static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 };
 
 static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf)
@@ -42,7 +37,7 @@ static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute
 	struct ms_tp_dev *dev_data = iio_priv(indio_dev);
 	int i, len = 0;
 
-	for (i = 0; i <= dev_data->hw->max_res_index; i++)
+	for (i = 0; i <= dev_data->data->hw->max_res_index; i++)
 		len += sysfs_emit_at(buf, len, "%u ", ms5637_samp_freq[i]);
 	sysfs_emit_at(buf, len - 1, "\n");
 
@@ -168,7 +163,7 @@ static int ms5637_probe(struct i2c_client *client)
 	dev_data = iio_priv(indio_dev);
 	dev_data->client = client;
 	dev_data->res_index = data->hw->max_res_index;
-	dev_data->hw = data->hw;
+	dev_data->data = data;
 	mutex_init(&dev_data->lock);
 
 	indio_dev->info = &ms5637_info;
Signature · 1 line
2.55.0
maintainer
#4 lore raw

Re: [PATCH v3 2/5] iio: pressure: ms5637: Move device data struct to header

Quoted 3 lines · On Thu, 20 Aug 2026 10:12:17 -0400 Louis Adamian <[email protected]> wrote:

ms_tp_dev duplicated the hw pointer already in ms_tp_data. This stores a pointer to ms_tp_data instead which requires moving the struct definition from ms5637.c to ms_sensors_i2c.h.

Why is this a good thing to do? Pointing to only the data we happen to need in the structure seems fine to me. Is it that you are going to add something else in there in a later patch?

If so, mention that because as it stands this patch doesn't have a strong justification.

Jonathan

Quoted 101 lines

No functional change intended

---
 drivers/iio/common/ms_sensors/ms_sensors_i2c.c |  4 ++--
 drivers/iio/common/ms_sensors/ms_sensors_i2c.h | 13 ++++++++++++-
 drivers/iio/pressure/ms5637.c                  |  9 ++-------
 3 files changed, 16 insertions(+), 10 deletions(-)
drivers/iio/common/ms_sensors/ms_sensors_i2c.c +2 -2
index 1960a2ce82a8..f9dc7c7468c1 100644
@@ -579,7 +579,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 	int i, ret;
 	bool valid;
 
-	for (i = 0; i < dev_data->hw->prom_len; i++) {
+	for (i = 0; i < dev_data->data->hw->prom_len; i++) {
 		ret = ms_sensors_read_prom_word(
 			dev_data->client,
 			MS_SENSORS_TP_PROM_READ + (i << 1),
@@ -589,7 +589,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 			return ret;
 	}
 
-	if (dev_data->hw->prom_len == 8)
+	if (dev_data->data->hw->prom_len == 8)
 		valid = ms_sensors_tp_crc_valid_128(dev_data->prom);
 	else
 		valid = ms_sensors_tp_crc_valid_112(dev_data->prom);
drivers/iio/common/ms_sensors/ms_sensors_i2c.h +12 -1
index f15b973f27c6..d9898098c066 100644
@@ -35,6 +35,16 @@ struct ms_tp_hw_data {
 	u8 max_res_index;
 };
 
+/**
+ * struct ms_tp_data - Temperature/Pressure sensor data
+ * @name: Device name
+ * @hw: Sensor hardware data
+ */
+struct ms_tp_data {
+	const char *name;
+	const struct ms_tp_hw_data *hw;
+};
+
 /**
  * struct ms_tp_dev - Temperature/Pressure sensor device structure
  * @client:	i2c client
@@ -42,11 +52,12 @@ struct ms_tp_hw_data {
  * @prom:	array of PROM coefficients used for conversion. Added element
  *              for CRC computation
  * @res_index:	index to selected sensor resolution
+ * @data:	Temperature/Pressure sensor data
  */
 struct ms_tp_dev {
 	struct i2c_client *client;
 	struct mutex lock;
-	const struct ms_tp_hw_data *hw;
+	const struct ms_tp_data *data;
 	u16 prom[MS_SENSORS_TP_PROM_WORDS_NB];
 	u8 res_index;
 };
drivers/iio/pressure/ms5637.c +2 -7
index 4f9f556bd123..6009d87f3d4c 100644
@@ -29,11 +29,6 @@
 
 #include "../common/ms_sensors/ms_sensors_i2c.h"
 
-struct ms_tp_data {
-	const char *name;
-	const struct ms_tp_hw_data *hw;
-};
-
 static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 };
 
 static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf)
@@ -42,7 +37,7 @@ static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute
 	struct ms_tp_dev *dev_data = iio_priv(indio_dev);
 	int i, len = 0;
 
-	for (i = 0; i <= dev_data->hw->max_res_index; i++)
+	for (i = 0; i <= dev_data->data->hw->max_res_index; i++)
 		len += sysfs_emit_at(buf, len, "%u ", ms5637_samp_freq[i]);
 	sysfs_emit_at(buf, len - 1, "\n");
 
@@ -168,7 +163,7 @@ static int ms5637_probe(struct i2c_client *client)
 	dev_data = iio_priv(indio_dev);
 	dev_data->client = client;
 	dev_data->res_index = data->hw->max_res_index;
-	dev_data->hw = data->hw;
+	dev_data->data = data;
 	mutex_init(&dev_data->lock);
 
 	indio_dev->info = &ms5637_info;
#5 lore raw

PATCH v3 3/5 dt-bindings: iio: pressure: Add MS5637

In reply to a message not in the archive

Create meas,ms5637 devicetree binding and move existing devices from trivial-devices.yaml. Explicit compatible strings are added for the different sub-variants because each requires different constants for the second-order temperature compensation formulas. Previously, the driver exposed the generic compatibles for the ms5637, MS5803, MS5805 and MS5837 families and applied the MS5637-02BA compensation to all of them. To preserve the DT ABI the existing compatibles are retained and mapped to the -02BA variant of each family (ms5637-02ba, ms5803-02ba, ms5837-02ba).

---
 .../bindings/iio/pressure/meas,ms5637.yaml    | 93 +++++++++++++++++++
 .../devicetree/bindings/trivial-devices.yaml  | 10 --
 2 files changed, 93 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml
Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml new file +93 -0
new file mode 100644
index 000000000000..befd81d1907b
@@ -0,0 +1,93 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/pressure/meas,ms5637.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+title: Measurement Specialties ms5637 and similar pressure sensors
+
+maintainers:
+  - Louis Adamian <[email protected]>
+
+description:
+  Measurement Specialties pressure and temperature sensors. The MS5803
+  family supports both I2C and SPI interfaces. All other variants are I2C only.
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - meas,ms5637-02ba
+          - meas,ms5637-30ba
+          - meas,ms5803-01ba
+          - meas,ms5803-02ba
+          - meas,ms5803-05ba
+          - meas,ms5803-14ba
+          - meas,ms5803-30ba
+          - meas,ms5805
+          - meas,ms5837-02ba
+          - meas,ms5837-30ba
+          - meas,ms8607-temppressure
+      # These generic compatible strings do not identify the sub-variants of
+      # the part. They are retained so that existing device trees continue
+      # to bind, and each is treated as the -02BA variant of its family.
+      - enum:
+          - meas,ms5637
+          - meas,ms5803
+          - meas,ms5837
+        deprecated: true
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - meas,ms5803
+              - meas,ms5803-01ba
+              - meas,ms5803-02ba
+              - meas,ms5803-05ba
+              - meas,ms5803-14ba
+              - meas,ms5803-30ba
+    then:
+      $ref: /schemas/spi/spi-peripheral-props.yaml#
+      properties:
+        spi-max-frequency:
+          maximum: 20000000
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pressure@76 {
+            compatible = "meas,ms5637-02ba";
+            reg = <0x76>;
+            vdd-supply = <&vcc_3v3>;
+        };
+    };
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pressure@0 {
+            compatible = "meas,ms5803-14ba";
+            reg = <0>;
+            vdd-supply = <&vcc_3v3>;
+            spi-max-frequency = <20000000>;
+        };
+    };
Documentation/devicetree/bindings/trivial-devices.yaml +0 -10
index 435c4baab436..2671040e8802 100644
@@ -240,18 +240,8 @@ properties:
           - meas,htu21
             # Measurement Specialities I2C temperature and humidity sensor
           - meas,htu31
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5637
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5803
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5805
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5837
             # Measurement Specialities temp and humidity part of ms8607 device
           - meas,ms8607-humidity
-            # Measurement Specialities temp and pressure part of ms8607 device
-          - meas,ms8607-temppressure
             # Measurement Specialties temperature sensor
           - meas,tsys01
             # MEMSIC magnetometer
Signature · 1 line
2.55.0
#6 lore raw

Re: [PATCH v3 3/5] dt-bindings: iio: pressure: Add MS5637

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Making `vdd-supply` an unconditionally required property breaks backward compatibility for…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Making vdd-supply an unconditionally required property breaks backward compatibility for existing device trees. --

--- Patch [3]: [PATCH v3 3/5] dt-bindings: iio: pressure: Add MS5637 --- commit f37736f8c819b5be2f362b907ebbc2d3373ecbfe
Author: Louis Adamian <[email protected]>

dt-bindings: iio: pressure: Add MS5637

Create meas,ms5637 devicetree binding and move existing devices from trivial-devices.yaml. Explicit compatible strings are added for the different sub-variants because each requires different constants for the second-order temperature compensation formulas.

Quoted 5 lines
Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml new file +0 -0
new file mode 100644
index 0000000000000..befd81d1907b4

[ ... ]

Quoted 24 lines
Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml new file +24 -0
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - meas,ms5637-02ba
+          - meas,ms5637-30ba
+          - meas,ms5803-01ba
+          - meas,ms5803-02ba
+          - meas,ms5803-05ba
+          - meas,ms5803-14ba
+          - meas,ms5803-30ba
+          - meas,ms5805
+          - meas,ms5837-02ba
+          - meas,ms5837-30ba
+          - meas,ms8607-temppressure
+      # These generic compatible strings do not identify the sub-variants of
+      # the part. They are retained so that existing device trees continue
+      # to bind, and each is treated as the -02BA variant of its family.
+      - enum:
+          - meas,ms5637
+          - meas,ms5803
+          - meas,ms5837
+        deprecated: true
+

Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml line 48

Quoted 10 lines
Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+  - vdd-supply

[Severity: Medium]
Will making vdd-supply unconditionally required break backward compatibility for existing device trees?

These generic compatible strings (e.g., meas,ms5637, meas,ms5803) were previously documented in trivial-devices.yaml. That schema restricts properties to a very narrow set and strictly forbids vdd-supply via
additionalProperties: false.

Consequently, existing valid device trees do not include vdd-supply.

By moving these devices to a new standalone binding and making vdd-supply unconditionally required, won't previously valid device trees fail validation?

Should newly documented properties remain optional, or be conditionally required using an if-then block only for the newly added specific compatible strings to preserve the DT ABI when extracting devices from trivial-devices.yaml?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Reviewed-by on v3 3/5
#7 lore raw

Re: [PATCH v3 3/5] dt-bindings: iio: pressure: Add MS5637

In reply to Louis Adamian
Quoted 11 lines · Louis Adamian

Create meas,ms5637 devicetree binding and move existing devices from trivial-devices.yaml. Explicit compatible strings are added for the different sub-variants because each requires different constants for the second-order temperature compensation formulas. Previously, the driver exposed the generic compatibles for the ms5637, MS5803, MS5805 and MS5837 families and applied the MS5637-02BA compensation to all of them. To preserve the DT ABI the existing compatibles are retained and mapped to the -02BA variant of each family (ms5637-02ba, ms5803-02ba, ms5837-02ba).

Firstly, please CC everyone on all the mails - or at least all the dt maintainers on all mails, so we don't have to go look at the context on lore.

Additionally, lore didn't even get your cover letter:
https://lore.kernel.org/all/[email protected]/

The patch itself seems okay. You could probably have made the ms5637-02ba fall back to the ms5637, but that's more a matter of taste I think than a technical thing.

pw-bot: not-applicable

Thanks,
Conor.

Quoted 131 lines
---
 .../bindings/iio/pressure/meas,ms5637.yaml    | 93 +++++++++++++++++++
 .../devicetree/bindings/trivial-devices.yaml  | 10 --
 2 files changed, 93 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml
Documentation/devicetree/bindings/iio/pressure/meas,ms5637.yaml new file +93 -0
new file mode 100644
index 000000000000..befd81d1907b
@@ -0,0 +1,93 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/pressure/meas,ms5637.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+title: Measurement Specialties ms5637 and similar pressure sensors
+
+maintainers:
+  - Louis Adamian <[email protected]>
+
+description:
+  Measurement Specialties pressure and temperature sensors. The MS5803
+  family supports both I2C and SPI interfaces. All other variants are I2C only.
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - meas,ms5637-02ba
+          - meas,ms5637-30ba
+          - meas,ms5803-01ba
+          - meas,ms5803-02ba
+          - meas,ms5803-05ba
+          - meas,ms5803-14ba
+          - meas,ms5803-30ba
+          - meas,ms5805
+          - meas,ms5837-02ba
+          - meas,ms5837-30ba
+          - meas,ms8607-temppressure
+      # These generic compatible strings do not identify the sub-variants of
+      # the part. They are retained so that existing device trees continue
+      # to bind, and each is treated as the -02BA variant of its family.
+      - enum:
+          - meas,ms5637
+          - meas,ms5803
+          - meas,ms5837
+        deprecated: true
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - meas,ms5803
+              - meas,ms5803-01ba
+              - meas,ms5803-02ba
+              - meas,ms5803-05ba
+              - meas,ms5803-14ba
+              - meas,ms5803-30ba
+    then:
+      $ref: /schemas/spi/spi-peripheral-props.yaml#
+      properties:
+        spi-max-frequency:
+          maximum: 20000000
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pressure@76 {
+            compatible = "meas,ms5637-02ba";
+            reg = <0x76>;
+            vdd-supply = <&vcc_3v3>;
+        };
+    };
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pressure@0 {
+            compatible = "meas,ms5803-14ba";
+            reg = <0>;
+            vdd-supply = <&vcc_3v3>;
+            spi-max-frequency = <20000000>;
+        };
+    };
Documentation/devicetree/bindings/trivial-devices.yaml +0 -10
index 435c4baab436..2671040e8802 100644
@@ -240,18 +240,8 @@ properties:
           - meas,htu21
             # Measurement Specialities I2C temperature and humidity sensor
           - meas,htu31
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5637
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5803
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5805
-            # Measurement Specialities I2C pressure and temperature sensor
-          - meas,ms5837
             # Measurement Specialities temp and humidity part of ms8607 device
           - meas,ms8607-humidity
-            # Measurement Specialities temp and pressure part of ms8607 device
-          - meas,ms8607-temppressure
             # Measurement Specialties temperature sensor
           - meas,tsys01
             # MEMSIC magnetometer
Signature · 1 line
2.55.0
#8 lore raw

PATCH v3 4/5 iio: pressure: ms5637: Parameterise second order temperature compensation

In reply to a message not in the archive

The temperature compensation formula is shared across these sensors but with different constants. Add ms_tp_comp_consts to capture these per-device differences. Add pressure variant specific pressure scale variable.

No functional change intended. IIO_VAL_FRACTIONAL prints 3 more decimal places than IIO_VAL_INT_PLUS_MICRO, giving in_pressure_input 3 more trailing zeros.

---
 .../iio/common/ms_sensors/ms_sensors_i2c.c    | 61 ++++++++++++-------
 .../iio/common/ms_sensors/ms_sensors_i2c.h    | 48 +++++++++++++++
 drivers/iio/pressure/ms5637.c                 | 61 ++++++++++++++++---
 3 files changed, 140 insertions(+), 30 deletions(-)
drivers/iio/common/ms_sensors/ms_sensors_i2c.c +39 -22
index f9dc7c7468c1..20f019ae51fd 100644
@@ -604,6 +604,38 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 }
 EXPORT_SYMBOL_NS(ms_sensors_tp_read_prom, "IIO_MEAS_SPEC_SENSORS");
 
+/* apply second order temperature compensation */
+static void ms_tp_compensate(const struct ms_tp_comp_consts *c,
+			     s32 temp, s32 dt, s64 *t2, s64 *off2, s64 *sens2)
+{
+	s64 tmp;
+
+	if (temp < 2000) {
+		tmp = temp - 2000;
+		*t2 = (c->low_t2_multiplier * ((s64)dt * (s64)dt)) >>
+		      c->low_t2_shift;
+		*off2 = (c->low_off2_multiplier * tmp * tmp) >>
+			c->low_off2_shift;
+		*sens2 = (c->low_sens2_multiplier * tmp * tmp) >>
+			 c->low_sens2_shift;
+
+		if (temp < -1500) {
+			tmp = temp + 1500;
+			*off2 += c->vlow_off2_multiplier * tmp * tmp;
+			*sens2 += c->vlow_sens2_multiplier * tmp * tmp;
+		}
+	} else {
+		*sens2 = 0;
+		if (c->has_vhigh_temp && temp > 4500)
+			*sens2 -= (((s64)temp - 4500) * ((s64)temp - 4500)) >> 3;
+
+		*t2 = (c->high_t2_multiplier * ((s64)dt * (s64)dt)) >> c->high_t2_shift;
+		*off2 = (c->high_off2_multiplier *
+			 ((s64)temp - 2000) * ((s64)temp - 2000)) >>
+			c->high_off2_shift;
+	}
+}
+
 /**
  * ms_sensors_read_temp_and_pressure() - read temp and pressure
  * @dev_data:	pointer to temperature/pressure device data
@@ -619,6 +651,7 @@ int ms_sensors_read_temp_and_pressure(struct ms_tp_dev *dev_data,
 				      int *temperature,
 				      unsigned int *pressure)
 {
+	const struct ms_tp_comp_consts *c = dev_data->data->comp_consts;
 	int ret;
 	u32 t_adc, p_adc;
 	s32 dt, temp;
@@ -654,37 +687,21 @@ int ms_sensors_read_temp_and_pressure(struct ms_tp_dev *dev_data,
 	/* Actual temperature = 2000 + dT * TEMPSENS */
 	temp = 2000 + (((s64)dt * prom[6]) >> 23);
 
-	/* Second order temperature compensation */
-	if (temp < 2000) {
-		s64 tmp = (s64)temp - 2000;
-
-		t2 = (3 * ((s64)dt * (s64)dt)) >> 33;
-		off2 = (61 * tmp * tmp) >> 4;
-		sens2 = (29 * tmp * tmp) >> 4;
-
-		if (temp < -1500) {
-			s64 tmp = (s64)temp + 1500;
-
-			off2 += 17 * tmp * tmp;
-			sens2 += 9 * tmp * tmp;
-		}
-	} else {
-		t2 = (5 * ((s64)dt * (s64)dt)) >> 38;
-		off2 = 0;
-		sens2 = 0;
-	}
+	ms_tp_compensate(c, temp, dt, &t2, &off2, &sens2);
 
 	/* OFF = OFF_T1 + TCO * dT */
-	off = (((s64)prom[2]) << 17) + ((((s64)prom[4]) * (s64)dt) >> 6);
+	off = (((s64)prom[2]) << c->off_t1_shift) +
+	      ((((s64)prom[4]) * (s64)dt) >> c->off_shift);
 	off -= off2;
 
 	/* Sensitivity at actual temperature = SENS_T1 + TCS * dT */
-	sens = (((s64)prom[1]) << 16) + (((s64)prom[3] * dt) >> 7);
+	sens = (((s64)prom[1]) << c->sens_t1_shift) +
+	       (((s64)prom[3] * dt) >> c->sens_shift);
 	sens -= sens2;
 
 	/* Temperature compensated pressure = D1 * SENS - OFF */
 	*temperature = (temp - t2) * 10;
-	*pressure = (u32)(((((s64)p_adc * sens) >> 21) - off) >> 15);
+	*pressure = (u32)(((((s64)p_adc * sens) >> c->press_sens_shift) - off) >> c->press_shift);
 
 	return 0;
 }
drivers/iio/common/ms_sensors/ms_sensors_i2c.h +48 -0

62 lines not on this page · raw message

drivers/iio/pressure/ms5637.c +53 -8

80 lines not on this page · raw message

Signature · 1 line
2.55.0
#9 lore raw

PATCH v3 5/5 iio: pressure: ms5637: Add per-variant compensation

In reply to a message not in the archive

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.

---
 drivers/iio/pressure/ms5637.c | 376 ++++++++++++++++++++++++++++++++--
 1 file changed, 360 insertions(+), 16 deletions(-)
drivers/iio/pressure/ms5637.c +360 -16
index 359f3a8e79b2..81b87b79e011 100644
@@ -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 },
 	{ }
 };
Signature · 1 line
2.55.0
maintainer
#10 lore raw

Re: [PATCH v3 5/5] iio: pressure: ms5637: Add per-variant compensation

Quoted 9 lines · On Thu, 20 Aug 2026 10:12:20 -0400 Louis Adamian <[email protected]> wrote:

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.

Quoted 5 lines

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.

For this one Sashiko raises a valid concern. The ABI is changing for those deprecated choices. To avoid that will require a slightly annoying dance with extra copies of the data to keep the old name.

One other question below.

Quoted 34 lines
---
 drivers/iio/pressure/ms5637.c | 376 ++++++++++++++++++++++++++++++++--
 1 file changed, 360 insertions(+), 16 deletions(-)
drivers/iio/pressure/ms5637.c +24 -0
index 359f3a8e79b2..81b87b79e011 100644
 
 
+/*
+ * 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,

drivers/iio/pressure/ms5637.c static const struct ms_tp_comp_consts ms5637_02_consts = { · line 474

Quoted 10 lines
drivers/iio/pressure/ms5637.c +4 -1
+	.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,

Is this change actually a fix?

Quoted 1 line

+};

#11 lore raw

Re: [PATCH v3 5/5] iio: pressure: ms5637: Add per-variant compensation

Quoted 7 lines · On Fri, 21 Aug 2026 02:01:22 +0100 Jonathan Cameron <[email protected]> wrote:

For this one Sashiko raises a valid concern. The ABI is changing for those deprecated choices. To avoid that will require a slightly annoying dance with extra copies of the data to keep the old name.

One other question below.

I will add ms_tp_data structs for the deprecated meas,ms5637, meas,ms5803 and meas,ms5837 compatible strings, so the name there matches.

Quoted 31 lines
Quoted 31 lines

+/*
+ * 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
+ */

drivers/iio/pressure/ms5637.c +21 -0
+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,
 };
Quoted 7 lines

drivers/iio/pressure/ms5637.c static const struct ms_tp_comp_consts ms5637_02_consts = { · line 474

Quoted 5 lines

static const struct ms_tp_data ms5805_data = {

drivers/iio/pressure/ms5637.c +1 -1
 	.name = "ms5805",
 	.hw = &ms5637_hw_data,
-	.comp_consts = &ms5637_02_consts,
+	.comp_consts = &ms5805_consts,  

Is this change actually a fix?

No, I miswrote that. It's here because the hardware is different, so there is no implied shared compensation between them. I prefer to keep them separate but it can be removed if you prefer.