diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-08-10 12:36:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-08-27 13:10:55 -0400 |
commit | 8c29ecd3620cce207f383fd3ab9b345061a9a8dc (patch) | |
tree | 0a01f5a90f93a8d8e665b3c776d3c326a000630b | |
parent | 525e643e4812cd0ced0f40908fafaf0c4317ac73 (diff) |
staging:iio:ad7793: Add ad7785 support
The ad7785 is similar to the ad7792/ad7793, but has 20 bit wide data samples.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/adc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7793.c | 27 |
2 files changed, 19 insertions, 12 deletions
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 0eab0c61c87b..a1fa1729acbe 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig | |||
@@ -113,8 +113,8 @@ config AD7793 | |||
113 | depends on SPI | 113 | depends on SPI |
114 | select AD_SIGMA_DELTA | 114 | select AD_SIGMA_DELTA |
115 | help | 115 | help |
116 | Say yes here to build support for Analog Devices AD7792, AD7793, AD7794 | 116 | Say yes here to build support for Analog Devices AD7785, AD7792, AD7793, |
117 | and AD7795 SPI analog to digital converters (ADC). | 117 | AD7794 and AD7795 SPI analog to digital converters (ADC). |
118 | If unsure, say N (but it's safe to say "Y"). | 118 | If unsure, say N (but it's safe to say "Y"). |
119 | 119 | ||
120 | To compile this driver as a module, choose M here: the | 120 | To compile this driver as a module, choose M here: the |
diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index f11dcaf0fbae..ddc7fd721e46 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * AD7792/AD7793/AD7794/AD7795 SPI ADC driver | 2 | * AD7785/AD7792/AD7793/AD7794/AD7795 SPI ADC driver |
3 | * | 3 | * |
4 | * Copyright 2011-2012 Analog Devices Inc. | 4 | * Copyright 2011-2012 Analog Devices Inc. |
5 | * | 5 | * |
@@ -54,6 +54,7 @@ struct ad7793_state { | |||
54 | }; | 54 | }; |
55 | 55 | ||
56 | enum ad7793_supported_device_ids { | 56 | enum ad7793_supported_device_ids { |
57 | ID_AD7785, | ||
57 | ID_AD7792, | 58 | ID_AD7792, |
58 | ID_AD7793, | 59 | ID_AD7793, |
59 | ID_AD7794, | 60 | ID_AD7794, |
@@ -386,14 +387,14 @@ static const struct iio_info ad7793_info = { | |||
386 | .driver_module = THIS_MODULE, | 387 | .driver_module = THIS_MODULE, |
387 | }; | 388 | }; |
388 | 389 | ||
389 | #define DECLARE_AD7793_CHANNELS(_name, _b, _sb) \ | 390 | #define DECLARE_AD7793_CHANNELS(_name, _b, _sb, _s) \ |
390 | const struct iio_chan_spec _name##_channels[] = { \ | 391 | const struct iio_chan_spec _name##_channels[] = { \ |
391 | AD_SD_DIFF_CHANNEL(0, 0, 0, AD7793_CH_AIN1P_AIN1M, (_b), (_sb), 0), \ | 392 | AD_SD_DIFF_CHANNEL(0, 0, 0, AD7793_CH_AIN1P_AIN1M, (_b), (_sb), (_s)), \ |
392 | AD_SD_DIFF_CHANNEL(1, 1, 1, AD7793_CH_AIN2P_AIN2M, (_b), (_sb), 0), \ | 393 | AD_SD_DIFF_CHANNEL(1, 1, 1, AD7793_CH_AIN2P_AIN2M, (_b), (_sb), (_s)), \ |
393 | AD_SD_DIFF_CHANNEL(2, 2, 2, AD7793_CH_AIN3P_AIN3M, (_b), (_sb), 0), \ | 394 | AD_SD_DIFF_CHANNEL(2, 2, 2, AD7793_CH_AIN3P_AIN3M, (_b), (_sb), (_s)), \ |
394 | AD_SD_SHORTED_CHANNEL(3, 0, AD7793_CH_AIN1M_AIN1M, (_b), (_sb), 0), \ | 395 | AD_SD_SHORTED_CHANNEL(3, 0, AD7793_CH_AIN1M_AIN1M, (_b), (_sb), (_s)), \ |
395 | AD_SD_TEMP_CHANNEL(4, AD7793_CH_TEMP, (_b), (_sb), 0), \ | 396 | AD_SD_TEMP_CHANNEL(4, AD7793_CH_TEMP, (_b), (_sb), (_s)), \ |
396 | AD_SD_SUPPLY_CHANNEL(5, 3, AD7793_CH_AVDD_MONITOR, (_b), (_sb), 0), \ | 397 | AD_SD_SUPPLY_CHANNEL(5, 3, AD7793_CH_AVDD_MONITOR, (_b), (_sb), (_s)), \ |
397 | IIO_CHAN_SOFT_TIMESTAMP(6), \ | 398 | IIO_CHAN_SOFT_TIMESTAMP(6), \ |
398 | } | 399 | } |
399 | 400 | ||
@@ -411,12 +412,17 @@ const struct iio_chan_spec _name##_channels[] = { \ | |||
411 | IIO_CHAN_SOFT_TIMESTAMP(9), \ | 412 | IIO_CHAN_SOFT_TIMESTAMP(9), \ |
412 | } | 413 | } |
413 | 414 | ||
414 | static DECLARE_AD7793_CHANNELS(ad7792, 16, 32); | 415 | static DECLARE_AD7793_CHANNELS(ad7785, 20, 32, 4); |
415 | static DECLARE_AD7793_CHANNELS(ad7793, 24, 32); | 416 | static DECLARE_AD7793_CHANNELS(ad7792, 16, 32, 0); |
417 | static DECLARE_AD7793_CHANNELS(ad7793, 24, 32, 0); | ||
416 | static DECLARE_AD7795_CHANNELS(ad7794, 16, 32); | 418 | static DECLARE_AD7795_CHANNELS(ad7794, 16, 32); |
417 | static DECLARE_AD7795_CHANNELS(ad7795, 24, 32); | 419 | static DECLARE_AD7795_CHANNELS(ad7795, 24, 32); |
418 | 420 | ||
419 | static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { | 421 | static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { |
422 | [ID_AD7785] = { | ||
423 | .channels = ad7785_channels, | ||
424 | .num_channels = ARRAY_SIZE(ad7785_channels), | ||
425 | }, | ||
420 | [ID_AD7792] = { | 426 | [ID_AD7792] = { |
421 | .channels = ad7792_channels, | 427 | .channels = ad7792_channels, |
422 | .num_channels = ARRAY_SIZE(ad7792_channels), | 428 | .num_channels = ARRAY_SIZE(ad7792_channels), |
@@ -535,6 +541,7 @@ static int ad7793_remove(struct spi_device *spi) | |||
535 | } | 541 | } |
536 | 542 | ||
537 | static const struct spi_device_id ad7793_id[] = { | 543 | static const struct spi_device_id ad7793_id[] = { |
544 | {"ad7785", ID_AD7785}, | ||
538 | {"ad7792", ID_AD7792}, | 545 | {"ad7792", ID_AD7792}, |
539 | {"ad7793", ID_AD7793}, | 546 | {"ad7793", ID_AD7793}, |
540 | {"ad7794", ID_AD7794}, | 547 | {"ad7794", ID_AD7794}, |