mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032
@ 2026-10-16 15:35 Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add ZillTek Technology Paulius Zaleckas
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas

The Zilltek ZTS8032 is a register compatible DPS310 with two more
pressure calibration coefficients (c31, c40) and a different TMP_CFG
layout.

1-2: Vendor prefix and the zilltek,zts8032 compatible.
3: Per-chip data in the I2C and ACPI match data, no functional change.
4: OF match table.
5: ZTS8032 chip data: the coefficient count, the TMP_CFG startup value,
   and a Horner step each for c40 and c31.

Based on iio/testing, on top of a22dc7ebb21a ("iio: pressure: dps310:
fix overflow in pressure compensation").

There is no public ZTS8032 datasheet.

Testing: ZTS8032 on an arm64 (MT7987) board, the series and a22dc7ebb21a
backported to 6.12. in_pressure_input matches the datasheet formula
evaluated from the raw and coefficient registers to within 1 Pa at every
oversampling rate from 1 to 128, and TMP_CFG reads 0x00 after probe.
Every patch builds without warnings with W=1 on x86_64 and i386,
dt_binding_check passes. I have no DPS310, so patches 3-4 are untested
on one. v4 only renames a macro; dps310.o code and data are identical
to v3.

An LLM coding assistant (Claude Code) was used for this series: it
ported the ZTS8032 support from the vendor driver, wrote the code and
changelogs and the hardware test scripts, under my direction. I
reviewed and tested the result.

Changes in v4:
- Rename DPS310_MAX_COEF_LEN to MAX_COEF_LEN, separated from the
  per-chip lengths by a blank line (Andy)
- Add Andy's and Joshua's Reviewed-by tags
- Link to v3: https://lore.kernel.org/r/20261015104945.2687162-1-paulius.zaleckas@gmail.com

Changes in v3:
- Drop v2 1/6, superseded by a22dc7ebb21a in iio/testing; rebase onto
  it and add c40 and c31 as Horner steps. This also covers the Sashiko
  overflow report on v2 1/6.
- C99 initializers for the ACPI ID (Andy, Uwe)
- Add DPS310_MAX_COEF_LEN in patch 3 and bump it in patch 5 (Andy)
- Parse c31/c40 based on a chip flag, not the coefficient count (Andy)
- List the supported sensors one per line in Kconfig (Andy)
- Link to v2: https://lore.kernel.org/r/20261013112124.1878296-1-paulius.zaleckas@gmail.com

Changes in v2:
- Split the driver patch into per-chip data, OF match table and
  ZTS8032 support (Andy)
- Drop the linux/mod_devicetable.h include (Andy, Uwe)
- Return -ENODATA when there is no match data (Andy)
- Add Conor's Acked-by to the bindings
- Link to v1: https://lore.kernel.org/r/20261012114550.1680054-1-paulius.zaleckas@ui.com

Paulius Zaleckas (5):
  dt-bindings: vendor-prefixes: Add ZillTek Technology
  dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032
  iio: pressure: dps310: add per-chip data
  iio: pressure: dps310: add an OF match table
  iio: pressure: dps310: add Zilltek ZTS8032 support

 .../iio/pressure/infineon,dps310.yaml         |  4 +-
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 drivers/iio/pressure/Kconfig                  |  6 +-
 drivers/iio/pressure/dps310.c                 | 74 ++++++++++++++++---
 4 files changed, 73 insertions(+), 13 deletions(-)


base-commit: a22dc7ebb21a6bd4c8b63bc2c1dd46a24945aae7
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add ZillTek Technology
  2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
@ 2026-10-16 15:35 ` Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 2/5] dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032 Paulius Zaleckas
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas,
	Conor Dooley

ZillTek Technology Corp. (Hsinchu, Taiwan) makes MEMS microphones and
barometric pressure sensors such as the ZTS8032.

Link: https://www.zilltek.com/
Assisted-by: LLM
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index ba2002969373..255dc56edc36 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1977,6 +1977,8 @@ patternProperties:
     description: Shenzhen Zidoo Technology Co., Ltd.
   "^zii,.*":
     description: Zodiac Inflight Innovations
+  "^zilltek,.*":
+    description: ZillTek Technology Corp.
   "^zinitix,.*":
     description: Zinitix Co., Ltd
   "^zkmagic,.*":
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 2/5] dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032
  2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add ZillTek Technology Paulius Zaleckas
@ 2026-10-16 15:35 ` Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 3/5] iio: pressure: dps310: add per-chip data Paulius Zaleckas
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas,
	Conor Dooley

The Zilltek ZTS8032 is register compatible with the DPS310, but has two
more pressure calibration coefficients and takes its temperature from a
different sensor by default, so it cannot use the DPS310 compatible as a
fallback.

Assisted-by: LLM
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
 .../devicetree/bindings/iio/pressure/infineon,dps310.yaml     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/pressure/infineon,dps310.yaml b/Documentation/devicetree/bindings/iio/pressure/infineon,dps310.yaml
index 1912a1b0b4ba..416117dfd927 100644
--- a/Documentation/devicetree/bindings/iio/pressure/infineon,dps310.yaml
+++ b/Documentation/devicetree/bindings/iio/pressure/infineon,dps310.yaml
@@ -11,12 +11,14 @@ maintainers:
 
 description:
   The DPS310 is a barometric pressure and temperature sensor with an I2C
-  interface.
+  interface. The Zilltek ZTS8032 is register compatible with it, but has
+  additional calibration coefficients.
 
 properties:
   compatible:
     enum:
       - infineon,dps310
+      - zilltek,zts8032
 
   reg:
     maxItems: 1
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 3/5] iio: pressure: dps310: add per-chip data
  2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add ZillTek Technology Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 2/5] dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032 Paulius Zaleckas
@ 2026-10-16 15:35 ` Paulius Zaleckas
  2026-10-16 23:57   ` Jonathan Cameron
  2026-10-16 15:35 ` [PATCH v4 4/5] iio: pressure: dps310: add an OF match table Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support Paulius Zaleckas
  4 siblings, 1 reply; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas

Move the coefficient count, the TMP_CFG startup value and the IIO device
name into a per-chip structure, passed through the I2C and ACPI match
data. This prepares for the Zilltek ZTS8032, which has two more
coefficients and a different TMP_CFG layout.

No functional change.

Assisted-by: LLM
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
 drivers/iio/pressure/dps310.c | 36 +++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
index 1d0b3232db9e..f2a8698e1e30 100644
--- a/drivers/iio/pressure/dps310.c
+++ b/drivers/iio/pressure/dps310.c
@@ -62,6 +62,9 @@
 #define DPS310_RESET		0x0c
 #define  DPS310_RESET_MAGIC	0x09
 #define DPS310_COEF_BASE	0x10
+#define DPS310_COEF_LEN		18
+
+#define MAX_COEF_LEN		18
 
 /* Make sure sleep time is <= 30ms for usleep_range */
 #define DPS310_POLL_SLEEP_US(t)		min(30000, (t) / 8)
@@ -86,10 +89,23 @@ static const int scale_factors[] = {
 	2088960,
 };
 
+struct dps310_chip_info {
+	const char *name;
+	u8 tmp_cfg;	/* TMP_CFG at startup: sensor the coefficients are for */
+	u8 coef_len;
+};
+
+static const struct dps310_chip_info dps310_chip_info = {
+	.name = "dps310",
+	.tmp_cfg = DPS310_TMP_EXT,
+	.coef_len = DPS310_COEF_LEN,
+};
+
 struct dps310_data {
 	struct i2c_client *client;
 	struct regmap *regmap;
 	struct mutex lock;	/* Lock for sequential HW access functions */
+	const struct dps310_chip_info *info;
 
 	s32 c0, c1;
 	s32 c00, c10, c20, c30, c01, c11, c21;
@@ -149,13 +165,13 @@ static const struct iio_chan_spec dps310_channels[] = {
 static int dps310_get_coefs(struct dps310_data *data)
 {
 	int rc;
-	u8 coef[18];
+	u8 coef[MAX_COEF_LEN];
 	u32 c0, c1;
 	u32 c00, c10, c20, c30, c01, c11, c21;
 
 	/* Read all sensor calibration coefficients from the COEF registers. */
 	rc = regmap_bulk_read(data->regmap, DPS310_COEF_BASE, coef,
-			      sizeof(coef));
+			      data->info->coef_len);
 	if (rc < 0)
 		return rc;
 
@@ -252,10 +268,10 @@ static int dps310_startup(struct dps310_data *data)
 		return rc;
 
 	/*
-	 * Set up external (MEMS) temperature sensor in single sample, one
-	 * measurement per second mode
+	 * Set up the temperature sensor the coefficients are for in single
+	 * sample, one measurement per second mode
 	 */
-	rc = regmap_write(data->regmap, DPS310_TMP_CFG, DPS310_TMP_EXT);
+	rc = regmap_write(data->regmap, DPS310_TMP_CFG, data->info->tmp_cfg);
 	if (rc)
 		return rc;
 
@@ -979,7 +995,11 @@ static int dps310_probe(struct i2c_client *client)
 	data->client = client;
 	mutex_init(&data->lock);
 
-	iio->name = DPS310_DEV_NAME;
+	data->info = i2c_get_match_data(client);
+	if (!data->info)
+		return -ENODATA;
+
+	iio->name = data->info->name;
 	iio->channels = dps310_channels;
 	iio->num_channels = ARRAY_SIZE(dps310_channels);
 	iio->info = &dps310_info;
@@ -1018,13 +1038,13 @@ static int dps310_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id dps310_id[] = {
-	{ .name = DPS310_DEV_NAME },
+	{ .name = "dps310", .driver_data = (kernel_ulong_t)&dps310_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, dps310_id);
 
 static const struct acpi_device_id dps310_acpi_match[] = {
-	{ "IFX3100" },
+	{ .id = "IFX3100", .driver_data = (kernel_ulong_t)&dps310_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(acpi, dps310_acpi_match);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 4/5] iio: pressure: dps310: add an OF match table
  2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
                   ` (2 preceding siblings ...)
  2026-10-16 15:35 ` [PATCH v4 3/5] iio: pressure: dps310: add per-chip data Paulius Zaleckas
@ 2026-10-16 15:35 ` Paulius Zaleckas
  2026-10-16 15:35 ` [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support Paulius Zaleckas
  4 siblings, 0 replies; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas

Devicetree nodes match the driver only through the I2C ID table fallback.
Add an OF match table, so the chip data comes from the compatible and the
module autoloads from the of: modalias the I2C core reports for
devicetree devices.

Assisted-by: LLM
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
 drivers/iio/pressure/dps310.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
index f2a8698e1e30..d0a2f6c6ec48 100644
--- a/drivers/iio/pressure/dps310.c
+++ b/drivers/iio/pressure/dps310.c
@@ -1043,6 +1043,12 @@ static const struct i2c_device_id dps310_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, dps310_id);
 
+static const struct of_device_id dps310_of_match[] = {
+	{ .compatible = "infineon,dps310", .data = &dps310_chip_info },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, dps310_of_match);
+
 static const struct acpi_device_id dps310_acpi_match[] = {
 	{ .id = "IFX3100", .driver_data = (kernel_ulong_t)&dps310_chip_info },
 	{ }
@@ -1052,6 +1058,7 @@ MODULE_DEVICE_TABLE(acpi, dps310_acpi_match);
 static struct i2c_driver dps310_driver = {
 	.driver = {
 		.name = DPS310_DEV_NAME,
+		.of_match_table = dps310_of_match,
 		.acpi_match_table = dps310_acpi_match,
 	},
 	.probe = dps310_probe,
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support
  2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
                   ` (3 preceding siblings ...)
  2026-10-16 15:35 ` [PATCH v4 4/5] iio: pressure: dps310: add an OF match table Paulius Zaleckas
@ 2026-10-16 15:35 ` Paulius Zaleckas
  2026-10-17  0:00   ` Jonathan Cameron
  4 siblings, 1 reply; 8+ messages in thread
From: Paulius Zaleckas @ 2026-10-16 15:35 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel, Paulius Zaleckas

The Zilltek ZTS8032 has the DPS310 register map, scale factors and
compensation, with these differences:

- two more pressure coefficients, c31 and c40 at 0x22-0x25, adding
  c40 * Praw_sc^4 + c31 * Traw_sc * Praw_sc^3 to the polynomial
- TMP_EXT is MEAS_CFG bit 3, and the temperature coefficients are for
  the internal sensor (COEF_SRCE reads 0x06). TMP_CFG bit 7 is the top
  bit of a 4-bit TMP_RATE, so the DPS310 TMP_EXT write would select a
  25/16 Hz background rate instead of the external sensor.
- product ID 0x11 instead of 0x10, the driver does not check it

Add its chip data, reading 22 coefficient bytes and leaving TMP_CFG at
0, a Horner step for each of c40 and c31, and the I2C and OF IDs.

Tested on a ZTS8032 over I2C: in_pressure_input is within 1 Pa of the
datasheet formula evaluated from the raw and coefficient registers at
every oversampling rate from 1 to 128, and TMP_CFG reads 0x00 after
probe.

Assisted-by: LLM
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
 drivers/iio/pressure/Kconfig  |  6 ++++--
 drivers/iio/pressure/dps310.c | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig
index cef8b90b9ae7..21363d542c38 100644
--- a/drivers/iio/pressure/Kconfig
+++ b/drivers/iio/pressure/Kconfig
@@ -115,8 +115,10 @@ config DPS310
 	select IIO_BUFFER
 	select IIO_TRIGGERED_BUFFER
 	help
-	  Support for the Infineon DPS310 digital barometric pressure sensor.
-	  It can be accessed over I2C bus.
+	  Support for the following digital barometric pressure sensors:
+	  - Infineon DPS310
+	  - Zilltek ZTS8032
+	  They can be accessed over I2C bus.
 
 	  This driver can also be built as a module.  If so, the module will be
 	  called dps310.
diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
index d0a2f6c6ec48..a97e82843dcd 100644
--- a/drivers/iio/pressure/dps310.c
+++ b/drivers/iio/pressure/dps310.c
@@ -7,6 +7,10 @@
  *
  * https://www.infineon.com/dgdl/?fileId=5546d462576f34750157750826c42242
  *
+ * The Zilltek ZTS8032 is register compatible, with two more pressure
+ * calibration coefficients (c31, c40) and temperature calibrated against
+ * the internal sensor.
+ *
  * Temperature calculation:
  *   c0 * 0.5 + c1 * T_raw / kT °C
  *
@@ -63,8 +67,9 @@
 #define  DPS310_RESET_MAGIC	0x09
 #define DPS310_COEF_BASE	0x10
 #define DPS310_COEF_LEN		18
+#define ZTS8032_COEF_LEN	22
 
-#define MAX_COEF_LEN		18
+#define MAX_COEF_LEN		22
 
 /* Make sure sleep time is <= 30ms for usleep_range */
 #define DPS310_POLL_SLEEP_US(t)		min(30000, (t) / 8)
@@ -93,6 +98,7 @@ struct dps310_chip_info {
 	const char *name;
 	u8 tmp_cfg;	/* TMP_CFG at startup: sensor the coefficients are for */
 	u8 coef_len;
+	bool has_c31_c40;
 };
 
 static const struct dps310_chip_info dps310_chip_info = {
@@ -101,6 +107,14 @@ static const struct dps310_chip_info dps310_chip_info = {
 	.coef_len = DPS310_COEF_LEN,
 };
 
+/* TMP_CFG bit 7 is a rate bit here; the internal sensor is the default */
+static const struct dps310_chip_info zts8032_chip_info = {
+	.name = "zts8032",
+	.tmp_cfg = 0,
+	.coef_len = ZTS8032_COEF_LEN,
+	.has_c31_c40 = true,
+};
+
 struct dps310_data {
 	struct i2c_client *client;
 	struct regmap *regmap;
@@ -109,6 +123,7 @@ struct dps310_data {
 
 	s32 c0, c1;
 	s32 c00, c10, c20, c30, c01, c11, c21;
+	s32 c31, c40;
 	s32 pressure_raw;
 	s32 temp_raw;
 	bool timeout_recovery_failed;
@@ -211,6 +226,11 @@ static int dps310_get_coefs(struct dps310_data *data)
 	c30 = (coef[16] << 8) | coef[17];
 	data->c30 = sign_extend32(c30, 15);
 
+	if (data->info->has_c31_c40) {
+		data->c31 = sign_extend32((coef[18] << 8) | coef[19], 15);
+		data->c40 = sign_extend32((coef[20] << 8) | coef[21], 15);
+	}
+
 	return 0;
 }
 
@@ -712,10 +732,15 @@ static int dps310_calculate_pressure(struct dps310_data *data, int *val)
 	if (rc)
 		return rc;
 
-	/* Section 4.9.1 of the DPS310 spec, Horner form to avoid overflow */
-	if (!dps310_horner_step(&prs, data->c30, p, kp) ||
+	/*
+	 * Section 4.9.1 of the DPS310 spec, Horner form to avoid overflow.
+	 * c40 and c31 are ZTS8032 only and zero on the DPS310.
+	 */
+	if (!dps310_horner_step(&prs, data->c40, p, kp) ||
+	    !dps310_horner_step(&prs, data->c30, p, kp) ||
 	    !dps310_horner_step(&prs, data->c20, p, kp) ||
 	    !dps310_horner_step(&prs, data->c10, p, kp) ||
+	    !dps310_horner_step(&tmp, data->c31, p, kp) ||
 	    !dps310_horner_step(&tmp, data->c21, p, kp) ||
 	    !dps310_horner_step(&tmp, data->c11, p, kp) ||
 	    !dps310_horner_step(&tmp, data->c01, t, kt))
@@ -1039,12 +1064,14 @@ static int dps310_probe(struct i2c_client *client)
 
 static const struct i2c_device_id dps310_id[] = {
 	{ .name = "dps310", .driver_data = (kernel_ulong_t)&dps310_chip_info },
+	{ .name = "zts8032", .driver_data = (kernel_ulong_t)&zts8032_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, dps310_id);
 
 static const struct of_device_id dps310_of_match[] = {
 	{ .compatible = "infineon,dps310", .data = &dps310_chip_info },
+	{ .compatible = "zilltek,zts8032", .data = &zts8032_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, dps310_of_match);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] iio: pressure: dps310: add per-chip data
  2026-10-16 15:35 ` [PATCH v4 3/5] iio: pressure: dps310: add per-chip data Paulius Zaleckas
