diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-11-20 13:36:00 +0000 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-11-20 21:26:37 +0000 |
commit | 484a0bf091c93c379e6524a17bb037c33c898e01 (patch) | |
tree | b84cf4f38c21825bcfdcba02a23f5216680c69fb /drivers/iio/imu/adis_buffer.c | |
parent | 9caed0d9d6db12cb6d81ba68d5bc98432d6b4711 (diff) | |
download | op-kernel-dev-484a0bf091c93c379e6524a17bb037c33c898e01.zip op-kernel-dev-484a0bf091c93c379e6524a17bb037c33c898e01.tar.gz |
iio:imu:adis: Add paging support
Some of the newer generation devices from the ADIS16XXX series have more
registers than what can be supported with the current register addressing
scheme. These devices implement register paging to support a larger register
range. Each page is 128 registers large and the currently active page can be
selected via register 0x00 in each page. This patch implements transparent
paging inside the common adis library. The register read/write interface stays
the same and when a register is accessed the library automatically switches to
the correct page if it is not already selected. The page number is encoded in
the upper bits of the register number, e.g. register 0x5 of page 1 is 0x85.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/imu/adis_buffer.c')
-rw-r--r-- | drivers/iio/imu/adis_buffer.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 7857133..99d8e0b 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -83,10 +83,25 @@ static irqreturn_t adis_trigger_handler(int irq, void *p) if (!adis->buffer) return -ENOMEM; + if (adis->data->has_paging) { + mutex_lock(&adis->txrx_lock); + if (adis->current_page != 0) { + adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); + adis->tx[1] = 0; + spi_write(adis->spi, adis->tx, 2); + } + } + ret = spi_sync(adis->spi, &adis->msg); if (ret) dev_err(&adis->spi->dev, "Failed to read data: %d", ret); + + if (adis->data->has_paging) { + adis->current_page = 0; + mutex_unlock(&adis->txrx_lock); + } + /* Guaranteed to be aligned with 8 byte boundary */ if (indio_dev->scan_timestamp) { void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64); |