aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-01-16 07:48:00 -0500
committerJonathan Cameron <jic23@kernel.org>2013-01-26 05:07:50 -0500
commit7ba8a04dcdfb5ebcb4985a92dfc4dc4f59510464 (patch)
tree91cdd183b50f4be62ac6e97dec52e6aee1f8e41e /drivers/iio
parentb24150e31ab27ffcd2aa9b33dca42c2070526054 (diff)
iio:adis16400: Add support for the 52.85 Hz base sampling rate
The adis16400 and similar have two different base sampling rate available, from which the actual sampling rate is derived. 1638 Hz and 52.85 Hz, switching to the lower base sampling rate allows to support lower sampling rates. This patch adds support for switching to the lower base sampling rate if the requested sampling frequency is outside of the range which can be supported by the higher base sampling rate. The function which is used to read the current sampling rate already has support for the lower sampling rate, so no changes are required there. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/imu/adis16400_core.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index 8551fde90563..58699ac22d02 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -92,18 +92,26 @@ static int adis16400_get_freq(struct adis16400_state *st)
92static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq) 92static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
93{ 93{
94 unsigned int t; 94 unsigned int t;
95 uint8_t val = 0;
95 96
96 t = 1638404 / freq; 97 t = 1638404 / freq;
97 if (t > 0) 98 if (t >= 128) {
99 val |= ADIS16400_SMPL_PRD_TIME_BASE;
100 t = 52851 / freq;
101 if (t >= 128)
102 t = 127;
103 } else if (t != 0) {
98 t--; 104 t--;
99 t &= ADIS16400_SMPL_PRD_DIV_MASK; 105 }
106
107 val |= t;
100 108
101 if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A) 109 if (t >= 0x0A || (val & ADIS16400_SMPL_PRD_TIME_BASE))
102 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW; 110 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
103 else 111 else
104 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; 112 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
105 113
106 return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, t); 114 return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, val);
107} 115}
108 116
109static ssize_t adis16400_read_frequency(struct device *dev, 117static ssize_t adis16400_read_frequency(struct device *dev,