Commit 6362d965 authored by Petre Rodan's avatar Petre Rodan Committed by Jonathan Cameron

iio: pressure: driver for Honeywell HSC/SSC series

Adds driver for digital Honeywell TruStability HSC and SSC series
pressure and temperature sensors.
Communication is one way. The sensor only requires 4 bytes worth of
clock pulses on both i2c and spi in order to push the data out.
The i2c address is hardcoded and depends on the part number.
There is no additional GPIO control.
code is now based on iio/togreg

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/trustability-ssc-series/documents/sps-siot-trustability-ssc-series-standard-accuracy-board-mount-pressure-sensors-50099533-a-en-ciid-151134.pdf [SSC]
Signed-off-by: default avatarPetre Rodan <petre.rodan@subdimension.ro>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231207164634.11998-2-petre.rodan@subdimension.roSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 5fc0a980
......@@ -9709,6 +9709,13 @@ F: lib/test_hmm*
F: mm/hmm*
F: tools/testing/selftests/mm/*hmm*
HONEYWELL HSC030PA PRESSURE SENSOR SERIES IIO DRIVER
M: Petre Rodan <petre.rodan@subdimension.ro>
L: linux-iio@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/iio/pressure/honeywell,hsc030pa.yaml
F: drivers/iio/pressure/hsc030pa*
HONEYWELL MPRLS0025PA PRESSURE SENSOR SERIES IIO DRIVER
M: Andreas Klinger <ak@it-klinger.de>
L: linux-iio@vger.kernel.org
......
......@@ -109,6 +109,28 @@ config HP03
To compile this driver as a module, choose M here: the module
will be called hp03.
config HSC030PA
tristate "Honeywell HSC/SSC TruStability pressure sensor series"
depends on (I2C || SPI_MASTER)
select HSC030PA_I2C if I2C
select HSC030PA_SPI if SPI_MASTER
help
Say Y here to build support for the Honeywell TruStability
HSC and SSC pressure and temperature sensor series.
To compile this driver as a module, choose M here: the module
will be called hsc030pa.
config HSC030PA_I2C
tristate
depends on HSC030PA
depends on I2C
config HSC030PA_SPI
tristate
depends on HSC030PA
depends on SPI_MASTER
config ICP10100
tristate "InvenSense ICP-101xx pressure and temperature sensor"
depends on I2C
......
......@@ -15,6 +15,9 @@ obj-$(CONFIG_DPS310) += dps310.o
obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o
obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o
obj-$(CONFIG_HP03) += hp03.o
obj-$(CONFIG_HSC030PA) += hsc030pa.o
obj-$(CONFIG_HSC030PA_I2C) += hsc030pa_i2c.o
obj-$(CONFIG_HSC030PA_SPI) += hsc030pa_spi.o
obj-$(CONFIG_ICP10100) += icp10100.o
obj-$(CONFIG_MPL115) += mpl115.o
obj-$(CONFIG_MPL115_I2C) += mpl115_i2c.o
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Honeywell TruStability HSC Series pressure/temperature sensor
*
* Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>
*/
#ifndef _HSC030PA_H
#define _HSC030PA_H
#include <linux/types.h>
#define HSC_REG_MEASUREMENT_RD_SIZE 4
struct device;
struct iio_chan_spec;
struct iio_dev;
struct hsc_data;
struct hsc_chip_data;
typedef int (*hsc_recv_fn)(struct hsc_data *);
/**
* struct hsc_data
* @dev: current device structure
* @chip: structure containing chip's channel properties
* @recv_cb: function that implements the chip reads
* @is_valid: true if last transfer has been validated
* @pmin: minimum measurable pressure limit
* @pmax: maximum measurable pressure limit
* @outmin: minimum raw pressure in counts (based on transfer function)
* @outmax: maximum raw pressure in counts (based on transfer function)
* @function: transfer function
* @p_scale: pressure scale
* @p_scale_dec: pressure scale, decimal places
* @p_offset: pressure offset
* @p_offset_dec: pressure offset, decimal places
* @buffer: raw conversion data
*/
struct hsc_data {
struct device *dev;
const struct hsc_chip_data *chip;
hsc_recv_fn recv_cb;
bool is_valid;
s32 pmin;
s32 pmax;
u32 outmin;
u32 outmax;
u32 function;
s64 p_scale;
s32 p_scale_dec;
s64 p_offset;
s32 p_offset_dec;
u8 buffer[HSC_REG_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
};
struct hsc_chip_data {
bool (*valid)(struct hsc_data *data);
const struct iio_chan_spec *channels;
u8 num_channels;
};
enum hsc_func_id {
HSC_FUNCTION_A,
HSC_FUNCTION_B,
HSC_FUNCTION_C,
HSC_FUNCTION_F,
};
int hsc_common_probe(struct device *dev, hsc_recv_fn recv);
#endif
// 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/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]
*/
#include <linux/errno.h>
#include <linux/i2c.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
#include "hsc030pa.h"
static int hsc_i2c_recv(struct hsc_data *data)
{
struct i2c_client *client = to_i2c_client(data->dev);
struct i2c_msg msg;
int ret;
msg.addr = client->addr;
msg.flags = client->flags | I2C_M_RD;
msg.len = HSC_REG_MEASUREMENT_RD_SIZE;
msg.buf = data->buffer;
ret = i2c_transfer(client->adapter, &msg, 1);
return (ret == 2) ? 0 : ret;
}
static int hsc_i2c_probe(struct i2c_client *client)
{
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -EOPNOTSUPP;
return hsc_common_probe(&client->dev, hsc_i2c_recv);
}
static const struct of_device_id hsc_i2c_match[] = {
{ .compatible = "honeywell,hsc030pa" },
{}
};
MODULE_DEVICE_TABLE(of, hsc_i2c_match);
static const struct i2c_device_id hsc_i2c_id[] = {
{ "hsc030pa" },
{}
};
MODULE_DEVICE_TABLE(i2c, hsc_i2c_id);
static struct i2c_driver hsc_i2c_driver = {
.driver = {
.name = "hsc030pa",
.of_match_table = hsc_i2c_match,
},
.probe = hsc_i2c_probe,
.id_table = hsc_i2c_id,
};
module_i2c_driver(hsc_i2c_driver);
MODULE_AUTHOR("Petre Rodan <petre.rodan@subdimension.ro>");
MODULE_DESCRIPTION("Honeywell HSC and SSC pressure sensor i2c driver");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(IIO_HONEYWELL_HSC030PA);
// 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/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/mod_devicetable.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/stddef.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,
};
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);
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