brintos

brintos / linux-shallow public Read only

0
0
Text · 1.8 KiB · 9b40f46 Raw
82 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Honeywell TruStability HSC Series pressure/temperature sensor4 *5 * Copyright (c) 2023 Petre Rodan <petre.rodan@subdimension.ro>6 */7 8#ifndef _HSC030PA_H9#define _HSC030PA_H10 11#include <linux/types.h>12 13#include <linux/iio/iio.h>14 15#define HSC_REG_MEASUREMENT_RD_SIZE 416#define HSC_RESP_TIME_MS            217 18struct device;19 20struct iio_chan_spec;21struct iio_dev;22 23struct hsc_data;24struct hsc_chip_data;25 26typedef int (*hsc_recv_fn)(struct hsc_data *);27 28/**29 * struct hsc_data30 * @dev: current device structure31 * @chip: structure containing chip's channel properties32 * @recv_cb: function that implements the chip reads33 * @is_valid: true if last transfer has been validated34 * @pmin: minimum measurable pressure limit35 * @pmax: maximum measurable pressure limit36 * @outmin: minimum raw pressure in counts (based on transfer function)37 * @outmax: maximum raw pressure in counts (based on transfer function)38 * @function: transfer function39 * @p_scale: pressure scale40 * @p_scale_dec: pressure scale, decimal places41 * @p_offset: pressure offset42 * @p_offset_dec: pressure offset, decimal places43 * @buffer: raw conversion data44 */45struct hsc_data {46	struct device *dev;47	const struct hsc_chip_data *chip;48	hsc_recv_fn recv_cb;49	bool is_valid;50	s32 pmin;51	s32 pmax;52	u32 outmin;53	u32 outmax;54	u32 function;55	s64 p_scale;56	s32 p_scale_dec;57	s64 p_offset;58	s32 p_offset_dec;59	struct {60		__be16 chan[2];61		s64 timestamp __aligned(8);62	} scan;63	u8 buffer[HSC_REG_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);64};65 66struct hsc_chip_data {67	bool (*valid)(struct hsc_data *data);68	const struct iio_chan_spec *channels;69	u8 num_channels;70};71 72enum hsc_func_id {73	HSC_FUNCTION_A,74	HSC_FUNCTION_B,75	HSC_FUNCTION_C,76	HSC_FUNCTION_F,77};78 79int hsc_common_probe(struct device *dev, hsc_recv_fn recv);80 81#endif82