aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-20 21:13:37 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-20 21:13:37 -0500
commit6e49557b316e8db983a6d40d18e88ab0ba8571ef (patch)
treeded6ad6cdaace89769d7a3464fd0170f4d4471b8 /include/linux/iio
parente60088575bcbaf8d71a0e9f1d44fbf136f95e2cd (diff)
parentdf1fad80dfa0a7644b525c4a0dd8f2be21f57358 (diff)
Merge tag 'iio-for-3.20a_take2' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing
Jonathan writes: First round of IIO new drivers, cleanups and functionality for the 3.20 cycle take 2 Updated pull request with Daniel's fix on top for the power management Kconfig changes that had snuck in since last update of the IIO tree worked it's way through from mainline. Original pull message New device support * jsa1212 proxmity / ambient light sensor * SM08500 supported added to the kxcjk-1013 accelerometer driver * KMX61 Accelerometer/Magnetometer. This took a somewhat rocky path being first merged, then reverted for a rewrite after a discussion of how to support additional functionality and finally being merged prior to some last reviews coming in, with resultant follow up patches. * Freescale mma9551l driver (minor follow up warning supression patch). * Semtech SX9500 proximity device driver. * ak8975 gains support for ak09911 and ak09912 and drop the standalone driver for the ak09911. New functionality * Dummy driver gains some virtual registers making it more flexible. * IIO_ACTIVITY channel types, with modifiers running, walking etc. This is to support on chip motion clasifiers. As such it is in the form of a confidence percentage. The only devices so far only do binary decisions but this gives us room when other devices give more nuanced clasification. * IIO_EV_DIR_NONE type for events where there is no obvious direction. First case is step detection. * IIO_STEPS channel type for pedometers. * ENABLE mask element used to control turning on counting types such as the pedometer that need a 'start point'. * INSTANCE event type to support things that happen once. * info element for height calibration (used in various motion estimation algorithms). Note heigh tof use * dummy driver demonstration of the use of all the new bits above. * event monitor support for the new events. * inv_mpu6050 gains an i2c mux to allow bypassing the device to access additional devices connected on the other side of it. Note that in Windows these are handled by firmware on the device and not exposed directly. * inv_mpu6050 gains ACPI enumeration. * inkern interface gains iio_write_channel_raw to allow in kernel users of DAC functionality via a simple wrapper. * Document input current readings in the ABI docs. * Add an error message when we get an out of range error in device tree processing for the in kernel interfaces. Basically a device tree debugging aid. * Add a sanity check that a scan index for a channel is unique during registration. There to help catch bugs as this should never happen in a bug free driver. Cleanups and fixlets A rework of buffer registration from Lars - a precursor to some other upcoming new stuff (a few patches from others rolled in here as well). * Ensure all drivers register the same channels for the device and buffer. * Move buffer registration into the core rather than using the old two step approach. Now we have simple ways of using a unified set channels for both without requiring channels be exposed by both interface, this removes a fair bit of boilerplate. * Stop sca3000 and ad5933 (both in staging) enabling buffer channels by default. It has long be convention in IIO to startup with no channels enabled and leave it up to userspace to say what goes in the buffer. Getting rid of these allows us to drop export of iio_scan_mask_set. * Drop get_bytes_per_datum from iio_buffer_access_funcs as not been used for a while. * Allocate standard buffer attributes in the core rather than in every driver with a buffer. * Make the length attribute read only when a driver is not able to set the length. * Drop the get_length callback for buffers as it is already available in struct iio_buffer. * Drop an unused arguement form iio_kfifo_allocate and add devm allocator for it. * some kconfig entries gain anotation with the resulting module name. * Fix a resulting compile issue in dummy driver due to a stub taking wrong parameters as a result of the above rework. * Fix an off by 2 error in copying the core assigned buffer attributes. Other cleanups, * Trivial space before comma fixups. * ak8975 fixlets - none critical. Rework to allow more device support. * Drop unnecessary sizeof(u8) calls. * bmp280 - refactor the compensation code to reduce copy operations and code length. A second patch futher optimized this and performed some other minor cleanups. * kxcjk-1013 - various power control cleanups to avoid unnecessary enable / disable of device. Make sure it is only controlled at all if CONFIG_PM is enabled. Also som cleanups of error paths. * Small cleanups in adf4530 driver - pointless message and unnecessary braces. * Clarifiy the proximity ABI docs to make it clear it should get bigger as we move futher away. * Drop a misleading comment form industrialio-core.c * Trivial white space cleanups. * sca3000 looses an unused debug function. * Fix char unsigned ordering in ad8366 * Increase the sleep time in ad9523 to make it predictable (value didn't really matter so make it more than 20 msecs) * mxs-lradc touchscreen property cleanups in device tree are fixed to ensure the meet all the 'interesting' documentation. * A couple of cleanups for the staging ad5933 driver to avoid unnecessary conversion to a processed temperature vlaue in kernel and remove platform data form the state structure as not needed after probe. * Fix a wrong scale factor in the docs. Misc * Add IIO include files to the maintainers entry.
Diffstat (limited to 'include/linux/iio')
-rw-r--r--include/linux/iio/buffer.h76
-rw-r--r--include/linux/iio/consumer.h12
-rw-r--r--include/linux/iio/iio.h2
-rw-r--r--include/linux/iio/kfifo_buf.h5
-rw-r--r--include/linux/iio/types.h10
5 files changed, 28 insertions, 77 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 519392763393..b65850a41127 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -25,9 +25,7 @@ struct iio_buffer;
25 * available. 25 * available.
26 * @request_update: if a parameter change has been marked, update underlying 26 * @request_update: if a parameter change has been marked, update underlying
27 * storage. 27 * storage.
28 * @get_bytes_per_datum:get current bytes per datum
29 * @set_bytes_per_datum:set number of bytes per datum 28 * @set_bytes_per_datum:set number of bytes per datum
30 * @get_length: get number of datums in buffer
31 * @set_length: set number of datums in buffer 29 * @set_length: set number of datums in buffer
32 * @release: called when the last reference to the buffer is dropped, 30 * @release: called when the last reference to the buffer is dropped,
33 * should free all resources allocated by the buffer. 31 * should free all resources allocated by the buffer.
@@ -49,9 +47,7 @@ struct iio_buffer_access_funcs {
49 47
50 int (*request_update)(struct iio_buffer *buffer); 48 int (*request_update)(struct iio_buffer *buffer);
51 49
52 int (*get_bytes_per_datum)(struct iio_buffer *buffer);
53 int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); 50 int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
54 int (*get_length)(struct iio_buffer *buffer);
55 int (*set_length)(struct iio_buffer *buffer, int length); 51 int (*set_length)(struct iio_buffer *buffer, int length);
56 52
57 void (*release)(struct iio_buffer *buffer); 53 void (*release)(struct iio_buffer *buffer);
@@ -85,10 +81,11 @@ struct iio_buffer {
85 bool scan_timestamp; 81 bool scan_timestamp;
86 const struct iio_buffer_access_funcs *access; 82 const struct iio_buffer_access_funcs *access;
87 struct list_head scan_el_dev_attr_list; 83 struct list_head scan_el_dev_attr_list;
84 struct attribute_group buffer_group;
88 struct attribute_group scan_el_group; 85 struct attribute_group scan_el_group;
89 wait_queue_head_t pollq; 86 wait_queue_head_t pollq;
90 bool stufftoread; 87 bool stufftoread;
91 const struct attribute_group *attrs; 88 const struct attribute **attrs;
92 struct list_head demux_list; 89 struct list_head demux_list;
93 void *demux_bounce; 90 void *demux_bounce;
94 struct list_head buffer_list; 91 struct list_head buffer_list;
@@ -117,15 +114,6 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
117 struct iio_buffer *buffer, int bit); 114 struct iio_buffer *buffer, int bit);
118 115
119/** 116/**
120 * iio_scan_mask_set() - set particular bit in the scan mask
121 * @indio_dev IIO device structure
122 * @buffer: the buffer whose scan mask we are interested in
123 * @bit: the bit to be set.
124 **/
125int iio_scan_mask_set(struct iio_dev *indio_dev,
126 struct iio_buffer *buffer, int bit);
127
128/**
129 * iio_push_to_buffers() - push to a registered buffer. 117 * iio_push_to_buffers() - push to a registered buffer.
130 * @indio_dev: iio_dev structure for device. 118 * @indio_dev: iio_dev structure for device.
131 * @data: Full scan. 119 * @data: Full scan.
@@ -159,56 +147,6 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
159 147
160int iio_update_demux(struct iio_dev *indio_dev); 148int iio_update_demux(struct iio_dev *indio_dev);
161 149
162/**
163 * iio_buffer_register() - register the buffer with IIO core
164 * @indio_dev: device with the buffer to be registered
165 * @channels: the channel descriptions used to construct buffer
166 * @num_channels: the number of channels
167 **/
168int iio_buffer_register(struct iio_dev *indio_dev,
169 const struct iio_chan_spec *channels,
170 int num_channels);
171
172/**
173 * iio_buffer_unregister() - unregister the buffer from IIO core
174 * @indio_dev: the device with the buffer to be unregistered
175 **/
176void iio_buffer_unregister(struct iio_dev *indio_dev);
177
178/**
179 * iio_buffer_read_length() - attr func to get number of datums in the buffer
180 **/
181ssize_t iio_buffer_read_length(struct device *dev,
182 struct device_attribute *attr,
183 char *buf);
184/**
185 * iio_buffer_write_length() - attr func to set number of datums in the buffer
186 **/
187ssize_t iio_buffer_write_length(struct device *dev,
188 struct device_attribute *attr,
189 const char *buf,
190 size_t len);
191/**
192 * iio_buffer_store_enable() - attr to turn the buffer on
193 **/
194ssize_t iio_buffer_store_enable(struct device *dev,
195 struct device_attribute *attr,
196 const char *buf,
197 size_t len);
198/**
199 * iio_buffer_show_enable() - attr to see if the buffer is on
200 **/
201ssize_t iio_buffer_show_enable(struct device *dev,
202 struct device_attribute *attr,
203 char *buf);
204#define IIO_BUFFER_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR, \
205 iio_buffer_read_length, \
206 iio_buffer_write_length)
207
208#define IIO_BUFFER_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
209 iio_buffer_show_enable, \
210 iio_buffer_store_enable)
211
212bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, 150bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
213 const unsigned long *mask); 151 const unsigned long *mask);
214 152
@@ -232,16 +170,6 @@ static inline void iio_device_attach_buffer(struct iio_dev *indio_dev,
232 170
233#else /* CONFIG_IIO_BUFFER */ 171#else /* CONFIG_IIO_BUFFER */
234 172
235static inline int iio_buffer_register(struct iio_dev *indio_dev,
236 const struct iio_chan_spec *channels,
237 int num_channels)
238{
239 return 0;
240}
241
242static inline void iio_buffer_unregister(struct iio_dev *indio_dev)
243{}
244
245static inline void iio_buffer_get(struct iio_buffer *buffer) {} 173static inline void iio_buffer_get(struct iio_buffer *buffer) {}
246static inline void iio_buffer_put(struct iio_buffer *buffer) {} 174static inline void iio_buffer_put(struct iio_buffer *buffer) {}
247 175
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 651f9a0e2765..26fb8f6342bb 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -151,6 +151,16 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
151int iio_read_channel_processed(struct iio_channel *chan, int *val); 151int iio_read_channel_processed(struct iio_channel *chan, int *val);
152 152
153/** 153/**
154 * iio_write_channel_raw() - write to a given channel
155 * @chan: The channel being queried.
156 * @val: Value being written.
157 *
158 * Note raw writes to iio channels are in dac counts and hence
159 * scale will need to be applied if standard units required.
160 */
161int iio_write_channel_raw(struct iio_channel *chan, int val);
162
163/**
154 * iio_get_channel_type() - get the type of a channel 164 * iio_get_channel_type() - get the type of a channel
155 * @channel: The channel being queried. 165 * @channel: The channel being queried.
156 * @type: The type of the channel. 166 * @type: The type of the channel.
@@ -191,7 +201,7 @@ int iio_read_channel_scale(struct iio_channel *chan, int *val,
191 * The scale factor allows to increase the precession of the returned value. For 201 * The scale factor allows to increase the precession of the returned value. For
192 * a scale factor of 1 the function will return the result in the normal IIO 202 * a scale factor of 1 the function will return the result in the normal IIO
193 * unit for the channel type. E.g. millivolt for voltage channels, if you want 203 * unit for the channel type. E.g. millivolt for voltage channels, if you want
194 * nanovolts instead pass 1000 as the scale factor. 204 * nanovolts instead pass 1000000 as the scale factor.
195 */ 205 */
196int iio_convert_raw_to_processed(struct iio_channel *chan, int raw, 206int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
197 int *processed, unsigned int scale); 207 int *processed, unsigned int scale);
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 3642ce7ef512..878d861b0610 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -38,6 +38,8 @@ enum iio_chan_info_enum {
38 IIO_CHAN_INFO_HARDWAREGAIN, 38 IIO_CHAN_INFO_HARDWAREGAIN,
39 IIO_CHAN_INFO_HYSTERESIS, 39 IIO_CHAN_INFO_HYSTERESIS,
40 IIO_CHAN_INFO_INT_TIME, 40 IIO_CHAN_INFO_INT_TIME,
41 IIO_CHAN_INFO_ENABLE,
42 IIO_CHAN_INFO_CALIBHEIGHT,
41}; 43};
42 44
43enum iio_shared_by { 45enum iio_shared_by {
diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h
index 25eeac762e84..1683bc710d14 100644
--- a/include/linux/iio/kfifo_buf.h
+++ b/include/linux/iio/kfifo_buf.h
@@ -5,7 +5,10 @@
5#include <linux/iio/iio.h> 5#include <linux/iio/iio.h>
6#include <linux/iio/buffer.h> 6#include <linux/iio/buffer.h>
7 7
8struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev); 8struct iio_buffer *iio_kfifo_allocate(void);
9void iio_kfifo_free(struct iio_buffer *r); 9void iio_kfifo_free(struct iio_buffer *r);
10 10
11struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev);
12void devm_iio_kfifo_free(struct device *dev, struct iio_buffer *r);
13
11#endif 14#endif
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 4a2af8adf874..904dcbbf0e6f 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -30,6 +30,8 @@ enum iio_chan_type {
30 IIO_CCT, 30 IIO_CCT,
31 IIO_PRESSURE, 31 IIO_PRESSURE,
32 IIO_HUMIDITYRELATIVE, 32 IIO_HUMIDITYRELATIVE,
33 IIO_ACTIVITY,
34 IIO_STEPS,
33}; 35};
34 36
35enum iio_modifier { 37enum iio_modifier {
@@ -59,7 +61,11 @@ enum iio_modifier {
59 IIO_MOD_NORTH_MAGN, 61 IIO_MOD_NORTH_MAGN,
60 IIO_MOD_NORTH_TRUE, 62 IIO_MOD_NORTH_TRUE,
61 IIO_MOD_NORTH_MAGN_TILT_COMP, 63 IIO_MOD_NORTH_MAGN_TILT_COMP,
62 IIO_MOD_NORTH_TRUE_TILT_COMP 64 IIO_MOD_NORTH_TRUE_TILT_COMP,
65 IIO_MOD_RUNNING,
66 IIO_MOD_JOGGING,
67 IIO_MOD_WALKING,
68 IIO_MOD_STILL,
63}; 69};
64 70
65enum iio_event_type { 71enum iio_event_type {
@@ -68,6 +74,7 @@ enum iio_event_type {
68 IIO_EV_TYPE_ROC, 74 IIO_EV_TYPE_ROC,
69 IIO_EV_TYPE_THRESH_ADAPTIVE, 75 IIO_EV_TYPE_THRESH_ADAPTIVE,
70 IIO_EV_TYPE_MAG_ADAPTIVE, 76 IIO_EV_TYPE_MAG_ADAPTIVE,
77 IIO_EV_TYPE_INSTANCE,
71}; 78};
72 79
73enum iio_event_info { 80enum iio_event_info {
@@ -81,6 +88,7 @@ enum iio_event_direction {
81 IIO_EV_DIR_EITHER, 88 IIO_EV_DIR_EITHER,
82 IIO_EV_DIR_RISING, 89 IIO_EV_DIR_RISING,
83 IIO_EV_DIR_FALLING, 90 IIO_EV_DIR_FALLING,
91 IIO_EV_DIR_NONE,
84}; 92};
85 93
86#define IIO_VAL_INT 1 94#define IIO_VAL_INT 1