Skip to contentSkip to conversation

iio: pressure: hsc030pa: cleanup and triggered buffer

PATCH Applied Petre Rodan 2 participants 8 messages Feb 11, 2024 – Feb 16, 2024

Subsystems (3)
lore
Share & tools
lore

Petre Rodan

author maintainer
#0 lore raw

v3 cover iio: pressure: hsc030pa: cleanup and triggered buffer

This set of patches covers the following:

- small cleanup
- mandatory 2ms delay between readings
- support for triggered buffer readings

The support for devices that have "sleep mode" factory option that was present in v1 of this patchset was removed, for a few reasons:

- a Honeywell employee told me that this chip variant is extremely unlikely to be found in the wild, which also makes testing the driver functionality impossible
- I found no reliable way of generating i2c/spi bus traffic with no payload (toggle CS for SPI case, send i2c packet containing only the address byte) that are required for the wakeup sequence.

Petre Rodan (6):
dt-bindings: iio: pressure: honeywell,hsc030pa.yaml add spi props
iio: pressure: hsc030pa: use signed type to hold div_64() result
iio: pressure: hsc030pa: include cleanup
iio: pressure: hsc030pa: update datasheet URLs
iio: pressure: hsc030pa add mandatory delay
iio: pressure: hsc030pa add triggered buffer

 .../iio/pressure/honeywell,hsc030pa.yaml      |  3 ++
 drivers/iio/pressure/Kconfig                  |  2 +
 drivers/iio/pressure/hsc030pa.c               | 49 ++++++++++++++++++-
 drivers/iio/pressure/hsc030pa.h               |  7 +++
 drivers/iio/pressure/hsc030pa_i2c.c           |  9 +++-
 drivers/iio/pressure/hsc030pa_spi.c           |  7 ++-
 6 files changed, 73 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v3 1/6 dt-bindings: iio: pressure: honeywell,hsc030pa.yaml add spi props

Add spi-peripheral-props.yaml requirement needed by the spi-max-frequency property.

---
v1 -> v2 change the commit message based on Krzysztof's request v2 -> v3 no changes

 .../devicetree/bindings/iio/pressure/honeywell,hsc030pa.yaml   | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/iio/pressure/honeywell,hsc030pa.yaml +3 -0
index 65a24ed67b3c..89977b9f01cf 100644
@@ -99,6 +99,9 @@ required:
   - honeywell,transfer-function
   - honeywell,pressure-triplet
 
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml
+
 additionalProperties: false
 
 dependentSchemas:
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v3 2/6 iio: pressure: hsc030pa: use signed type to hold div_64() result

In reply to Petre Rodan

Use signed type to variable holding the result given by div_s64().

---
v1 -> v2 no changes
v2 -> v3 split cleanup patch into 3 parts, no code changes

 drivers/iio/pressure/hsc030pa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/hsc030pa.c +1 -1
index d6a51f0c335f..7e3f74d53b47 100644
@@ -406,7 +406,7 @@ int hsc_common_probe(struct device *dev, hsc_recv_fn recv)
 	struct hsc_data *hsc;
 	struct iio_dev *indio_dev;
 	const char *triplet;
-	u64 tmp;
+	s64 tmp;
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*hsc));
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v3 3/6 iio: pressure: hsc030pa: include cleanup

In reply to Petre Rodan

Add includes based on prior reviews from Andy.

---
v1 -> v2 no changes
v2 -> v3 split cleanup patch into 3 parts, no code changes

 drivers/iio/pressure/hsc030pa.h     | 2 ++
 drivers/iio/pressure/hsc030pa_i2c.c | 2 ++
 drivers/iio/pressure/hsc030pa_spi.c | 2 ++
 3 files changed, 6 insertions(+)
drivers/iio/pressure/hsc030pa.h +2 -0
index d20420dba4f6..f1079a70799f 100644
@@ -10,6 +10,8 @@
 
 #include <linux/types.h>
 
+#include <linux/iio/iio.h>
+
 #define HSC_REG_MEASUREMENT_RD_SIZE 4
 
 struct device;
