unsigned int burst_length;
u8 *tx;
- if (st->variant->flags & ADIS16400_NO_BURST)
+ if (!adis->burst || !adis->burst->en)
return adis_update_scan_mode(indio_dev, scan_mask);
kfree(adis->xfer);
/* All but the timestamp channel */
burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
- if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
- burst_length += sizeof(u16);
+ burst_length += adis->burst->extra_len;
adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
if (!adis->xfer)
return -ENOMEM;
tx = adis->buffer + burst_length;
- tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
+ tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);
tx[1] = 0;
adis->xfer[0].tx_buf = tx;
ADIS16448,
};
+static struct adis_burst adis16400_burst = {
+ .en = true,
+ .reg_cmd = ADIS16400_GLOB_CMD,
+};
+
static int adis16334_get_freq(struct adis16400_state *st)
{
int ret;
if (!(st->variant->flags & ADIS16400_NO_BURST)) {
adis16400_setup_chan_mask(st);
indio_dev->available_scan_masks = st->avail_scan_mask;
+ st->adis.burst = &adis16400_burst;
+ if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
+ st->adis.burst->extra_len = sizeof(u16);
}
ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
#define ADIS_REG_PAGE_ID 0x00
struct adis;
+struct adis_burst;
/**
* struct adis_data - ADIS chip variant specific data
struct iio_trigger *trig;
const struct adis_data *data;
+ struct adis_burst *burst;
struct mutex txrx_lock;
struct spi_message msg;
#ifdef CONFIG_IIO_ADIS_LIB_BUFFER
+/**
+ * struct adis_burst - ADIS data for burst transfers
+ * @en burst mode enabled
+ * @reg_cmd register command that triggers burst
+ * @extra_len extra length to account in the SPI RX buffer
+ */
+struct adis_burst {
+ bool en;
+ unsigned int reg_cmd;
+ unsigned int extra_len;
+};
+
int adis_setup_buffer_and_trigger(struct adis *adis,
struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *));
void adis_cleanup_buffer_and_trigger(struct adis *adis,