@ 2026-10-16 23:57   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-10-16 23:57 UTC (permalink / raw)
  To: Paulius Zaleckas
  Cc: linux-iio, Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel

On Fri, 16 Oct 2026 18:35:31 +0300
Paulius Zaleckas <paulius.zaleckas@gmail.com> wrote:

> Move the coefficient count, the TMP_CFG startup value and the IIO device
> name into a per-chip structure, passed through the I2C and ACPI match
> data. This prepares for the Zilltek ZTS8032, which has two more
> coefficients and a different TMP_CFG layout.
> 
> No functional change.
> 
> Assisted-by: LLM
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
A few little things in line.

Sorry I'm late to the game - too much travel and catch up recently!

Jonathan

> ---
>  drivers/iio/pressure/dps310.c | 36 +++++++++++++++++++++++++++--------
>  1 file changed, 28 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
> index 1d0b3232db9e..f2a8698e1e30 100644
> --- a/drivers/iio/pressure/dps310.c
> +++ b/drivers/iio/pressure/dps310.c
> @@ -62,6 +62,9 @@
>  #define DPS310_RESET		0x0c
>  #define  DPS310_RESET_MAGIC	0x09
>  #define DPS310_COEF_BASE	0x10
> +#define DPS310_COEF_LEN		18
> +
> +#define MAX_COEF_LEN		18
>  
>  /* Make sure sleep time is <= 30ms for usleep_range */
>  #define DPS310_POLL_SLEEP_US(t)		min(30000, (t) / 8)
> @@ -86,10 +89,23 @@ static const int scale_factors[] = {
>  	2088960,
>  };
>  
> +struct dps310_chip_info {
> +	const char *name;
> +	u8 tmp_cfg;	/* TMP_CFG at startup: sensor the coefficients are for */

I had to look at the datasheet for the dps310 to figure out what this
meant.  Can we instead use a field for exactly what it is within TMP_CFG?

	bool coef_for_ext_sensor;


> +	u8 coef_len;
> +};
> +
> +static const struct dps310_chip_info dps310_chip_info = {
> +	.name = "dps310",
> +	.tmp_cfg = DPS310_TMP_EXT,
> +	.coef_len = DPS310_COEF_LEN,
> +};
> +
>  struct dps310_data {
>  	struct i2c_client *client;
>  	struct regmap *regmap;
>  	struct mutex lock;	/* Lock for sequential HW access functions */
> +	const struct dps310_chip_info *info;
>  
>  	s32 c0, c1;
>  	s32 c00, c10, c20, c30, c01, c11, c21;
> @@ -149,13 +165,13 @@ static const struct iio_chan_spec dps310_channels[] = {
>  static int dps310_get_coefs(struct dps310_data *data)
>  {
>  	int rc;
> -	u8 coef[18];
> +	u8 coef[MAX_COEF_LEN];
>  	u32 c0, c1;
>  	u32 c00, c10, c20, c30, c01, c11, c21;
>  
>  	/* Read all sensor calibration coefficients from the COEF registers. */
>  	rc = regmap_bulk_read(data->regmap, DPS310_COEF_BASE, coef,
> -			      sizeof(coef));
> +			      data->info->coef_len);
>  	if (rc < 0)
>  		return rc;
>  
> @@ -252,10 +268,10 @@ static int dps310_startup(struct dps310_data *data)
>  		return rc;
>  
>  	/*
> -	 * Set up external (MEMS) temperature sensor in single sample, one
> -	 * measurement per second mode
> +	 * Set up the temperature sensor the coefficients are for in single
> +	 * sample, one measurement per second mode
>  	 */
> -	rc = regmap_write(data->regmap, DPS310_TMP_CFG, DPS310_TMP_EXT);
> +	rc = regmap_write(data->regmap, DPS310_TMP_CFG, data->info->tmp_cfg);
With change above this would then ideally use appropriate FIELD_PREP()
calls to write 3 fields such that we don't need the comment at all. Something
like
	rc = regmap_write(data->regmap, DPS310_TMP_CFG,
			  FIELD_PREP(DPS310_TMP_PRC_BITS, DPS310_TMP_PRC_1) |
			  FIELD_PREP(DPS310_TMP_RATE_BITS, DPS310_TMP_RATE_1SPS) |
 			  FIELD_PREP(DPS310_TMP_EXT,
				     data->info->coef_for_ext_sensor ? 1 : 0));
(with a few defines to make that work).
BTW I love that the PRC values are defined as 'optional, and may not be relevant'.
Huh? What does that mean. I guess - don't use them!

>  	if (rc)
>  		return rc;
>  
> @@ -979,7 +995,11 @@ static int dps310_probe(struct i2c_client *client)
>  	data->client = client;
>  	mutex_init(&data->lock);
>  
> -	iio->name = DPS310_DEV_NAME;
> +	data->info = i2c_get_match_data(client);
> +	if (!data->info)
> +		return -ENODATA;
> +
> +	iio->name = data->info->name;
>  	iio->channels = dps310_channels;
>  	iio->num_channels = ARRAY_SIZE(dps310_channels);
>  	iio->info = &dps310_info;
> @@ -1018,13 +1038,13 @@ static int dps310_probe(struct i2c_client *client)
>  }
>  
>  static const struct i2c_device_id dps310_id[] = {
> -	{ .name = DPS310_DEV_NAME },
> +	{ .name = "dps310", .driver_data = (kernel_ulong_t)&dps310_chip_info },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, dps310_id);
>  
>  static const struct acpi_device_id dps310_acpi_match[] = {
> -	{ "IFX3100" },
> +	{ .id = "IFX3100", .driver_data = (kernel_ulong_t)&dps310_chip_info },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(acpi, dps310_acpi_match);


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support
  2026-10-16 15:35 ` [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support Paulius Zaleckas
@ 2026-10-17  0:00   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-10-17  0:00 UTC (permalink / raw)
  To: Paulius Zaleckas
  Cc: linux-iio, Eddie James, Joel Stanley, David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Uwe Kleine-König,
	Joshua Crofts, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Rupesh Majhi, devicetree, linux-kernel

On Fri, 16 Oct 2026 18:35:33 +0300
Paulius Zaleckas <paulius.zaleckas@gmail.com> wrote:

> The Zilltek ZTS8032 has the DPS310 register map, scale factors and
> compensation, with these differences:
> 
> - two more pressure coefficients, c31 and c40 at 0x22-0x25, adding
>   c40 * Praw_sc^4 + c31 * Traw_sc * Praw_sc^3 to the polynomial
> - TMP_EXT is MEAS_CFG bit 3, and the temperature coefficients are for
>   the internal sensor (COEF_SRCE reads 0x06). TMP_CFG bit 7 is the top
>   bit of a 4-bit TMP_RATE, so the DPS310 TMP_EXT write would select a
>   25/16 Hz background rate instead of the external sensor.
> - product ID 0x11 instead of 0x10, the driver does not check it
> 
> Add its chip data, reading 22 coefficient bytes and leaving TMP_CFG at
> 0, a Horner step for each of c40 and c31, and the I2C and OF IDs.
> 
> Tested on a ZTS8032 over I2C: in_pressure_input is within 1 Pa of the
> datasheet formula evaluated from the raw and coefficient registers at
> every oversampling rate from 1 to 128, and TMP_CFG reads 0x00 after
> probe.
> 
> Assisted-by: LLM
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>

Just a few small things.

Thanks,

Jonathan

> diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
> index d0a2f6c6ec48..a97e82843dcd 100644
> --- a/drivers/iio/pressure/dps310.c
> +++ b/drivers/iio/pressure/dps310.c

>  static const struct dps310_chip_info dps310_chip_info = {
> @@ -101,6 +107,14 @@ static const struct dps310_chip_info dps310_chip_info = {
>  	.coef_len = DPS310_COEF_LEN,
>  };
>  
> +/* TMP_CFG bit 7 is a rate bit here; the internal sensor is the default */

This is the comment that really confused me and lead to suggestion
of using a boolean for whether it was the external sensor or not.

> +static const struct dps310_chip_info zts8032_chip_info = {
> +	.name = "zts8032",
> +	.tmp_cfg = 0,
> +	.coef_len = ZTS8032_COEF_LEN,
> +	.has_c31_c40 = true,
> +};
> +
>  struct dps310_data {
>  	struct i2c_client *client;
>  	struct regmap *regmap;
> @@ -109,6 +123,7 @@ struct dps310_data {
>  
>  	s32 c0, c1;
>  	s32 c00, c10, c20, c30, c01, c11, c21;
> +	s32 c31, c40;
>  	s32 pressure_raw;
>  	s32 temp_raw;
>  	bool timeout_recovery_failed;
> @@ -211,6 +226,11 @@ static int dps310_get_coefs(struct dps310_data *data)
>  	c30 = (coef[16] << 8) | coef[17];
>  	data->c30 = sign_extend32(c30, 15);
>  
> +	if (data->info->has_c31_c40) {
> +		data->c31 = sign_extend32((coef[18] << 8) | coef[19], 15);
> +		data->c40 = sign_extend32((coef[20] << 8) | coef[21], 15);

Obviously lots of it here already but ideally use

data->c31 = sign_extend32(get_unaligned_be16(&coef[18]), 15);
etc

> +	}
> +
>  	return 0;


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-17  0:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 15:35 [PATCH v4 0/5] iio: pressure: dps310: add Zilltek ZTS8032 Paulius Zaleckas
2026-10-16 15:35 ` [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add ZillTek Technology Paulius Zaleckas
2026-10-16 15:35 ` [PATCH v4 2/5] dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032 Paulius Zaleckas
2026-10-16 15:35 ` [PATCH v4 3/5] iio: pressure: dps310: add per-chip data Paulius Zaleckas
2026-10-16 23:57   ` Jonathan Cameron
2026-10-16 15:35 ` [PATCH v4 4/5] iio: pressure: dps310: add an OF match table Paulius Zaleckas
2026-10-16 15:35 ` [PATCH v4 5/5] iio: pressure: dps310: add Zilltek ZTS8032 support Paulius Zaleckas
2026-10-17  0:00   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®