drivers/iio/pressure/hsc030pa_i2c.c +2 -0
index e2b524b36417..b0c47f863afb 100644
@@ -8,10 +8,12 @@
  * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/common/documents/sps-siot-i2c-comms-digital-output-pressure-sensors-tn-008201-3-en-ciid-45841.pdf [i2c related]
  */
 
+#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/types.h>
 
 #include <linux/iio/iio.h>
 
drivers/iio/pressure/hsc030pa_spi.c +2 -0
index a719bade8326..f6da49cdb5e5 100644
@@ -7,10 +7,12 @@
  * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/trustability-hsc-series/documents/sps-siot-trustability-hsc-series-high-accuracy-board-mount-pressure-sensors-50099148-a-en-ciid-151133.pdf
  */
 
+#include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
 #include <linux/stddef.h>
+#include <linux/types.h>
 
 #include <linux/iio/iio.h>
 
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH v3 4/6 iio: pressure: hsc030pa: update datasheet URLs

In reply to Petre Rodan

Provide bus-specific technical datasheet in the _i2c.c _spi.c headers instead of the generic one.

---
v1 -> v2 no changes
v2 -> v3 split cleanup patch into 3 parts, no code changes

 drivers/iio/pressure/hsc030pa_i2c.c | 4 ++--
 drivers/iio/pressure/hsc030pa_spi.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/iio/pressure/hsc030pa_i2c.c +2 -2
index b0c47f863afb..b5810bafef40 100644
@@ -4,8 +4,8 @@
  *
  * Copyright (c) 2023 Petre Rodan <[email protected]>
  *
- * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/trustability-hsc-series/documents/sps-siot-trustability-hsc-series-high-accuracy-board-mount-pressure-sensors-50099148-a-en-ciid-151133.pdf [hsc]
- * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/common/documents/sps-siot-i2c-comms-digital-output-pressure-sensors-tn-008201-3-en-ciid-45841.pdf [i2c related]
+ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/common/documents/sps-siot-i2c-comms-digital-output-pressure-sensors-tn-008201-3-en-ciid-45841.pdf
+ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf
  */
 
 #include <linux/device.h>
drivers/iio/pressure/hsc030pa_spi.c +2 -1
index f6da49cdb5e5..8d3441f1dcf9 100644
@@ -4,7 +4,8 @@
  *
  * Copyright (c) 2023 Petre Rodan <[email protected]>
  *
- * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/trustability-hsc-series/documents/sps-siot-trustability-hsc-series-high-accuracy-board-mount-pressure-sensors-50099148-a-en-ciid-151133.pdf
+ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-spi-comms-digital-ouptu-pressure-sensors-tn-008202-3-en-ciid-45843.pdf
+ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf
  */
 
 #include <linux/device.h>
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v3 5/6 iio: pressure: hsc030pa add mandatory delay

In reply to Petre Rodan

Add a mandatory 2ms delay between consecutive chip reads.

A Technical Note pdf specifies that the measurement cycle in these chips takes around 1.26ms. By adding this 2ms delay we make sure that we never get stale measurements.

For more details, please see "Figure 1" in the pdf below:

https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf

---
v1 -> v3 no changes

 drivers/iio/pressure/hsc030pa.h     | 1 +
 drivers/iio/pressure/hsc030pa_i2c.c | 3 +++
 drivers/iio/pressure/hsc030pa_spi.c | 2 ++
 3 files changed, 6 insertions(+)
drivers/iio/pressure/hsc030pa.h +1 -0
index f1079a70799f..56dc8e88194b 100644
@@ -13,6 +13,7 @@
 #include <linux/iio/iio.h>
 
 #define HSC_REG_MEASUREMENT_RD_SIZE 4
+#define HSC_RESP_TIME_MS            2
 
 struct device;
 
drivers/iio/pressure/hsc030pa_i2c.c +3 -0
index b5810bafef40..b3fd230e71da 100644
@@ -8,6 +8,7 @@
  * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf
  */
 
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
@@ -25,6 +26,8 @@ static int hsc_i2c_recv(struct hsc_data *data)
 	struct i2c_msg msg;
 	int ret;
 
