xref: /linux/drivers/iio/pressure/hsc030pa_spi.c (revision 889600e21e3be388a6817c2a0dac0411df860751)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Honeywell TruStability HSC Series pressure/temperature sensor
4  *
5  * Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>
6  *
7  * 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
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
9  */
10 
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/module.h>
14 #include <linux/spi/spi.h>
15 #include <linux/stddef.h>
16 #include <linux/types.h>
17 
18 #include <linux/iio/iio.h>
19 
20 #include "hsc030pa.h"
21 
hsc_spi_recv(struct hsc_data * data)22 static int hsc_spi_recv(struct hsc_data *data)
23 {
24 	struct spi_device *spi = to_spi_device(data->dev);
25 
26 	msleep_interruptible(HSC_RESP_TIME_MS);
27 	return spi_read(spi, data->buffer, HSC_REG_MEASUREMENT_RD_SIZE);
28 }
29 
hsc_spi_probe(struct spi_device * spi)30 static int hsc_spi_probe(struct spi_device *spi)
31 {
32 	return hsc_common_probe(&spi->dev, hsc_spi_recv);
33 }
34 
35 static const struct of_device_id hsc_spi_match[] = {
36 	{ .compatible = "honeywell,hsc030pa" },
37 	{ }
38 };
39 MODULE_DEVICE_TABLE(of, hsc_spi_match);
40 
41 static const struct spi_device_id hsc_spi_id[] = {
42 	{ .name = "hsc030pa" },
43 	{ }
44 };
45 MODULE_DEVICE_TABLE(spi, hsc_spi_id);
46 
47 static struct spi_driver hsc_spi_driver = {
48 	.driver = {
49 		.name = "hsc030pa",
50 		.of_match_table = hsc_spi_match,
51 	},
52 	.probe = hsc_spi_probe,
53 	.id_table = hsc_spi_id,
54 };
55 module_spi_driver(hsc_spi_driver);
56 
57 MODULE_AUTHOR("Petre Rodan <petre.rodan@subdimension.ro>");
58 MODULE_DESCRIPTION("Honeywell HSC and SSC pressure sensor spi driver");
59 MODULE_LICENSE("GPL");
60 MODULE_IMPORT_NS("IIO_HONEYWELL_HSC030PA");
61