1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2011 Jonathan Cameron
5 * Join together the various functionality of iio_simple_dummy driver
8 #ifndef _IIO_SIMPLE_DUMMY_H_
9 #define _IIO_SIMPLE_DUMMY_H_
10 #include <linux/kernel.h>
12 struct iio_dummy_accel_calibscale;
13 struct iio_dummy_regs;
16 * struct iio_dummy_state - device instance specific state.
17 * @dac_val: cache for dac value
18 * @single_ended_adc_val: cache for single ended adc value
19 * @differential_adc_val: cache for differential adc value
20 * @accel_val: cache for acceleration value
21 * @accel_calibbias: cache for acceleration calibbias
22 * @accel_calibscale: cache for acceleration calibscale
23 * @lock: lock to ensure state is consistent
24 * @event_irq: irq number for event line (faked)
25 * @event_val: cache for event threshold value
26 * @event_en: cache of whether event is enabled
28 struct iio_dummy_state {
30 int single_ended_adc_val;
31 int differential_adc_val[2];
36 const struct iio_dummy_accel_calibscale *accel_calibscale;
38 struct iio_dummy_regs *regs;
42 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
47 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
50 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
54 int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
55 const struct iio_chan_spec *chan,
56 enum iio_event_type type,
57 enum iio_event_direction dir);
59 int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
60 const struct iio_chan_spec *chan,
61 enum iio_event_type type,
62 enum iio_event_direction dir,
65 int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
66 const struct iio_chan_spec *chan,
67 enum iio_event_type type,
68 enum iio_event_direction dir,
69 enum iio_event_info info, int *val,
72 int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
73 const struct iio_chan_spec *chan,
74 enum iio_event_type type,
75 enum iio_event_direction dir,
76 enum iio_event_info info, int val,
79 int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
80 void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
82 #else /* Stubs for when events are disabled at compile time */
85 iio_simple_dummy_events_register(struct iio_dev *indio_dev)
91 iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
94 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
97 * enum iio_simple_dummy_scan_elements - scan index enum
98 * @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel
99 * @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel
100 * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel
101 * @DUMMY_INDEX_ACCELX: acceleration channel
103 * Enum provides convenient numbering for the scan index.
105 enum iio_simple_dummy_scan_elements {
106 DUMMY_INDEX_VOLTAGE_0,
107 DUMMY_INDEX_DIFFVOLTAGE_1M2,
108 DUMMY_INDEX_DIFFVOLTAGE_3M4,
112 #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
113 int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev);
114 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
116 static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
122 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
125 #endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
126 #endif /* _IIO_SIMPLE_DUMMY_H_ */