iio: imu: Add support for Kionix KMX61 sensor
[deliverable/linux.git] / drivers / staging / iio / iio_simple_dummy.h
CommitLineData
e6477000
JC
1/**
2 * Copyright (c) 2011 Jonathan Cameron
3 *
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.
7 *
8 * Join together the various functionality of iio_simple_dummy driver
9 */
10
f3f883b4
RD
11#ifndef _IIO_SIMPLE_DUMMY_H_
12#define _IIO_SIMPLE_DUMMY_H_
e6477000
JC
13#include <linux/kernel.h>
14
15struct iio_dummy_accel_calibscale;
16
17/**
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
29 */
30struct iio_dummy_state {
31 int dac_val;
32 int single_ended_adc_val;
33 int differential_adc_val[2];
34 int accel_val;
35 int accel_calibbias;
36 const struct iio_dummy_accel_calibscale *accel_calibscale;
37 struct mutex lock;
38#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
39 int event_irq;
40 int event_val;
41 bool event_en;
42#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
43};
44
45#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
46
47struct iio_dev;
48
49int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
50 const struct iio_chan_spec *chan,
51 enum iio_event_type type,
52 enum iio_event_direction dir);
e6477000
JC
53
54int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
55 const struct iio_chan_spec *chan,
56 enum iio_event_type type,
57 enum iio_event_direction dir,
e6477000
JC
58 int state);
59
60int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
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,
65 int *val2);
e6477000
JC
66
67int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
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,
72 int val2);
e6477000
JC
73
74int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
75int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
76
77#else /* Stubs for when events are disabled at compile time */
78
79static inline int
80iio_simple_dummy_events_register(struct iio_dev *indio_dev)
81{
82 return 0;
83};
84
85static inline int
86iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
87{
88 return 0;
89};
90
91#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
92
9ad2e2e1
JC
93/**
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
99 *
100 * Enum provides convenient numbering for the scan index.
101 */
102enum iio_simple_dummy_scan_elements {
103 voltage0,
104 diffvoltage1m2,
105 diffvoltage3m4,
106 accelx,
107};
e6477000 108
9ad2e2e1 109#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
3fff2274
LPC
110int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
111 const struct iio_chan_spec *channels, unsigned int num_channels);
9ad2e2e1
JC
112void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
113#else
3fff2274
LPC
114static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
115 const struct iio_chan_spec *channels, unsigned int num_channels)
9ad2e2e1
JC
116{
117 return 0;
118};
119static inline
120void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
121{};
f3f883b4 122
9ad2e2e1 123#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
f3f883b4 124#endif /* _IIO_SIMPLE_DUMMY_H_ */
This page took 0.284242 seconds and 5 git commands to generate.