aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/pressure/hsc030pa_spi.c
blob: a719bade83266b7fd8c0cdfb843372bca7c8e844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 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);