Commit 597e1a86 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

staging:iio:adis16130: Report scale and offset

Report scale and offset for the temperature and voltage channels.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 19155762
...@@ -78,14 +78,47 @@ static int adis16130_read_raw(struct iio_dev *indio_dev, ...@@ -78,14 +78,47 @@ static int adis16130_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
u32 temp; u32 temp;
/* Take the iio_dev status lock */ switch (mask) {
mutex_lock(&indio_dev->mlock); case IIO_CHAN_INFO_RAW:
ret = adis16130_spi_read(indio_dev, chan->address, &temp); /* Take the iio_dev status lock */
mutex_unlock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
if (ret) ret = adis16130_spi_read(indio_dev, chan->address, &temp);
return ret; mutex_unlock(&indio_dev->mlock);
*val = temp; if (ret)
return IIO_VAL_INT; return ret;
*val = temp;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
/* 0 degree = 838860, 250 degree = 14260608 */
*val = 250;
*val2 = 336440817; /* RAD_TO_DEGREE(14260608 - 8388608) */
return IIO_VAL_FRACTIONAL;
case IIO_TEMP:
/* 0C = 8036283, 105C = 9516048 */
*val = 105000;
*val2 = 9516048 - 8036283;
return IIO_VAL_FRACTIONAL;
default:
return -EINVAL;
}
break;
case IIO_CHAN_INFO_OFFSET:
switch (chan->type) {
case IIO_ANGL_VEL:
*val = -8388608;
return IIO_VAL_INT;
case IIO_TEMP:
*val = -8036283;
return IIO_VAL_INT;
default:
return -EINVAL;
}
break;
}
return -EINVAL;
} }
static const struct iio_chan_spec adis16130_channels[] = { static const struct iio_chan_spec adis16130_channels[] = {
...@@ -93,13 +126,17 @@ static const struct iio_chan_spec adis16130_channels[] = { ...@@ -93,13 +126,17 @@ static const struct iio_chan_spec adis16130_channels[] = {
.type = IIO_ANGL_VEL, .type = IIO_ANGL_VEL,
.modified = 1, .modified = 1,
.channel2 = IIO_MOD_Z, .channel2 = IIO_MOD_Z,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_OFFSET),
.address = ADIS16130_RATEDATA, .address = ADIS16130_RATEDATA,
}, { }, {
.type = IIO_TEMP, .type = IIO_TEMP,
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_OFFSET),
.address = ADIS16130_TEMPDATA, .address = ADIS16130_TEMPDATA,
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment