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
;
16 struct iio_dummy_regs
;
19 * struct iio_dummy_state - device instance specific state.
20 * @dac_val: cache for dac value
21 * @single_ended_adc_val: cache for single ended adc value
22 * @differential_adc_val: cache for differential adc value
23 * @accel_val: cache for acceleration value
24 * @accel_calibbias: cache for acceleration calibbias
25 * @accel_calibscale: cache for acceleration calibscale
26 * @lock: lock to ensure state is consistent
27 * @event_irq: irq number for event line (faked)
28 * @event_val: cache for event threshold value
29 * @event_en: cache of whether event is enabled
31 struct iio_dummy_state
{
33 int single_ended_adc_val
;
34 int differential_adc_val
[2];
39 const struct iio_dummy_accel_calibscale
*accel_calibscale
;
41 struct iio_dummy_regs
*regs
;
45 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
50 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
53 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
57 int iio_simple_dummy_read_event_config(struct iio_dev
*indio_dev
,
58 const struct iio_chan_spec
*chan
,
59 enum iio_event_type type
,
60 enum iio_event_direction dir
);
62 int iio_simple_dummy_write_event_config(struct iio_dev
*indio_dev
,
63 const struct iio_chan_spec
*chan
,
64 enum iio_event_type type
,
65 enum iio_event_direction dir
,
68 int iio_simple_dummy_read_event_value(struct iio_dev
*indio_dev
,
69 const struct iio_chan_spec
*chan
,
70 enum iio_event_type type
,
71 enum iio_event_direction dir
,
72 enum iio_event_info info
, int *val
,
75 int iio_simple_dummy_write_event_value(struct iio_dev
*indio_dev
,
76 const struct iio_chan_spec
*chan
,
77 enum iio_event_type type
,
78 enum iio_event_direction dir
,
79 enum iio_event_info info
, int val
,
82 int iio_simple_dummy_events_register(struct iio_dev
*indio_dev
);
83 void iio_simple_dummy_events_unregister(struct iio_dev
*indio_dev
);
85 #else /* Stubs for when events are disabled at compile time */
88 iio_simple_dummy_events_register(struct iio_dev
*indio_dev
)
94 iio_simple_dummy_events_unregister(struct iio_dev
*indio_dev
)
97 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
100 * enum iio_simple_dummy_scan_elements - scan index enum
101 * @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel
102 * @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel
103 * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel
104 * @DUMMY_INDEX_ACCELX: acceleration channel
106 * Enum provides convenient numbering for the scan index.
108 enum iio_simple_dummy_scan_elements
{
109 DUMMY_INDEX_VOLTAGE_0
,
110 DUMMY_INDEX_DIFFVOLTAGE_1M2
,
111 DUMMY_INDEX_DIFFVOLTAGE_3M4
,
115 #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
116 int iio_simple_dummy_configure_buffer(struct iio_dev
*indio_dev
);
117 void iio_simple_dummy_unconfigure_buffer(struct iio_dev
*indio_dev
);
119 static inline int iio_simple_dummy_configure_buffer(struct iio_dev
*indio_dev
)
125 void iio_simple_dummy_unconfigure_buffer(struct iio_dev
*indio_dev
)
128 #endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
129 #endif /* _IIO_SIMPLE_DUMMY_H_ */