Commit c01ef023ec1d2af185e55f7600405dcce1813d5d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Merge branch 'togreg' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Showing 19 changed files Side-by-side Diff
- drivers/iio/adc/Kconfig
- drivers/iio/adc/Makefile
- drivers/iio/adc/ad7266.c
- drivers/iio/dac/Kconfig
- drivers/iio/dac/ad5064.c
- drivers/iio/industrialio-core.c
- drivers/iio/inkern.c
- drivers/staging/iio/accel/adis16201_core.c
- drivers/staging/iio/accel/adis16203_core.c
- drivers/staging/iio/accel/adis16204_core.c
- drivers/staging/iio/accel/adis16209_core.c
- drivers/staging/iio/accel/adis16220_core.c
- drivers/staging/iio/accel/adis16240_core.c
- drivers/staging/iio/gyro/adis16260_core.c
- drivers/staging/iio/iio_hwmon.c
- drivers/staging/iio/imu/adis16400_core.c
- include/linux/iio/consumer.h
- include/linux/iio/types.h
- include/linux/platform_data/ad7266.h
drivers/iio/adc/Kconfig
... | ... | @@ -3,6 +3,16 @@ |
3 | 3 | # |
4 | 4 | menu "Analog to digital converters" |
5 | 5 | |
6 | +config AD7266 | |
7 | + tristate "Analog Devices AD7265/AD7266 ADC driver" | |
8 | + depends on SPI_MASTER | |
9 | + select IIO_BUFFER | |
10 | + select IIO_TRIGGER | |
11 | + select IIO_TRIGGERED_BUFFER | |
12 | + help | |
13 | + Say yes here to build support for Analog Devices AD7265 and AD7266 | |
14 | + ADCs. | |
15 | + | |
6 | 16 | config AT91_ADC |
7 | 17 | tristate "Atmel AT91 ADC" |
8 | 18 | depends on ARCH_AT91 |
drivers/iio/adc/Makefile
drivers/iio/adc/ad7266.c
1 | +/* | |
2 | + * AD7266/65 SPI ADC driver | |
3 | + * | |
4 | + * Copyright 2012 Analog Devices Inc. | |
5 | + * | |
6 | + * Licensed under the GPL-2. | |
7 | + */ | |
8 | + | |
9 | +#include <linux/device.h> | |
10 | +#include <linux/kernel.h> | |
11 | +#include <linux/slab.h> | |
12 | +#include <linux/spi/spi.h> | |
13 | +#include <linux/regulator/consumer.h> | |
14 | +#include <linux/err.h> | |
15 | +#include <linux/gpio.h> | |
16 | +#include <linux/module.h> | |
17 | + | |
18 | +#include <linux/interrupt.h> | |
19 | + | |
20 | +#include <linux/iio/iio.h> | |
21 | +#include <linux/iio/buffer.h> | |
22 | +#include <linux/iio/trigger_consumer.h> | |
23 | +#include <linux/iio/triggered_buffer.h> | |
24 | + | |
25 | +#include <linux/platform_data/ad7266.h> | |
26 | + | |
27 | +struct ad7266_state { | |
28 | + struct spi_device *spi; | |
29 | + struct regulator *reg; | |
30 | + unsigned long vref_uv; | |
31 | + | |
32 | + struct spi_transfer single_xfer[3]; | |
33 | + struct spi_message single_msg; | |
34 | + | |
35 | + enum ad7266_range range; | |
36 | + enum ad7266_mode mode; | |
37 | + bool fixed_addr; | |
38 | + struct gpio gpios[3]; | |
39 | + | |
40 | + /* | |
41 | + * DMA (thus cache coherency maintenance) requires the | |
42 | + * transfer buffers to live in their own cache lines. | |
43 | + * The buffer needs to be large enough to hold two samples (4 bytes) and | |
44 | + * the naturally aligned timestamp (8 bytes). | |
45 | + */ | |
46 | + uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned; | |
47 | +}; | |
48 | + | |
49 | +static int ad7266_wakeup(struct ad7266_state *st) | |
50 | +{ | |
51 | + /* Any read with >= 2 bytes will wake the device */ | |
52 | + return spi_read(st->spi, st->data, 2); | |
53 | +} | |
54 | + | |
55 | +static int ad7266_powerdown(struct ad7266_state *st) | |
56 | +{ | |
57 | + /* Any read with < 2 bytes will powerdown the device */ | |
58 | + return spi_read(st->spi, st->data, 1); | |
59 | +} | |
60 | + | |
61 | +static int ad7266_preenable(struct iio_dev *indio_dev) | |
62 | +{ | |
63 | + struct ad7266_state *st = iio_priv(indio_dev); | |
64 | + int ret; | |
65 | + | |
66 | + ret = ad7266_wakeup(st); | |
67 | + if (ret) | |
68 | + return ret; | |
69 | + | |
70 | + ret = iio_sw_buffer_preenable(indio_dev); | |
71 | + if (ret) | |
72 | + ad7266_powerdown(st); | |
73 | + | |
74 | + return ret; | |
75 | +} | |
76 | + | |
77 | +static int ad7266_postdisable(struct iio_dev *indio_dev) | |
78 | +{ | |
79 | + struct ad7266_state *st = iio_priv(indio_dev); | |
80 | + return ad7266_powerdown(st); | |
81 | +} | |
82 | + | |
83 | +static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = { | |
84 | + .preenable = &ad7266_preenable, | |
85 | + .postenable = &iio_triggered_buffer_postenable, | |
86 | + .predisable = &iio_triggered_buffer_predisable, | |
87 | + .postdisable = &ad7266_postdisable, | |
88 | +}; | |
89 | + | |
90 | +static irqreturn_t ad7266_trigger_handler(int irq, void *p) | |
91 | +{ | |
92 | + struct iio_poll_func *pf = p; | |
93 | + struct iio_dev *indio_dev = pf->indio_dev; | |
94 | + struct iio_buffer *buffer = indio_dev->buffer; | |
95 | + struct ad7266_state *st = iio_priv(indio_dev); | |
96 | + int ret; | |
97 | + | |
98 | + ret = spi_read(st->spi, st->data, 4); | |
99 | + if (ret == 0) { | |
100 | + if (indio_dev->scan_timestamp) | |
101 | + ((s64 *)st->data)[1] = pf->timestamp; | |
102 | + iio_push_to_buffer(buffer, (u8 *)st->data, pf->timestamp); | |
103 | + } | |
104 | + | |
105 | + iio_trigger_notify_done(indio_dev->trig); | |
106 | + | |
107 | + return IRQ_HANDLED; | |
108 | +} | |
109 | + | |
110 | +static void ad7266_select_input(struct ad7266_state *st, unsigned int nr) | |
111 | +{ | |
112 | + unsigned int i; | |
113 | + | |
114 | + if (st->fixed_addr) | |
115 | + return; | |
116 | + | |
117 | + switch (st->mode) { | |
118 | + case AD7266_MODE_SINGLE_ENDED: | |
119 | + nr >>= 1; | |
120 | + break; | |
121 | + case AD7266_MODE_PSEUDO_DIFF: | |
122 | + nr |= 1; | |
123 | + break; | |
124 | + case AD7266_MODE_DIFF: | |
125 | + nr &= ~1; | |
126 | + break; | |
127 | + } | |
128 | + | |
129 | + for (i = 0; i < 3; ++i) | |
130 | + gpio_set_value(st->gpios[i].gpio, (bool)(nr & BIT(i))); | |
131 | +} | |
132 | + | |
133 | +static int ad7266_update_scan_mode(struct iio_dev *indio_dev, | |
134 | + const unsigned long *scan_mask) | |
135 | +{ | |
136 | + struct ad7266_state *st = iio_priv(indio_dev); | |
137 | + unsigned int nr = find_first_bit(scan_mask, indio_dev->masklength); | |
138 | + | |
139 | + ad7266_select_input(st, nr); | |
140 | + | |
141 | + return 0; | |
142 | +} | |
143 | + | |
144 | +static int ad7266_read_single(struct ad7266_state *st, int *val, | |
145 | + unsigned int address) | |
146 | +{ | |
147 | + int ret; | |
148 | + | |
149 | + ad7266_select_input(st, address); | |
150 | + | |
151 | + ret = spi_sync(st->spi, &st->single_msg); | |
152 | + *val = be16_to_cpu(st->data[address % 2]); | |
153 | + | |
154 | + return ret; | |
155 | +} | |
156 | + | |
157 | +static int ad7266_read_raw(struct iio_dev *indio_dev, | |
158 | + struct iio_chan_spec const *chan, int *val, int *val2, long m) | |
159 | +{ | |
160 | + struct ad7266_state *st = iio_priv(indio_dev); | |
161 | + unsigned long scale_uv; | |
162 | + int ret; | |
163 | + | |
164 | + switch (m) { | |
165 | + case IIO_CHAN_INFO_RAW: | |
166 | + if (iio_buffer_enabled(indio_dev)) | |
167 | + return -EBUSY; | |
168 | + | |
169 | + ret = ad7266_read_single(st, val, chan->address); | |
170 | + if (ret) | |
171 | + return ret; | |
172 | + | |
173 | + *val = (*val >> 2) & 0xfff; | |
174 | + if (chan->scan_type.sign == 's') | |
175 | + *val = sign_extend32(*val, 11); | |
176 | + | |
177 | + return IIO_VAL_INT; | |
178 | + case IIO_CHAN_INFO_SCALE: | |
179 | + scale_uv = (st->vref_uv * 100); | |
180 | + if (st->mode == AD7266_MODE_DIFF) | |
181 | + scale_uv *= 2; | |
182 | + if (st->range == AD7266_RANGE_2VREF) | |
183 | + scale_uv *= 2; | |
184 | + | |
185 | + scale_uv >>= chan->scan_type.realbits; | |
186 | + *val = scale_uv / 100000; | |
187 | + *val2 = (scale_uv % 100000) * 10; | |
188 | + return IIO_VAL_INT_PLUS_MICRO; | |
189 | + case IIO_CHAN_INFO_OFFSET: | |
190 | + if (st->range == AD7266_RANGE_2VREF && | |
191 | + st->mode != AD7266_MODE_DIFF) | |
192 | + *val = 2048; | |
193 | + else | |
194 | + *val = 0; | |
195 | + return IIO_VAL_INT; | |
196 | + } | |
197 | + return -EINVAL; | |
198 | +} | |
199 | + | |
200 | +#define AD7266_CHAN(_chan, _sign) { \ | |
201 | + .type = IIO_VOLTAGE, \ | |
202 | + .indexed = 1, \ | |
203 | + .channel = (_chan), \ | |
204 | + .address = (_chan), \ | |
205 | + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \ | |
206 | + | IIO_CHAN_INFO_SCALE_SHARED_BIT \ | |
207 | + | IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ | |
208 | + .scan_index = (_chan), \ | |
209 | + .scan_type = { \ | |
210 | + .sign = (_sign), \ | |
211 | + .realbits = 12, \ | |
212 | + .storagebits = 16, \ | |
213 | + .shift = 2, \ | |
214 | + .endianness = IIO_BE, \ | |
215 | + }, \ | |
216 | +} | |
217 | + | |
218 | +#define AD7266_DECLARE_SINGLE_ENDED_CHANNELS(_name, _sign) \ | |
219 | +const struct iio_chan_spec ad7266_channels_##_name[] = { \ | |
220 | + AD7266_CHAN(0, (_sign)), \ | |
221 | + AD7266_CHAN(1, (_sign)), \ | |
222 | + AD7266_CHAN(2, (_sign)), \ | |
223 | + AD7266_CHAN(3, (_sign)), \ | |
224 | + AD7266_CHAN(4, (_sign)), \ | |
225 | + AD7266_CHAN(5, (_sign)), \ | |
226 | + AD7266_CHAN(6, (_sign)), \ | |
227 | + AD7266_CHAN(7, (_sign)), \ | |
228 | + AD7266_CHAN(8, (_sign)), \ | |
229 | + AD7266_CHAN(9, (_sign)), \ | |
230 | + AD7266_CHAN(10, (_sign)), \ | |
231 | + AD7266_CHAN(11, (_sign)), \ | |
232 | + IIO_CHAN_SOFT_TIMESTAMP(13), \ | |
233 | +} | |
234 | + | |
235 | +#define AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(_name, _sign) \ | |
236 | +const struct iio_chan_spec ad7266_channels_##_name##_fixed[] = { \ | |
237 | + AD7266_CHAN(0, (_sign)), \ | |
238 | + AD7266_CHAN(1, (_sign)), \ | |
239 | + IIO_CHAN_SOFT_TIMESTAMP(2), \ | |
240 | +} | |
241 | + | |
242 | +static AD7266_DECLARE_SINGLE_ENDED_CHANNELS(u, 'u'); | |
243 | +static AD7266_DECLARE_SINGLE_ENDED_CHANNELS(s, 's'); | |
244 | +static AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(u, 'u'); | |
245 | +static AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(s, 's'); | |
246 | + | |
247 | +#define AD7266_CHAN_DIFF(_chan, _sign) { \ | |
248 | + .type = IIO_VOLTAGE, \ | |
249 | + .indexed = 1, \ | |
250 | + .channel = (_chan) * 2, \ | |
251 | + .channel2 = (_chan) * 2 + 1, \ | |
252 | + .address = (_chan), \ | |
253 | + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \ | |
254 | + | IIO_CHAN_INFO_SCALE_SHARED_BIT \ | |
255 | + | IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ | |
256 | + .scan_index = (_chan), \ | |
257 | + .scan_type = { \ | |
258 | + .sign = _sign, \ | |
259 | + .realbits = 12, \ | |
260 | + .storagebits = 16, \ | |
261 | + .shift = 2, \ | |
262 | + .endianness = IIO_BE, \ | |
263 | + }, \ | |
264 | + .differential = 1, \ | |
265 | +} | |
266 | + | |
267 | +#define AD7266_DECLARE_DIFF_CHANNELS(_name, _sign) \ | |
268 | +const struct iio_chan_spec ad7266_channels_diff_##_name[] = { \ | |
269 | + AD7266_CHAN_DIFF(0, (_sign)), \ | |
270 | + AD7266_CHAN_DIFF(1, (_sign)), \ | |
271 | + AD7266_CHAN_DIFF(2, (_sign)), \ | |
272 | + AD7266_CHAN_DIFF(3, (_sign)), \ | |
273 | + AD7266_CHAN_DIFF(4, (_sign)), \ | |
274 | + AD7266_CHAN_DIFF(5, (_sign)), \ | |
275 | + IIO_CHAN_SOFT_TIMESTAMP(6), \ | |
276 | +} | |
277 | + | |
278 | +static AD7266_DECLARE_DIFF_CHANNELS(s, 's'); | |
279 | +static AD7266_DECLARE_DIFF_CHANNELS(u, 'u'); | |
280 | + | |
281 | +#define AD7266_DECLARE_DIFF_CHANNELS_FIXED(_name, _sign) \ | |
282 | +const struct iio_chan_spec ad7266_channels_diff_fixed_##_name[] = { \ | |
283 | + AD7266_CHAN_DIFF(0, (_sign)), \ | |
284 | + AD7266_CHAN_DIFF(1, (_sign)), \ | |
285 | + IIO_CHAN_SOFT_TIMESTAMP(2), \ | |
286 | +} | |
287 | + | |
288 | +static AD7266_DECLARE_DIFF_CHANNELS_FIXED(s, 's'); | |
289 | +static AD7266_DECLARE_DIFF_CHANNELS_FIXED(u, 'u'); | |
290 | + | |
291 | +static const struct iio_info ad7266_info = { | |
292 | + .read_raw = &ad7266_read_raw, | |
293 | + .update_scan_mode = &ad7266_update_scan_mode, | |
294 | + .driver_module = THIS_MODULE, | |
295 | +}; | |
296 | + | |
297 | +static unsigned long ad7266_available_scan_masks[] = { | |
298 | + 0x003, | |
299 | + 0x00c, | |
300 | + 0x030, | |
301 | + 0x0c0, | |
302 | + 0x300, | |
303 | + 0xc00, | |
304 | + 0x000, | |
305 | +}; | |
306 | + | |
307 | +static unsigned long ad7266_available_scan_masks_diff[] = { | |
308 | + 0x003, | |
309 | + 0x00c, | |
310 | + 0x030, | |
311 | + 0x000, | |
312 | +}; | |
313 | + | |
314 | +static unsigned long ad7266_available_scan_masks_fixed[] = { | |
315 | + 0x003, | |
316 | + 0x000, | |
317 | +}; | |
318 | + | |
319 | +struct ad7266_chan_info { | |
320 | + const struct iio_chan_spec *channels; | |
321 | + unsigned int num_channels; | |
322 | + unsigned long *scan_masks; | |
323 | +}; | |
324 | + | |
325 | +#define AD7266_CHAN_INFO_INDEX(_differential, _signed, _fixed) \ | |
326 | + (((_differential) << 2) | ((_signed) << 1) | ((_fixed) << 0)) | |
327 | + | |
328 | +static const struct ad7266_chan_info ad7266_chan_infos[] = { | |
329 | + [AD7266_CHAN_INFO_INDEX(0, 0, 0)] = { | |
330 | + .channels = ad7266_channels_u, | |
331 | + .num_channels = ARRAY_SIZE(ad7266_channels_u), | |
332 | + .scan_masks = ad7266_available_scan_masks, | |
333 | + }, | |
334 | + [AD7266_CHAN_INFO_INDEX(0, 0, 1)] = { | |
335 | + .channels = ad7266_channels_u_fixed, | |
336 | + .num_channels = ARRAY_SIZE(ad7266_channels_u_fixed), | |
337 | + .scan_masks = ad7266_available_scan_masks_fixed, | |
338 | + }, | |
339 | + [AD7266_CHAN_INFO_INDEX(0, 1, 0)] = { | |
340 | + .channels = ad7266_channels_s, | |
341 | + .num_channels = ARRAY_SIZE(ad7266_channels_s), | |
342 | + .scan_masks = ad7266_available_scan_masks, | |
343 | + }, | |
344 | + [AD7266_CHAN_INFO_INDEX(0, 1, 1)] = { | |
345 | + .channels = ad7266_channels_s_fixed, | |
346 | + .num_channels = ARRAY_SIZE(ad7266_channels_s_fixed), | |
347 | + .scan_masks = ad7266_available_scan_masks_fixed, | |
348 | + }, | |
349 | + [AD7266_CHAN_INFO_INDEX(1, 0, 0)] = { | |
350 | + .channels = ad7266_channels_diff_u, | |
351 | + .num_channels = ARRAY_SIZE(ad7266_channels_diff_u), | |
352 | + .scan_masks = ad7266_available_scan_masks_diff, | |
353 | + }, | |
354 | + [AD7266_CHAN_INFO_INDEX(1, 0, 1)] = { | |
355 | + .channels = ad7266_channels_diff_fixed_u, | |
356 | + .num_channels = ARRAY_SIZE(ad7266_channels_diff_fixed_u), | |
357 | + .scan_masks = ad7266_available_scan_masks_fixed, | |
358 | + }, | |
359 | + [AD7266_CHAN_INFO_INDEX(1, 1, 0)] = { | |
360 | + .channels = ad7266_channels_diff_s, | |
361 | + .num_channels = ARRAY_SIZE(ad7266_channels_diff_s), | |
362 | + .scan_masks = ad7266_available_scan_masks_diff, | |
363 | + }, | |
364 | + [AD7266_CHAN_INFO_INDEX(1, 1, 1)] = { | |
365 | + .channels = ad7266_channels_diff_fixed_s, | |
366 | + .num_channels = ARRAY_SIZE(ad7266_channels_diff_fixed_s), | |
367 | + .scan_masks = ad7266_available_scan_masks_fixed, | |
368 | + }, | |
369 | +}; | |
370 | + | |
371 | +static void __devinit ad7266_init_channels(struct iio_dev *indio_dev) | |
372 | +{ | |
373 | + struct ad7266_state *st = iio_priv(indio_dev); | |
374 | + bool is_differential, is_signed; | |
375 | + const struct ad7266_chan_info *chan_info; | |
376 | + int i; | |
377 | + | |
378 | + is_differential = st->mode != AD7266_MODE_SINGLE_ENDED; | |
379 | + is_signed = (st->range == AD7266_RANGE_2VREF) | | |
380 | + (st->mode == AD7266_MODE_DIFF); | |
381 | + | |
382 | + i = AD7266_CHAN_INFO_INDEX(is_differential, is_signed, st->fixed_addr); | |
383 | + chan_info = &ad7266_chan_infos[i]; | |
384 | + | |
385 | + indio_dev->channels = chan_info->channels; | |
386 | + indio_dev->num_channels = chan_info->num_channels; | |
387 | + indio_dev->available_scan_masks = chan_info->scan_masks; | |
388 | + indio_dev->masklength = chan_info->num_channels - 1; | |
389 | +} | |
390 | + | |
391 | +static const char * const ad7266_gpio_labels[] = { | |
392 | + "AD0", "AD1", "AD2", | |
393 | +}; | |
394 | + | |
395 | +static int __devinit ad7266_probe(struct spi_device *spi) | |
396 | +{ | |
397 | + struct ad7266_platform_data *pdata = spi->dev.platform_data; | |
398 | + struct iio_dev *indio_dev; | |
399 | + struct ad7266_state *st; | |
400 | + unsigned int i; | |
401 | + int ret; | |
402 | + | |
403 | + indio_dev = iio_device_alloc(sizeof(*st)); | |
404 | + if (indio_dev == NULL) | |
405 | + return -ENOMEM; | |
406 | + | |
407 | + st = iio_priv(indio_dev); | |
408 | + | |
409 | + st->reg = regulator_get(&spi->dev, "vref"); | |
410 | + if (!IS_ERR_OR_NULL(st->reg)) { | |
411 | + ret = regulator_enable(st->reg); | |
412 | + if (ret) | |
413 | + goto error_put_reg; | |
414 | + | |
415 | + st->vref_uv = regulator_get_voltage(st->reg); | |
416 | + } else { | |
417 | + /* Use internal reference */ | |
418 | + st->vref_uv = 2500000; | |
419 | + } | |
420 | + | |
421 | + if (pdata) { | |
422 | + st->fixed_addr = pdata->fixed_addr; | |
423 | + st->mode = pdata->mode; | |
424 | + st->range = pdata->range; | |
425 | + | |
426 | + if (!st->fixed_addr) { | |
427 | + for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) { | |
428 | + st->gpios[i].gpio = pdata->addr_gpios[i]; | |
429 | + st->gpios[i].flags = GPIOF_OUT_INIT_LOW; | |
430 | + st->gpios[i].label = ad7266_gpio_labels[i]; | |
431 | + } | |
432 | + ret = gpio_request_array(st->gpios, | |
433 | + ARRAY_SIZE(st->gpios)); | |
434 | + if (ret) | |
435 | + goto error_disable_reg; | |
436 | + } | |
437 | + } else { | |
438 | + st->fixed_addr = true; | |
439 | + st->range = AD7266_RANGE_VREF; | |
440 | + st->mode = AD7266_MODE_DIFF; | |
441 | + } | |
442 | + | |
443 | + spi_set_drvdata(spi, indio_dev); | |
444 | + st->spi = spi; | |
445 | + | |
446 | + indio_dev->dev.parent = &spi->dev; | |
447 | + indio_dev->name = spi_get_device_id(spi)->name; | |
448 | + indio_dev->modes = INDIO_DIRECT_MODE; | |
449 | + indio_dev->info = &ad7266_info; | |
450 | + | |
451 | + ad7266_init_channels(indio_dev); | |
452 | + | |
453 | + /* wakeup */ | |
454 | + st->single_xfer[0].rx_buf = &st->data; | |
455 | + st->single_xfer[0].len = 2; | |
456 | + st->single_xfer[0].cs_change = 1; | |
457 | + /* conversion */ | |
458 | + st->single_xfer[1].rx_buf = &st->data; | |
459 | + st->single_xfer[1].len = 4; | |
460 | + st->single_xfer[1].cs_change = 1; | |
461 | + /* powerdown */ | |
462 | + st->single_xfer[2].tx_buf = &st->data; | |
463 | + st->single_xfer[2].len = 1; | |
464 | + | |
465 | + spi_message_init(&st->single_msg); | |
466 | + spi_message_add_tail(&st->single_xfer[0], &st->single_msg); | |
467 | + spi_message_add_tail(&st->single_xfer[1], &st->single_msg); | |
468 | + spi_message_add_tail(&st->single_xfer[2], &st->single_msg); | |
469 | + | |
470 | + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, | |
471 | + &ad7266_trigger_handler, &iio_triggered_buffer_setup_ops); | |
472 | + if (ret) | |
473 | + goto error_free_gpios; | |
474 | + | |
475 | + ret = iio_device_register(indio_dev); | |
476 | + if (ret) | |
477 | + goto error_buffer_cleanup; | |
478 | + | |
479 | + return 0; | |
480 | + | |
481 | +error_buffer_cleanup: | |
482 | + iio_triggered_buffer_cleanup(indio_dev); | |
483 | +error_free_gpios: | |
484 | + if (!st->fixed_addr) | |
485 | + gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios)); | |
486 | +error_disable_reg: | |
487 | + if (!IS_ERR_OR_NULL(st->reg)) | |
488 | + regulator_disable(st->reg); | |
489 | +error_put_reg: | |
490 | + if (!IS_ERR_OR_NULL(st->reg)) | |
491 | + regulator_put(st->reg); | |
492 | + | |
493 | + iio_device_free(indio_dev); | |
494 | + | |
495 | + return ret; | |
496 | +} | |
497 | + | |
498 | +static int __devexit ad7266_remove(struct spi_device *spi) | |
499 | +{ | |
500 | + struct iio_dev *indio_dev = spi_get_drvdata(spi); | |
501 | + struct ad7266_state *st = iio_priv(indio_dev); | |
502 | + | |
503 | + iio_device_unregister(indio_dev); | |
504 | + iio_triggered_buffer_cleanup(indio_dev); | |
505 | + if (!st->fixed_addr) | |
506 | + gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios)); | |
507 | + if (!IS_ERR_OR_NULL(st->reg)) { | |
508 | + regulator_disable(st->reg); | |
509 | + regulator_put(st->reg); | |
510 | + } | |
511 | + iio_device_free(indio_dev); | |
512 | + | |
513 | + return 0; | |
514 | +} | |
515 | + | |
516 | +static const struct spi_device_id ad7266_id[] = { | |
517 | + {"ad7265", 0}, | |
518 | + {"ad7266", 0}, | |
519 | + { } | |
520 | +}; | |
521 | +MODULE_DEVICE_TABLE(spi, ad7266_id); | |
522 | + | |
523 | +static struct spi_driver ad7266_driver = { | |
524 | + .driver = { | |
525 | + .name = "ad7266", | |
526 | + .owner = THIS_MODULE, | |
527 | + }, | |
528 | + .probe = ad7266_probe, | |
529 | + .remove = __devexit_p(ad7266_remove), | |
530 | + .id_table = ad7266_id, | |
531 | +}; | |
532 | +module_spi_driver(ad7266_driver); | |
533 | + | |
534 | +MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | |
535 | +MODULE_DESCRIPTION("Analog Devices AD7266/65 ADC"); | |
536 | +MODULE_LICENSE("GPL v2"); |
drivers/iio/dac/Kconfig
... | ... | @@ -4,12 +4,12 @@ |
4 | 4 | menu "Digital to analog converters" |
5 | 5 | |
6 | 6 | config AD5064 |
7 | - tristate "Analog Devices AD5064/64-1/65/44/45/24/25, AD5628/48/66/68 DAC driver" | |
8 | - depends on SPI | |
7 | + tristate "Analog Devices AD5064 and similar multi-channel DAC driver" | |
8 | + depends on (SPI_MASTER || I2C) | |
9 | 9 | help |
10 | 10 | Say yes here to build support for Analog Devices AD5024, AD5025, AD5044, |
11 | - AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, AD5666, AD5668 Digital | |
12 | - to Analog Converter. | |
11 | + AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, AD5648, AD5666, AD5668, | |
12 | + AD5669R Digital to Analog Converter. | |
13 | 13 | |
14 | 14 | To compile this driver as a module, choose M here: the |
15 | 15 | module will be called ad5064. |
drivers/iio/dac/ad5064.c
1 | 1 | /* |
2 | - * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, | |
3 | - * AD5666, AD5668 Digital to analog converters driver | |
2 | + * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, | |
3 | + * AD5648, AD5666, AD5668, AD5669R Digital to analog converters driver | |
4 | 4 | * |
5 | 5 | * Copyright 2011 Analog Devices Inc. |
6 | 6 | * |
7 | 7 | |
... | ... | @@ -12,9 +12,11 @@ |
12 | 12 | #include <linux/module.h> |
13 | 13 | #include <linux/kernel.h> |
14 | 14 | #include <linux/spi/spi.h> |
15 | +#include <linux/i2c.h> | |
15 | 16 | #include <linux/slab.h> |
16 | 17 | #include <linux/sysfs.h> |
17 | 18 | #include <linux/regulator/consumer.h> |
19 | +#include <asm/unaligned.h> | |
18 | 20 | |
19 | 21 | #include <linux/iio/iio.h> |
20 | 22 | #include <linux/iio/sysfs.h> |
21 | 23 | |
... | ... | @@ -62,9 +64,14 @@ |
62 | 64 | unsigned int num_channels; |
63 | 65 | }; |
64 | 66 | |
67 | +struct ad5064_state; | |
68 | + | |
69 | +typedef int (*ad5064_write_func)(struct ad5064_state *st, unsigned int cmd, | |
70 | + unsigned int addr, unsigned int val); | |
71 | + | |
65 | 72 | /** |
66 | 73 | * struct ad5064_state - driver instance specific data |
67 | - * @spi: spi_device | |
74 | + * @dev: the device for this driver instance | |
68 | 75 | * @chip_info: chip model specific constants, available modes etc |
69 | 76 | * @vref_reg: vref supply regulators |
70 | 77 | * @pwr_down: whether channel is powered down |
71 | 78 | |
... | ... | @@ -72,11 +79,12 @@ |
72 | 79 | * @dac_cache: current DAC raw value (chip does not support readback) |
73 | 80 | * @use_internal_vref: set to true if the internal reference voltage should be |
74 | 81 | * used. |
75 | - * @data: spi transfer buffers | |
82 | + * @write: register write callback | |
83 | + * @data: i2c/spi transfer buffers | |
76 | 84 | */ |
77 | 85 | |
78 | 86 | struct ad5064_state { |
79 | - struct spi_device *spi; | |
87 | + struct device *dev; | |
80 | 88 | const struct ad5064_chip_info *chip_info; |
81 | 89 | struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS]; |
82 | 90 | bool pwr_down[AD5064_MAX_DAC_CHANNELS]; |
83 | 91 | |
... | ... | @@ -84,11 +92,16 @@ |
84 | 92 | unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS]; |
85 | 93 | bool use_internal_vref; |
86 | 94 | |
95 | + ad5064_write_func write; | |
96 | + | |
87 | 97 | /* |
88 | 98 | * DMA (thus cache coherency maintenance) requires the |
89 | 99 | * transfer buffers to live in their own cache lines. |
90 | 100 | */ |
91 | - __be32 data ____cacheline_aligned; | |
101 | + union { | |
102 | + u8 i2c[3]; | |
103 | + __be32 spi; | |
104 | + } data ____cacheline_aligned; | |
92 | 105 | }; |
93 | 106 | |
94 | 107 | enum ad5064_type { |
95 | 108 | |
96 | 109 | |
... | ... | @@ -109,14 +122,31 @@ |
109 | 122 | ID_AD5668_2, |
110 | 123 | }; |
111 | 124 | |
125 | +static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd, | |
126 | + unsigned int addr, unsigned int val) | |
127 | +{ | |
128 | + struct i2c_client *i2c = to_i2c_client(st->dev); | |
129 | + | |
130 | + st->data.i2c[0] = (cmd << 4) | addr; | |
131 | + put_unaligned_be16(val, &st->data.i2c[1]); | |
132 | + return i2c_master_send(i2c, st->data.i2c, 3); | |
133 | +} | |
134 | + | |
112 | 135 | static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd, |
136 | + unsigned int addr, unsigned int val) | |
137 | +{ | |
138 | + struct spi_device *spi = to_spi_device(st->dev); | |
139 | + | |
140 | + st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); | |
141 | + return spi_write(spi, &st->data.spi, sizeof(st->data.spi)); | |
142 | +} | |
143 | + | |
144 | +static int ad5064_write(struct ad5064_state *st, unsigned int cmd, | |
113 | 145 | unsigned int addr, unsigned int val, unsigned int shift) |
114 | 146 | { |
115 | 147 | val <<= shift; |
116 | 148 | |
117 | - st->data = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); | |
118 | - | |
119 | - return spi_write(st->spi, &st->data, sizeof(st->data)); | |
149 | + return st->write(st, cmd, addr, val); | |
120 | 150 | } |
121 | 151 | |
122 | 152 | static int ad5064_sync_powerdown_mode(struct ad5064_state *st, |
... | ... | @@ -130,7 +160,7 @@ |
130 | 160 | if (st->pwr_down[channel]) |
131 | 161 | val |= st->pwr_down_mode[channel] << 8; |
132 | 162 | |
133 | - ret = ad5064_spi_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0); | |
163 | + ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0); | |
134 | 164 | |
135 | 165 | return ret; |
136 | 166 | } |
... | ... | @@ -251,7 +281,7 @@ |
251 | 281 | return -EINVAL; |
252 | 282 | |
253 | 283 | mutex_lock(&indio_dev->mlock); |
254 | - ret = ad5064_spi_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N, | |
284 | + ret = ad5064_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N, | |
255 | 285 | chan->address, val, chan->scan_type.shift); |
256 | 286 | if (ret == 0) |
257 | 287 | st->dac_cache[chan->channel] = val; |
258 | 288 | |
... | ... | @@ -413,9 +443,9 @@ |
413 | 443 | return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref]; |
414 | 444 | } |
415 | 445 | |
416 | -static int __devinit ad5064_probe(struct spi_device *spi) | |
446 | +static int __devinit ad5064_probe(struct device *dev, enum ad5064_type type, | |
447 | + const char *name, ad5064_write_func write) | |
417 | 448 | { |
418 | - enum ad5064_type type = spi_get_device_id(spi)->driver_data; | |
419 | 449 | struct iio_dev *indio_dev; |
420 | 450 | struct ad5064_state *st; |
421 | 451 | unsigned int i; |
422 | 452 | |
423 | 453 | |
424 | 454 | |
425 | 455 | |
... | ... | @@ -426,24 +456,25 @@ |
426 | 456 | return -ENOMEM; |
427 | 457 | |
428 | 458 | st = iio_priv(indio_dev); |
429 | - spi_set_drvdata(spi, indio_dev); | |
459 | + dev_set_drvdata(dev, indio_dev); | |
430 | 460 | |
431 | 461 | st->chip_info = &ad5064_chip_info_tbl[type]; |
432 | - st->spi = spi; | |
462 | + st->dev = dev; | |
463 | + st->write = write; | |
433 | 464 | |
434 | 465 | for (i = 0; i < ad5064_num_vref(st); ++i) |
435 | 466 | st->vref_reg[i].supply = ad5064_vref_name(st, i); |
436 | 467 | |
437 | - ret = regulator_bulk_get(&st->spi->dev, ad5064_num_vref(st), | |
468 | + ret = regulator_bulk_get(dev, ad5064_num_vref(st), | |
438 | 469 | st->vref_reg); |
439 | 470 | if (ret) { |
440 | 471 | if (!st->chip_info->internal_vref) |
441 | 472 | goto error_free; |
442 | 473 | st->use_internal_vref = true; |
443 | - ret = ad5064_spi_write(st, AD5064_CMD_CONFIG, 0, | |
474 | + ret = ad5064_write(st, AD5064_CMD_CONFIG, 0, | |
444 | 475 | AD5064_CONFIG_INT_VREF_ENABLE, 0); |
445 | 476 | if (ret) { |
446 | - dev_err(&spi->dev, "Failed to enable internal vref: %d\n", | |
477 | + dev_err(dev, "Failed to enable internal vref: %d\n", | |
447 | 478 | ret); |
448 | 479 | goto error_free; |
449 | 480 | } |
... | ... | @@ -458,8 +489,8 @@ |
458 | 489 | st->dac_cache[i] = 0x8000; |
459 | 490 | } |
460 | 491 | |
461 | - indio_dev->dev.parent = &spi->dev; | |
462 | - indio_dev->name = spi_get_device_id(spi)->name; | |
492 | + indio_dev->dev.parent = dev; | |
493 | + indio_dev->name = name; | |
463 | 494 | indio_dev->info = &ad5064_info; |
464 | 495 | indio_dev->modes = INDIO_DIRECT_MODE; |
465 | 496 | indio_dev->channels = st->chip_info->channels; |
466 | 497 | |
... | ... | @@ -483,10 +514,9 @@ |
483 | 514 | return ret; |
484 | 515 | } |
485 | 516 | |
486 | - | |
487 | -static int __devexit ad5064_remove(struct spi_device *spi) | |
517 | +static int __devexit ad5064_remove(struct device *dev) | |
488 | 518 | { |
489 | - struct iio_dev *indio_dev = spi_get_drvdata(spi); | |
519 | + struct iio_dev *indio_dev = dev_get_drvdata(dev); | |
490 | 520 | struct ad5064_state *st = iio_priv(indio_dev); |
491 | 521 | |
492 | 522 | iio_device_unregister(indio_dev); |
... | ... | @@ -501,7 +531,22 @@ |
501 | 531 | return 0; |
502 | 532 | } |
503 | 533 | |
504 | -static const struct spi_device_id ad5064_id[] = { | |
534 | +#if IS_ENABLED(CONFIG_SPI_MASTER) | |
535 | + | |
536 | +static int __devinit ad5064_spi_probe(struct spi_device *spi) | |
537 | +{ | |
538 | + const struct spi_device_id *id = spi_get_device_id(spi); | |
539 | + | |
540 | + return ad5064_probe(&spi->dev, id->driver_data, id->name, | |
541 | + ad5064_spi_write); | |
542 | +} | |
543 | + | |
544 | +static int __devexit ad5064_spi_remove(struct spi_device *spi) | |
545 | +{ | |
546 | + return ad5064_remove(&spi->dev); | |
547 | +} | |
548 | + | |
549 | +static const struct spi_device_id ad5064_spi_ids[] = { | |
505 | 550 | {"ad5024", ID_AD5024}, |
506 | 551 | {"ad5025", ID_AD5025}, |
507 | 552 | {"ad5044", ID_AD5044}, |
508 | 553 | |
509 | 554 | |
510 | 555 | |
511 | 556 | |
512 | 557 | |
... | ... | @@ -520,20 +565,113 @@ |
520 | 565 | {"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */ |
521 | 566 | {} |
522 | 567 | }; |
523 | -MODULE_DEVICE_TABLE(spi, ad5064_id); | |
568 | +MODULE_DEVICE_TABLE(spi, ad5064_spi_ids); | |
524 | 569 | |
525 | -static struct spi_driver ad5064_driver = { | |
570 | +static struct spi_driver ad5064_spi_driver = { | |
526 | 571 | .driver = { |
527 | 572 | .name = "ad5064", |
528 | 573 | .owner = THIS_MODULE, |
529 | 574 | }, |
530 | - .probe = ad5064_probe, | |
531 | - .remove = __devexit_p(ad5064_remove), | |
532 | - .id_table = ad5064_id, | |
575 | + .probe = ad5064_spi_probe, | |
576 | + .remove = __devexit_p(ad5064_spi_remove), | |
577 | + .id_table = ad5064_spi_ids, | |
533 | 578 | }; |
534 | -module_spi_driver(ad5064_driver); | |
535 | 579 | |
580 | +static int __init ad5064_spi_register_driver(void) | |
581 | +{ | |
582 | + return spi_register_driver(&ad5064_spi_driver); | |
583 | +} | |
584 | + | |
585 | +static void __exit ad5064_spi_unregister_driver(void) | |
586 | +{ | |
587 | + spi_unregister_driver(&ad5064_spi_driver); | |
588 | +} | |
589 | + | |
590 | +#else | |
591 | + | |
592 | +static inline int ad5064_spi_register_driver(void) { return 0; } | |
593 | +static inline void ad5064_spi_unregister_driver(void) { } | |
594 | + | |
595 | +#endif | |
596 | + | |
597 | +#if IS_ENABLED(CONFIG_I2C) | |
598 | + | |
599 | +static int __devinit ad5064_i2c_probe(struct i2c_client *i2c, | |
600 | + const struct i2c_device_id *id) | |
601 | +{ | |
602 | + return ad5064_probe(&i2c->dev, id->driver_data, id->name, | |
603 | + ad5064_i2c_write); | |
604 | +} | |
605 | + | |
606 | +static int __devexit ad5064_i2c_remove(struct i2c_client *i2c) | |
607 | +{ | |
608 | + return ad5064_remove(&i2c->dev); | |
609 | +} | |
610 | + | |
611 | +static const struct i2c_device_id ad5064_i2c_ids[] = { | |
612 | + {"ad5629-1", ID_AD5628_1}, | |
613 | + {"ad5629-2", ID_AD5628_2}, | |
614 | + {"ad5629-3", ID_AD5628_2}, /* similar enough to ad5629-2 */ | |
615 | + {"ad5669-1", ID_AD5668_1}, | |
616 | + {"ad5669-2", ID_AD5668_2}, | |
617 | + {"ad5669-3", ID_AD5668_2}, /* similar enough to ad5669-2 */ | |
618 | + {} | |
619 | +}; | |
620 | +MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids); | |
621 | + | |
622 | +static struct i2c_driver ad5064_i2c_driver = { | |
623 | + .driver = { | |
624 | + .name = "ad5064", | |
625 | + .owner = THIS_MODULE, | |
626 | + }, | |
627 | + .probe = ad5064_i2c_probe, | |
628 | + .remove = __devexit_p(ad5064_i2c_remove), | |
629 | + .id_table = ad5064_i2c_ids, | |
630 | +}; | |
631 | + | |
632 | +static int __init ad5064_i2c_register_driver(void) | |
633 | +{ | |
634 | + return i2c_add_driver(&ad5064_i2c_driver); | |
635 | +} | |
636 | + | |
637 | +static void __exit ad5064_i2c_unregister_driver(void) | |
638 | +{ | |
639 | + i2c_del_driver(&ad5064_i2c_driver); | |
640 | +} | |
641 | + | |
642 | +#else | |
643 | + | |
644 | +static inline int ad5064_i2c_register_driver(void) { return 0; } | |
645 | +static inline void ad5064_i2c_unregister_driver(void) { } | |
646 | + | |
647 | +#endif | |
648 | + | |
649 | +static int __init ad5064_init(void) | |
650 | +{ | |
651 | + int ret; | |
652 | + | |
653 | + ret = ad5064_spi_register_driver(); | |
654 | + if (ret) | |
655 | + return ret; | |
656 | + | |
657 | + ret = ad5064_i2c_register_driver(); | |
658 | + if (ret) { | |
659 | + ad5064_spi_unregister_driver(); | |
660 | + return ret; | |
661 | + } | |
662 | + | |
663 | + return 0; | |
664 | +} | |
665 | +module_init(ad5064_init); | |
666 | + | |
667 | +static void __exit ad5064_exit(void) | |
668 | +{ | |
669 | + ad5064_i2c_unregister_driver(); | |
670 | + ad5064_spi_unregister_driver(); | |
671 | +} | |
672 | +module_exit(ad5064_exit); | |
673 | + | |
536 | 674 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
537 | -MODULE_DESCRIPTION("Analog Devices AD5024/25/44/45/64/64-1/65, AD5628/48/66/68 DAC"); | |
675 | +MODULE_DESCRIPTION("Analog Devices AD5024 and similar multi-channel DACs"); | |
538 | 676 | MODULE_LICENSE("GPL v2"); |
drivers/iio/industrialio-core.c
drivers/iio/inkern.c
... | ... | @@ -92,8 +92,7 @@ |
92 | 92 | EXPORT_SYMBOL_GPL(iio_map_array_unregister); |
93 | 93 | |
94 | 94 | static const struct iio_chan_spec |
95 | -*iio_chan_spec_from_name(const struct iio_dev *indio_dev, | |
96 | - const char *name) | |
95 | +*iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name) | |
97 | 96 | { |
98 | 97 | int i; |
99 | 98 | const struct iio_chan_spec *chan = NULL; |
... | ... | @@ -108,8 +107,7 @@ |
108 | 107 | } |
109 | 108 | |
110 | 109 | |
111 | -struct iio_channel *iio_st_channel_get(const char *name, | |
112 | - const char *channel_name) | |
110 | +struct iio_channel *iio_channel_get(const char *name, const char *channel_name) | |
113 | 111 | { |
114 | 112 | struct iio_map_internal *c_i = NULL, *c = NULL; |
115 | 113 | struct iio_channel *channel; |
116 | 114 | |
117 | 115 | |
118 | 116 | |
... | ... | @@ -145,16 +143,16 @@ |
145 | 143 | |
146 | 144 | return channel; |
147 | 145 | } |
148 | -EXPORT_SYMBOL_GPL(iio_st_channel_get); | |
146 | +EXPORT_SYMBOL_GPL(iio_channel_get); | |
149 | 147 | |
150 | -void iio_st_channel_release(struct iio_channel *channel) | |
148 | +void iio_channel_release(struct iio_channel *channel) | |
151 | 149 | { |
152 | 150 | iio_device_put(channel->indio_dev); |
153 | 151 | kfree(channel); |
154 | 152 | } |
155 | -EXPORT_SYMBOL_GPL(iio_st_channel_release); | |
153 | +EXPORT_SYMBOL_GPL(iio_channel_release); | |
156 | 154 | |
157 | -struct iio_channel *iio_st_channel_get_all(const char *name) | |
155 | +struct iio_channel *iio_channel_get_all(const char *name) | |
158 | 156 | { |
159 | 157 | struct iio_channel *chans; |
160 | 158 | struct iio_map_internal *c = NULL; |
161 | 159 | |
... | ... | @@ -217,9 +215,9 @@ |
217 | 215 | |
218 | 216 | return ERR_PTR(ret); |
219 | 217 | } |
220 | -EXPORT_SYMBOL_GPL(iio_st_channel_get_all); | |
218 | +EXPORT_SYMBOL_GPL(iio_channel_get_all); | |
221 | 219 | |
222 | -void iio_st_channel_release_all(struct iio_channel *channels) | |
220 | +void iio_channel_release_all(struct iio_channel *channels) | |
223 | 221 | { |
224 | 222 | struct iio_channel *chan = &channels[0]; |
225 | 223 | |
226 | 224 | |
... | ... | @@ -229,9 +227,9 @@ |
229 | 227 | } |
230 | 228 | kfree(channels); |
231 | 229 | } |
232 | -EXPORT_SYMBOL_GPL(iio_st_channel_release_all); | |
230 | +EXPORT_SYMBOL_GPL(iio_channel_release_all); | |
233 | 231 | |
234 | -int iio_st_read_channel_raw(struct iio_channel *chan, int *val) | |
232 | +int iio_read_channel_raw(struct iio_channel *chan, int *val) | |
235 | 233 | { |
236 | 234 | int val2, ret; |
237 | 235 | |
238 | 236 | |
... | ... | @@ -248,9 +246,9 @@ |
248 | 246 | |
249 | 247 | return ret; |
250 | 248 | } |
251 | -EXPORT_SYMBOL_GPL(iio_st_read_channel_raw); | |
249 | +EXPORT_SYMBOL_GPL(iio_read_channel_raw); | |
252 | 250 | |
253 | -int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2) | |
251 | +int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2) | |
254 | 252 | { |
255 | 253 | int ret; |
256 | 254 | |
257 | 255 | |
... | ... | @@ -269,10 +267,9 @@ |
269 | 267 | |
270 | 268 | return ret; |
271 | 269 | } |
272 | -EXPORT_SYMBOL_GPL(iio_st_read_channel_scale); | |
270 | +EXPORT_SYMBOL_GPL(iio_read_channel_scale); | |
273 | 271 | |
274 | -int iio_st_get_channel_type(struct iio_channel *chan, | |
275 | - enum iio_chan_type *type) | |
272 | +int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type) | |
276 | 273 | { |
277 | 274 | int ret = 0; |
278 | 275 | /* Need to verify underlying driver has not gone away */ |
... | ... | @@ -289,5 +286,5 @@ |
289 | 286 | |
290 | 287 | return ret; |
291 | 288 | } |
292 | -EXPORT_SYMBOL_GPL(iio_st_get_channel_type); | |
289 | +EXPORT_SYMBOL_GPL(iio_get_channel_type); |
drivers/staging/iio/accel/adis16201_core.c
... | ... | @@ -159,21 +159,6 @@ |
159 | 159 | return ret; |
160 | 160 | } |
161 | 161 | |
162 | -static ssize_t adis16201_write_reset(struct device *dev, | |
163 | - struct device_attribute *attr, | |
164 | - const char *buf, size_t len) | |
165 | -{ | |
166 | - int ret; | |
167 | - bool res; | |
168 | - | |
169 | - if (len < 1) | |
170 | - return -EINVAL; | |
171 | - ret = strtobool(buf, &res); | |
172 | - if (ret || !res) | |
173 | - return ret; | |
174 | - return adis16201_reset(dev_to_iio_dev(dev)); | |
175 | -} | |
176 | - | |
177 | 162 | int adis16201_set_irq(struct iio_dev *indio_dev, bool enable) |
178 | 163 | { |
179 | 164 | int ret = 0; |
180 | 165 | |
... | ... | @@ -507,19 +492,7 @@ |
507 | 492 | IIO_CHAN_SOFT_TIMESTAMP(7) |
508 | 493 | }; |
509 | 494 | |
510 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0); | |
511 | - | |
512 | -static struct attribute *adis16201_attributes[] = { | |
513 | - &iio_dev_attr_reset.dev_attr.attr, | |
514 | - NULL | |
515 | -}; | |
516 | - | |
517 | -static const struct attribute_group adis16201_attribute_group = { | |
518 | - .attrs = adis16201_attributes, | |
519 | -}; | |
520 | - | |
521 | 495 | static const struct iio_info adis16201_info = { |
522 | - .attrs = &adis16201_attribute_group, | |
523 | 496 | .read_raw = &adis16201_read_raw, |
524 | 497 | .write_raw = &adis16201_write_raw, |
525 | 498 | .driver_module = THIS_MODULE, |
drivers/staging/iio/accel/adis16203_core.c
... | ... | @@ -178,22 +178,6 @@ |
178 | 178 | return ret; |
179 | 179 | } |
180 | 180 | |
181 | -static ssize_t adis16203_write_reset(struct device *dev, | |
182 | - struct device_attribute *attr, | |
183 | - const char *buf, size_t len) | |
184 | -{ | |
185 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
186 | - if (len < 1) | |
187 | - return -EINVAL; | |
188 | - switch (buf[0]) { | |
189 | - case '1': | |
190 | - case 'y': | |
191 | - case 'Y': | |
192 | - return adis16203_reset(indio_dev); | |
193 | - } | |
194 | - return -EINVAL; | |
195 | -} | |
196 | - | |
197 | 181 | int adis16203_set_irq(struct iio_dev *indio_dev, bool enable) |
198 | 182 | { |
199 | 183 | int ret = 0; |
200 | 184 | |
... | ... | @@ -444,19 +428,7 @@ |
444 | 428 | IIO_CHAN_SOFT_TIMESTAMP(5), |
445 | 429 | }; |
446 | 430 | |
447 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0); | |
448 | - | |
449 | -static struct attribute *adis16203_attributes[] = { | |
450 | - &iio_dev_attr_reset.dev_attr.attr, | |
451 | - NULL | |
452 | -}; | |
453 | - | |
454 | -static const struct attribute_group adis16203_attribute_group = { | |
455 | - .attrs = adis16203_attributes, | |
456 | -}; | |
457 | - | |
458 | 431 | static const struct iio_info adis16203_info = { |
459 | - .attrs = &adis16203_attribute_group, | |
460 | 432 | .read_raw = &adis16203_read_raw, |
461 | 433 | .write_raw = &adis16203_write_raw, |
462 | 434 | .driver_module = THIS_MODULE, |
drivers/staging/iio/accel/adis16204_core.c
... | ... | @@ -169,32 +169,6 @@ |
169 | 169 | return ret; |
170 | 170 | } |
171 | 171 | |
172 | -static ssize_t adis16204_read_14bit_signed(struct device *dev, | |
173 | - struct device_attribute *attr, | |
174 | - char *buf) | |
175 | -{ | |
176 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
177 | - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); | |
178 | - s16 val = 0; | |
179 | - ssize_t ret; | |
180 | - | |
181 | - mutex_lock(&indio_dev->mlock); | |
182 | - | |
183 | - ret = adis16204_spi_read_reg_16(indio_dev, | |
184 | - this_attr->address, (u16 *)&val); | |
185 | - if (!ret) { | |
186 | - if (val & ADIS16204_ERROR_ACTIVE) | |
187 | - adis16204_check_status(indio_dev); | |
188 | - | |
189 | - val = ((s16)(val << 2) >> 2); | |
190 | - ret = sprintf(buf, "%d\n", val); | |
191 | - } | |
192 | - | |
193 | - mutex_unlock(&indio_dev->mlock); | |
194 | - | |
195 | - return ret; | |
196 | -} | |
197 | - | |
198 | 172 | static int adis16204_reset(struct iio_dev *indio_dev) |
199 | 173 | { |
200 | 174 | int ret; |
... | ... | @@ -207,23 +181,6 @@ |
207 | 181 | return ret; |
208 | 182 | } |
209 | 183 | |
210 | -static ssize_t adis16204_write_reset(struct device *dev, | |
211 | - struct device_attribute *attr, | |
212 | - const char *buf, size_t len) | |
213 | -{ | |
214 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
215 | - | |
216 | - if (len < 1) | |
217 | - return -EINVAL; | |
218 | - switch (buf[0]) { | |
219 | - case '1': | |
220 | - case 'y': | |
221 | - case 'Y': | |
222 | - return adis16204_reset(indio_dev); | |
223 | - } | |
224 | - return -EINVAL; | |
225 | -} | |
226 | - | |
227 | 184 | int adis16204_set_irq(struct iio_dev *indio_dev, bool enable) |
228 | 185 | { |
229 | 186 | int ret = 0; |
230 | 187 | |
231 | 188 | |
232 | 189 | |
... | ... | @@ -299,28 +256,17 @@ |
299 | 256 | } |
300 | 257 | |
301 | 258 | /* Unique to this driver currently */ |
302 | -#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \ | |
303 | - IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr) | |
304 | -#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \ | |
305 | - IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr) | |
306 | 259 | |
307 | -static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed, | |
308 | - ADIS16204_XY_RSS_OUT); | |
309 | -static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed, | |
310 | - ADIS16204_XY_PEAK_OUT); | |
311 | -static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125"); | |
312 | - | |
313 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0); | |
314 | - | |
315 | 260 | enum adis16204_channel { |
316 | 261 | in_supply, |
317 | 262 | in_aux, |
318 | 263 | temp, |
319 | 264 | accel_x, |
320 | 265 | accel_y, |
266 | + accel_xy, | |
321 | 267 | }; |
322 | 268 | |
323 | -static u8 adis16204_addresses[5][3] = { | |
269 | +static u8 adis16204_addresses[6][3] = { | |
324 | 270 | [in_supply] = { ADIS16204_SUPPLY_OUT }, |
325 | 271 | [in_aux] = { ADIS16204_AUX_ADC }, |
326 | 272 | [temp] = { ADIS16204_TEMP_OUT }, |
... | ... | @@ -328,6 +274,8 @@ |
328 | 274 | ADIS16204_X_PEAK_OUT }, |
329 | 275 | [accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL, |
330 | 276 | ADIS16204_Y_PEAK_OUT }, |
277 | + [accel_xy] = { ADIS16204_XY_RSS_OUT, 0, | |
278 | + ADIS16204_XY_PEAK_OUT }, | |
331 | 279 | }; |
332 | 280 | |
333 | 281 | static int adis16204_read_raw(struct iio_dev *indio_dev, |
334 | 282 | |
335 | 283 | |
... | ... | @@ -381,10 +329,16 @@ |
381 | 329 | return IIO_VAL_INT_PLUS_MICRO; |
382 | 330 | case IIO_ACCEL: |
383 | 331 | *val = 0; |
384 | - if (chan->channel2 == IIO_MOD_X) | |
332 | + switch (chan->channel2) { | |
333 | + case IIO_MOD_X: | |
334 | + case IIO_MOD_ROOT_SUM_SQUARED_X_Y: | |
385 | 335 | *val2 = 17125; |
386 | - else | |
336 | + break; | |
337 | + case IIO_MOD_Y: | |
338 | + case IIO_MOD_Z: | |
387 | 339 | *val2 = 8407; |
340 | + break; | |
341 | + } | |
388 | 342 | return IIO_VAL_INT_PLUS_MICRO; |
389 | 343 | default: |
390 | 344 | return -EINVAL; |
391 | 345 | |
392 | 346 | |
... | ... | @@ -517,22 +471,23 @@ |
517 | 471 | }, |
518 | 472 | }, |
519 | 473 | IIO_CHAN_SOFT_TIMESTAMP(5), |
474 | + { | |
475 | + .type = IIO_ACCEL, | |
476 | + .modified = 1, | |
477 | + .channel2 = IIO_MOD_ROOT_SUM_SQUARED_X_Y, | |
478 | + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | |
479 | + IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | |
480 | + IIO_CHAN_INFO_PEAK_SEPARATE_BIT, | |
481 | + .address = accel_xy, | |
482 | + .scan_type = { | |
483 | + .sign = 'u', | |
484 | + .realbits = 14, | |
485 | + .storagebits = 16, | |
486 | + }, | |
487 | + } | |
520 | 488 | }; |
521 | 489 | |
522 | -static struct attribute *adis16204_attributes[] = { | |
523 | - &iio_dev_attr_reset.dev_attr.attr, | |
524 | - &iio_dev_attr_in_accel_xy.dev_attr.attr, | |
525 | - &iio_dev_attr_in_accel_xypeak.dev_attr.attr, | |
526 | - &iio_const_attr_in_accel_xy_scale.dev_attr.attr, | |
527 | - NULL | |
528 | -}; | |
529 | - | |
530 | -static const struct attribute_group adis16204_attribute_group = { | |
531 | - .attrs = adis16204_attributes, | |
532 | -}; | |
533 | - | |
534 | 490 | static const struct iio_info adis16204_info = { |
535 | - .attrs = &adis16204_attribute_group, | |
536 | 491 | .read_raw = &adis16204_read_raw, |
537 | 492 | .write_raw = &adis16204_write_raw, |
538 | 493 | .driver_module = THIS_MODULE, |
... | ... | @@ -569,7 +524,7 @@ |
569 | 524 | |
570 | 525 | ret = iio_buffer_register(indio_dev, |
571 | 526 | adis16204_channels, |
572 | - ARRAY_SIZE(adis16204_channels)); | |
527 | + 6); | |
573 | 528 | if (ret) { |
574 | 529 | printk(KERN_ERR "failed to initialize the ring\n"); |
575 | 530 | goto error_unreg_ring_funcs; |
drivers/staging/iio/accel/adis16209_core.c
... | ... | @@ -153,23 +153,6 @@ |
153 | 153 | return ret; |
154 | 154 | } |
155 | 155 | |
156 | -static ssize_t adis16209_write_reset(struct device *dev, | |
157 | - struct device_attribute *attr, | |
158 | - const char *buf, size_t len) | |
159 | -{ | |
160 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
161 | - | |
162 | - if (len < 1) | |
163 | - return -EINVAL; | |
164 | - switch (buf[0]) { | |
165 | - case '1': | |
166 | - case 'y': | |
167 | - case 'Y': | |
168 | - return adis16209_reset(indio_dev); | |
169 | - } | |
170 | - return -EINVAL; | |
171 | -} | |
172 | - | |
173 | 156 | int adis16209_set_irq(struct iio_dev *indio_dev, bool enable) |
174 | 157 | { |
175 | 158 | int ret = 0; |
176 | 159 | |
... | ... | @@ -519,19 +502,7 @@ |
519 | 502 | IIO_CHAN_SOFT_TIMESTAMP(8) |
520 | 503 | }; |
521 | 504 | |
522 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0); | |
523 | - | |
524 | -static struct attribute *adis16209_attributes[] = { | |
525 | - &iio_dev_attr_reset.dev_attr.attr, | |
526 | - NULL | |
527 | -}; | |
528 | - | |
529 | -static const struct attribute_group adis16209_attribute_group = { | |
530 | - .attrs = adis16209_attributes, | |
531 | -}; | |
532 | - | |
533 | 505 | static const struct iio_info adis16209_info = { |
534 | - .attrs = &adis16209_attribute_group, | |
535 | 506 | .read_raw = &adis16209_read_raw, |
536 | 507 | .write_raw = &adis16209_write_raw, |
537 | 508 | .driver_module = THIS_MODULE, |
drivers/staging/iio/accel/adis16220_core.c
... | ... | @@ -204,26 +204,6 @@ |
204 | 204 | return ret; |
205 | 205 | } |
206 | 206 | |
207 | -static ssize_t adis16220_write_reset(struct device *dev, | |
208 | - struct device_attribute *attr, | |
209 | - const char *buf, size_t len) | |
210 | -{ | |
211 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
212 | - bool val; | |
213 | - int ret; | |
214 | - | |
215 | - ret = strtobool(buf, &val); | |
216 | - if (ret) | |
217 | - return ret; | |
218 | - if (!val) | |
219 | - return -EINVAL; | |
220 | - | |
221 | - ret = adis16220_reset(indio_dev); | |
222 | - if (ret) | |
223 | - return ret; | |
224 | - return len; | |
225 | -} | |
226 | - | |
227 | 207 | static ssize_t adis16220_write_capture(struct device *dev, |
228 | 208 | struct device_attribute *attr, |
229 | 209 | const char *buf, size_t len) |
... | ... | @@ -454,9 +434,6 @@ |
454 | 434 | .size = ADIS16220_CAPTURE_SIZE, |
455 | 435 | }; |
456 | 436 | |
457 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, | |
458 | - adis16220_write_reset, 0); | |
459 | - | |
460 | 437 | #define IIO_DEV_ATTR_CAPTURE(_store) \ |
461 | 438 | IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0) |
462 | 439 | |
... | ... | @@ -611,7 +588,6 @@ |
611 | 588 | }; |
612 | 589 | |
613 | 590 | static struct attribute *adis16220_attributes[] = { |
614 | - &iio_dev_attr_reset.dev_attr.attr, | |
615 | 591 | &iio_dev_attr_capture.dev_attr.attr, |
616 | 592 | &iio_dev_attr_capture_count.dev_attr.attr, |
617 | 593 | NULL |
drivers/staging/iio/accel/adis16240_core.c
... | ... | @@ -199,23 +199,6 @@ |
199 | 199 | return ret; |
200 | 200 | } |
201 | 201 | |
202 | -static ssize_t adis16240_write_reset(struct device *dev, | |
203 | - struct device_attribute *attr, | |
204 | - const char *buf, size_t len) | |
205 | -{ | |
206 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
207 | - | |
208 | - if (len < 1) | |
209 | - return -EINVAL; | |
210 | - switch (buf[0]) { | |
211 | - case '1': | |
212 | - case 'y': | |
213 | - case 'Y': | |
214 | - return adis16240_reset(indio_dev); | |
215 | - } | |
216 | - return -EINVAL; | |
217 | -} | |
218 | - | |
219 | 202 | int adis16240_set_irq(struct iio_dev *indio_dev, bool enable) |
220 | 203 | { |
221 | 204 | int ret = 0; |
... | ... | @@ -329,8 +312,6 @@ |
329 | 312 | adis16240_read_12bit_signed, NULL, |
330 | 313 | ADIS16240_XYZPEAK_OUT); |
331 | 314 | |
332 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0); | |
333 | - | |
334 | 315 | static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096"); |
335 | 316 | |
336 | 317 | enum adis16240_chan { |
... | ... | @@ -559,7 +540,6 @@ |
559 | 540 | static struct attribute *adis16240_attributes[] = { |
560 | 541 | &iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr, |
561 | 542 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, |
562 | - &iio_dev_attr_reset.dev_attr.attr, | |
563 | 543 | NULL |
564 | 544 | }; |
565 | 545 |
drivers/staging/iio/gyro/adis16260_core.c
... | ... | @@ -233,22 +233,6 @@ |
233 | 233 | return ret; |
234 | 234 | } |
235 | 235 | |
236 | -static ssize_t adis16260_write_reset(struct device *dev, | |
237 | - struct device_attribute *attr, | |
238 | - const char *buf, size_t len) | |
239 | -{ | |
240 | - struct iio_dev *indio_dev = dev_to_iio_dev(dev); | |
241 | - if (len < 1) | |
242 | - return -EINVAL; | |
243 | - switch (buf[0]) { | |
244 | - case '1': | |
245 | - case 'y': | |
246 | - case 'Y': | |
247 | - return adis16260_reset(indio_dev); | |
248 | - } | |
249 | - return -EINVAL; | |
250 | -} | |
251 | - | |
252 | 236 | int adis16260_set_irq(struct iio_dev *indio_dev, bool enable) |
253 | 237 | { |
254 | 238 | int ret; |
... | ... | @@ -375,8 +359,6 @@ |
375 | 359 | adis16260_read_frequency, |
376 | 360 | adis16260_write_frequency); |
377 | 361 | |
378 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0); | |
379 | - | |
380 | 362 | static IIO_DEVICE_ATTR(sampling_frequency_available, |
381 | 363 | S_IRUGO, adis16260_read_frequency_available, NULL, 0); |
382 | 364 | |
... | ... | @@ -604,7 +586,6 @@ |
604 | 586 | static struct attribute *adis16260_attributes[] = { |
605 | 587 | &iio_dev_attr_sampling_frequency.dev_attr.attr, |
606 | 588 | &iio_dev_attr_sampling_frequency_available.dev_attr.attr, |
607 | - &iio_dev_attr_reset.dev_attr.attr, | |
608 | 589 | NULL |
609 | 590 | }; |
610 | 591 |
drivers/staging/iio/iio_hwmon.c
... | ... | @@ -51,12 +51,12 @@ |
51 | 51 | * No locking between this pair, so theoretically possible |
52 | 52 | * the scale has changed. |
53 | 53 | */ |
54 | - ret = iio_st_read_channel_raw(&state->channels[sattr->index], | |
54 | + ret = iio_read_channel_raw(&state->channels[sattr->index], | |
55 | 55 | &val); |
56 | 56 | if (ret < 0) |
57 | 57 | return ret; |
58 | 58 | |
59 | - ret = iio_st_read_channel_scale(&state->channels[sattr->index], | |
59 | + ret = iio_read_channel_scale(&state->channels[sattr->index], | |
60 | 60 | &scaleint, &scalepart); |
61 | 61 | if (ret < 0) |
62 | 62 | return ret; |
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | goto error_ret; |
107 | 107 | } |
108 | 108 | |
109 | - st->channels = iio_st_channel_get_all(dev_name(&pdev->dev)); | |
109 | + st->channels = iio_channel_get_all(dev_name(&pdev->dev)); | |
110 | 110 | if (IS_ERR(st->channels)) { |
111 | 111 | ret = PTR_ERR(st->channels); |
112 | 112 | goto error_free_state; |
... | ... | @@ -130,7 +130,7 @@ |
130 | 130 | } |
131 | 131 | |
132 | 132 | sysfs_attr_init(&a->dev_attr.attr); |
133 | - ret = iio_st_get_channel_type(&st->channels[i], &type); | |
133 | + ret = iio_get_channel_type(&st->channels[i], &type); | |
134 | 134 | if (ret < 0) { |
135 | 135 | kfree(a); |
136 | 136 | goto error_free_attrs; |
... | ... | @@ -186,7 +186,7 @@ |
186 | 186 | iio_hwmon_free_attrs(st); |
187 | 187 | kfree(st->attrs); |
188 | 188 | error_release_channels: |
189 | - iio_st_channel_release_all(st->channels); | |
189 | + iio_channel_release_all(st->channels); | |
190 | 190 | error_free_state: |
191 | 191 | kfree(st); |
192 | 192 | error_ret: |
... | ... | @@ -201,7 +201,7 @@ |
201 | 201 | sysfs_remove_group(&pdev->dev.kobj, &st->attr_group); |
202 | 202 | iio_hwmon_free_attrs(st); |
203 | 203 | kfree(st->attrs); |
204 | - iio_st_channel_release_all(st->channels); | |
204 | + iio_channel_release_all(st->channels); | |
205 | 205 | |
206 | 206 | return 0; |
207 | 207 | } |
drivers/staging/iio/imu/adis16400_core.c
... | ... | @@ -268,25 +268,6 @@ |
268 | 268 | return ret; |
269 | 269 | } |
270 | 270 | |
271 | -static ssize_t adis16400_write_reset(struct device *dev, | |
272 | - struct device_attribute *attr, | |
273 | - const char *buf, size_t len) | |
274 | -{ | |
275 | - bool val; | |
276 | - int ret; | |
277 | - | |
278 | - ret = strtobool(buf, &val); | |
279 | - if (ret < 0) | |
280 | - return ret; | |
281 | - if (val) { | |
282 | - ret = adis16400_reset(dev_to_iio_dev(dev)); | |
283 | - if (ret < 0) | |
284 | - return ret; | |
285 | - } | |
286 | - | |
287 | - return len; | |
288 | -} | |
289 | - | |
290 | 271 | int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) |
291 | 272 | { |
292 | 273 | int ret; |
... | ... | @@ -454,8 +435,6 @@ |
454 | 435 | adis16400_read_frequency, |
455 | 436 | adis16400_write_frequency); |
456 | 437 | |
457 | -static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0); | |
458 | - | |
459 | 438 | static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638"); |
460 | 439 | |
461 | 440 | enum adis16400_chan { |
... | ... | @@ -1066,7 +1045,6 @@ |
1066 | 1045 | static struct attribute *adis16400_attributes[] = { |
1067 | 1046 | &iio_dev_attr_sampling_frequency.dev_attr.attr, |
1068 | 1047 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, |
1069 | - &iio_dev_attr_reset.dev_attr.attr, | |
1070 | 1048 | NULL |
1071 | 1049 | }; |
1072 | 1050 |
include/linux/iio/consumer.h
... | ... | @@ -33,17 +33,17 @@ |
33 | 33 | * side. This typically describes the channels use within |
34 | 34 | * the consumer. E.g. 'battery_voltage' |
35 | 35 | */ |
36 | -struct iio_channel *iio_st_channel_get(const char *name, | |
37 | - const char *consumer_channel); | |
36 | +struct iio_channel *iio_channel_get(const char *name, | |
37 | + const char *consumer_channel); | |
38 | 38 | |
39 | 39 | /** |
40 | - * iio_st_channel_release() - release channels obtained via iio_st_channel_get | |
40 | + * iio_channel_release() - release channels obtained via iio_channel_get | |
41 | 41 | * @chan: The channel to be released. |
42 | 42 | */ |
43 | -void iio_st_channel_release(struct iio_channel *chan); | |
43 | +void iio_channel_release(struct iio_channel *chan); | |
44 | 44 | |
45 | 45 | /** |
46 | - * iio_st_channel_get_all() - get all channels associated with a client | |
46 | + * iio_channel_get_all() - get all channels associated with a client | |
47 | 47 | * @name: name of consumer device. |
48 | 48 | * |
49 | 49 | * Returns an array of iio_channel structures terminated with one with |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | 56 | |
... | ... | @@ -51,37 +51,37 @@ |
51 | 51 | * This function is used by fairly generic consumers to get all the |
52 | 52 | * channels registered as having this consumer. |
53 | 53 | */ |
54 | -struct iio_channel *iio_st_channel_get_all(const char *name); | |
54 | +struct iio_channel *iio_channel_get_all(const char *name); | |
55 | 55 | |
56 | 56 | /** |
57 | - * iio_st_channel_release_all() - reverse iio_st_get_all | |
57 | + * iio_channel_release_all() - reverse iio_channel_get_all | |
58 | 58 | * @chan: Array of channels to be released. |
59 | 59 | */ |
60 | -void iio_st_channel_release_all(struct iio_channel *chan); | |
60 | +void iio_channel_release_all(struct iio_channel *chan); | |
61 | 61 | |
62 | 62 | /** |
63 | - * iio_st_read_channel_raw() - read from a given channel | |
63 | + * iio_read_channel_raw() - read from a given channel | |
64 | 64 | * @channel: The channel being queried. |
65 | 65 | * @val: Value read back. |
66 | 66 | * |
67 | 67 | * Note raw reads from iio channels are in adc counts and hence |
68 | 68 | * scale will need to be applied if standard units required. |
69 | 69 | */ |
70 | -int iio_st_read_channel_raw(struct iio_channel *chan, | |
71 | - int *val); | |
70 | +int iio_read_channel_raw(struct iio_channel *chan, | |
71 | + int *val); | |
72 | 72 | |
73 | 73 | /** |
74 | - * iio_st_get_channel_type() - get the type of a channel | |
74 | + * iio_get_channel_type() - get the type of a channel | |
75 | 75 | * @channel: The channel being queried. |
76 | 76 | * @type: The type of the channel. |
77 | 77 | * |
78 | 78 | * returns the enum iio_chan_type of the channel |
79 | 79 | */ |
80 | -int iio_st_get_channel_type(struct iio_channel *channel, | |
81 | - enum iio_chan_type *type); | |
80 | +int iio_get_channel_type(struct iio_channel *channel, | |
81 | + enum iio_chan_type *type); | |
82 | 82 | |
83 | 83 | /** |
84 | - * iio_st_read_channel_scale() - read the scale value for a channel | |
84 | + * iio_read_channel_scale() - read the scale value for a channel | |
85 | 85 | * @channel: The channel being queried. |
86 | 86 | * @val: First part of value read back. |
87 | 87 | * @val2: Second part of value read back. |
... | ... | @@ -90,8 +90,8 @@ |
90 | 90 | * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val |
91 | 91 | * + val2/1e6 |
92 | 92 | */ |
93 | -int iio_st_read_channel_scale(struct iio_channel *chan, int *val, | |
94 | - int *val2); | |
93 | +int iio_read_channel_scale(struct iio_channel *chan, int *val, | |
94 | + int *val2); | |
95 | 95 | |
96 | 96 | #endif |
include/linux/iio/types.h
include/linux/platform_data/ad7266.h
1 | +/* | |
2 | + * AD7266/65 SPI ADC driver | |
3 | + * | |
4 | + * Copyright 2012 Analog Devices Inc. | |
5 | + * | |
6 | + * Licensed under the GPL-2. | |
7 | + */ | |
8 | + | |
9 | +#ifndef __IIO_ADC_AD7266_H__ | |
10 | +#define __IIO_ADC_AD7266_H__ | |
11 | + | |
12 | +/** | |
13 | + * enum ad7266_range - AD7266 reference voltage range | |
14 | + * @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF | |
15 | + * (RANGE pin set to low) | |
16 | + * @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF | |
17 | + * (RANGE pin set to high) | |
18 | + */ | |
19 | +enum ad7266_range { | |
20 | + AD7266_RANGE_VREF, | |
21 | + AD7266_RANGE_2VREF, | |
22 | +}; | |
23 | + | |
24 | +/** | |
25 | + * enum ad7266_mode - AD7266 sample mode | |
26 | + * @AD7266_MODE_DIFF: Device is configured for full differential mode | |
27 | + * (SGL/DIFF pin set to low, AD0 pin set to low) | |
28 | + * @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode | |
29 | + * (SGL/DIFF pin set to low, AD0 pin set to high) | |
30 | + * @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode | |
31 | + * (SGL/DIFF pin set to high) | |
32 | + */ | |
33 | +enum ad7266_mode { | |
34 | + AD7266_MODE_DIFF, | |
35 | + AD7266_MODE_PSEUDO_DIFF, | |
36 | + AD7266_MODE_SINGLE_ENDED, | |
37 | +}; | |
38 | + | |
39 | +/** | |
40 | + * struct ad7266_platform_data - Platform data for the AD7266 driver | |
41 | + * @range: Reference voltage range the device is configured for | |
42 | + * @mode: Sample mode the device is configured for | |
43 | + * @fixed_addr: Whether the address pins are hard-wired | |
44 | + * @addr_gpios: GPIOs used for controlling the address pins, only used if | |
45 | + * fixed_addr is set to false. | |
46 | + */ | |
47 | +struct ad7266_platform_data { | |
48 | + enum ad7266_range range; | |
49 | + enum ad7266_mode mode; | |
50 | + bool fixed_addr; | |
51 | + unsigned int addr_gpios[3]; | |
52 | +}; | |
53 | + | |
54 | +#endif |