linux/drivers/iio/pressure/hsc030pa_spi.c
Petre Rodan df3186e829 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.pdf

Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
Link: https://lore.kernel.org/r/20240211075645.28777-6-petre.rodan@subdimension.ro
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-19 19:32:22 +00:00

67 lines
1.9 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Honeywell TruStability HSC Series pressure/temperature sensor
*
* Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>
*
* 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/delay.h>
#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>
#include "hsc030pa.h"
static int hsc_spi_recv(struct hsc_data *data)
{
struct spi_device *spi = to_spi_device(data->dev);
struct spi_transfer xfer = {
.tx_buf = NULL,
.rx_buf = data->buffer,
.len = HSC_REG_MEASUREMENT_RD_SIZE,
};
msleep_interruptible(HSC_RESP_TIME_MS);
return spi_sync_transfer(spi, &xfer, 1);
}
static int hsc_spi_probe(struct spi_device *spi)
{
return hsc_common_probe(&spi->dev, hsc_spi_recv);
}
static const struct of_device_id hsc_spi_match[] = {
{ .compatible = "honeywell,hsc030pa" },
{}
};
MODULE_DEVICE_TABLE(of, hsc_spi_match);
static const struct spi_device_id hsc_spi_id[] = {
{ "hsc030pa" },
{}
};
MODULE_DEVICE_TABLE(spi, hsc_spi_id);
static struct spi_driver hsc_spi_driver = {
.driver = {
.name = "hsc030pa",
.of_match_table = hsc_spi_match,
},
.probe = hsc_spi_probe,
.id_table = hsc_spi_id,
};
module_spi_driver(hsc_spi_driver);
MODULE_AUTHOR("Petre Rodan <petre.rodan@subdimension.ro>");
MODULE_DESCRIPTION("Honeywell HSC and SSC pressure sensor spi driver");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(IIO_HONEYWELL_HSC030PA);