+	msleep_interruptible(HSC_RESP_TIME_MS);
+
 	msg.addr = client->addr;
 	msg.flags = client->flags | I2C_M_RD;
 	msg.len = HSC_REG_MEASUREMENT_RD_SIZE;
drivers/iio/pressure/hsc030pa_spi.c +2 -0
index 8d3441f1dcf9..818fa6303454 100644
@@ -8,6 +8,7 @@
  * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf
  */
 
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -28,6 +29,7 @@ static int hsc_spi_recv(struct hsc_data *data)
 		.len = HSC_REG_MEASUREMENT_RD_SIZE,
 	};
 
+	msleep_interruptible(HSC_RESP_TIME_MS);
 	return spi_sync_transfer(spi, &xfer, 1);
 }
 
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v3 6/6 iio: pressure: hsc030pa add triggered buffer

In reply to Petre Rodan

Add triggered buffer feature.

---
v1 -> v2 add Kconfig select for IIO_*BUFFER
a few changes based on Jonathan's review
v2 -> v3 fixed array pointer based on Andy's review

 drivers/iio/pressure/Kconfig    |  2 ++
 drivers/iio/pressure/hsc030pa.c | 47 +++++++++++++++++++++++++++++++++
 drivers/iio/pressure/hsc030pa.h |  4 +++
 3 files changed, 53 insertions(+)
drivers/iio/pressure/Kconfig +2 -0
index 5da7931dc537..3ad38506028e 100644
@@ -114,6 +114,8 @@ config HSC030PA
 	depends on (I2C || SPI_MASTER)
 	select HSC030PA_I2C if I2C
 	select HSC030PA_SPI if SPI_MASTER
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
 	help
 	  Say Y here to build support for the Honeywell TruStability
 	  HSC and SSC pressure and temperature sensor series.
drivers/iio/pressure/hsc030pa.c +47 -0

80 lines not on this page · raw message

drivers/iio/pressure/hsc030pa.h +4 -0
index 56dc8e88194b..9b40f46f575f 100644
@@ -56,6 +56,10 @@ struct hsc_data {
 	s32 p_scale_dec;
 	s64 p_offset;
 	s32 p_offset_dec;
+	struct {
+		__be16 chan[2];
+		s64 timestamp __aligned(8);
+	} scan;
 	u8 buffer[HSC_REG_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
 };
 
Signature · 1 line
2.43.0
maintainer Applied
#7 lore raw
In reply to Petre Rodan
Quoted 5 lines · On Sun, 11 Feb 2024 09:56:31 +0200 Petre Rodan <[email protected]>…

This set of patches covers the following:

- small cleanup
- mandatory 2ms delay between readings
- support for triggered buffer readings

Hi Petre

Applied to the togreg branch of iio.git but that will initially be pushed out as testing for 0-day to take a look at it.

Thanks,

Jonathan

Quoted 28 lines

The support for devices that have "sleep mode" factory option that was present in v1 of this patchset was removed, for a few reasons:

- a Honeywell employee told me that this chip variant is extremely unlikely to be found in the wild, which also makes testing the driver functionality impossible
- I found no reliable way of generating i2c/spi bus traffic with no payload (toggle CS for SPI case, send i2c packet containing only the address byte) that are required for the wakeup sequence.

Petre Rodan (6):
dt-bindings: iio: pressure: honeywell,hsc030pa.yaml add spi props
iio: pressure: hsc030pa: use signed type to hold div_64() result
iio: pressure: hsc030pa: include cleanup
iio: pressure: hsc030pa: update datasheet URLs
iio: pressure: hsc030pa add mandatory delay
iio: pressure: hsc030pa add triggered buffer

 .../iio/pressure/honeywell,hsc030pa.yaml      |  3 ++
 drivers/iio/pressure/Kconfig                  |  2 +
 drivers/iio/pressure/hsc030pa.c               | 49 ++++++++++++++++++-
 drivers/iio/pressure/hsc030pa.h               |  7 +++
 drivers/iio/pressure/hsc030pa_i2c.c           |  9 +++-
 drivers/iio/pressure/hsc030pa_spi.c           |  7 ++-
 6 files changed, 73 insertions(+), 4 deletions(-)