Debian Codegraph @

drivers/iio/pressure/mprls0025pa.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver
4 *
5 * Copyright (c) Andreas Klinger <[email protected]>
6 *
7 * Data sheet:
8 * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
9 */
10
11 #ifndef _MPRLS0025PA_H
12 #define _MPRLS0025PA_H
13
14 #include <linux/completion.h>
15 #include <linux/mutex.h>
16 #include <linux/types.h>
17
18 #include <linux/iio/iio.h>
19
20 #define MPR_MEASUREMENT_RD_SIZE 4
21 #define MPR_CMD_NOP 0xf0
22 #define MPR_CMD_SYNC 0xaa
23 #define MPR_PKT_NOP_LEN MPR_MEASUREMENT_RD_SIZE
24 #define MPR_PKT_SYNC_LEN 3
25
26 struct device;
27
28 struct mpr_data;
29 struct mpr_ops;
30
31 enum mpr_func_id {
32 MPR_FUNCTION_A,
33 MPR_FUNCTION_B,
34 MPR_FUNCTION_C,
35 };
36
37 /**
38 * struct mpr_data
39 * @dev: current device structure
40 * @ops: functions that implement the sensor reads/writes, bus init
41 * @lock: access to device during read
42 * @pmin: minimal pressure in pascal
43 * @pmax: maximal pressure in pascal
44 * @function: transfer function
45 * @outmin: minimum raw pressure in counts (based on transfer function)
46 * @outmax: maximum raw pressure in counts (based on transfer function)
47 * @scale: pressure scale
48 * @scale2: pressure scale, decimal number
49 * @offset: pressure offset
50 * @gpiod_reset: reset
51 * @irq: end of conversion irq. used to distinguish between irq mode and
52 * reading in a loop until data is ready
53 * @completion: handshake from irq to read
54 * @chan: channel values for buffered mode
55 * @chan.pres: pressure value
56 * @chan.ts: timestamp
57 * @rx_buf: raw conversion data
58 * @tx_buf: output buffer
59 */
60 struct mpr_data {
61 struct device *dev;
62 const struct mpr_ops *ops;
63 struct mutex lock;
64 u32 pmin;
65 u32 pmax;
66 enum mpr_func_id function;
67 u32 outmin;
68 u32 outmax;
69 int scale;
70 int scale2;
71 int offset;
72 struct gpio_desc *gpiod_reset;
73 int irq;
74 struct completion completion;
75 struct {
76 s32 pres;
77 aligned_s64 ts;
78 } chan;
79 u8 rx_buf[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
80 u8 tx_buf[MPR_MEASUREMENT_RD_SIZE];
81 };
82
83 struct mpr_ops {
84 int (*read)(struct mpr_data *data, const u8 cmd, const u8 cnt);
85 int (*write)(struct mpr_data *data, const u8 cmd, const u8 cnt);
86 };
87
88 int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq);
89
90 #endif