1 // SPDX-License-Identifier: GPL-2.0-only
3 * Honeywell TruStability HSC Series pressure/temperature sensor
5 * Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>
7 * 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
8 * 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
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/errno.h>
14 #include <linux/i2c.h>
15 #include <linux/mod_devicetable.h>
16 #include <linux/module.h>
17 #include <linux/types.h>
19 #include <linux/iio/iio.h>
23 static int hsc_i2c_recv(struct hsc_data
*data
)
25 struct i2c_client
*client
= to_i2c_client(data
->dev
);
29 msleep_interruptible(HSC_RESP_TIME_MS
);
31 msg
.addr
= client
->addr
;
32 msg
.flags
= client
->flags
| I2C_M_RD
;
33 msg
.len
= HSC_REG_MEASUREMENT_RD_SIZE
;
34 msg
.buf
= data
->buffer
;
36 ret
= i2c_transfer(client
->adapter
, &msg
, 1);
38 return (ret
== 2) ? 0 : ret
;
41 static int hsc_i2c_probe(struct i2c_client
*client
)
43 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_I2C
))
46 return hsc_common_probe(&client
->dev
, hsc_i2c_recv
);
49 static const struct of_device_id hsc_i2c_match
[] = {
50 { .compatible
= "honeywell,hsc030pa" },
53 MODULE_DEVICE_TABLE(of
, hsc_i2c_match
);
55 static const struct i2c_device_id hsc_i2c_id
[] = {
59 MODULE_DEVICE_TABLE(i2c
, hsc_i2c_id
);
61 static struct i2c_driver hsc_i2c_driver
= {
64 .of_match_table
= hsc_i2c_match
,
66 .probe
= hsc_i2c_probe
,
67 .id_table
= hsc_i2c_id
,
69 module_i2c_driver(hsc_i2c_driver
);
71 MODULE_AUTHOR("Petre Rodan <petre.rodan@subdimension.ro>");
72 MODULE_DESCRIPTION("Honeywell HSC and SSC pressure sensor i2c driver");
73 MODULE_LICENSE("GPL");
74 MODULE_IMPORT_NS("IIO_HONEYWELL_HSC030PA");