Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad9467: add support for ad9211

The AD9211 is a 10-bit monolithic sampling analog-to-digital converter
optimized for high performance, low power, and ease of use. The product
operates at up to a 300 MSPS conversion rate and is optimized for
outstanding dynamic performance in wideband carrier and broadband systems.

The scale table implemented here is not an exact match with the
datasheet as the table presented there is missing some information.
The reference presents these values as being linear,
but that does not add up. There is information missing in the table.
Implemented scale table matches values at the middle and at the ends,
smoothing the curve towards middle and end.
Impact on end result from deviation in scale factor affects only software
using it for scaling. All the possible hw-settings are also available with
this implementation.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9211.pdf
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Tomas Melin and committed by
Jonathan Cameron
77a01741 1f0b6415

+43
+43
drivers/iio/adc/ad9467.c
··· 21 21 #include <linux/seq_file.h> 22 22 #include <linux/slab.h> 23 23 #include <linux/spi/spi.h> 24 + #include <linux/units.h> 24 25 25 26 #include <linux/iio/backend.h> 26 27 #include <linux/iio/iio.h> ··· 79 78 80 79 /* AN877_ADC_REG_OUTPUT_DELAY */ 81 80 #define AN877_ADC_DCO_DELAY_ENABLE 0x80 81 + 82 + /* 83 + * Analog Devices AD9211 10-Bit, 200/250/300 MSPS ADC 84 + */ 85 + 86 + #define CHIPID_AD9211 0x06 87 + #define AD9211_DEF_OUTPUT_MODE 0x00 88 + #define AD9211_REG_VREF_MASK GENMASK(4, 0) 82 89 83 90 /* 84 91 * Analog Devices AD9265 16-Bit, 125/105/80 MSPS ADC ··· 246 237 -128, 1, 127, 247 238 }; 248 239 240 + static const unsigned int ad9211_scale_table[][2] = { 241 + {980, 0x10}, {1000, 0x11}, {1020, 0x12}, {1040, 0x13}, 242 + {1060, 0x14}, {1080, 0x15}, {1100, 0x16}, {1120, 0x17}, 243 + {1140, 0x18}, {1160, 0x19}, {1180, 0x1A}, {1190, 0x1B}, 244 + {1200, 0x1C}, {1210, 0x1D}, {1220, 0x1E}, {1230, 0x1F}, 245 + {1250, 0x0}, {1270, 0x1}, {1290, 0x2}, {1310, 0x3}, 246 + {1330, 0x4}, {1350, 0x5}, {1370, 0x6}, {1390, 0x7}, 247 + {1410, 0x8}, {1430, 0x9}, {1450, 0xA}, {1460, 0xB}, 248 + {1470, 0xC}, {1480, 0xD}, {1490, 0xE}, {1500, 0xF}, 249 + }; 250 + 249 251 static const unsigned int ad9265_scale_table[][2] = { 250 252 {1250, 0x00}, {1500, 0x40}, {1750, 0x80}, {2000, 0xC0}, 251 253 }; ··· 319 299 .storagebits = 16, \ 320 300 }, \ 321 301 } 302 + 303 + static const struct iio_chan_spec ad9211_channels[] = { 304 + AD9467_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 0, 10, 's'), 305 + }; 322 306 323 307 static const struct iio_chan_spec ad9434_channels[] = { 324 308 { ··· 412 388 .vref_mask = AD9434_REG_VREF_MASK, 413 389 .num_lanes = 6, 414 390 .offset_range = ad9434_offset_range, 391 + }; 392 + 393 + static const struct ad9467_chip_info ad9211_chip_tbl = { 394 + .name = "ad9211", 395 + .id = CHIPID_AD9211, 396 + .max_rate = 300 * HZ_PER_MHZ, 397 + .scale_table = ad9211_scale_table, 398 + .num_scales = ARRAY_SIZE(ad9211_scale_table), 399 + .channels = ad9211_channels, 400 + .num_channels = ARRAY_SIZE(ad9211_channels), 401 + .test_points = AD9647_MAX_TEST_POINTS, 402 + .test_mask = GENMASK(AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE, 403 + AN877_ADC_TESTMODE_OFF), 404 + .test_mask_len = AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE + 1, 405 + .default_output_mode = AD9211_DEF_OUTPUT_MODE, 406 + .vref_mask = AD9211_REG_VREF_MASK, 407 + .has_dco = true, 415 408 }; 416 409 417 410 static const struct ad9467_chip_info ad9265_chip_tbl = { ··· 1361 1320 } 1362 1321 1363 1322 static const struct of_device_id ad9467_of_match[] = { 1323 + { .compatible = "adi,ad9211", .data = &ad9211_chip_tbl, }, 1364 1324 { .compatible = "adi,ad9265", .data = &ad9265_chip_tbl, }, 1365 1325 { .compatible = "adi,ad9434", .data = &ad9434_chip_tbl, }, 1366 1326 { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl, }, ··· 1373 1331 MODULE_DEVICE_TABLE(of, ad9467_of_match); 1374 1332 1375 1333 static const struct spi_device_id ad9467_ids[] = { 1334 + { "ad9211", (kernel_ulong_t)&ad9211_chip_tbl }, 1376 1335 { "ad9265", (kernel_ulong_t)&ad9265_chip_tbl }, 1377 1336 { "ad9434", (kernel_ulong_t)&ad9434_chip_tbl }, 1378 1337 { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl },