diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-09-10 04:34:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-15 05:02:15 -0400 |
commit | 4c337de870d9bd1459ab603574256bb0e7644ad6 (patch) | |
tree | 1247ed98864855a526e78622b6c25b1381542a98 /drivers/iio | |
parent | ac5332b1475b474a478d9336635849339546e235 (diff) |
iio:ad7476: Add ad7940 support
The AD7940 is a single channel 14 bit ADC similar to the ADCs already supported
by the ad7476 driver, but it does have a different shift factor.
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/adc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/iio/adc/ad7476.c | 18 |
2 files changed, 16 insertions, 6 deletions
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index c71a0009cc79..e2e696395ac8 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig | |||
@@ -37,8 +37,8 @@ config AD7476 | |||
37 | select IIO_TRIGGERED_BUFFER | 37 | select IIO_TRIGGERED_BUFFER |
38 | help | 38 | help |
39 | Say yes here to build support for Analog Devices AD7475, AD7476, AD7477, | 39 | Say yes here to build support for Analog Devices AD7475, AD7476, AD7477, |
40 | AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920 SPI analog to | 40 | AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920, AD7920 SPI analog |
41 | digital converters (ADC). | 41 | to digital converters (ADC). |
42 | 42 | ||
43 | If unsure, say N (but it's safe to say "Y"). | 43 | If unsure, say N (but it's safe to say "Y"). |
44 | 44 | ||
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 093a4ed900d8..be22757d54e4 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c | |||
@@ -48,7 +48,8 @@ enum ad7476_supported_device_ids { | |||
48 | ID_AD7466, | 48 | ID_AD7466, |
49 | ID_AD7467, | 49 | ID_AD7467, |
50 | ID_AD7468, | 50 | ID_AD7468, |
51 | ID_AD7495 | 51 | ID_AD7495, |
52 | ID_AD7940, | ||
52 | }; | 53 | }; |
53 | 54 | ||
54 | static irqreturn_t ad7476_trigger_handler(int irq, void *p) | 55 | static irqreturn_t ad7476_trigger_handler(int irq, void *p) |
@@ -126,7 +127,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, | |||
126 | return -EINVAL; | 127 | return -EINVAL; |
127 | } | 128 | } |
128 | 129 | ||
129 | #define AD7476_CHAN(bits) \ | 130 | #define _AD7476_CHAN(bits, _shift) \ |
130 | { \ | 131 | { \ |
131 | .type = IIO_VOLTAGE, \ | 132 | .type = IIO_VOLTAGE, \ |
132 | .indexed = 1, \ | 133 | .indexed = 1, \ |
@@ -134,12 +135,16 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, | |||
134 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 135 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ |
135 | .scan_type = { \ | 136 | .scan_type = { \ |
136 | .sign = 'u', \ | 137 | .sign = 'u', \ |
137 | .realbits = bits, \ | 138 | .realbits = (bits), \ |
138 | .storagebits = 16, \ | 139 | .storagebits = 16, \ |
139 | .shift = 13 - bits, \ | 140 | .shift = (_shift), \ |
141 | .endianness = IIO_BE, \ | ||
140 | }, \ | 142 | }, \ |
141 | } | 143 | } |
142 | 144 | ||
145 | #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits)) | ||
146 | #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits)) | ||
147 | |||
143 | static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { | 148 | static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { |
144 | [ID_AD7466] = { | 149 | [ID_AD7466] = { |
145 | .channel[0] = AD7476_CHAN(12), | 150 | .channel[0] = AD7476_CHAN(12), |
@@ -158,6 +163,10 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { | |||
158 | .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), | 163 | .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), |
159 | .int_vref_uv = 2500000, | 164 | .int_vref_uv = 2500000, |
160 | }, | 165 | }, |
166 | [ID_AD7940] = { | ||
167 | .channel[0] = AD7940_CHAN(14), | ||
168 | .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), | ||
169 | }, | ||
161 | }; | 170 | }; |
162 | 171 | ||
163 | static const struct iio_info ad7476_info = { | 172 | static const struct iio_info ad7476_info = { |
@@ -260,6 +269,7 @@ static const struct spi_device_id ad7476_id[] = { | |||
260 | {"ad7495", ID_AD7495}, | 269 | {"ad7495", ID_AD7495}, |
261 | {"ad7910", ID_AD7467}, | 270 | {"ad7910", ID_AD7467}, |
262 | {"ad7920", ID_AD7466}, | 271 | {"ad7920", ID_AD7466}, |
272 | {"ad7940", ID_AD7940}, | ||
263 | {} | 273 | {} |
264 | }; | 274 | }; |
265 | MODULE_DEVICE_TABLE(spi, ad7476_id); | 275 | MODULE_DEVICE_TABLE(spi, ad7476_id); |