3 #include <linux/kernel.h>
5 #include <linux/slab.h>
6 #include <linux/bitops.h>
7 #include <linux/export.h>
10 #include "../ring_sw.h"
19 static int adis16400_spi_read_burst(
struct iio_dev *indio_dev,
u8 *
rx)
23 u32 old_speed_hz = st->
us->max_speed_hz;
42 spi_message_init(&
msg);
43 spi_message_add_tail(&xfers[0], &
msg);
44 spi_message_add_tail(&xfers[1], &
msg);
51 dev_err(&st->
us->dev,
"problem when burst reading");
53 st->
us->max_speed_hz = old_speed_hz;
59 static const u16 read_all_tx_array[] = {
73 static int adis16350_spi_read_all(
struct iio_dev *indio_dev,
u8 *rx)
83 xfers = kzalloc(
sizeof(*xfers)*(scan_count + 1),
88 for (i = 0; i <
ARRAY_SIZE(read_all_tx_array); i++)
90 xfers[
j].
tx_buf = &read_all_tx_array[
i];
93 xfers[j + 1].
rx_buf = rx + j*2;
99 spi_message_init(&
msg);
100 for (j = 0; j < scan_count + 1; j++)
101 spi_message_add_tail(&xfers[j], &
msg);
112 static irqreturn_t adis16400_trigger_handler(
int irq,
void *
p)
118 int i = 0,
j, ret = 0;
127 dev_err(&st->
us->dev,
"memory alloc failed in ring bh");
133 ret = adis16350_spi_read_all(indio_dev, st->rx);
136 for (; i < scan_count; i++)
137 data[i] = *(
s16 *)(st->rx + i*2);
139 ret = adis16400_spi_read_burst(indio_dev, st->rx);
142 for (; i < scan_count; i++) {
146 (
__be16 *)&(st->rx[j*2]));
151 if (ring->scan_timestamp)
177 struct iio_buffer *ring;
185 ring->scan_timestamp =
true;
186 indio_dev->
setup_ops = &adis16400_ring_setup_ops;
189 &adis16400_trigger_handler,
197 goto error_iio_sw_rb_free;
202 error_iio_sw_rb_free: