1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Honeywell TruStability HSC Series pressure/temperature sensor 4 * 5 * Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro> 6 */ 7 8 #ifndef _HSC030PA_H 9 #define _HSC030PA_H 10 11 #include <linux/types.h> 12 13 #define HSC_REG_MEASUREMENT_RD_SIZE 4 14 15 struct device; 16 17 struct iio_chan_spec; 18 struct iio_dev; 19 20 struct hsc_data; 21 struct hsc_chip_data; 22 23 typedef int (*hsc_recv_fn)(struct hsc_data *); 24 25 /** 26 * struct hsc_data 27 * @dev: current device structure 28 * @chip: structure containing chip's channel properties 29 * @recv_cb: function that implements the chip reads 30 * @is_valid: true if last transfer has been validated 31 * @pmin: minimum measurable pressure limit 32 * @pmax: maximum measurable pressure limit 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 places 38 * @p_offset: pressure offset 39 * @p_offset_dec: pressure offset, decimal places 40 * @buffer: raw conversion data 41 */ 42 struct hsc_data { 43 struct device *dev; 44 const struct hsc_chip_data *chip; 45 hsc_recv_fn recv_cb; 46 bool is_valid; 47 s32 pmin; 48 s32 pmax; 49 u32 outmin; 50 u32 outmax; 51 u32 function; 52 s64 p_scale; 53 s32 p_scale_dec; 54 s64 p_offset; 55 s32 p_offset_dec; 56 u8 buffer[HSC_REG_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); 57 }; 58 59 struct hsc_chip_data { 60 bool (*valid)(struct hsc_data *data); 61 const struct iio_chan_spec *channels; 62 u8 num_channels; 63 }; 64 65 enum hsc_func_id { 66 HSC_FUNCTION_A, 67 HSC_FUNCTION_B, 68 HSC_FUNCTION_C, 69 HSC_FUNCTION_F, 70 }; 71 72 int hsc_common_probe(struct device *dev, hsc_recv_fn recv); 73 74 #endif 75