18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/* The industrial I/O core function defs.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2008 Jonathan Cameron
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * These definitions are meant for use only within the IIO core, not individual
78c2ecf20Sopenharmony_ci * drivers.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _IIO_CORE_H_
118c2ecf20Sopenharmony_ci#define _IIO_CORE_H_
128c2ecf20Sopenharmony_ci#include <linux/kernel.h>
138c2ecf20Sopenharmony_ci#include <linux/device.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct iio_chan_spec;
168c2ecf20Sopenharmony_cistruct iio_dev;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciextern struct device_type iio_device_type;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciint __iio_add_chan_devattr(const char *postfix,
218c2ecf20Sopenharmony_ci			   struct iio_chan_spec const *chan,
228c2ecf20Sopenharmony_ci			   ssize_t (*func)(struct device *dev,
238c2ecf20Sopenharmony_ci					   struct device_attribute *attr,
248c2ecf20Sopenharmony_ci					   char *buf),
258c2ecf20Sopenharmony_ci			   ssize_t (*writefunc)(struct device *dev,
268c2ecf20Sopenharmony_ci						struct device_attribute *attr,
278c2ecf20Sopenharmony_ci						const char *buf,
288c2ecf20Sopenharmony_ci						size_t len),
298c2ecf20Sopenharmony_ci			   u64 mask,
308c2ecf20Sopenharmony_ci			   enum iio_shared_by shared_by,
318c2ecf20Sopenharmony_ci			   struct device *dev,
328c2ecf20Sopenharmony_ci			   struct list_head *attr_list);
338c2ecf20Sopenharmony_civoid iio_free_chan_devattr_list(struct list_head *attr_list);
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cissize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* Event interface flags */
388c2ecf20Sopenharmony_ci#define IIO_BUSY_BIT_POS 1
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#ifdef CONFIG_IIO_BUFFER
418c2ecf20Sopenharmony_cistruct poll_table_struct;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci__poll_t iio_buffer_poll(struct file *filp,
448c2ecf20Sopenharmony_ci			     struct poll_table_struct *wait);
458c2ecf20Sopenharmony_cissize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
468c2ecf20Sopenharmony_ci			      size_t n, loff_t *f_ps);
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciint iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
498c2ecf20Sopenharmony_civoid iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define iio_buffer_poll_addr (&iio_buffer_poll)
528c2ecf20Sopenharmony_ci#define iio_buffer_read_outer_addr (&iio_buffer_read_outer)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_civoid iio_disable_all_buffers(struct iio_dev *indio_dev);
558c2ecf20Sopenharmony_civoid iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#else
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define iio_buffer_poll_addr NULL
608c2ecf20Sopenharmony_ci#define iio_buffer_read_outer_addr NULL
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
638c2ecf20Sopenharmony_ci{
648c2ecf20Sopenharmony_ci	return 0;
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistatic inline void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
708c2ecf20Sopenharmony_cistatic inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#endif
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciint iio_device_register_eventset(struct iio_dev *indio_dev);
758c2ecf20Sopenharmony_civoid iio_device_unregister_eventset(struct iio_dev *indio_dev);
768c2ecf20Sopenharmony_civoid iio_device_wakeup_eventset(struct iio_dev *indio_dev);
778c2ecf20Sopenharmony_ciint iio_event_getfd(struct iio_dev *indio_dev);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistruct iio_event_interface;
808c2ecf20Sopenharmony_cibool iio_event_enabled(const struct iio_event_interface *ev_int);
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#endif
83