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

staging:iio:ad7606: Add support for the ad7605-4

Add support for the AD7605-4 to the AD7606 driver. The AD7605-4 is mostly
interface compatible to the AD7606-6 with the only difference being not
having support for oversampling.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
bb9fc6ad 6eb17c6c

+36 -6
+1 -1
drivers/staging/iio/adc/Kconfig
··· 11 11 select IIO_TRIGGERED_BUFFER 12 12 help 13 13 Say yes here to build support for Analog Devices: 14 - ad7606, ad7606-6, ad7606-4 analog to digital converters (ADC). 14 + ad7605-4, ad7606, ad7606-6, ad7606-4 analog to digital converters (ADC). 15 15 16 16 To compile this driver as a module, choose M here: the 17 17 module will be called ad7606.
+28 -5
drivers/staging/iio/adc/ad7606.c
··· 276 276 .attrs = ad7606_attributes_range, 277 277 }; 278 278 279 - #define AD7606_CHANNEL(num) \ 279 + #define AD760X_CHANNEL(num, mask) \ 280 280 { \ 281 281 .type = IIO_VOLTAGE, \ 282 282 .indexed = 1, \ ··· 284 284 .address = num, \ 285 285 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 286 286 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\ 287 - .info_mask_shared_by_all = \ 288 - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ 287 + .info_mask_shared_by_all = mask, \ 289 288 .scan_index = num, \ 290 289 .scan_type = { \ 291 290 .sign = 's', \ ··· 293 294 .endianness = IIO_CPU, \ 294 295 }, \ 295 296 } 297 + 298 + #define AD7605_CHANNEL(num) \ 299 + AD760X_CHANNEL(num, 0) 300 + 301 + #define AD7606_CHANNEL(num) \ 302 + AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO)) 303 + 304 + static const struct iio_chan_spec ad7605_channels[] = { 305 + IIO_CHAN_SOFT_TIMESTAMP(4), 306 + AD7605_CHANNEL(0), 307 + AD7605_CHANNEL(1), 308 + AD7605_CHANNEL(2), 309 + AD7605_CHANNEL(3), 310 + }; 296 311 297 312 static const struct iio_chan_spec ad7606_channels[] = { 298 313 IIO_CHAN_SOFT_TIMESTAMP(8), ··· 324 311 /* 325 312 * More devices added in future 326 313 */ 314 + [ID_AD7605_4] = { 315 + .channels = ad7605_channels, 316 + .num_channels = 5, 317 + }, 327 318 [ID_AD7606_8] = { 328 319 .channels = ad7606_channels, 329 320 .num_channels = 9, 321 + .has_oversampling = true, 330 322 }, 331 323 [ID_AD7606_6] = { 332 324 .channels = ad7606_channels, 333 325 .num_channels = 7, 326 + .has_oversampling = true, 334 327 }, 335 328 [ID_AD7606_4] = { 336 329 .channels = ad7606_channels, 337 330 .num_channels = 5, 331 + .has_oversampling = true, 338 332 }, 339 333 }; 340 334 ··· 371 351 GPIOD_IN); 372 352 if (IS_ERR(st->gpio_frstdata)) 373 353 return PTR_ERR(st->gpio_frstdata); 354 + 355 + if (!st->chip_info->has_oversampling) 356 + return 0; 374 357 375 358 st->gpio_os = devm_gpiod_get_array_optional(dev, "oversampling-ratio", 376 359 GPIOD_OUT_LOW); ··· 453 430 return ret; 454 431 } 455 432 433 + st->chip_info = &ad7606_chip_info_tbl[id]; 434 + 456 435 ret = ad7606_request_gpios(st); 457 436 if (ret) 458 437 goto error_disable_reg; 459 - 460 - st->chip_info = &ad7606_chip_info_tbl[id]; 461 438 462 439 indio_dev->dev.parent = dev; 463 440 if (st->gpio_os) {
+3
drivers/staging/iio/adc/ad7606.h
··· 13 13 * struct ad7606_chip_info - chip specific information 14 14 * @channels: channel specification 15 15 * @num_channels: number of channels 16 + * @has_oversampling: whether the device has oversampling support 16 17 */ 17 18 18 19 struct ad7606_chip_info { 19 20 const struct iio_chan_spec *channels; 20 21 unsigned int num_channels; 22 + bool has_oversampling; 21 23 }; 22 24 23 25 /** ··· 90 88 int ad7606_remove(struct device *dev, int irq); 91 89 92 90 enum ad7606_supported_device_ids { 91 + ID_AD7605_4, 93 92 ID_AD7606_8, 94 93 ID_AD7606_6, 95 94 ID_AD7606_4
+3
drivers/staging/iio/adc/ad7606_par.c
··· 79 79 80 80 static const struct platform_device_id ad7606_driver_ids[] = { 81 81 { 82 + .name = "ad7605-4", 83 + .driver_data = ID_AD7605_4, 84 + }, { 82 85 .name = "ad7606-8", 83 86 .driver_data = ID_AD7606_8, 84 87 }, {
+1
drivers/staging/iio/adc/ad7606_spi.c
··· 55 55 } 56 56 57 57 static const struct spi_device_id ad7606_id[] = { 58 + {"ad7605-4", ID_AD7605_4}, 58 59 {"ad7606-8", ID_AD7606_8}, 59 60 {"ad7606-6", ID_AD7606_6}, 60 61 {"ad7606-4", ID_AD7606_4},