Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / iio / pressure / hsc030pa.h
blob9b40f46f575fff8ba7e04c9f5fd696f79d94ba9a
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Honeywell TruStability HSC Series pressure/temperature sensor
5 * Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>
6 */
8 #ifndef _HSC030PA_H
9 #define _HSC030PA_H
11 #include <linux/types.h>
13 #include <linux/iio/iio.h>
15 #define HSC_REG_MEASUREMENT_RD_SIZE 4
16 #define HSC_RESP_TIME_MS 2
18 struct device;
20 struct iio_chan_spec;
21 struct iio_dev;
23 struct hsc_data;
24 struct hsc_chip_data;
26 typedef int (*hsc_recv_fn)(struct hsc_data *);
28 /**
29 * struct hsc_data
30 * @dev: current device structure
31 * @chip: structure containing chip's channel properties
32 * @recv_cb: function that implements the chip reads
33 * @is_valid: true if last transfer has been validated
34 * @pmin: minimum measurable pressure limit
35 * @pmax: maximum measurable pressure limit
36 * @outmin: minimum raw pressure in counts (based on transfer function)
37 * @outmax: maximum raw pressure in counts (based on transfer function)
38 * @function: transfer function
39 * @p_scale: pressure scale
40 * @p_scale_dec: pressure scale, decimal places
41 * @p_offset: pressure offset
42 * @p_offset_dec: pressure offset, decimal places
43 * @buffer: raw conversion data
45 struct hsc_data {
46 struct device *dev;
47 const struct hsc_chip_data *chip;
48 hsc_recv_fn recv_cb;
49 bool is_valid;
50 s32 pmin;
51 s32 pmax;
52 u32 outmin;
53 u32 outmax;
54 u32 function;
55 s64 p_scale;
56 s32 p_scale_dec;
57 s64 p_offset;
58 s32 p_offset_dec;
59 struct {
60 __be16 chan[2];
61 s64 timestamp __aligned(8);
62 } scan;
63 u8 buffer[HSC_REG_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
66 struct hsc_chip_data {
67 bool (*valid)(struct hsc_data *data);
68 const struct iio_chan_spec *channels;
69 u8 num_channels;
72 enum hsc_func_id {
73 HSC_FUNCTION_A,
74 HSC_FUNCTION_B,
75 HSC_FUNCTION_C,
76 HSC_FUNCTION_F,
79 int hsc_common_probe(struct device *dev, hsc_recv_fn recv);
81 #endif