Commit df3186e8 authored by Petre Rodan's avatar Petre Rodan Committed by Jonathan Cameron

iio: pressure: hsc030pa add mandatory delay

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.pdfSigned-off-by: default avatarPetre Rodan <petre.rodan@subdimension.ro>
Link: https://lore.kernel.org/r/20240211075645.28777-6-petre.rodan@subdimension.roSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent b0e42c9e
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
#define HSC_REG_MEASUREMENT_RD_SIZE 4 #define HSC_REG_MEASUREMENT_RD_SIZE 4
#define HSC_RESP_TIME_MS 2
struct device; struct device;
......
...@@ -8,6 +8,7 @@ ...@@ -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 * 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/device.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -25,6 +26,8 @@ static int hsc_i2c_recv(struct hsc_data *data) ...@@ -25,6 +26,8 @@ static int hsc_i2c_recv(struct hsc_data *data)
struct i2c_msg msg; struct i2c_msg msg;
int ret; int ret;
msleep_interruptible(HSC_RESP_TIME_MS);
msg.addr = client->addr; msg.addr = client->addr;
msg.flags = client->flags | I2C_M_RD; msg.flags = client->flags | I2C_M_RD;
msg.len = HSC_REG_MEASUREMENT_RD_SIZE; msg.len = HSC_REG_MEASUREMENT_RD_SIZE;
......
...@@ -8,6 +8,7 @@ ...@@ -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 * 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/device.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -28,6 +29,7 @@ static int hsc_spi_recv(struct hsc_data *data) ...@@ -28,6 +29,7 @@ static int hsc_spi_recv(struct hsc_data *data)
.len = HSC_REG_MEASUREMENT_RD_SIZE, .len = HSC_REG_MEASUREMENT_RD_SIZE,
}; };
msleep_interruptible(HSC_RESP_TIME_MS);
return spi_sync_transfer(spi, &xfer, 1); return spi_sync_transfer(spi, &xfer, 1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment