Skip to contentSkip to conversation

iio: pressure: add driver and bindings for adp810

PATCH Superseded Akhilesh Patil 3 participants 9 messages Oct 21, 2025 – Oct 25, 2025

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Akhilesh Patil

author maintainer
#0 lore raw

v3 cover iio: pressure: add driver and bindings for adp810

This patch series adds support for aosong adp810 differential pressure and temperature sensor driver in the IIO subsystem.

Patch 1: Adds bindings for this hardware. Patch 2: Adds driver code with device tree support.

Overview of adp810:
This is digital differential pressure and temperature sensor from aosong under the brand name of ASAIR. This sensor can measure pressure from -500 to +500Pa and temperature from -40 to +85 degree. It provides simple protocol to measure readings over I2C bus interface.

How to read from sensor (Protocol)?
To read from sensor, i2c master needs to send measure command 0x372d to start the data acquisition. Then host/master should wait for minimum 10ms for data to be ready before reading. Post this delay i2c master can read 9 bytes of measurement data which includes - pressure(u16): crc(u8): temperature(u16): crc(u8) scale factor (u16): crc(8).
Host/master can optionally verify crc for data integrity. Read sequence can be terminated anytime by sending NAK.

Datasheet: https://aosong.com/userfiles/files/media/Datasheet%20ADP810-Digital.pdf

Testing:
Driver is tested on Texas Instruments am62x sk board by connecting sensor at i2c-2. Data communication is validated with i2c bus at 100KHz and 400KHz using logic analyzer. Sensor values are read using iio subsystem's sysfs interface.

Changes in v3:
- Followed Include What You Use (IWYU) by adding additional include files (mutex.h, dev_printk.h and few others)
- Improved error handling of i2c_master_send() and i2c_master_recv() with additional transfer length checks.
- Changed style of structure initialization from {0} to { }
- Rebased on top of v6.18-rc2
- Link to v2: https://lore.kernel.org/lkml/[email protected]/

Changes in v2:
- Wrapped yaml binding description to 80 lines.
- Dropped block scalar ' | ' from binding description.
- Carry forward Reviewed-by tag from Krzysztof on device tree binding.
- Grammar and spelling fixes at multiple places.
- Ordered makefile alphabetically.
- Ordered include files alphabetically and used IWYU principle
- Explicitly mentioned unit of measure latency macro in MS (milliseconds)
- Added inline comments for explaining CRC8 polynomial for CRC calculation
- Used scoped_guard() for mutex for safe and clean lock handling.
- Used resource managed mutex_init() -> devm_mutex_init()
- Removed dead code in _probe() function.
- Used __be16 and related helpers to handle big endian data processing.
- Apply reverse xmas tree guideline while declaring local variables if possible.
- Used parent device pointer in dev_err() calls.
- Hardcode device name string in _probe() function for simplicity.
- Made default return value of _probe() function to 0.
- Rebased and retested driver on top of 6.18-rc1
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

Akhilesh Patil (2):
dt-bindings: iio: pressure: Add Aosong adp810
iio: pressure: adp810: Add driver for adp810 sensor

 .../bindings/iio/pressure/aosong,adp810.yaml  |  46 ++++
 MAINTAINERS                                   |   7 +
 drivers/iio/pressure/Kconfig                  |  12 +
 drivers/iio/pressure/Makefile                 |   8 +-
 drivers/iio/pressure/adp810.c                 | 222 ++++++++++++++++++
 5 files changed, 291 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml
 create mode 100644 drivers/iio/pressure/adp810.c
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v3 1/2 dt-bindings: iio: pressure: Add Aosong adp810

Add bindings for adp810 differential pressure and temperature sensor. This sensor communicates over I2C with CRC support and can measure pressure in the range -500 to 500Pa and temperature in the range -40 to +85 degree celsius.

---
 .../bindings/iio/pressure/aosong,adp810.yaml  | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml
Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml new file +46 -0
new file mode 100644
index 000000000000..b35eb63531c2
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/pressure/aosong,adp810.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: aosong adp810 differential pressure sensor
+
+maintainers:
+  - Akhilesh Patil <[email protected]>
+
+description:
+  ADP810 is differential pressure and temperature sensor. It has I2C bus
+  interface with fixed address of 0x25. This sensor supports 8 bit CRC for
+  reliable data transfer. It can measure differential pressure in the
+  range -500 to 500Pa and temperate in the range -40 to +85 degree celsius.
+
+properties:
+  compatible:
+    enum:
+      - aosong,adp810
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        pressure-sensor@25 {
+            compatible = "aosong,adp810";
+            reg = <0x25>;
+            vdd-supply = <&vdd_regulator>;
+        };
+    };
+
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v3 2/2 iio: pressure: adp810: Add driver for adp810 sensor

