iio: pressure: add Sensirion SDP31 driver
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
v5 cover iio: pressure: add Sensirion SDP31 driver
This series adds support for the Sensirion SDP3x family of differential pressure sensors (SDP31, SDP32 and SDP33), I2C devices that also report temperature.
The SDP3x uses a completely different I2C command protocol from the already supported SDP500, so extending the sdp500 driver does not make sense.
Patch 1 adds the device tree binding.
Patch 2 adds the IIO driver, which exposes differential pressure and temperature channels and validates each measurement using the sensor's CRC-8 checksum. The SDP32 and SDP33 differ from the SDP31 only in range and use it as a fallback compatible; the scale factor is read from the sensor at runtime. Tested on an SDP31 wired to the I2C bus of a Raspberry Pi 4.
Changes since v4:
- dt-bindings: use sensirion,sdp31 as the fallback compatible for the SDP32 and SDP33 instead of listing them as independent compatibles.
- driver: match only sensirion,sdp31 and report the device as sdp31.
- driver: include headers for everything used directly, drop redundant casts and use KILO.
- Add the Assisted-by tags, which were missing from earlier versions.
v1: https://lore.kernel.org/linux-iio/[email protected]/
v2: https://lore.kernel.org/linux-iio/[email protected]/
v3: https://lore.kernel.org/linux-iio/[email protected]/
v4: https://lore.kernel.org/linux-iio/[email protected]/
Muhammad Abu Bakar (2):
dt-bindings: iio: pressure: add Sensirion SDP31
iio: pressure: add Sensirion SDP31 driver
.../iio/pressure/sensirion,sdp31.yaml | 51 ++++ MAINTAINERS | 6 + drivers/iio/pressure/Kconfig | 11 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/sdp31.c | 244 ++++++++++++++++++ 5 files changed, 313 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml create mode 100644 drivers/iio/pressure/sdp31.c
Signature · 1 line
2.43.0
PATCH v5 1/2 dt-bindings: iio: pressure: add Sensirion SDP31
Add device tree bindings for the Sensirion SDP3x family of differential pressure sensors (SDP31, SDP32 and SDP33), I2C devices that also report temperature.
--- .../iio/pressure/sensirion,sdp31.yaml | 51 +++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml
Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/pressure/sensirion,sdp31.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SDP31, SDP32 and SDP33 differential pressure sensors + +maintainers: + - Muhammad Abu Bakar <[email protected]> + +description: | + Differential pressure sensors from Sensirion with an I2C interface. + The SDP31, SDP32 and SDP33 differ only in their measurement range. + +properties: + compatible: + oneOf: + - items: + - enum: + - sensirion,sdp32 + - sensirion,sdp33 + - const: sensirion,sdp31 + - const: sensirion,sdp31 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: true + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + pressure@21 { + compatible = "sensirion,sdp31"; + reg = <0x21>; + vdd-supply = <&vdd_3v3>; + }; + };
MAINTAINERS +5 -0
@@ -24855,6 +24855,11 @@ S: Maintained F: Documentation/devicetree/bindings/iio/chemical/sensirion,scd4x.yaml F: drivers/iio/chemical/scd4x.c +SENSIRION SDP31 DIFFERENTIAL PRESSURE SENSOR DRIVER +M: Muhammad Abu Bakar <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml + SENSIRION SDP500 DIFFERENTIAL PRESSURE SENSOR DRIVER M: Petar Stoykov <[email protected]> S: Maintained
Signature · 1 line
2.43.0
Re: [PATCH v5 1/2] dt-bindings: iio: pressure: add Sensirion SDP31
Quoted 5 lines · Muhammad Abu Bakar
Add device tree bindings for the Sensirion SDP3x family of differential pressure sensors (SDP31, SDP32 and SDP33), I2C devices that also report temperature.
Assisted-by Claude:claude-opus-4-8
LLM, see current kernel docs for Assisted-by format.
Quoted 1 line
Assisted-by Claude:claude-opus-5-5
Drop
Quoted 15 lines
Signed-off-by Muhammad Abu Bakar <[email protected]>--- .../iio/pressure/sensirion,sdp31.yaml | 51 +++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yamlDocumentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml new file +2
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/iio/pressure/sensirion,sdp31.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SDP31, SDP32 and SDP33 differential pressure sensors + +maintainers: + - Muhammad Abu Bakar <[email protected]> + +description: |
Do not need '|' unless you need to preserve formatting.
Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml line 15
Quoted 3 lines
Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml new file +3
-0+ Differential pressure sensors from Sensirion with an I2C interface. + The SDP31, SDP32 and SDP33 differ only in their measurement range. +
With these two fixed:
Best regards,
Krzysztof
PATCH v5 2/2 iio: pressure: add Sensirion SDP31 driver
In reply to Muhammad Abu BakarAdd an IIO driver for the Sensirion SDP3x family of differential pressure sensors (SDP31, SDP32 and SDP33). The devices are accessed over I2C and report differential pressure and temperature. Each measurement is validated using the sensor's CRC-8 checksum. The scale factor is read from the sensor at runtime, so all three parts are supported.
Tested on an SDP31 connected to a Raspberry Pi 4 I2C bus.
--- MAINTAINERS | 1 + drivers/iio/pressure/Kconfig | 11 ++ drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/sdp31.c | 244 ++++++++++++++++++++++++++++++++++ 4 files changed, 257 insertions(+) create mode 100644 drivers/iio/pressure/sdp31.c
MAINTAINERS +1 -0
@@ -24859,6 +24859,7 @@ SENSIRION SDP31 DIFFERENTIAL PRESSURE SENSOR DRIVER M: Muhammad Abu Bakar <[email protected]> S: Maintained F: Documentation/devicetree/bindings/iio/pressure/sensirion,sdp31.yaml +F: drivers/iio/pressure/sdp31.c SENSIRION SDP500 DIFFERENTIAL PRESSURE SENSOR DRIVER M: Petar Stoykov <[email protected]>
drivers/iio/pressure/Kconfig +11 -0
@@ -286,6 +286,17 @@ config MS5637 This driver can also be built as a module. If so, the module will be called ms5637. +config SDP31 + tristate "Sensirion SDP31 differential pressure sensor I2C driver" + depends on I2C + select CRC8 + help + Say Y here to build support for Sensirion SDP31 differential pressure + sensor I2C driver. + + To compile this driver as a module, choose M here: the core module + will be called sdp31. + config SDP500 tristate "Sensirion SDP500 differential pressure sensor I2C driver" depends on I2C
drivers/iio/pressure/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_MS5611) += ms5611_core.o obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o obj-$(CONFIG_MS5637) += ms5637.o +obj-$(CONFIG_SDP31) += sdp31.o obj-$(CONFIG_SDP500) += sdp500.o obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o st_pressure-y := st_pressure_core.o
drivers/iio/pressure/sdp31.c new file +244 -0
244 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 7 lines · Muhammad Abu Bakar
Add an IIO driver for the Sensirion SDP3x family of differential pressure sensors (SDP31, SDP32 and SDP33). The devices are accessed over I2C and report differential pressure and temperature. Each measurement is validated using the sensor's CRC-8 checksum. The scale factor is read from the sensor at runtime, so all three parts are supported.
Tested on an SDP31 connected to a Raspberry Pi 4 I2C bus.
With the nit-picks addressed,
Quoted 2 lines
Assisted-by Claude:claude-opus-4-8Assisted-by Claude:claude-opus-5-5
Quoted 1 line
Signed-off-by Muhammad Abu Bakar <[email protected]>
...
drivers/iio/pressure/sdp31.c line 16
Quoted 10 lines
drivers/iio/pressure/sdp31.c new file +9
-0+#include <linux/array_size.h> +#include <linux/bits.h> +#include <linux/cleanup.h> +#include <linux/crc8.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h>
Not in the new code.
Quoted 7 lines
drivers/iio/pressure/sdp31.c new file +7
-0+#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/once.h> +#include <linux/regulator/consumer.h> +#include <linux/types.h> +#include <linux/unaligned.h> +#include <linux/units.h>
...
drivers/iio/pressure/sdp31.c line 86
Quoted 2 lines
drivers/iio/pressure/sdp31.c new file +2
-0+static int sdp31_read_measurement (struct sdp31_data *data,s16 *pressure, +s16 *temp)
Better to split on logical boundary
static int sdp31_read_measurement(struct sdp31_data *data,
s16 *pressure, s16 *temp)
Signature · 2 lines
With Best Regards, Andy Shevchenko