* [PATCH v2 0/4] Add support for AD7405/ADUM770x
@ 2025-05-08 12:30 Pop Ioan Daniel
2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Pop Ioan Daniel @ 2025-05-08 12:30 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean,
Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco,
Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman,
Marcelo Schmitt, Trevor Gamblin, AngeloGioacchino Del Regno,
Ioan Daniel, linux-iio, devicetree, linux-kernel
The AD7405 is a high performance, second-order, Σ-Δ modulator
that converts an analog input signal into a high speed, single-bit
LVDS data stream, with on-chip digital isolation based on Analog
Devices, Inc., iCoupler technology. The AD7405 operates from a
4.5 V to 5.5 V (VDD1) power supply and accepts a differential input
signal of ±250 mV (±320 mV full-scale). The differential input is ideally
suited to shunt voltage monitoring in high voltage applications
where galvanic isolation is required.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Pop Ioan Daniel (4):
iio: backend: update iio_backend_oversampling_ratio_set
iio: adc: adi-axi-adc: add set decimation rate
dt-bindings: iio: adc: add ad7405
iio: adc: ad7405: add ad7405 driver
.../bindings/iio/adc/adi,ad7405.yaml | 60 ++++
drivers/iio/adc/Kconfig | 10 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/ad4851.c | 2 +-
drivers/iio/adc/ad7405.c | 264 ++++++++++++++++++
drivers/iio/adc/adi-axi-adc.c | 18 +-
drivers/iio/industrialio-backend.c | 3 +-
include/linux/iio/backend.h | 3 +-
8 files changed, 357 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml
create mode 100644 drivers/iio/adc/ad7405.c
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set 2025-05-08 12:30 [PATCH v2 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel @ 2025-05-08 12:30 ` Pop Ioan Daniel 2025-05-08 16:41 ` David Lechner ` (3 more replies) 2025-05-08 12:30 ` [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate Pop Ioan Daniel ` (2 subsequent siblings) 3 siblings, 4 replies; 16+ messages in thread From: Pop Ioan Daniel @ 2025-05-08 12:30 UTC (permalink / raw) To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Pop Ioan Daniel, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel In the function iio_backend_oversampling_ratio_set the chan parameter was added. The function can be used in contexts where the channel must be specified. All affected files have been modified. Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> --- changes in v2: - remove iio_backend_set_dec_rate function and use iio_backend_oversampling_ratio_set function drivers/iio/adc/ad4851.c | 2 +- drivers/iio/adc/adi-axi-adc.c | 3 ++- drivers/iio/industrialio-backend.c | 3 ++- include/linux/iio/backend.h | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c index 98ebc853db79..a943d5aac9e5 100644 --- a/drivers/iio/adc/ad4851.c +++ b/drivers/iio/adc/ad4851.c @@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, return ret; } - ret = iio_backend_oversampling_ratio_set(st->back, osr); + ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); if (ret) return ret; diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 4116c44197b8..9e8c30230791 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -381,7 +381,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_backend *back, } static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back, - unsigned int ratio) + unsigned int chan, + unsigned int ratio) { struct adi_axi_adc_state *st = iio_backend_get_priv(back); diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c index c1eb9ef9db08..a4e3e54fecb1 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -720,9 +720,10 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_data_size_set, "IIO_BACKEND"); * 0 on success, negative error number on failure. */ int iio_backend_oversampling_ratio_set(struct iio_backend *back, + unsigned int chan, unsigned int ratio) { - return iio_backend_op_call(back, oversampling_ratio_set, ratio); + return iio_backend_op_call(back, oversampling_ratio_set, chan, ratio); } EXPORT_SYMBOL_NS_GPL(iio_backend_oversampling_ratio_set, "IIO_BACKEND"); diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index e59d909cb659..dbf4e4a5f4b1 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -144,7 +144,7 @@ struct iio_backend_ops { enum iio_backend_interface_type *type); int (*data_size_set)(struct iio_backend *back, unsigned int size); int (*oversampling_ratio_set)(struct iio_backend *back, - unsigned int ratio); + unsigned int chan, unsigned int ratio); int (*read_raw)(struct iio_backend *back, struct iio_chan_spec const *chan, int *val, int *val2, long mask); @@ -209,6 +209,7 @@ int iio_backend_interface_type_get(struct iio_backend *back, enum iio_backend_interface_type *type); int iio_backend_data_size_set(struct iio_backend *back, unsigned int size); int iio_backend_oversampling_ratio_set(struct iio_backend *back, + unsigned int chan, unsigned int ratio); int iio_backend_read_raw(struct iio_backend *back, struct iio_chan_spec const *chan, int *val, int *val2, -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel @ 2025-05-08 16:41 ` David Lechner 2025-05-09 10:10 ` kernel test robot ` (2 subsequent siblings) 3 siblings, 0 replies; 16+ messages in thread From: David Lechner @ 2025-05-08 16:41 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel On 5/8/25 7:30 AM, Pop Ioan Daniel wrote: > In the function iio_backend_oversampling_ratio_set the chan parameter > was added. The function can be used in contexts where the channel > must be specified. All affected files have been modified. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> > --- > changes in v2: > - remove iio_backend_set_dec_rate function and use > iio_backend_oversampling_ratio_set function > drivers/iio/adc/ad4851.c | 2 +- > drivers/iio/adc/adi-axi-adc.c | 3 ++- > drivers/iio/industrialio-backend.c | 3 ++- > include/linux/iio/backend.h | 3 ++- > 4 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c > index 98ebc853db79..a943d5aac9e5 100644 > --- a/drivers/iio/adc/ad4851.c > +++ b/drivers/iio/adc/ad4851.c > @@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, > return ret; > } > > - ret = iio_backend_oversampling_ratio_set(st->back, osr); > + ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); Isn't this a compile error? chan here is const struct iio_chan_spec *, not unsigned int. > if (ret) > return ret; > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel 2025-05-08 16:41 ` David Lechner @ 2025-05-09 10:10 ` kernel test robot 2025-05-09 10:21 ` kernel test robot 2025-05-09 18:03 ` kernel test robot 3 siblings, 0 replies; 16+ messages in thread From: kernel test robot @ 2025-05-09 10:10 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel Cc: llvm, oe-kbuild-all Hi Pop, kernel test robot noticed the following build errors: [auto build test ERROR on jic23-iio/togreg] [also build test ERROR on linus/master v6.15-rc5 next-20250508] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Pop-Ioan-Daniel/iio-backend-update-iio_backend_oversampling_ratio_set/20250508-203339 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20250508123107.3797042-2-pop.ioan-daniel%40analog.com patch subject: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set config: arm-randconfig-004-20250509 (https://download.01.org/0day-ci/archive/20250509/202505091706.owR2rZED-lkp@intel.com/config) compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250509/202505091706.owR2rZED-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202505091706.owR2rZED-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/iio/adc/ad4851.c:324:53: error: incompatible pointer to integer conversion passing 'const struct iio_chan_spec *' to parameter of type 'unsigned int' [-Wint-conversion] 324 | ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); | ^~~~ include/linux/iio/backend.h:212:25: note: passing argument to parameter 'chan' here 212 | unsigned int chan, | ^ 1 error generated. vim +324 drivers/iio/adc/ad4851.c 295 296 static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, 297 const struct iio_chan_spec *chan, 298 unsigned int osr) 299 { 300 struct ad4851_state *st = iio_priv(indio_dev); 301 int val, ret; 302 303 guard(mutex)(&st->lock); 304 305 if (osr == 1) { 306 ret = regmap_clear_bits(st->regmap, AD4851_REG_OVERSAMPLE, 307 AD4851_OS_EN_MSK); 308 if (ret) 309 return ret; 310 } else { 311 val = ad4851_osr_to_regval(osr); 312 if (val < 0) 313 return -EINVAL; 314 315 ret = regmap_update_bits(st->regmap, AD4851_REG_OVERSAMPLE, 316 AD4851_OS_EN_MSK | 317 AD4851_OS_RATIO_MSK, 318 FIELD_PREP(AD4851_OS_EN_MSK, 1) | 319 FIELD_PREP(AD4851_OS_RATIO_MSK, val)); 320 if (ret) 321 return ret; 322 } 323 > 324 ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); 325 if (ret) 326 return ret; 327 328 switch (st->info->resolution) { 329 case 20: 330 switch (osr) { 331 case 0: 332 return -EINVAL; 333 case 1: 334 val = 20; 335 break; 336 default: 337 val = 24; 338 break; 339 } 340 break; 341 case 16: 342 val = 16; 343 break; 344 default: 345 return -EINVAL; 346 } 347 348 ret = iio_backend_data_size_set(st->back, val); 349 if (ret) 350 return ret; 351 352 if (osr == 1 || st->info->resolution == 16) { 353 ret = regmap_clear_bits(st->regmap, AD4851_REG_PACKET, 354 AD4851_PACKET_FORMAT_MASK); 355 if (ret) 356 return ret; 357 358 st->resolution_boost_enabled = false; 359 } else { 360 ret = regmap_update_bits(st->regmap, AD4851_REG_PACKET, 361 AD4851_PACKET_FORMAT_MASK, 362 FIELD_PREP(AD4851_PACKET_FORMAT_MASK, 1)); 363 if (ret) 364 return ret; 365 366 st->resolution_boost_enabled = true; 367 } 368 369 if (st->osr != osr) { 370 ret = ad4851_scale_fill(indio_dev); 371 if (ret) 372 return ret; 373 374 st->osr = osr; 375 } 376 377 return 0; 378 } 379 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel 2025-05-08 16:41 ` David Lechner 2025-05-09 10:10 ` kernel test robot @ 2025-05-09 10:21 ` kernel test robot 2025-05-09 18:03 ` kernel test robot 3 siblings, 0 replies; 16+ messages in thread From: kernel test robot @ 2025-05-09 10:21 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel Cc: oe-kbuild-all Hi Pop, kernel test robot noticed the following build warnings: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on linus/master v6.15-rc5 next-20250508] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Pop-Ioan-Daniel/iio-backend-update-iio_backend_oversampling_ratio_set/20250508-203339 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20250508123107.3797042-2-pop.ioan-daniel%40analog.com patch subject: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set config: nios2-randconfig-001-20250509 (https://download.01.org/0day-ci/archive/20250509/202505091838.a9sKlbJN-lkp@intel.com/config) compiler: nios2-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250509/202505091838.a9sKlbJN-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202505091838.a9sKlbJN-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/iio/adc/ad4851.c: In function 'ad4851_set_oversampling_ratio': >> drivers/iio/adc/ad4851.c:324:60: warning: passing argument 2 of 'iio_backend_oversampling_ratio_set' makes integer from pointer without a cast [-Wint-conversion] 324 | ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); | ^~~~ | | | const struct iio_chan_spec * In file included from drivers/iio/adc/ad4851.c:26: include/linux/iio/backend.h:212:53: note: expected 'unsigned int' but argument is of type 'const struct iio_chan_spec *' 212 | unsigned int chan, | ~~~~~~~~~~~~~^~~~ vim +/iio_backend_oversampling_ratio_set +324 drivers/iio/adc/ad4851.c 295 296 static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, 297 const struct iio_chan_spec *chan, 298 unsigned int osr) 299 { 300 struct ad4851_state *st = iio_priv(indio_dev); 301 int val, ret; 302 303 guard(mutex)(&st->lock); 304 305 if (osr == 1) { 306 ret = regmap_clear_bits(st->regmap, AD4851_REG_OVERSAMPLE, 307 AD4851_OS_EN_MSK); 308 if (ret) 309 return ret; 310 } else { 311 val = ad4851_osr_to_regval(osr); 312 if (val < 0) 313 return -EINVAL; 314 315 ret = regmap_update_bits(st->regmap, AD4851_REG_OVERSAMPLE, 316 AD4851_OS_EN_MSK | 317 AD4851_OS_RATIO_MSK, 318 FIELD_PREP(AD4851_OS_EN_MSK, 1) | 319 FIELD_PREP(AD4851_OS_RATIO_MSK, val)); 320 if (ret) 321 return ret; 322 } 323 > 324 ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); 325 if (ret) 326 return ret; 327 328 switch (st->info->resolution) { 329 case 20: 330 switch (osr) { 331 case 0: 332 return -EINVAL; 333 case 1: 334 val = 20; 335 break; 336 default: 337 val = 24; 338 break; 339 } 340 break; 341 case 16: 342 val = 16; 343 break; 344 default: 345 return -EINVAL; 346 } 347 348 ret = iio_backend_data_size_set(st->back, val); 349 if (ret) 350 return ret; 351 352 if (osr == 1 || st->info->resolution == 16) { 353 ret = regmap_clear_bits(st->regmap, AD4851_REG_PACKET, 354 AD4851_PACKET_FORMAT_MASK); 355 if (ret) 356 return ret; 357 358 st->resolution_boost_enabled = false; 359 } else { 360 ret = regmap_update_bits(st->regmap, AD4851_REG_PACKET, 361 AD4851_PACKET_FORMAT_MASK, 362 FIELD_PREP(AD4851_PACKET_FORMAT_MASK, 1)); 363 if (ret) 364 return ret; 365 366 st->resolution_boost_enabled = true; 367 } 368 369 if (st->osr != osr) { 370 ret = ad4851_scale_fill(indio_dev); 371 if (ret) 372 return ret; 373 374 st->osr = osr; 375 } 376 377 return 0; 378 } 379 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel ` (2 preceding siblings ...) 2025-05-09 10:21 ` kernel test robot @ 2025-05-09 18:03 ` kernel test robot 3 siblings, 0 replies; 16+ messages in thread From: kernel test robot @ 2025-05-09 18:03 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel Cc: oe-kbuild-all Hi Pop, kernel test robot noticed the following build warnings: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on linus/master v6.15-rc5 next-20250509] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Pop-Ioan-Daniel/iio-backend-update-iio_backend_oversampling_ratio_set/20250508-203339 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20250508123107.3797042-2-pop.ioan-daniel%40analog.com patch subject: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set config: i386-randconfig-061-20250509 (https://download.01.org/0day-ci/archive/20250510/202505100131.FZe7C8ot-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250510/202505100131.FZe7C8ot-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202505100131.FZe7C8ot-lkp@intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/iio/adc/ad4851.c:324:60: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int chan @@ got struct iio_chan_spec const *chan @@ drivers/iio/adc/ad4851.c:324:60: sparse: expected unsigned int chan drivers/iio/adc/ad4851.c:324:60: sparse: got struct iio_chan_spec const *chan vim +324 drivers/iio/adc/ad4851.c 295 296 static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, 297 const struct iio_chan_spec *chan, 298 unsigned int osr) 299 { 300 struct ad4851_state *st = iio_priv(indio_dev); 301 int val, ret; 302 303 guard(mutex)(&st->lock); 304 305 if (osr == 1) { 306 ret = regmap_clear_bits(st->regmap, AD4851_REG_OVERSAMPLE, 307 AD4851_OS_EN_MSK); 308 if (ret) 309 return ret; 310 } else { 311 val = ad4851_osr_to_regval(osr); 312 if (val < 0) 313 return -EINVAL; 314 315 ret = regmap_update_bits(st->regmap, AD4851_REG_OVERSAMPLE, 316 AD4851_OS_EN_MSK | 317 AD4851_OS_RATIO_MSK, 318 FIELD_PREP(AD4851_OS_EN_MSK, 1) | 319 FIELD_PREP(AD4851_OS_RATIO_MSK, val)); 320 if (ret) 321 return ret; 322 } 323 > 324 ret = iio_backend_oversampling_ratio_set(st->back, chan, osr); 325 if (ret) 326 return ret; 327 328 switch (st->info->resolution) { 329 case 20: 330 switch (osr) { 331 case 0: 332 return -EINVAL; 333 case 1: 334 val = 20; 335 break; 336 default: 337 val = 24; 338 break; 339 } 340 break; 341 case 16: 342 val = 16; 343 break; 344 default: 345 return -EINVAL; 346 } 347 348 ret = iio_backend_data_size_set(st->back, val); 349 if (ret) 350 return ret; 351 352 if (osr == 1 || st->info->resolution == 16) { 353 ret = regmap_clear_bits(st->regmap, AD4851_REG_PACKET, 354 AD4851_PACKET_FORMAT_MASK); 355 if (ret) 356 return ret; 357 358 st->resolution_boost_enabled = false; 359 } else { 360 ret = regmap_update_bits(st->regmap, AD4851_REG_PACKET, 361 AD4851_PACKET_FORMAT_MASK, 362 FIELD_PREP(AD4851_PACKET_FORMAT_MASK, 1)); 363 if (ret) 364 return ret; 365 366 st->resolution_boost_enabled = true; 367 } 368 369 if (st->osr != osr) { 370 ret = ad4851_scale_fill(indio_dev); 371 if (ret) 372 return ret; 373 374 st->osr = osr; 375 } 376 377 return 0; 378 } 379 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate 2025-05-08 12:30 [PATCH v2 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel @ 2025-05-08 12:30 ` Pop Ioan Daniel 2025-05-08 16:45 ` David Lechner 2025-05-08 12:30 ` [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel 3 siblings, 1 reply; 16+ messages in thread From: Pop Ioan Daniel @ 2025-05-08 12:30 UTC (permalink / raw) To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Esteban Blanc, Ioan Daniel, linux-iio, devicetree, linux-kernel Add support for setting decimation rate. Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> --- changes in v2: - update ADI_AXI_ADC_REG_CHAN_USR_CTRL_2 register in a per-channel register - rename ADI_AXI_ADC_DEC_RATE_MASK in ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK - add channel index parameter to keep axi_adc_set_dec_rate generic - remove ad7405 chip-specific struct drivers/iio/adc/adi-axi-adc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 9e8c30230791..33eb8f337e0b 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -80,6 +80,9 @@ #define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40) #define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16) +#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40) +#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15, 0) + /* IO Delays */ #define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4) #define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0) @@ -242,6 +245,17 @@ static int axi_adc_test_pattern_set(struct iio_backend *back, } } +static int axi_adc_set_dec_rate(struct iio_backend *back, unsigned int chan, + unsigned int rate) +{ + struct adi_axi_adc_state *st = iio_backend_get_priv(back); + + return regmap_update_bits(st->regmap, + ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan), + ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, + FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, rate)); +} + static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned int chan, unsigned int *status) { @@ -550,6 +564,7 @@ static const struct iio_backend_ops adi_axi_adc_ops = { .test_pattern_set = axi_adc_test_pattern_set, .chan_status = axi_adc_chan_status, .interface_type_get = axi_adc_interface_type_get, + .oversampling_ratio_set = axi_adc_set_dec_rate, .debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access), .debugfs_print_chan_status = iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status), }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate 2025-05-08 12:30 ` [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate Pop Ioan Daniel @ 2025-05-08 16:45 ` David Lechner 0 siblings, 0 replies; 16+ messages in thread From: David Lechner @ 2025-05-08 16:45 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Marcelo Schmitt, Alisa-Dariana Roman, Esteban Blanc, linux-iio, devicetree, linux-kernel On 5/8/25 7:30 AM, Pop Ioan Daniel wrote: > Add support for setting decimation rate. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> > --- > changes in v2: > - update ADI_AXI_ADC_REG_CHAN_USR_CTRL_2 register in a per-channel register > - rename ADI_AXI_ADC_DEC_RATE_MASK in > ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK > - add channel index parameter to keep axi_adc_set_dec_rate generic > - remove ad7405 chip-specific struct > drivers/iio/adc/adi-axi-adc.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c > index 9e8c30230791..33eb8f337e0b 100644 > --- a/drivers/iio/adc/adi-axi-adc.c > +++ b/drivers/iio/adc/adi-axi-adc.c > @@ -80,6 +80,9 @@ > #define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40) > #define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16) > > +#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40) > +#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15, 0) > + > /* IO Delays */ > #define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4) > #define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0) > @@ -242,6 +245,17 @@ static int axi_adc_test_pattern_set(struct iio_backend *back, > } > } > > +static int axi_adc_set_dec_rate(struct iio_backend *back, unsigned int chan, > + unsigned int rate) > +{ > + struct adi_axi_adc_state *st = iio_backend_get_priv(back); > + > + return regmap_update_bits(st->regmap, > + ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan), > + ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, > + FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, rate)); Rate is getting a bit far past 80 chars, so would be nice to wrap that line. > +} > + > static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned int chan, > unsigned int *status) > { > @@ -550,6 +564,7 @@ static const struct iio_backend_ops adi_axi_adc_ops = { > .test_pattern_set = axi_adc_test_pattern_set, > .chan_status = axi_adc_chan_status, > .interface_type_get = axi_adc_interface_type_get, > + .oversampling_ratio_set = axi_adc_set_dec_rate, Would make more sense if function was named axi_adc_oversampling_ratio_set. (Making the names match exactly (with namespace prefix added) make less info you have to hold in your head when reading the driver.) > .debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access), > .debugfs_print_chan_status = iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status), > }; ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 2025-05-08 12:30 [PATCH v2 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel 2025-05-08 12:30 ` [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate Pop Ioan Daniel @ 2025-05-08 12:30 ` Pop Ioan Daniel 2025-05-08 14:41 ` Conor Dooley 2025-05-09 13:45 ` Rob Herring (Arm) 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel 3 siblings, 2 replies; 16+ messages in thread From: Pop Ioan Daniel @ 2025-05-08 12:30 UTC (permalink / raw) To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Pop Ioan Daniel, AngeloGioacchino Del Regno, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel Add devicetree bindings for ad7405/adum770x family. Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> --- changes in v2: - remove #address-cells and #size-cells - add additionalProperties: false instead of unevaluatedProperties: false - remove #include <dt-bindings/interrupt-controller/irq.h> because it's not used - add new line at the end of the file - add mantainer .../bindings/iio/adc/adi,ad7405.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml new file mode 100644 index 000000000000..8c30a712968d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2025 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7405.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7405 family + +maintainers: + - Dragos Bogdan <dragos.bogdan@analog.com> + - Pop Ioan Daniel <pop.ioan-daniel@analog.com> + +description: | + Analog Devices AD7405 is a high performance isolated ADC, 1-channel, + 16-bit with a second-order Σ-Δ modulator that converts an analog input signal + into a high speed, single-bit data stream. + + https://www.analog.com/media/en/technical-documentation/data-sheets/ad7405.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/adum7701.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/adum7702.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ADuM7703.pdf + +properties: + compatible: + enum: + - adi,ad7405 + - adi,adum7701 + - adi,adum7702 + - adi,adum7703 + + vdd1-supply: true + + vdd2-supply: true + + clocks: + maxitems: 1 + + io-backends: + maxItems: 1 + +required: + - compatible + - vdd1-supply + - vdd2-supply + - clocks + - io-backends + +additionalProperties: false + +examples: + - | + adc { + compatible = "adi,ad7405"; + clocks = <&axi_clk_gen 0>; + vdd1-supply = <&vdd1>; + vdd2-supply = <&vdd2>; + io-backends = <&iio_backend>; + }; +... -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 2025-05-08 12:30 ` [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel @ 2025-05-08 14:41 ` Conor Dooley 2025-05-09 13:45 ` Rob Herring (Arm) 1 sibling, 0 replies; 16+ messages in thread From: Conor Dooley @ 2025-05-08 14:41 UTC (permalink / raw) To: Pop Ioan Daniel Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, AngeloGioacchino Del Regno, Ramona Alexandra Nechita, linux-iio, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2854 bytes --] On Thu, May 08, 2025 at 03:30:56PM +0300, Pop Ioan Daniel wrote: > Add devicetree bindings for ad7405/adum770x family. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> > --- > changes in v2: > - remove #address-cells and #size-cells > - add additionalProperties: false instead of unevaluatedProperties: false > - remove #include <dt-bindings/interrupt-controller/irq.h> > because it's not used > - add new line at the end of the file > - add mantainer > .../bindings/iio/adc/adi,ad7405.yaml | 60 +++++++++++++++++++ > 1 file changed, 60 insertions(+) > create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml > > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml > new file mode 100644 > index 000000000000..8c30a712968d > --- /dev/null > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml > @@ -0,0 +1,60 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +# Copyright 2025 Analog Devices Inc. > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/iio/adc/adi,ad7405.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Analog Devices AD7405 family > + > +maintainers: > + - Dragos Bogdan <dragos.bogdan@analog.com> > + - Pop Ioan Daniel <pop.ioan-daniel@analog.com> > + > +description: | > + Analog Devices AD7405 is a high performance isolated ADC, 1-channel, > + 16-bit with a second-order Σ-Δ modulator that converts an analog input signal > + into a high speed, single-bit data stream. > + > + https://www.analog.com/media/en/technical-documentation/data-sheets/ad7405.pdf > + https://www.analog.com/media/en/technical-documentation/data-sheets/adum7701.pdf > + https://www.analog.com/media/en/technical-documentation/data-sheets/adum7702.pdf > + https://www.analog.com/media/en/technical-documentation/data-sheets/ADuM7703.pdf > + > +properties: > + compatible: > + enum: > + - adi,ad7405 > + - adi,adum7701 > + - adi,adum7702 > + - adi,adum7703 These last three devices have the same match data, why is a fallback compatible not appropriate? (Please list the reason in your commit message). > + > + vdd1-supply: true > + > + vdd2-supply: true > + > + clocks: > + maxitems: 1 > + > + io-backends: > + maxItems: 1 > + > +required: > + - compatible > + - vdd1-supply > + - vdd2-supply > + - clocks > + - io-backends > + > +additionalProperties: false > + > +examples: > + - | > + adc { > + compatible = "adi,ad7405"; > + clocks = <&axi_clk_gen 0>; > + vdd1-supply = <&vdd1>; > + vdd2-supply = <&vdd2>; > + io-backends = <&iio_backend>; > + }; > +... > -- > 2.34.1 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 2025-05-08 12:30 ` [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel 2025-05-08 14:41 ` Conor Dooley @ 2025-05-09 13:45 ` Rob Herring (Arm) 1 sibling, 0 replies; 16+ messages in thread From: Rob Herring (Arm) @ 2025-05-09 13:45 UTC (permalink / raw) To: Pop Ioan Daniel Cc: Matti Vaittinen, Conor Dooley, Dragos Bogdan, Sergiu Cuciurean, Marcelo Schmitt, devicetree, Javier Carrasco, Jonathan Cameron, David Lechner, Olivier Moysan, Lars-Peter Clausen, linux-iio, linux-kernel, AngeloGioacchino Del Regno, Tobias Sperling, Nuno Sá, Michael Hennerich, Krzysztof Kozlowski, Ramona Alexandra Nechita, Antoniu Miclaus, Alisa-Dariana Roman, Andy Shevchenko On Thu, 08 May 2025 15:30:56 +0300, Pop Ioan Daniel wrote: > Add devicetree bindings for ad7405/adum770x family. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> > --- > changes in v2: > - remove #address-cells and #size-cells > - add additionalProperties: false instead of unevaluatedProperties: false > - remove #include <dt-bindings/interrupt-controller/irq.h> > because it's not used > - add new line at the end of the file > - add mantainer > .../bindings/iio/adc/adi,ad7405.yaml | 60 +++++++++++++++++++ > 1 file changed, 60 insertions(+) > create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: dtschema/dtc warnings/errors: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml: properties:clocks: 'anyOf' conditional failed, one must be fixed: 'maxitems' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected from schema $id: http://devicetree.org/meta-schemas/keywords.yaml# /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml: properties:clocks: 'anyOf' conditional failed, one must be fixed: 'maxItems' is a required property hint: Only "maxItems" is required for a single entry if there are no constraints defined for the values. 'maxitems' is not one of ['maxItems', 'description', 'deprecated'] hint: Only "maxItems" is required for a single entry if there are no constraints defined for the values. Additional properties are not allowed ('maxitems' was unexpected) hint: Arrays must be described with a combination of minItems/maxItems/items 'maxitems' is not one of ['description', 'deprecated', 'const', 'enum', 'minimum', 'maximum', 'multipleOf', 'default', '$ref', 'oneOf'] hint: cell array properties must define how many entries and what the entries are when there is more than one entry. from schema $id: http://devicetree.org/meta-schemas/clocks.yaml# doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250508123107.3797042-4-pop.ioan-daniel@analog.com The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver 2025-05-08 12:30 [PATCH v2 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel ` (2 preceding siblings ...) 2025-05-08 12:30 ` [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel @ 2025-05-08 12:30 ` Pop Ioan Daniel 2025-05-08 17:08 ` David Lechner ` (2 more replies) 3 siblings, 3 replies; 16+ messages in thread From: Pop Ioan Daniel @ 2025-05-08 12:30 UTC (permalink / raw) To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Matteo Martelli, Ioan Daniel, linux-iio, devicetree, linux-kernel Add support for the AD7405/ADUM770x, a high performance isolated ADC, 1-channel, 16-bit with a second-order Σ-Δ modulator that converts an analog input signal into a high speed, single-bit data stream. Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> --- changes in v2: - sort the includes in alphabetical order - delete headers that aren't used - remove min_rate member - remove ad7405_update_scan_mode because there is only one channel - rename axi_clk_gen to clk - remove unuseful members from ad7405 state struct - return -EINVAL on ad7405_write_raw - fix indentation - remove blank lines - remove chan, bits, sign parameters from AD7405_IIO_CHANNEL - remove shift = 0 - add info_mask_shared_by_type with IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_OFFSET flags - add scan_index, differential, channel2 in AD7405_IIO_CHANNEL - remove ad7405_channel_masks[] - remove unuseful members from ad7405_chip_info struct - remove platform_get_drvdata() from probe - use device_get_match_data to be able to use different chip info - use devm_clk_get_enabled() for efficiency - add devm_add_action_or_reset to disable_unprepare the clock when the driver is removed - replace the devm_regulator_bulk_get_enable before applying any other signals - check for return value of 0 for st->ref_frequency - remove indio_dev->modes = INDIO_DIRECT_MODE - remove iio_backend_disable/enable that is done implicitly by devm_iio_backend_enable() drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7405.c | 264 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 drivers/iio/adc/ad7405.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index ad06cf556785..6ed1042636d9 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -251,6 +251,16 @@ config AD7380 To compile this driver as a module, choose M here: the module will be called ad7380. +config AD7405 + tristate "Analog Device AD7405 ADC Driver" + select IIO_BACKEND + help + Say yes here to build support for Analog Devices AD7405, ADUM7701, + ADUM7702, ADUM7703 analog to digital converters (ADC). + + To compile this driver as a module, choose M here: the module will be + called ad7405. + config AD7476 tristate "Analog Devices AD7476 1-channel ADCs driver and other similar devices from AD and TI" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 07d4b832c42e..8115f30b7862 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7292) += ad7292.o obj-$(CONFIG_AD7298) += ad7298.o obj-$(CONFIG_AD7380) += ad7380.o +obj-$(CONFIG_AD7405) += ad7405.o obj-$(CONFIG_AD7476) += ad7476.o obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c new file mode 100644 index 000000000000..5fe36ce61819 --- /dev/null +++ b/drivers/iio/adc/ad7405.c @@ -0,0 +1,264 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Analog Devices AD7405 driver + * + * Copyright 2025 Analog Devices Inc. + */ + +#include <linux/clk.h> +#include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regulator/consumer.h> +#include <linux/util_macros.h> + +#include <linux/iio/backend.h> +#include <linux/iio/iio.h> + +const unsigned int ad7405_dec_rates[] = { + 4096, 2048, 1024, 512, 256, 128, 64, 32, +}; + +struct ad7405_chip_info { + const char *name; + unsigned int max_rate; + struct iio_chan_spec channel[]; +}; + +struct ad7405_state { + struct iio_backend *back; + /* lock to protect multiple accesses to the device registers */ + struct mutex lock; + const struct ad7405_chip_info *info; + unsigned int sample_frequency_tbl[ARRAY_SIZE(ad7405_dec_rates)]; + unsigned int sample_frequency; + unsigned int ref_frequency; +}; + +static void ad7405_fill_samp_freq_table(struct ad7405_state *st) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ad7405_dec_rates); i++) + st->sample_frequency_tbl[i] = + DIV_ROUND_CLOSEST_ULL(st->ref_frequency, ad7405_dec_rates[i]); +} + +static int ad7405_set_sampling_rate(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int samp_rate) +{ + struct ad7405_state *st = iio_priv(indio_dev); + unsigned int dec_rate, idx; + int ret; + + dec_rate = DIV_ROUND_CLOSEST_ULL(st->ref_frequency, samp_rate); + + idx = find_closest_descending(dec_rate, ad7405_dec_rates, + ARRAY_SIZE(ad7405_dec_rates)); + + dec_rate = ad7405_dec_rates[idx]; + + ret = iio_backend_oversampling_ratio_set(st->back, 0, dec_rate); + if (ret) + return ret; + + st->sample_frequency = DIV_ROUND_CLOSEST_ULL(st->ref_frequency, dec_rate); + + return 0; +} + +static int ad7405_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, int *val, + int *val2, long info) +{ + struct ad7405_state *st = iio_priv(indio_dev); + + switch (info) { + case IIO_CHAN_INFO_SAMP_FREQ: + *val = st->sample_frequency; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int ad7405_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, + int val2, long info) +{ + switch (info) { + case IIO_CHAN_INFO_SAMP_FREQ: + if (val < 1) + return -EINVAL; + return ad7405_set_sampling_rate(indio_dev, chan, val); + default: + return -EINVAL; + } +} + +static int ad7405_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long info) +{ + struct ad7405_state *st = iio_priv(indio_dev); + + switch (info) { + case IIO_CHAN_INFO_SAMP_FREQ: + *vals = st->sample_frequency_tbl; + *length = ARRAY_SIZE(st->sample_frequency_tbl); + *type = IIO_VAL_INT; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static void ad7405_clk_disable_unprepare(void *clk) +{ + clk_disable_unprepare(clk); +} + +static const struct iio_info ad7405_iio_info = { + .read_raw = &ad7405_read_raw, + .write_raw = &ad7405_write_raw, + .read_avail = &ad7405_read_avail, +}; + +#define AD7405_IIO_CHANNEL { \ + .type = IIO_VOLTAGE, \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .indexed = 1, \ + .channel = 0, \ + .channel2 = 1, \ + .differential = 1, \ + .scan_index = 0, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 16, \ + .storagebits = 16, \ + }, \ +} + +static const struct ad7405_chip_info ad7405_chip_info = { + .name = "AD7405", + .channel = { + AD7405_IIO_CHANNEL, + }, +}; + +static const struct ad7405_chip_info adum7701_chip_info = { + .name = "ADUM7701", + .channel = { + AD7405_IIO_CHANNEL, + }, +}; + +static const char * const ad7405_power_supplies[] = { + "vdd1", "vdd2", +}; + +static int ad7405_probe(struct platform_device *pdev) +{ + const struct ad7405_chip_info *chip_info; + struct device *dev = &pdev->dev; + struct iio_dev *indio_dev; + struct ad7405_state *st; + struct clk *clk; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + + ret = devm_mutex_init(dev, &st->lock); + if (ret) + return ret; + + chip_info = device_get_match_data(dev); + if (!chip_info) + return dev_err_probe(dev, -EINVAL, "no chip info\n"); + + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad7405_power_supplies), + ad7405_power_supplies); + + if (ret) + return dev_err_probe(dev, ret, "failed to get and enable supplies"); + + clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + ret = devm_add_action_or_reset(dev, ad7405_clk_disable_unprepare, clk); + if (ret) + return ret; + + st->ref_frequency = clk_get_rate(clk); + if (!(st->ref_frequency)) + return -EINVAL; + + ad7405_fill_samp_freq_table(st); + + indio_dev->dev.parent = dev; + indio_dev->name = chip_info->name; + indio_dev->channels = chip_info->channel; + indio_dev->num_channels = 1; + indio_dev->info = &ad7405_iio_info; + + st->back = devm_iio_backend_get(dev, NULL); + if (IS_ERR(st->back)) + return dev_err_probe(dev, PTR_ERR(st->back), + "failed to get IIO backend"); + + ret = iio_backend_chan_enable(st->back, 0); + if (ret) + return ret; + + ret = devm_iio_backend_request_buffer(dev, st->back, indio_dev); + if (ret) + return ret; + + ret = devm_iio_backend_enable(dev, st->back); + if (ret) + return ret; + + ret = ad7405_set_sampling_rate(indio_dev, &indio_dev->channels[0], + chip_info->max_rate); + if (ret) + return ret; + + return devm_iio_device_register(dev, indio_dev); +} + +/* Match table for of_platform binding */ +static const struct of_device_id ad7405_of_match[] = { + { .compatible = "adi,ad7405", .data = &ad7405_chip_info, }, + { .compatible = "adi,adum7701", .data = &adum7701_chip_info, }, + { .compatible = "adi,adum7702", .data = &adum7701_chip_info, }, + { .compatible = "adi,adum7703", .data = &adum7701_chip_info, }, + { /* end of list */ }, +}; +MODULE_DEVICE_TABLE(of, ad7405_of_match); + +static struct platform_driver ad7405_driver = { + .driver = { + .name = "ad7405", + .owner = THIS_MODULE, + .of_match_table = ad7405_of_match, + }, + .probe = ad7405_probe, +}; +module_platform_driver(ad7405_driver); + +MODULE_AUTHOR("Dragos Bogdan <dragos.bogdan@analog.com>"); +MODULE_AUTHOR("Pop Ioan Daniel <pop.ioan-daniel@analog.com>"); +MODULE_DESCRIPTION("Analog Devices AD7405 driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_BACKEND"); -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel @ 2025-05-08 17:08 ` David Lechner 2025-05-11 14:45 ` Jonathan Cameron 2025-05-09 11:45 ` kernel test robot 2025-05-11 15:02 ` Jonathan Cameron 2 siblings, 1 reply; 16+ messages in thread From: David Lechner @ 2025-05-08 17:08 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Matteo Martelli, linux-iio, devicetree, linux-kernel On 5/8/25 7:30 AM, Pop Ioan Daniel wrote: > Add support for the AD7405/ADUM770x, a high performance isolated ADC, > 1-channel, 16-bit with a second-order Σ-Δ modulator that converts an > analog input signal into a high speed, single-bit data stream. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> > --- ... > diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c > new file mode 100644 > index 000000000000..5fe36ce61819 > --- /dev/null > +++ b/drivers/iio/adc/ad7405.c > @@ -0,0 +1,264 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Analog Devices AD7405 driver > + * > + * Copyright 2025 Analog Devices Inc. > + */ > + > +#include <linux/clk.h> > +#include <linux/module.h> > +#include <linux/mod_devicetable.h> > +#include <linux/platform_device.h> > +#include <linux/property.h> > +#include <linux/regulator/consumer.h> > +#include <linux/util_macros.h> > + > +#include <linux/iio/backend.h> > +#include <linux/iio/iio.h> > + > +const unsigned int ad7405_dec_rates[] = { > + 4096, 2048, 1024, 512, 256, 128, 64, 32, > +}; > + > +struct ad7405_chip_info { > + const char *name; > + unsigned int max_rate; > + struct iio_chan_spec channel[]; Since there is only one channel, we can drop the [] here. > +}; > + > +struct ad7405_state { > + struct iio_backend *back; > + /* lock to protect multiple accesses to the device registers */ > + struct mutex lock; This lock isn't used and can be removed. > + const struct ad7405_chip_info *info; > + unsigned int sample_frequency_tbl[ARRAY_SIZE(ad7405_dec_rates)]; > + unsigned int sample_frequency; > + unsigned int ref_frequency; > +}; > + > +static void ad7405_fill_samp_freq_table(struct ad7405_state *st) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(ad7405_dec_rates); i++) > + st->sample_frequency_tbl[i] = > + DIV_ROUND_CLOSEST_ULL(st->ref_frequency, ad7405_dec_rates[i]); > +} > + > +static int ad7405_set_sampling_rate(struct iio_dev *indio_dev, > + const struct iio_chan_spec *chan, > + unsigned int samp_rate) > +{ > + struct ad7405_state *st = iio_priv(indio_dev); > + unsigned int dec_rate, idx; > + int ret; > + > + dec_rate = DIV_ROUND_CLOSEST_ULL(st->ref_frequency, samp_rate); > + > + idx = find_closest_descending(dec_rate, ad7405_dec_rates, > + ARRAY_SIZE(ad7405_dec_rates)); > + > + dec_rate = ad7405_dec_rates[idx]; > + > + ret = iio_backend_oversampling_ratio_set(st->back, 0, dec_rate); > + if (ret) > + return ret; > + > + st->sample_frequency = DIV_ROUND_CLOSEST_ULL(st->ref_frequency, dec_rate); > + > + return 0; > +} > + > +static int ad7405_read_raw(struct iio_dev *indio_dev, > + const struct iio_chan_spec *chan, int *val, > + int *val2, long info) > +{ > + struct ad7405_state *st = iio_priv(indio_dev); > + > + switch (info) { This is missing an implementation for IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_OFFSET. > + case IIO_CHAN_INFO_SAMP_FREQ: > + *val = st->sample_frequency; > + return IIO_VAL_INT; > + default: > + return -EINVAL; > + } > +} > + > +static int ad7405_write_raw(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, int val, > + int val2, long info) > +{ > + switch (info) { > + case IIO_CHAN_INFO_SAMP_FREQ: > + if (val < 1) > + return -EINVAL; > + return ad7405_set_sampling_rate(indio_dev, chan, val); > + default: > + return -EINVAL; > + } > +} > + > +static int ad7405_read_avail(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, > + const int **vals, int *type, int *length, > + long info) > +{ > + struct ad7405_state *st = iio_priv(indio_dev); > + > + switch (info) { > + case IIO_CHAN_INFO_SAMP_FREQ: > + *vals = st->sample_frequency_tbl; > + *length = ARRAY_SIZE(st->sample_frequency_tbl); > + *type = IIO_VAL_INT; > + return IIO_AVAIL_LIST; > + default: > + return -EINVAL; > + } > +} > + > +static void ad7405_clk_disable_unprepare(void *clk) > +{ > + clk_disable_unprepare(clk); > +} > + > +static const struct iio_info ad7405_iio_info = { > + .read_raw = &ad7405_read_raw, > + .write_raw = &ad7405_write_raw, > + .read_avail = &ad7405_read_avail, > +}; > + > +#define AD7405_IIO_CHANNEL { \ > + .type = IIO_VOLTAGE, \ > + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ Would it make more sense to use IIO_CHAN_INFO_OVERSAMPLING_RATIO for controlling the decimation rate and have IIO_CHAN_INFO_SAMP_FREQ be read-only? Maybe also useful to have a read-only filter_type attribute to say that the backend is providing a sinc3 filter? > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ > + BIT(IIO_CHAN_INFO_OFFSET), \ > + .indexed = 1, \ > + .channel = 0, \ > + .channel2 = 1, \ > + .differential = 1, \ > + .scan_index = 0, \ > + .scan_type = { \ > + .sign = 'u', \ > + .realbits = 16, \ > + .storagebits = 16, \ > + }, \ > +} > + > +static const struct ad7405_chip_info ad7405_chip_info = { > + .name = "AD7405", > + .channel = { > + AD7405_IIO_CHANNEL, > + }, > +}; > + > +static const struct ad7405_chip_info adum7701_chip_info = { > + .name = "ADUM7701", > + .channel = { > + AD7405_IIO_CHANNEL, > + }, > +}; > + > +static const char * const ad7405_power_supplies[] = { > + "vdd1", "vdd2", > +}; > + > +static int ad7405_probe(struct platform_device *pdev) > +{ > + const struct ad7405_chip_info *chip_info; > + struct device *dev = &pdev->dev; > + struct iio_dev *indio_dev; > + struct ad7405_state *st; > + struct clk *clk; > + int ret; > + > + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); > + if (!indio_dev) > + return -ENOMEM; > + > + st = iio_priv(indio_dev); > + > + ret = devm_mutex_init(dev, &st->lock); > + if (ret) > + return ret; > + > + chip_info = device_get_match_data(dev); > + if (!chip_info) > + return dev_err_probe(dev, -EINVAL, "no chip info\n"); > + > + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad7405_power_supplies), > + ad7405_power_supplies); > + > + if (ret) > + return dev_err_probe(dev, ret, "failed to get and enable supplies"); > + > + clk = devm_clk_get_enabled(dev, NULL); > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > + > + ret = devm_add_action_or_reset(dev, ad7405_clk_disable_unprepare, clk); devm_clk_get_enabled() already make sure the clock is disabled when the dirver is removed, so this is not needed. > + if (ret) > + return ret; > + > + st->ref_frequency = clk_get_rate(clk); > + if (!(st->ref_frequency)) Inner () not needed. > + return -EINVAL; > + > + ad7405_fill_samp_freq_table(st); > + > + indio_dev->dev.parent = dev; > + indio_dev->name = chip_info->name; > + indio_dev->channels = chip_info->channel; > + indio_dev->num_channels = 1; > + indio_dev->info = &ad7405_iio_info; > + > + st->back = devm_iio_backend_get(dev, NULL); > + if (IS_ERR(st->back)) > + return dev_err_probe(dev, PTR_ERR(st->back), > + "failed to get IIO backend"); > + > + ret = iio_backend_chan_enable(st->back, 0); > + if (ret) > + return ret; > + > + ret = devm_iio_backend_request_buffer(dev, st->back, indio_dev); > + if (ret) > + return ret; > + > + ret = devm_iio_backend_enable(dev, st->back); > + if (ret) > + return ret; > + > + ret = ad7405_set_sampling_rate(indio_dev, &indio_dev->channels[0], > + chip_info->max_rate); max_rate is never set, so will always be 0. > + if (ret) > + return ret; > + > + return devm_iio_device_register(dev, indio_dev); > +} > + > +/* Match table for of_platform binding */ > +static const struct of_device_id ad7405_of_match[] = { > + { .compatible = "adi,ad7405", .data = &ad7405_chip_info, }, > + { .compatible = "adi,adum7701", .data = &adum7701_chip_info, }, > + { .compatible = "adi,adum7702", .data = &adum7701_chip_info, }, > + { .compatible = "adi,adum7703", .data = &adum7701_chip_info, }, > + { /* end of list */ }, { } We standardized on this style in the IIO subsystem. > +}; > +MODULE_DEVICE_TABLE(of, ad7405_of_match); > + > +static struct platform_driver ad7405_driver = { > + .driver = { > + .name = "ad7405", > + .owner = THIS_MODULE, > + .of_match_table = ad7405_of_match, > + }, > + .probe = ad7405_probe, > +}; > +module_platform_driver(ad7405_driver); > + > +MODULE_AUTHOR("Dragos Bogdan <dragos.bogdan@analog.com>"); > +MODULE_AUTHOR("Pop Ioan Daniel <pop.ioan-daniel@analog.com>"); > +MODULE_DESCRIPTION("Analog Devices AD7405 driver"); > +MODULE_LICENSE("GPL"); > +MODULE_IMPORT_NS("IIO_BACKEND"); ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver 2025-05-08 17:08 ` David Lechner @ 2025-05-11 14:45 ` Jonathan Cameron 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Cameron @ 2025-05-11 14:45 UTC (permalink / raw) To: David Lechner Cc: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Matteo Martelli, linux-iio, devicetree, linux-kernel > > + > > +static const struct iio_info ad7405_iio_info = { > > + .read_raw = &ad7405_read_raw, > > + .write_raw = &ad7405_write_raw, > > + .read_avail = &ad7405_read_avail, > > +}; > > + > > +#define AD7405_IIO_CHANNEL { \ > > + .type = IIO_VOLTAGE, \ > > + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > > + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > > Would it make more sense to use IIO_CHAN_INFO_OVERSAMPLING_RATIO for controlling > the decimation rate and have IIO_CHAN_INFO_SAMP_FREQ be read-only? My initial reaction to this was that we'd be not providing one of the longest standing and user friendly(ish) interfaces. However if it literally only affects oversampling then indeed I think oversampling is the more informative interface. Which is to say I started writing no then thought some more and ended up agreeing with you ;) As you say, a read only sampling frequency is fine. We use those when it's controlled by some outside factor (like a clock frequency) so userspace should in theory at least cope fine with that being RO. > Maybe also useful to have a read-only filter_type attribute to say that the > backend is providing a sinc3 filter? Nice to have perhaps. J ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel 2025-05-08 17:08 ` David Lechner @ 2025-05-09 11:45 ` kernel test robot 2025-05-11 15:02 ` Jonathan Cameron 2 siblings, 0 replies; 16+ messages in thread From: kernel test robot @ 2025-05-09 11:45 UTC (permalink / raw) To: Pop Ioan Daniel, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Matteo Martelli, linux-iio, devicetree, linux-kernel Cc: oe-kbuild-all Hi Pop, kernel test robot noticed the following build warnings: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on linus/master v6.15-rc5 next-20250508] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Pop-Ioan-Daniel/iio-backend-update-iio_backend_oversampling_ratio_set/20250508-203339 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20250508123107.3797042-5-pop.ioan-daniel%40analog.com patch subject: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver config: m68k-randconfig-r123-20250509 (https://download.01.org/0day-ci/archive/20250509/202505091958.k0P7xNyC-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 13.3.0 reproduce: (https://download.01.org/0day-ci/archive/20250509/202505091958.k0P7xNyC-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202505091958.k0P7xNyC-lkp@intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/iio/adc/ad7405.c:19:20: sparse: sparse: symbol 'ad7405_dec_rates' was not declared. Should it be static? vim +/ad7405_dec_rates +19 drivers/iio/adc/ad7405.c 18 > 19 const unsigned int ad7405_dec_rates[] = { 20 4096, 2048, 1024, 512, 256, 128, 64, 32, 21 }; 22 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel 2025-05-08 17:08 ` David Lechner 2025-05-09 11:45 ` kernel test robot @ 2025-05-11 15:02 ` Jonathan Cameron 2 siblings, 0 replies; 16+ messages in thread From: Jonathan Cameron @ 2025-05-11 15:02 UTC (permalink / raw) To: Pop Ioan Daniel Cc: Lars-Peter Clausen, Michael Hennerich, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sergiu Cuciurean, Dragos Bogdan, Antoniu Miclaus, Olivier Moysan, Javier Carrasco, Matti Vaittinen, Tobias Sperling, Alisa-Dariana Roman, Marcelo Schmitt, Matteo Martelli, linux-iio, devicetree, linux-kernel On Thu, 8 May 2025 15:30:57 +0300 Pop Ioan Daniel <pop.ioan-daniel@analog.com> wrote: > Add support for the AD7405/ADUM770x, a high performance isolated ADC, > 1-channel, 16-bit with a second-order Σ-Δ modulator that converts an > analog input signal into a high speed, single-bit data stream. > > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> Hi, Just a few comments inline. In particular I'd avoid the gcc specific behaviour unless we have it documented somewhere in the kernel that static flexible array instantiation is allowed. Doesn't make sense here anyway just make it 1 element. Jonathan > diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c > new file mode 100644 > index 000000000000..5fe36ce61819 > --- /dev/null > +++ b/drivers/iio/adc/ad7405.c > @@ -0,0 +1,264 @@ > + > +struct ad7405_chip_info { > + const char *name; > + unsigned int max_rate; > + struct iio_chan_spec channel[]; See below. > +}; > +static int ad7405_read_avail(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, > + const int **vals, int *type, int *length, > + long info) > +{ > + struct ad7405_state *st = iio_priv(indio_dev); > + > + switch (info) { > + case IIO_CHAN_INFO_SAMP_FREQ: > + *vals = st->sample_frequency_tbl; 1 tab only. > + *length = ARRAY_SIZE(st->sample_frequency_tbl); > + *type = IIO_VAL_INT; > + return IIO_AVAIL_LIST; > + default: > + return -EINVAL; > + } > +} > + > +static const struct ad7405_chip_info ad7405_chip_info = { > + .name = "AD7405", > + .channel = { > + AD7405_IIO_CHANNEL, > + }, > +}; > + > +static const struct ad7405_chip_info adum7701_chip_info = { > + .name = "ADUM7701", Convention here is 1 tab indent only. > + .channel = { This will look nicer without the array of 1 thing going on. Interesting corner of the c spec to use a flexible array member for this. Definitely don't do that as I hate reading that spec to check corners like this. On this occasion I looked and could not find an answer. There is a gcc extension that makes this work though. > + AD7405_IIO_CHANNEL, > + }, > +}; ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-05-11 15:02 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-08 12:30 [PATCH v2 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel 2025-05-08 12:30 ` [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel 2025-05-08 16:41 ` David Lechner 2025-05-09 10:10 ` kernel test robot 2025-05-09 10:21 ` kernel test robot 2025-05-09 18:03 ` kernel test robot 2025-05-08 12:30 ` [PATCH v2 2/4] iio: adc: adi-axi-adc: add set decimation rate Pop Ioan Daniel 2025-05-08 16:45 ` David Lechner 2025-05-08 12:30 ` [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel 2025-05-08 14:41 ` Conor Dooley 2025-05-09 13:45 ` Rob Herring (Arm) 2025-05-08 12:30 ` [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel 2025-05-08 17:08 ` David Lechner 2025-05-11 14:45 ` Jonathan Cameron 2025-05-09 11:45 ` kernel test robot 2025-05-11 15:02 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox