aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/iio/buffer.h31
-rw-r--r--include/linux/iio/common/st_sensors.h1
-rw-r--r--include/linux/iio/consumer.h2
-rw-r--r--include/linux/iio/iio.h35
-rw-r--r--include/linux/iio/sysfs.h15
-rw-r--r--include/linux/mfd/ti_am335x_tscadc.h9
6 files changed, 78 insertions, 15 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 2bac0eb8948d..a1124bdc4cac 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -36,7 +36,7 @@ struct iio_buffer;
36 * any of them not existing. 36 * any of them not existing.
37 **/ 37 **/
38struct iio_buffer_access_funcs { 38struct iio_buffer_access_funcs {
39 int (*store_to)(struct iio_buffer *buffer, u8 *data); 39 int (*store_to)(struct iio_buffer *buffer, const void *data);
40 int (*read_first_n)(struct iio_buffer *buffer, 40 int (*read_first_n)(struct iio_buffer *buffer,
41 size_t n, 41 size_t n,
42 char __user *buf); 42 char __user *buf);
@@ -81,7 +81,7 @@ struct iio_buffer {
81 bool stufftoread; 81 bool stufftoread;
82 const struct attribute_group *attrs; 82 const struct attribute_group *attrs;
83 struct list_head demux_list; 83 struct list_head demux_list;
84 unsigned char *demux_bounce; 84 void *demux_bounce;
85 struct list_head buffer_list; 85 struct list_head buffer_list;
86}; 86};
87 87
@@ -120,7 +120,32 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
120 * @indio_dev: iio_dev structure for device. 120 * @indio_dev: iio_dev structure for device.
121 * @data: Full scan. 121 * @data: Full scan.
122 */ 122 */
123int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data); 123int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
124
125/*
126 * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
127 * @indio_dev: iio_dev structure for device.
128 * @data: sample data
129 * @timestamp: timestamp for the sample data
130 *
131 * Pushes data to the IIO device's buffers. If timestamps are enabled for the
132 * device the function will store the supplied timestamp as the last element in
133 * the sample data buffer before pushing it to the device buffers. The sample
134 * data buffer needs to be large enough to hold the additional timestamp
135 * (usually the buffer should be indio->scan_bytes bytes large).
136 *
137 * Returns 0 on success, a negative error code otherwise.
138 */
139static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
140 void *data, int64_t timestamp)
141{
142 if (indio_dev->scan_timestamp) {
143 size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
144 ((int64_t *)data)[ts_offset] = timestamp;
145 }
146
147 return iio_push_to_buffers(indio_dev, data);
148}
124 149
125int iio_update_demux(struct iio_dev *indio_dev); 150int iio_update_demux(struct iio_dev *indio_dev);
126 151
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index e51f65480ea5..e732fda6c8e6 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -184,6 +184,7 @@ struct st_sensors {
184 u8 wai; 184 u8 wai;
185 char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME]; 185 char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME];
186 struct iio_chan_spec *ch; 186 struct iio_chan_spec *ch;
187 int num_ch;
187 struct st_sensor_odr odr; 188 struct st_sensor_odr odr;
188 struct st_sensor_power pw; 189 struct st_sensor_power pw;
189 struct st_sensor_axis enable_axis; 190 struct st_sensor_axis enable_axis;
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 833926c91aa8..2752b1fd12be 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -77,7 +77,7 @@ struct iio_cb_buffer;
77 * fail. 77 * fail.
78 */ 78 */
79struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, 79struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
80 int (*cb)(u8 *data, 80 int (*cb)(const void *data,
81 void *private), 81 void *private),
82 void *private); 82 void *private);
83/** 83/**
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 2103cc32a5fb..ac1cb8f1858c 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -36,6 +36,14 @@ enum iio_chan_info_enum {
36 IIO_CHAN_INFO_PHASE, 36 IIO_CHAN_INFO_PHASE,
37 IIO_CHAN_INFO_HARDWAREGAIN, 37 IIO_CHAN_INFO_HARDWAREGAIN,
38 IIO_CHAN_INFO_HYSTERESIS, 38 IIO_CHAN_INFO_HYSTERESIS,
39 IIO_CHAN_INFO_INT_TIME,
40};
41
42enum iio_shared_by {
43 IIO_SEPARATE,
44 IIO_SHARED_BY_TYPE,
45 IIO_SHARED_BY_DIR,
46 IIO_SHARED_BY_ALL
39}; 47};
40 48
41enum iio_endian { 49enum iio_endian {
@@ -57,7 +65,7 @@ struct iio_dev;
57 */ 65 */
58struct iio_chan_spec_ext_info { 66struct iio_chan_spec_ext_info {
59 const char *name; 67 const char *name;
60 bool shared; 68 enum iio_shared_by shared;
61 ssize_t (*read)(struct iio_dev *, uintptr_t private, 69 ssize_t (*read)(struct iio_dev *, uintptr_t private,
62 struct iio_chan_spec const *, char *buf); 70 struct iio_chan_spec const *, char *buf);
63 ssize_t (*write)(struct iio_dev *, uintptr_t private, 71 ssize_t (*write)(struct iio_dev *, uintptr_t private,
@@ -125,7 +133,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
125#define IIO_ENUM_AVAILABLE(_name, _e) \ 133#define IIO_ENUM_AVAILABLE(_name, _e) \
126{ \ 134{ \
127 .name = (_name "_available"), \ 135 .name = (_name "_available"), \
128 .shared = true, \ 136 .shared = IIO_SHARED_BY_TYPE, \
129 .read = iio_enum_available_read, \ 137 .read = iio_enum_available_read, \
130 .private = (uintptr_t)(_e), \ 138 .private = (uintptr_t)(_e), \
131} 139}
@@ -146,12 +154,14 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
146 * shift: Shift right by this before masking out 154 * shift: Shift right by this before masking out
147 * realbits. 155 * realbits.
148 * endianness: little or big endian 156 * endianness: little or big endian
149 * @info_mask: What information is to be exported about this channel.
150 * This includes calibbias, scale etc.
151 * @info_mask_separate: What information is to be exported that is specific to 157 * @info_mask_separate: What information is to be exported that is specific to
152 * this channel. 158 * this channel.
153 * @info_mask_shared_by_type: What information is to be exported that is shared 159 * @info_mask_shared_by_type: What information is to be exported that is shared
154* by all channels of the same type. 160 * by all channels of the same type.
161 * @info_mask_shared_by_dir: What information is to be exported that is shared
162 * by all channels of the same direction.
163 * @info_mask_shared_by_all: What information is to be exported that is shared
164 * by all channels.
155 * @event_mask: What events can this channel produce. 165 * @event_mask: What events can this channel produce.
156 * @ext_info: Array of extended info attributes for this channel. 166 * @ext_info: Array of extended info attributes for this channel.
157 * The array is NULL terminated, the last element should 167 * The array is NULL terminated, the last element should
@@ -186,9 +196,10 @@ struct iio_chan_spec {
186 u8 shift; 196 u8 shift;
187 enum iio_endian endianness; 197 enum iio_endian endianness;
188 } scan_type; 198 } scan_type;
189 long info_mask;
190 long info_mask_separate; 199 long info_mask_separate;
191 long info_mask_shared_by_type; 200 long info_mask_shared_by_type;
201 long info_mask_shared_by_dir;
202 long info_mask_shared_by_all;
192 long event_mask; 203 long event_mask;
193 const struct iio_chan_spec_ext_info *ext_info; 204 const struct iio_chan_spec_ext_info *ext_info;
194 const char *extend_name; 205 const char *extend_name;
@@ -212,7 +223,9 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
212 enum iio_chan_info_enum type) 223 enum iio_chan_info_enum type)
213{ 224{
214 return (chan->info_mask_separate & BIT(type)) | 225 return (chan->info_mask_separate & BIT(type)) |
215 (chan->info_mask_shared_by_type & BIT(type)); 226 (chan->info_mask_shared_by_type & BIT(type)) |
227 (chan->info_mask_shared_by_dir & BIT(type)) |
228 (chan->info_mask_shared_by_all & BIT(type));
216} 229}
217 230
218#define IIO_ST(si, rb, sb, sh) \ 231#define IIO_ST(si, rb, sb, sh) \
@@ -457,7 +470,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
457{ 470{
458 if (indio_dev) 471 if (indio_dev)
459 put_device(&indio_dev->dev); 472 put_device(&indio_dev->dev);
460};