brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 9d5c30a Raw
103 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver4 *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.pdf9 */10 11#ifndef _MPRLS0025PA_H12#define _MPRLS0025PA_H13 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 424#define MPR_CMD_NOP      0xf025#define MPR_CMD_SYNC     0xaa26#define MPR_PKT_NOP_LEN  MPR_MEASUREMENT_RD_SIZE27#define MPR_PKT_SYNC_LEN 328 29struct device;30 31struct iio_chan_spec;32struct iio_dev;33 34struct mpr_data;35struct mpr_ops;36 37/**38 * struct mpr_chan39 * @pres: pressure value40 * @ts: timestamp41 */42struct mpr_chan {43	s32 pres;44	s64 ts;45};46 47enum mpr_func_id {48	MPR_FUNCTION_A,49	MPR_FUNCTION_B,50	MPR_FUNCTION_C,51};52 53/**54 * struct mpr_data55 * @dev: current device structure56 * @ops: functions that implement the sensor reads/writes, bus init57 * @lock: access to device during read58 * @pmin: minimal pressure in pascal59 * @pmax: maximal pressure in pascal60 * @function: transfer function61 * @outmin: minimum raw pressure in counts (based on transfer function)62 * @outmax: maximum raw pressure in counts (based on transfer function)63 * @scale: pressure scale64 * @scale2: pressure scale, decimal number65 * @offset: pressure offset66 * @offset2: pressure offset, decimal number67 * @gpiod_reset: reset68 * @irq: end of conversion irq. used to distinguish between irq mode and69 *       reading in a loop until data is ready70 * @completion: handshake from irq to read71 * @chan: channel values for buffered mode72 * @buffer: raw conversion data73 */74struct mpr_data {75	struct device		*dev;76	const struct mpr_ops	*ops;77	struct mutex		lock;78	u32			pmin;79	u32			pmax;80	enum mpr_func_id	function;81	u32			outmin;82	u32			outmax;83	int			scale;84	int			scale2;85	int			offset;86	int			offset2;87	struct gpio_desc	*gpiod_reset;88	int			irq;89	struct completion	completion;90	struct mpr_chan		chan;91	u8	    buffer[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);92};93 94struct mpr_ops {95	int (*init)(struct device *dev);96	int (*read)(struct mpr_data *data, const u8 cmd, const u8 cnt);97	int (*write)(struct mpr_data *data, const u8 cmd, const u8 cnt);98};99 100int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq);101 102#endif103