In reply to Akhilesh Patil

Add driver for Aosong adp810 differential pressure and temperature sensor. This sensor provides an I2C interface for reading data. Calculate CRC of the data received using standard crc8 library to verify data integrity.

Tested on TI am62x sk board with sensor connected at i2c-2.

---
 MAINTAINERS                   |   7 ++
 drivers/iio/pressure/Kconfig  |  12 ++
 drivers/iio/pressure/Makefile |   8 +-
 drivers/iio/pressure/adp810.c | 222 ++++++++++++++++++++++++++++++++++
 4 files changed, 245 insertions(+), 4 deletions(-)
 create mode 100644 drivers/iio/pressure/adp810.c
MAINTAINERS +7 -0
index 545a4776795e..89c56c7dccb4 100644
@@ -3745,6 +3745,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/chemical/aosong,ags02ma.yaml
 F:	drivers/iio/chemical/ags02ma.c
 
+AOSONG ADP810 DIFFERENTIAL PRESSURE SENSOR DRIVER
+M:	Akhilesh Patil <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml
+F:	drivers/iio/pressure/adp810.c
+
 ASC7621 HARDWARE MONITOR DRIVER
 M:	George Joseph <[email protected]>
 L:	[email protected]
drivers/iio/pressure/Kconfig +12 -0
index d2cb8c871f6a..2fe9dc90cceb 100644
@@ -339,4 +339,16 @@ config ZPA2326_SPI
 	tristate
 	select REGMAP_SPI
 
+config ADP810
+	tristate "Aosong adp810 differential pressure and temperature sensor"
+	depends on I2C
+	select CRC8
+	help
+	  Say yes here to build adp810 differential pressure and temperature
+	  sensor driver. ADP810 can measure pressure range up to 500Pa.
+	  It supports an I2C interface for data communication.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called adp810
+
 endmenu
drivers/iio/pressure/Makefile +4 -4
index 6482288e07ee..a21443e992b9 100644
@@ -5,6 +5,7 @@
 
 # When adding new entries keep the list in alphabetical order
 obj-$(CONFIG_ABP060MG) += abp060mg.o
+obj-$(CONFIG_ADP810) += adp810.o
 obj-$(CONFIG_ROHM_BM1390) += rohm-bm1390.o
 obj-$(CONFIG_BMP280) += bmp280.o
 bmp280-objs := bmp280-core.o bmp280-regmap.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_DPS310) += dps310.o
 obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_HP03) += hp03.o
+obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_HSC030PA) += hsc030pa.o
 obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
 obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
@@ -34,11 +36,9 @@ obj-$(CONFIG_SDP500) += sdp500.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
+obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
+obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
 obj-$(CONFIG_T5403) += t5403.o
-obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_ZPA2326) += zpa2326.o
 obj-$(CONFIG_ZPA2326_I2C) += zpa2326_i2c.o
 obj-$(CONFIG_ZPA2326_SPI) += zpa2326_spi.o
-
-obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
-obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
drivers/iio/pressure/adp810.c new file +222 -0

222 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

Quoted 4 lines · Akhilesh Patil

Add driver for Aosong adp810 differential pressure and temperature sensor. This sensor provides an I2C interface for reading data. Calculate CRC of the data received using standard crc8 library to verify data integrity.

Thanks for an update! Looks almost good to me, some comments below.

...

MAINTAINERS S: Maintained · line 3752

Quoted 4 lines
MAINTAINERS +4 -0
+M:	Akhilesh Patil <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml

Putting it here makes checkpatch unhappy. If someone thinks that is a false positive of the tool, perhaps one needs to fix that.

Quoted 1 line

+F: drivers/iio/pressure/adp810.c

...

Quoted 18 lines

# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ABP060MG) += abp060mg.o

drivers/iio/pressure/Makefile +2 -0
+obj-$(CONFIG_ADP810) += adp810.o
 obj-$(CONFIG_ROHM_BM1390) += rohm-bm1390.o
 obj-$(CONFIG_BMP280) += bmp280.o
 bmp280-objs := bmp280-core.o bmp280-regmap.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_DPS310) += dps310.o
 obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_HP03) += hp03.o
+obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_HSC030PA) += hsc030pa.o
 obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
 obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
@@ -34,11 +36,9 @@ obj-$(CONFIG_SDP500) += sdp500.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o

drivers/iio/pressure/Makefile obj-$(CONFIG_SDP500) += sdp500.o · line 44

Quoted 10 lines
drivers/iio/pressure/Makefile +2 -4
+obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
+obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
 obj-$(CONFIG_T5403) += t5403.o
-obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_ZPA2326) += zpa2326.o
 obj-$(CONFIG_ZPA2326_I2C) += zpa2326_i2c.o
 obj-$(CONFIG_ZPA2326_SPI) += zpa2326_spi.o
-
-obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
-obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o

I would split order fix into a separate change, but if maintainers are okay with this approach, I would not object.

...

drivers/iio/pressure/adp810.c line 19

Quoted 10 lines
drivers/iio/pressure/adp810.c new file +10 -0
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dev_printk.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/unaligned.h>

Something is still missing.

...

drivers/iio/pressure/adp810.c line 45

Quoted 7 lines
drivers/iio/pressure/adp810.c new file +7 -0
+struct adp810_read_buf {
+	__be16 dp;
+	u8 dp_crc;
+	__be16 tmp;
+	u8 tmp_crc;
+	__be16 sf;
+	u8 sf_crc;

All these types are provided in types.h

Quoted 1 line

+} __packed;

...

drivers/iio/pressure/adp810.c line 59

Quoted 6 lines
drivers/iio/pressure/adp810.c new file +6 -0
+static int adp810_measure(struct adp810_data *data, struct adp810_read_buf *buf)
+{
+	struct i2c_client *client = data->client;
+	struct device *dev = &client->dev;
+	int ret;
+	u16 trig_cmd = ADP810_TRIGGER_COMMAND;

Shouldn't this be __be16 or __le16? Or is that really a full 16-bit command? I have a gut feeling that this should be u8 x[2] = { ... }; instead.

drivers/iio/pressure/adp810.c line 68

Quoted 8 lines
drivers/iio/pressure/adp810.c new file +8 -0
+	/* Send trigger to the sensor for measurement */
+	ret = i2c_master_send(client, (char *)&trig_cmd, sizeof(trig_cmd));
+	if (ret < 0) {
+		dev_err(dev, "Error sending trigger command\n");
+		return ret;
+	}
+	if (ret != sizeof(trig_cmd))
+		return -EIO;

-EIO is defined down from linux/errno.h.

Quoted 34 lines
drivers/iio/pressure/adp810.c new file +34 -0
+	/*
+	 * Wait for the sensor to acquire data. As per datasheet section 5.3.1,
+	 * wait for at least 10ms before reading measurements from the sensor.
+	 */
+	msleep(ADP810_MEASURE_LATENCY_MS);
+
+	/* Read sensor values */
+	ret = i2c_master_recv(client, (char *)buf, sizeof(*buf));
+	if (ret < 0) {
+		dev_err(dev, "Error reading from sensor\n");
+		return ret;
+	}
+	if (ret != sizeof(*buf))
+		return -EIO;
+
+	/* CRC checks */
+	crc8_populate_msb(crc_table, ADP810_CRC8_POLYNOMIAL);
+	if (buf->dp_crc != crc8(crc_table, (u8 *)&buf->dp, 0x2, CRC8_INIT_VALUE)) {
+		dev_err(dev, "CRC error for pressure\n");
+		return -EIO;
+	}
+
+	if (buf->tmp_crc != crc8(crc_table, (u8 *)&buf->tmp, 0x2, CRC8_INIT_VALUE)) {
+		dev_err(dev, "CRC error for temperature\n");
+		return -EIO;
+	}
+
+	if (buf->sf_crc != crc8(crc_table, (u8 *)&buf->sf, 0x2, CRC8_INIT_VALUE)) {
+		dev_err(dev, "CRC error for scale\n");
+		return -EIO;
+	}
+
+	return 0;
+}

...

drivers/iio/pressure/adp810.c line 187

Quoted 1 line
drivers/iio/pressure/adp810.c new file +1 -0
+	indio_dev->num_channels = ARRAY_SIZE(adp810_channels);

