iio: adis16260: Add ADIS16266 support
The ADIS16266 is mostly register compatible to the ADIS16260. The difference is a different gyroscope scale factor as well not having the relative angular displacement channel. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Родитель
3c38676079
Коммит
f1afda124b
|
@ -101,19 +101,24 @@
|
||||||
#define ADIS16260_SCAN_TEMP 3
|
#define ADIS16260_SCAN_TEMP 3
|
||||||
#define ADIS16260_SCAN_ANGL 4
|
#define ADIS16260_SCAN_ANGL 4
|
||||||
|
|
||||||
/* Power down the device */
|
struct adis16260_chip_info {
|
||||||
static int adis16260_stop_device(struct iio_dev *indio_dev)
|
unsigned int gyro_max_val;
|
||||||
{
|
unsigned int gyro_max_scale;
|
||||||
struct adis *adis = iio_priv(indio_dev);
|
const struct iio_chan_spec *channels;
|
||||||
int ret;
|
unsigned int num_channels;
|
||||||
u16 val = ADIS16260_SLP_CNT_POWER_OFF;
|
};
|
||||||
|
|
||||||
ret = adis_write_reg_16(adis, ADIS16260_SLP_CNT, val);
|
struct adis16260 {
|
||||||
if (ret)
|
const struct adis16260_chip_info *info;
|
||||||
dev_err(&indio_dev->dev, "problem with turning device off: SLP_CNT");
|
|
||||||
|
|
||||||
return ret;
|
struct adis adis;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
enum adis16260_type {
|
||||||
|
ADIS16251,
|
||||||
|
ADIS16260,
|
||||||
|
ADIS16266,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct iio_chan_spec adis16260_channels[] = {
|
static const struct iio_chan_spec adis16260_channels[] = {
|
||||||
ADIS_GYRO_CHAN(X, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO,
|
ADIS_GYRO_CHAN(X, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO,
|
||||||
|
@ -131,6 +136,55 @@ static const struct iio_chan_spec adis16260_channels[] = {
|
||||||
IIO_CHAN_SOFT_TIMESTAMP(5),
|
IIO_CHAN_SOFT_TIMESTAMP(5),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct iio_chan_spec adis16266_channels[] = {
|
||||||
|
ADIS_GYRO_CHAN(X, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO,
|
||||||
|
BIT(IIO_CHAN_INFO_CALIBBIAS) |
|
||||||
|
BIT(IIO_CHAN_INFO_CALIBSCALE),
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ), 14),
|
||||||
|
ADIS_TEMP_CHAN(ADIS16260_TEMP_OUT, ADIS16260_SCAN_TEMP,
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ), 12),
|
||||||
|
ADIS_SUPPLY_CHAN(ADIS16260_SUPPLY_OUT, ADIS16260_SCAN_SUPPLY,
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ), 12),
|
||||||
|
ADIS_AUX_ADC_CHAN(ADIS16260_AUX_ADC, ADIS16260_SCAN_AUX_ADC,
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ), 12),
|
||||||
|
IIO_CHAN_SOFT_TIMESTAMP(4),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct adis16260_chip_info adis16260_chip_info_table[] = {
|
||||||
|
[ADIS16251] = {
|
||||||
|
.gyro_max_scale = 80,
|
||||||
|
.gyro_max_val = IIO_RAD_TO_DEGREE(4368),
|
||||||
|
.channels = adis16260_channels,
|
||||||
|
.num_channels = ARRAY_SIZE(adis16260_channels),
|
||||||
|
},
|
||||||
|
[ADIS16260] = {
|
||||||
|
.gyro_max_scale = 320,
|
||||||
|
.gyro_max_val = IIO_RAD_TO_DEGREE(4368),
|
||||||
|
.channels = adis16260_channels,
|
||||||
|
.num_channels = ARRAY_SIZE(adis16260_channels),
|
||||||
|
},
|
||||||
|
[ADIS16266] = {
|
||||||
|
.gyro_max_scale = 14000,
|
||||||
|
.gyro_max_val = IIO_RAD_TO_DEGREE(3357),
|
||||||
|
.channels = adis16266_channels,
|
||||||
|
.num_channels = ARRAY_SIZE(adis16266_channels),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Power down the device */
|
||||||
|
static int adis16260_stop_device(struct iio_dev *indio_dev)
|
||||||
|
{
|
||||||
|
struct adis16260 *adis16260 = iio_priv(indio_dev);
|
||||||
|
int ret;
|
||||||
|
u16 val = ADIS16260_SLP_CNT_POWER_OFF;
|
||||||
|
|
||||||
|
ret = adis_write_reg_16(&adis16260->adis, ADIS16260_SLP_CNT, val);
|
||||||
|
if (ret)
|
||||||
|
dev_err(&indio_dev->dev, "problem with turning device off: SLP_CNT");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static const u8 adis16260_addresses[][2] = {
|
static const u8 adis16260_addresses[][2] = {
|
||||||
[ADIS16260_SCAN_GYRO] = { ADIS16260_GYRO_OFF, ADIS16260_GYRO_SCALE },
|
[ADIS16260_SCAN_GYRO] = { ADIS16260_GYRO_OFF, ADIS16260_GYRO_SCALE },
|
||||||
};
|
};
|
||||||
|
@ -140,7 +194,9 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
|
||||||
int *val, int *val2,
|
int *val, int *val2,
|
||||||
long mask)
|
long mask)
|
||||||
{
|
{
|
||||||
struct adis *adis = iio_priv(indio_dev);
|
struct adis16260 *adis16260 = iio_priv(indio_dev);
|
||||||
|
const struct adis16260_chip_info *info = adis16260->info;
|
||||||
|
struct adis *adis = &adis16260->adis;
|
||||||
int ret;
|
int ret;
|
||||||
u8 addr;
|
u8 addr;
|
||||||
s16 val16;
|
s16 val16;
|
||||||
|
@ -152,15 +208,9 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
|
||||||
case IIO_CHAN_INFO_SCALE:
|
case IIO_CHAN_INFO_SCALE:
|
||||||
switch (chan->type) {
|
switch (chan->type) {
|
||||||
case IIO_ANGL_VEL:
|
case IIO_ANGL_VEL:
|
||||||
*val = 0;
|
*val = info->gyro_max_scale;
|
||||||
if (spi_get_device_id(adis->spi)->driver_data) {
|
*val2 = info->gyro_max_val;
|
||||||
/* 0.01832 degree / sec */
|
return IIO_VAL_FRACTIONAL;
|
||||||
*val2 = IIO_DEGREE_TO_RAD(18320);
|
|
||||||
} else {
|
|
||||||
/* 0.07326 degree / sec */
|
|
||||||
*val2 = IIO_DEGREE_TO_RAD(73260);
|
|
||||||
}
|
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
|
||||||
case IIO_INCLI:
|
case IIO_INCLI:
|
||||||
*val = 0;
|
*val = 0;
|
||||||
*val2 = IIO_DEGREE_TO_RAD(36630);
|
*val2 = IIO_DEGREE_TO_RAD(36630);
|
||||||
|
@ -224,7 +274,8 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
|
||||||
int val2,
|
int val2,
|
||||||
long mask)
|
long mask)
|
||||||
{
|
{
|
||||||
struct adis *adis = iio_priv(indio_dev);
|
struct adis16260 *adis16260 = iio_priv(indio_dev);
|
||||||
|
struct adis *adis = &adis16260->adis;
|
||||||
int ret;
|
int ret;
|
||||||
u8 addr;
|
u8 addr;
|
||||||
u8 t;
|
u8 t;
|
||||||
|
@ -305,35 +356,42 @@ static const struct adis_data adis16260_data = {
|
||||||
|
|
||||||
static int adis16260_probe(struct spi_device *spi)
|
static int adis16260_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
|
const struct spi_device_id *id;
|
||||||
|
struct adis16260 *adis16260;
|
||||||
struct iio_dev *indio_dev;
|
struct iio_dev *indio_dev;
|
||||||
struct adis *adis;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
id = spi_get_device_id(spi);
|
||||||
|
if (!id)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
/* setup the industrialio driver allocated elements */
|
/* setup the industrialio driver allocated elements */
|
||||||
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis));
|
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16260));
|
||||||
if (!indio_dev)
|
if (!indio_dev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
adis = iio_priv(indio_dev);
|
adis16260 = iio_priv(indio_dev);
|
||||||
/* this is only used for removal purposes */
|
/* this is only used for removal purposes */
|
||||||
spi_set_drvdata(spi, indio_dev);
|
spi_set_drvdata(spi, indio_dev);
|
||||||
|
|
||||||
indio_dev->name = spi_get_device_id(spi)->name;
|
adis16260->info = &adis16260_chip_info_table[id->driver_data];
|
||||||
|
|
||||||
|
indio_dev->name = id->name;
|
||||||
indio_dev->dev.parent = &spi->dev;
|
indio_dev->dev.parent = &spi->dev;
|
||||||
indio_dev->info = &adis16260_info;
|
indio_dev->info = &adis16260_info;
|
||||||
indio_dev->channels = adis16260_channels;
|
indio_dev->channels = adis16260->info->channels;
|
||||||
indio_dev->num_channels = ARRAY_SIZE(adis16260_channels);
|
indio_dev->num_channels = adis16260->info->num_channels;
|
||||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
|
|
||||||
ret = adis_init(adis, indio_dev, spi, &adis16260_data);
|
ret = adis_init(&adis16260->adis, indio_dev, spi, &adis16260_data);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL);
|
ret = adis_setup_buffer_and_trigger(&adis16260->adis, indio_dev, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Get the device into a sane initial state */
|
/* Get the device into a sane initial state */
|
||||||
ret = adis_initial_startup(adis);
|
ret = adis_initial_startup(&adis16260->adis);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_cleanup_buffer_trigger;
|
goto error_cleanup_buffer_trigger;
|
||||||
ret = iio_device_register(indio_dev);
|
ret = iio_device_register(indio_dev);
|
||||||
|
@ -343,18 +401,18 @@ static int adis16260_probe(struct spi_device *spi)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_cleanup_buffer_trigger:
|
error_cleanup_buffer_trigger:
|
||||||
adis_cleanup_buffer_and_trigger(adis, indio_dev);
|
adis_cleanup_buffer_and_trigger(&adis16260->adis, indio_dev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adis16260_remove(struct spi_device *spi)
|
static int adis16260_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||||
struct adis *adis = iio_priv(indio_dev);
|
struct adis16260 *adis16260 = iio_priv(indio_dev);
|
||||||
|
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
adis16260_stop_device(indio_dev);
|
adis16260_stop_device(indio_dev);
|
||||||
adis_cleanup_buffer_and_trigger(adis, indio_dev);
|
adis_cleanup_buffer_and_trigger(&adis16260->adis, indio_dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -364,11 +422,12 @@ static int adis16260_remove(struct spi_device *spi)
|
||||||
* support for the on chip filtering.
|
* support for the on chip filtering.
|
||||||
*/
|
*/
|
||||||
static const struct spi_device_id adis16260_id[] = {
|
static const struct spi_device_id adis16260_id[] = {
|
||||||
{"adis16260", 0},
|
{"adis16260", ADIS16260},
|
||||||
{"adis16265", 0},
|
{"adis16265", ADIS16260},
|
||||||
{"adis16250", 0},
|
{"adis16266", ADIS16266},
|
||||||
{"adis16255", 0},
|
{"adis16250", ADIS16260},
|
||||||
{"adis16251", 1},
|
{"adis16255", ADIS16260},
|
||||||
|
{"adis16251", ADIS16251},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(spi, adis16260_id);
|
MODULE_DEVICE_TABLE(spi, adis16260_id);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче