File Index
Files and directories
Sign in
FILE

mprls0025pa.h

File preview with syntax highlighting.

linux-6.19.14/drivers/iio/pressure/mprls0025pa.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver
 4 *
 5 * Copyright (c) Andreas Klinger <ak@it-klinger.de>
 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/delay.h>
16#include <linux/device.h>
17#include <linux/mutex.h>
18#include <linux/stddef.h>
19#include <linux/types.h>
20
21#include <linux/iio/iio.h>
22
23#define MPR_MEASUREMENT_RD_SIZE 4
24#define MPR_CMD_NOP      0xf0
25#define MPR_CMD_SYNC     0xaa
26#define MPR_PKT_NOP_LEN  MPR_MEASUREMENT_RD_SIZE
27#define MPR_PKT_SYNC_LEN 3
28
29struct device;
30
31struct iio_chan_spec;
32struct iio_dev;
33
34struct mpr_data;
35struct mpr_ops;
36
37enum mpr_func_id {
38	MPR_FUNCTION_A,
39	MPR_FUNCTION_B,
40	MPR_FUNCTION_C,
41};
42
43/**
44 * struct mpr_data
45 * @dev: current device structure
46 * @ops: functions that implement the sensor reads/writes, bus init
47 * @lock: access to device during read
48 * @pmin: minimal pressure in pascal
49 * @pmax: maximal pressure in pascal
50 * @function: transfer function
51 * @outmin: minimum raw pressure in counts (based on transfer function)
52 * @outmax: maximum raw pressure in counts (based on transfer function)
53 * @scale: pressure scale
54 * @scale2: pressure scale, decimal number
55 * @offset: pressure offset
56 * @gpiod_reset: reset
57 * @irq: end of conversion irq. used to distinguish between irq mode and
58 *       reading in a loop until data is ready
59 * @completion: handshake from irq to read
60 * @chan: channel values for buffered mode
61 * @chan.pres: pressure value
62 * @chan.ts: timestamp
63 * @buffer: raw conversion data
64 */
65struct mpr_data {
66	struct device		*dev;
67	const struct mpr_ops	*ops;
68	struct mutex		lock;
69	u32			pmin;
70	u32			pmax;
71	enum mpr_func_id	function;
72	u32			outmin;
73	u32			outmax;
74	int			scale;
75	int			scale2;
76	int			offset;
77	struct gpio_desc	*gpiod_reset;
78	int			irq;
79	struct completion	completion;
80	struct {
81		s32 pres;
82		aligned_s64 ts;
83	} chan;
84	u8	    buffer[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
85};
86
87struct mpr_ops {
88	int (*init)(struct device *dev);
89	int (*read)(struct mpr_data *data, const u8 cmd, const u8 cnt);
90	int (*write)(struct mpr_data *data, const u8 cmd, const u8 cnt);
91};
92
93int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq);
94
95#endif
~/ Read-only file preview.