From: Paulius Zaleckas <paulius.zaleckas@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Cc: "Eddie James" <eajames@linux.ibm.com>,
"Joel Stanley" <joel@jms.id.au>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Rupesh Majhi" <zoone.rupert@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
"Paulius Zaleckas" <paulius.zaleckas@gmail.com>
Subject: [PATCH v2 6/6] iio: pressure: dps310: add Zilltek ZTS8032 support
Date: Tue, 13 Oct 2026 14:21:24 +0300 [thread overview]
Message-ID: <20261013112124.1878296-7-paulius.zaleckas@gmail.com> (raw)
In-Reply-To: <20261013112124.1878296-1-paulius.zaleckas@gmail.com>
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, and the I2C and OF IDs.
Tested on a ZTS8032 at 0x76 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
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
---
drivers/iio/pressure/Kconfig | 4 ++--
drivers/iio/pressure/dps310.c | 26 +++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig
index cef8b90b9ae7..e407243e131c 100644
--- a/drivers/iio/pressure/Kconfig
+++ b/drivers/iio/pressure/Kconfig
@@ -115,8 +115,8 @@ 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 Infineon DPS310 and Zilltek ZTS8032 digital
+ barometric pressure sensors. 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 3b27a61b70a5..be8b0c053c4a 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
*
@@ -62,6 +66,7 @@
#define DPS310_RESET_MAGIC 0x09
#define DPS310_COEF_BASE 0x10
#define DPS310_COEF_LEN 18
+#define ZTS8032_COEF_LEN 22
/* Make sure sleep time is <= 30ms for usleep_range */
#define DPS310_POLL_SLEEP_US(t) min(30000, (t) / 8)
@@ -98,6 +103,13 @@ 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,
+};
+
struct dps310_data {
struct i2c_client *client;
struct regmap *regmap;
@@ -106,6 +118,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;
@@ -162,7 +175,7 @@ static const struct iio_chan_spec dps310_channels[] = {
static int dps310_get_coefs(struct dps310_data *data)
{
int rc;
- u8 coef[DPS310_COEF_LEN];
+ u8 coef[ZTS8032_COEF_LEN];
u32 c0, c1;
u32 c00, c10, c20, c30, c01, c11, c21;
@@ -208,6 +221,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->coef_len == ZTS8032_COEF_LEN) {
+ data->c31 = sign_extend32((coef[18] << 8) | coef[19], 15);
+ data->c40 = sign_extend32((coef[20] << 8) | coef[21], 15);
+ }
+
return 0;
}
@@ -696,6 +714,7 @@ static int dps310_calculate_pressure(struct dps310_data *data, int *val)
s64 ts;
s64 x2;
s64 x3;
+ s64 x4;
rc = dps310_get_pres_k(data, &kp);
if (rc)
@@ -716,6 +735,7 @@ static int dps310_calculate_pressure(struct dps310_data *data, int *val)
ts = div_s64(t * DPS310_Q_ONE, kt);
x2 = dps310_mul_q(ps, ps);
x3 = dps310_mul_q(x2, ps);
+ x4 = dps310_mul_q(x3, ps);
pressure = data->c00 * DPS310_Q_ONE;
pressure += div_s64(p * data->c10 * DPS310_Q_ONE, kp);
@@ -723,6 +743,8 @@ static int dps310_calculate_pressure(struct dps310_data *data, int *val)
pressure += dps310_mul_q(data->c11 * ps, ts);
pressure += data->c20 * x2 + data->c30 * x3;
pressure += dps310_mul_q(data->c21 * x2, ts);
+ /* ZTS8032 only, c31 and c40 are zero on the DPS310 */
+ pressure += data->c40 * x4 + dps310_mul_q(data->c31 * x3, ts);
pressure >>= DPS310_Q;
if (pressure < 0LL)
return -ERANGE;
@@ -1041,12 +1063,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
next prev parent reply other threads:[~2026-10-13 11:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 11:21 [PATCH v2 0/6] iio: pressure: dps310: fix pressure overflow, add Zilltek ZTS8032 Paulius Zaleckas
2026-10-13 11:21 ` [PATCH v2 1/6] iio: pressure: dps310: fix overflow in the pressure compensation Paulius Zaleckas
2026-10-13 11:21 ` [PATCH v2 2/6] dt-bindings: vendor-prefixes: Add ZillTek Technology Paulius Zaleckas
2026-10-13 11:21 ` [PATCH v2 3/6] dt-bindings: iio: pressure: infineon,dps310: Add Zilltek ZTS8032 Paulius Zaleckas
2026-10-13 11:21 ` [PATCH v2 4/6] iio: pressure: dps310: add per-chip data Paulius Zaleckas
2026-10-13 16:52 ` Andy Shevchenko
2026-10-13 11:21 ` [PATCH v2 5/6] iio: pressure: dps310: add an OF match table Paulius Zaleckas
2026-10-13 11:21 ` Paulius Zaleckas [this message]
2026-10-13 16:59 ` [PATCH v2 6/6] iio: pressure: dps310: add Zilltek ZTS8032 support Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013112124.1878296-7-paulius.zaleckas@gmail.com \
--to=paulius.zaleckas@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=eajames@linux.ibm.com \
--cc=jic23@kernel.org \
--cc=joel@jms.id.au \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=zoone.rupert@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®