iio: imu: adis: generalize burst mode support

Some variants in the ADIS16400 family support burst mode. This mechanism is
implemented in the `adis16400_buffer.c` file.

Some variants in ADIS16480 are also adding burst mode, which is
functionally similar to ADIS16400, but with different parameters. To get
there, a `adis_burst` struct is added to parametrize certain bits of the
SPI communication to setup: the register that triggers burst-mode, and the
extra-data-length that needs be accounted for when building the bust-length
buffer.

The trigger handler cannot be made generic, since it's very specific to
each ADIS164XX family.

A future enhancement of this `adis_burst` mode will be the possibility to
enable/disable burst-mode. For the ADIS16400 family it's hard-coded to on
by default. But for ADIS16480 there will be a need to disable this.

When that will be implemented, both ADIS16400 & ADIS16480 will have the
burst-mode enable-able/disable-able.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
此提交包含在:
Alexandru Ardelean
2019-03-22 22:44:39 +02:00
提交者 Jonathan Cameron
父節點 74878d4fa8
當前提交 5075e0720d
共有 3 個檔案被更改,包括 25 行新增4 行删除

查看文件

@@ -22,7 +22,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
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);
@@ -30,8 +30,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
/* 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)
@@ -42,7 +41,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
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;

查看文件

@@ -146,6 +146,11 @@ enum adis16400_chip_variant {
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;
@@ -972,6 +977,9 @@ static int adis16400_probe(struct spi_device *spi)
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);