| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Honeywell ABP2 series pressure sensor driver |
| 4 |
* |
| 5 |
* Copyright (c) 2025 Petre Rodan <[email protected]> |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef _ABP2030PA_H |
| 9 |
#define _ABP2030PA_H |
| 10 |
|
| 11 |
#include <linux/completion.h> |
| 12 |
#include <linux/types.h> |
| 13 |
|
| 14 |
#include <linux/iio/iio.h> |
| 15 |
|
| 16 |
#define ABP2_MEASUREMENT_RD_SIZE 7 |
| 17 |
|
| 18 |
struct device; |
| 19 |
|
| 20 |
struct abp2_data; |
| 21 |
struct abp2_ops; |
| 22 |
|
| 23 |
enum abp2_func_id { |
| 24 |
ABP2_FUNCTION_A, |
| 25 |
}; |
| 26 |
|
| 27 |
/** |
| 28 |
* struct abp2_data |
| 29 |
* @dev: current device structure |
| 30 |
* @ops: pointers for bus specific read and write functions |
| 31 |
* @pmin: minimal pressure in pascal |
| 32 |
* @pmax: maximal pressure in pascal |
| 33 |
* @outmin: minimum raw pressure in counts (based on transfer function) |
| 34 |
* @outmax: maximum raw pressure in counts (based on transfer function) |
| 35 |
* @function: transfer function |
| 36 |
* @p_scale: pressure scale |
| 37 |
* @p_scale_dec: pressure scale, decimal number |
| 38 |
* @p_offset: pressure offset |
| 39 |
* @irq: end of conversion - applies only to the i2c sensor |
| 40 |
* @completion: handshake from irq to read |
| 41 |
* @scan: channel values for buffered mode |
| 42 |
* @tx_buf: transmit buffer used during the SPI communication |
| 43 |
* @rx_buf: raw data provided by sensor |
| 44 |
*/ |
| 45 |
struct abp2_data { |
| 46 |
struct device *dev; |
| 47 |
const struct abp2_ops *ops; |
| 48 |
s32 pmin; |
| 49 |
s32 pmax; |
| 50 |
u32 outmin; |
| 51 |
u32 outmax; |
| 52 |
enum abp2_func_id function; |
| 53 |
int p_scale; |
| 54 |
int p_scale_dec; |
| 55 |
int p_offset; |
| 56 |
int irq; |
| 57 |
struct completion completion; |
| 58 |
struct { |
| 59 |
u32 chan[2]; |
| 60 |
aligned_s64 timestamp; |
| 61 |
} scan; |
| 62 |
u8 rx_buf[ABP2_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); |
| 63 |
u8 tx_buf[ABP2_MEASUREMENT_RD_SIZE]; |
| 64 |
}; |
| 65 |
|
| 66 |
struct abp2_ops { |
| 67 |
int (*read)(struct abp2_data *data, u8 cmd, u8 nbytes); |
| 68 |
int (*write)(struct abp2_data *data, u8 cmd, u8 nbytes); |
| 69 |
}; |
| 70 |
|
| 71 |
int abp2_common_probe(struct device *dev, const struct abp2_ops *ops, int irq); |
| 72 |
|
| 73 |
#endif |