1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _IIO_BACKEND_H_
3 #define _IIO_BACKEND_H_
5 #include <linux/types.h>
12 enum iio_backend_data_type {
13 IIO_BACKEND_TWOS_COMPLEMENT,
14 IIO_BACKEND_OFFSET_BINARY,
15 IIO_BACKEND_DATA_TYPE_MAX
19 * struct iio_backend_data_fmt - Backend data format
21 * @sign_extend: Bool to tell if the data is sign extended.
22 * @enable: Enable/Disable the data format module. If disabled,
23 * not formatting will happen.
25 struct iio_backend_data_fmt {
26 enum iio_backend_data_type type;
32 * struct iio_backend_ops - operations structure for an iio_backend
33 * @enable: Enable backend.
34 * @disable: Disable backend.
35 * @chan_enable: Enable one channel.
36 * @chan_disable: Disable one channel.
37 * @data_format_set: Configure the data format for a specific channel.
38 * @request_buffer: Request an IIO buffer.
39 * @free_buffer: Free an IIO buffer.
41 struct iio_backend_ops {
42 int (*enable)(struct iio_backend *back);
43 void (*disable)(struct iio_backend *back);
44 int (*chan_enable)(struct iio_backend *back, unsigned int chan);
45 int (*chan_disable)(struct iio_backend *back, unsigned int chan);
46 int (*data_format_set)(struct iio_backend *back, unsigned int chan,
47 const struct iio_backend_data_fmt *data);
48 struct iio_buffer *(*request_buffer)(struct iio_backend *back,
49 struct iio_dev *indio_dev);
50 void (*free_buffer)(struct iio_backend *back,
51 struct iio_buffer *buffer);
54 int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
55 int iio_backend_chan_disable(struct iio_backend *back, unsigned int chan);
56 int devm_iio_backend_enable(struct device *dev, struct iio_backend *back);
57 int iio_backend_data_format_set(struct iio_backend *back, unsigned int chan,
58 const struct iio_backend_data_fmt *data);
59 int devm_iio_backend_request_buffer(struct device *dev,
60 struct iio_backend *back,
61 struct iio_dev *indio_dev);
63 void *iio_backend_get_priv(const struct iio_backend *conv);
64 struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name);
66 __devm_iio_backend_get_from_fwnode_lookup(struct device *dev,
67 struct fwnode_handle *fwnode);
69 int devm_iio_backend_register(struct device *dev,
70 const struct iio_backend_ops *ops, void *priv);