ARRAY_SIZE() is defined in a specific header.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

Quoted 25 lines
Quoted 25 lines

# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ABP060MG) += abp060mg.o

drivers/iio/pressure/Makefile +4 -1
+obj-$(CONFIG_ADP810) += adp810.o
 obj-$(CONFIG_ROHM_BM1390) += rohm-bm1390.o
 obj-$(CONFIG_BMP280) += bmp280.o
 bmp280-objs := bmp280-core.o bmp280-regmap.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_DPS310) += dps310.o
 obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_HP03) += hp03.o
+obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_HSC030PA) += hsc030pa.o
 obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
 obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
@@ -34,11 +36,9 @@ obj-$(CONFIG_SDP500) += sdp500.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
+obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
+obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
 obj-$(CONFIG_T5403) += t5403.o
-obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_ZPA2326) += zpa2326.o
Quoted 8 lines

drivers/iio/pressure/Makefile obj-$(CONFIG_SDP500) += sdp500.o · line 44

Quoted 5 lines
drivers/iio/pressure/Makefile +0 -3
 obj-$(CONFIG_ZPA2326_I2C) += zpa2326_i2c.o
 obj-$(CONFIG_ZPA2326_SPI) += zpa2326_spi.o
-
-obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
-obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o  

I would split order fix into a separate change, but if maintainers are okay with this approach, I would not object.

I was late to replying to v2 on this. Split it out please.

author maintainer
#5 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

Quoted 34 lines · Jonathan Cameron
Quoted 25 lines
Quoted 25 lines

# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ABP060MG) += abp060mg.o

drivers/iio/pressure/Makefile +4 -1
+obj-$(CONFIG_ADP810) += adp810.o
 obj-$(CONFIG_ROHM_BM1390) += rohm-bm1390.o
 obj-$(CONFIG_BMP280) += bmp280.o
 bmp280-objs := bmp280-core.o bmp280-regmap.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_DPS310) += dps310.o
 obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_HP03) += hp03.o
+obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_HSC030PA) += hsc030pa.o
 obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
 obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
@@ -34,11 +36,9 @@ obj-$(CONFIG_SDP500) += sdp500.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
+obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
+obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
 obj-$(CONFIG_T5403) += t5403.o
-obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_ZPA2326) += zpa2326.o
Quoted 8 lines

drivers/iio/pressure/Makefile obj-$(CONFIG_SDP500) += sdp500.o · line 44

Quoted 5 lines
drivers/iio/pressure/Makefile +0 -3
 obj-$(CONFIG_ZPA2326_I2C) += zpa2326_i2c.o
 obj-$(CONFIG_ZPA2326_SPI) += zpa2326_spi.o
-
-obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
-obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o  

I would split order fix into a separate change, but if maintainers are okay with this approach, I would not object.

Quoted 1 line

I was late to replying to v2 on this. Split it out please.

Sure. I will take reordering of other entries as an independent patch. In this series, let's add adp810.o only at alphabetically correct place.

Regards,
Akhilesh

author maintainer
#6 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Akhilesh Patil

Add driver for Aosong adp810 differential pressure and temperature sensor. This sensor provides an I2C interface for reading data. Calculate CRC of the data received using standard crc8 library to verify data integrity.

Thanks for an update! Looks almost good to me, some comments below.

Thanks for the below comments and suggestions.
Addressed them in v4.

Regards,
Akhilesh

Quoted 10 lines

...

MAINTAINERS S: Maintained · line 3752

Quoted 4 lines
MAINTAINERS +4 -0
+M:	Akhilesh Patil <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/pressure/aosong,adp810.yaml

Putting it here makes checkpatch unhappy. If someone thinks that is a false positive of the tool, perhaps one needs to fix that.

This is being followed up in v1 thread.
https://lore.kernel.org/lkml/[email protected]/

Quoted 28 lines
Quoted 2 lines

+F: drivers/iio/pressure/adp810.c

...

Quoted 23 lines

# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ABP060MG) += abp060mg.o

drivers/iio/pressure/Makefile +4 -1
+obj-$(CONFIG_ADP810) += adp810.o
 obj-$(CONFIG_ROHM_BM1390) += rohm-bm1390.o
 obj-$(CONFIG_BMP280) += bmp280.o
 bmp280-objs := bmp280-core.o bmp280-regmap.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_DPS310) += dps310.o
 obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_HP03) += hp03.o
+obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_HSC030PA) += hsc030pa.o
 obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
 obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
@@ -34,11 +36,9 @@ obj-$(CONFIG_SDP500) += sdp500.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
+obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
+obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o
 obj-$(CONFIG_T5403) += t5403.o
-obj-$(CONFIG_HP206C) += hp206c.o
 obj-$(CONFIG_ZPA2326) += zpa2326.o
Quoted 8 lines

drivers/iio/pressure/Makefile obj-$(CONFIG_SDP500) += sdp500.o · line 44

Quoted 5 lines
drivers/iio/pressure/Makefile +0 -3
 obj-$(CONFIG_ZPA2326_I2C) += zpa2326_i2c.o
 obj-$(CONFIG_ZPA2326_SPI) += zpa2326_spi.o
-
-obj-$(CONFIG_IIO_ST_PRESS_I2C) += st_pressure_i2c.o
-obj-$(CONFIG_IIO_ST_PRESS_SPI) += st_pressure_spi.o

I would split order fix into a separate change, but if maintainers are okay with this approach, I would not object.

Okay. Adding only adp810.o here. Will revert all other entries. This will make this change logically connected to this series.

Quoted 15 lines

...

drivers/iio/pressure/adp810.c line 19

Quoted 10 lines
drivers/iio/pressure/adp810.c new file +10 -0
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dev_printk.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/unaligned.h>

Something is still missing.

Added more include files as pointed out further below.

Quoted 12 lines

...

drivers/iio/pressure/adp810.c line 45

Quoted 7 lines
drivers/iio/pressure/adp810.c new file +7 -0
+struct adp810_read_buf {
+	__be16 dp;
+	u8 dp_crc;
+	__be16 tmp;
+	u8 tmp_crc;
+	__be16 sf;
+	u8 sf_crc;

All these types are provided in types.h

ACK. Added linux/types.h

Quoted 5 lines
Quoted 2 lines

+} __packed;

...

Quoted 9 lines

drivers/iio/pressure/adp810.c line 59

Quoted 6 lines
drivers/iio/pressure/adp810.c new file +6 -0
+static int adp810_measure(struct adp810_data *data, struct adp810_read_buf *buf)
+{
+	struct i2c_client *client = data->client;
+	struct device *dev = &client->dev;
+	int ret;
+	u16 trig_cmd = ADP810_TRIGGER_COMMAND;

Shouldn't this be __be16 or __le16? Or is that really a full 16-bit command? I have a gut feeling that this should be u8 x[2] = { ... }; instead.

Ohh yes. Nice catch !
This is 16 bit trigger command. We need to send 0x37 then 0x2d. I defined trig_cmd = 0x2d37 which will work fine on little endian systems, but will fail on big endian systems I think.
I use ARM v8-A configured in little endian, so did not catch this. Let me use u8 trig_cmd[2] = {0x37, 0x2d} to make this architecture agnostic.

Quoted 11 lines

drivers/iio/pressure/adp810.c line 68

Quoted 9 lines
drivers/iio/pressure/adp810.c new file +8 -0
+	/* Send trigger to the sensor for measurement */
+	ret = i2c_master_send(client, (char *)&trig_cmd, sizeof(trig_cmd));
+	if (ret < 0) {
+		dev_err(dev, "Error sending trigger command\n");
+		return ret;
+	}
+	if (ret != sizeof(trig_cmd))
+		return -EIO;

-EIO is defined down from linux/errno.h.

ACK. Added linux/errno.h

Quoted 27 lines
Quoted 24 lines
drivers/iio/pressure/adp810.c new file +23 -0
+	/*
+	 * Wait for the sensor to acquire data. As per datasheet section 5.3.1,
+	 * wait for at least 10ms before reading measurements from the sensor.
+	 */
+	msleep(ADP810_MEASURE_LATENCY_MS);
+
+	/* Read sensor values */
+	ret = i2c_master_recv(client, (char *)buf, sizeof(*buf));
+	if (ret < 0) {
+		dev_err(dev, "Error reading from sensor\n");
+		return ret;
+	}
+	if (ret != sizeof(*buf))
+		return -EIO;
+
+
+	if (buf->sf_crc != crc8(crc_table, (u8 *)&buf->sf, 0x2, CRC8_INIT_VALUE)) {
+		dev_err(dev, "CRC error for scale\n");
+		return -EIO;
+	}
+
+	return 0;
+}

...

Quoted 3 lines

drivers/iio/pressure/adp810.c line 187

Quoted 1 line
drivers/iio/pressure/adp810.c new file +1 -0
+	indio_dev->num_channels = ARRAY_SIZE(adp810_channels);

ARRAY_SIZE() is defined in a specific header.

ACK. Added linux/array_size.h

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

In reply to Akhilesh Patil
Quoted 8 lines · On Tue, 21 Oct 2025 11:20:30 +0530 Akhilesh Patil <[email protected]>…

Add driver for Aosong adp810 differential pressure and temperature sensor. This sensor provides an I2C interface for reading data. Calculate CRC of the data received using standard crc8 library to verify data integrity.

Tested on TI am62x sk board with sensor connected at i2c-2.

A couple of trivial bits of follow up from me given you are going to be doing a v4 for the stuff Andy picked up on. Otherwise I'd just have tweaked it whilst applying for these two.

drivers/iio/pressure/adp810.c line 28

Quoted 11 lines
drivers/iio/pressure/adp810.c new file +5 -0
new file mode 100644
index 000000000000..5fcb0447c628
 
+/*
+ * Time taken in ms by sensor to do measurements after triggering.
+ * As per datasheet 10ms is sufficient but we define 30ms for better margin.
+ */
+#define ADP810_MEASURE_LATENCY_MS	30

I'd just put this value in the one place that it is used and combine the two comments on why it has this particular value.

30ms seems like a bit over the top for handling silicon variation etc. Any background for the large margin? If you've seen this as necessary in practice then just state that - it's useful info to have available to a future reader of the driver.

drivers/iio/pressure/adp810.c line 151

Quoted 2 lines
drivers/iio/pressure/adp810.c new file +2 -0
+static const struct iio_info adp810_info = {
+	.read_raw	= adp810_read_raw,

Trivial but there is no benefit in using a tab before the =

In general aligning this stuff isn't a good plan. It causes a mass of churn in the long run as some of the callbacks have longer names and suddenly whole thing needs reindenting.

Quoted 1 line

+};

author maintainer
#8 lore raw

Re: [PATCH v3 2/2] iio: pressure: adp810: Add driver for adp810 sensor

Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Tue, 21 Oct 2025 11:20:30 +0530 Akhilesh Patil <[email protected]>…

Add driver for Aosong adp810 differential pressure and temperature sensor. This sensor provides an I2C interface for reading data. Calculate CRC of the data received using standard crc8 library to verify data integrity.

Quoted 7 lines
Quoted 3 lines

Tested on TI am62x sk board with sensor connected at i2c-2.

A couple of trivial bits of follow up from me given you are going to be doing a v4 for the stuff Andy picked up on. Otherwise I'd just have tweaked it whilst applying for these two.

Sure.

Quoted 7 lines
Quoted 6 lines
drivers/iio/pressure/adp810.c new file +0 -0
new file mode 100644
index 000000000000..5fcb0447c628
Quoted 7 lines

drivers/iio/pressure/adp810.c line 28

Quoted 5 lines
drivers/iio/pressure/adp810.c new file +5 -0
+/*
+ * Time taken in ms by sensor to do measurements after triggering.
+ * As per datasheet 10ms is sufficient but we define 30ms for better margin.
+ */
+#define ADP810_MEASURE_LATENCY_MS	30

I'd just put this value in the one place that it is used and combine the two comments on why it has this particular value.

Okay. Removed this macro and used value directly along with improved comment.

Quoted 5 lines

30ms seems like a bit over the top for handling silicon variation etc. Any background for the large margin? If you've seen this as necessary in practice then just state that - it's useful info to have available to a future reader of the driver.

Datasheet recommends value greater than 10ms. 30ms is what I started with for initial testing. I have checked it working for even 10ms, 20ms etc. Let me use 20ms here with margin over 10 and mention it in the comment in code.

Quoted 9 lines

drivers/iio/pressure/adp810.c line 151

Quoted 4 lines
drivers/iio/pressure/adp810.c new file +2 -0
+static const struct iio_info adp810_info = {
+	.read_raw	= adp810_read_raw,

Trivial but there is no benefit in using a tab before the =

In general aligning this stuff isn't a good plan. It causes a mass of churn in the long run as some of the callbacks have longer names and suddenly whole thing needs reindenting.

okay, got it. Fixed.

Regards,
Akhilesh