2 * Copyright (c) 2011 Jonathan Cameron
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
8 * Join together the various functionality of iio_simple_dummy driver
11 #ifndef _IIO_SIMPLE_DUMMY_H_
12 #define _IIO_SIMPLE_DUMMY_H_
13 #include <linux/kernel.h>
15 struct iio_dummy_accel_calibscale;
18 * struct iio_dummy_state - device instance specific state.
19 * @dac_val: cache for dac value
20 * @single_ended_adc_val: cache for single ended adc value
21 * @differential_adc_val: cache for differential adc value
22 * @accel_val: cache for acceleration value
23 * @accel_calibbias: cache for acceleration calibbias
24 * @accel_calibscale: cache for acceleration calibscale
25 * @lock: lock to ensure state is consistent
26 * @event_irq: irq number for event line (faked)
27 * @event_val: cache for event theshold value
28 * @event_en: cache of whether event is enabled
30 struct iio_dummy_state {
32 int single_ended_adc_val;
33 int differential_adc_val[2];
36 const struct iio_dummy_accel_calibscale *accel_calibscale;
38 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
42 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
45 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
49 int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
50 const struct iio_chan_spec *chan,
51 enum iio_event_type type,
52 enum iio_event_direction dir);
54 int iio_simple_dummy_write_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,
60 int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
61 const struct iio_chan_spec *chan,
62 enum iio_event_type type,
63 enum iio_event_direction dir,
64 enum iio_event_info info, int *val,
67 int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
68 const struct iio_chan_spec *chan,
69 enum iio_event_type type,
70 enum iio_event_direction dir,
71 enum iio_event_info info, int val,
74 int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
75 int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
77 #else /* Stubs for when events are disabled at compile time */
80 iio_simple_dummy_events_register(struct iio_dev *indio_dev)
86 iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
91 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
94 * enum iio_simple_dummy_scan_elements - scan index enum
95 * @voltage0: the single ended voltage channel
96 * @diffvoltage1m2: first differential channel
97 * @diffvoltage3m4: second differenial channel
98 * @accelx: acceleration channel
100 * Enum provides convenient numbering for the scan index.
102 enum iio_simple_dummy_scan_elements {
109 #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
110 int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
111 const struct iio_chan_spec *channels, unsigned int num_channels);
112 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
114 static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
115 const struct iio_chan_spec *channels, unsigned int num_channels)
120 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
123 #endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
124 #endif /* _IIO_SIMPLE_DUMMY_H_ */