aboutsummaryrefslogtreecommitdiff
path: root/drivers/iio/adc
AgeCommit message (Collapse)AuthorFilesLines
2024-10-24iio: adc: ad7124: fix division by zero in ad7124_set_channel_odr()Zicheng Qu1-1/+1
In the ad7124_write_raw() function, parameter val can potentially be zero. This may lead to a division by zero when DIV_ROUND_CLOSEST() is called within ad7124_set_channel_odr(). The ad7124_write_raw() function is invoked through the sequence: iio_write_channel_raw() -> iio_write_channel_attribute() -> iio_channel_write(), with no checks in place to ensure val is non-zero. Cc: [email protected] Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels") Signed-off-by: Zicheng Qu <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-24iio: adc: ad7380: fix supplies for ad7380-4Julien Stephan1-10/+26
ad7380-4 is the only device in the family that does not have an internal reference. It uses "refin" as a required external reference. All other devices in the family use "refio"" as an optional external reference. Fixes: 737413da8704 ("iio: adc: ad7380: add support for ad738x-4 4 channels variants") Reviewed-by: Nuno Sa <[email protected]> Reviewed-by: David Lechner <[email protected]> Signed-off-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-24iio: adc: ad7380: add missing suppliesJulien Stephan1-0/+43
vcc and vlogic are required but are not retrieved and enabled in the probe. Add them. In order to prepare support for additional parts requiring different supplies, add vcc and vlogic to the platform specific structures Reviewed-by: Nuno Sa <[email protected]> Reviewed-by: David Lechner <[email protected]> Signed-off-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-24iio: adc: ad7380: use devm_regulator_get_enable_read_voltage()Julien Stephan1-60/+21
Use devm_regulator_get_enable_read_voltage() to simplify the code. Reviewed-by: Nuno Sa <[email protected]> Reviewed-by: David Lechner <[email protected]> Signed-off-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-13Merge tag 'iio-fixes-for-6.12a' of ↵Greg Kroah-Hartman1-0/+11
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus Jonathan writes: IIO: 1st set of fixes for the 6.12 cycle. Most of this pull request is the result of Javier Carrasco doing a careful audit for missing Kconfig dependencies that luck has meant the random builds have never hit. The rest is the usual mix of old bugs that have surfaced and some fallout from the recent merge window. adi,ad5686 - Fix binding duplication of compatible strings. bosch,bma400 - Fix an uninitialized variable in the event tap handling. bosch,bmi323 - Fix several issues in the register saving and restore on suspend/resume sensiron,spd500 - Fix missing CRC8 dependency ti,op3001 - Fix a missing full-scale range value (values above this point were all reported wrongly) vishay,veml6030 - Fix a segmentation fault due to some type confusion. - Fix wrong ambient light sensor resolution. * tag 'iio-fixes-for-6.12a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (34 commits) iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig iio: frequency: {admv4420,adrf6780}: format Kconfig entries iio: adc: ad4695: Add missing Kconfig select iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency() iioc: dac: ltc2664: Fix span variable usage in ltc2664_channel_config() iio: dac: stm32-dac-core: add missing select REGMAP_MMIO in Kconfig iio: dac: ltc1660: add missing select REGMAP_SPI in Kconfig iio: dac: ad5770r: add missing select REGMAP_SPI in Kconfig iio: amplifiers: ada4250: add missing select REGMAP_SPI in Kconfig iio: frequency: adf4377: add missing select REMAP_SPI in Kconfig iio: resolver: ad2s1210: add missing select (TRIGGERED_)BUFFER in Kconfig iio: resolver: ad2s1210 add missing select REGMAP in Kconfig iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: pressure: bm1390: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: magnetometer: af8133j: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: light: bu27008: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: chemical: ens160: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad5766: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad3552r: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig ...
2024-10-10iio: adc: ad4695: Add missing Kconfig selectDavid Lechner1-0/+2
Add select IIO_BUFFER and select IIO_TRIGGERED_BUFFER to the Kconfig for the ad4695 driver. Fixes: 6cc7e4bf2e08 ("iio: adc: ad4695: implement triggered buffer") Signed-off-by: David Lechner <[email protected]> Reviewed-by: Javier Carrasco <[email protected]> Link: https://patch.msgid.link/20241009-iio-adc-ad4695-fix-kconfig-v1-1-e2a4dfde8d55@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-10iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in KconfigJavier Carrasco1-0/+2
This driver makes use of triggered buffers, but does not select the required modules. Fixes: 2a86487786b5 ("iio: adc: ti-ads8688: add trigger and buffer support") Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'. Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Sean Nyekjaer <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-06iio: adc: ti-lmp92064: add missing select IIO_(TRIGGERED_)BUFFER in KconfigJavier Carrasco1-0/+2
This driver makes use of triggered buffers, but does not select the required modules. Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'. Fixes: 6c7bc1d27bb2 ("iio: adc: ti-lmp92064: add buffering support") Signed-off-by: Javier Carrasco <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-06iio: adc: ti-lmp92064: add missing select REGMAP_SPI in KconfigJavier Carrasco1-0/+1
This driver makes use of regmap_spi, but does not select the required module. Add the missing 'select REGMAP_SPI'. Fixes: 627198942641 ("iio: adc: add ADC driver for the TI LMP92064 controller") Signed-off-by: Javier Carrasco <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-06iio: adc: ti-ads124s08: add missing select IIO_(TRIGGERED_)BUFFER in KconfigJavier Carrasco1-0/+2
This driver makes use of triggered buffers, but does not select the required modules. Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'. Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code") Signed-off-by: Javier Carrasco <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-06iio: adc: ad7944: add missing select IIO_(TRIGGERED_)BUFFER in KconfigJavier Carrasco1-0/+2
This driver makes use of triggered buffers, but does not select the required modules. Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'. Fixes: d1efcf8871db ("iio: adc: ad7944: add driver for AD7944/AD7985/AD7986") Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro17-17/+17
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-09-09Merge 6.11-rc7 into char-misc-nextGreg Kroah-Hartman7-52/+73
We need the char-misc fixes in here as well. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2024-09-07iio: adc: axp20x_adc: add support for AXP717 ADCChris Morgan1-0/+160
Add support for the AXP717 ADC. The AXP717 differs from other ADCs in this series by utilizing a 14 bit ADC for all channels (a full 16 bits with the first 2 digits reserved). It also differs by lacking a battery discharge current channel. Note that while the current charge channel itself is included in this driver for the AXP717 and listed in the datasheet, no scale or offset was given for this channel. For now no scale or offset is provided in this driver. Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Chris Morgan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-07iio: adc: axp20x_adc: Add adc_en1 and adc_en2 to axp_dataChris Morgan1-7/+15
Add the register for adc_en1 and adc_en2 to the axp_data struct. This allows us to specify a different register to enable the adc channels for different devices such as the AXP717. Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Chris Morgan <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-05iio: adc: standardize on formatting for id match tablesJonathan Cameron64-169/+169
This is a frequent minor comment in reviews, so start cleaning up existing drivers in the hope we get fewer cases of cut and paste. There are not kernel wide rules for these, but for IIO the style that I prefer (and hence most common) is: - Space after { and before } - No comma after terminator { } This may cause merge conflicts but they should be trivial to resolve hence I have not broken this into per driver patches. Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-03iio: adc: sophgo-saradc: Add driver for Sophgo CV1800B SARADCThomas Bonnefille3-0/+238
This adds a driver for the Sophgo CV1800B SARADC. Signed-off-by: Thomas Bonnefille <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-03iio: adc: mcp320x: Drop vendorless compatible stringsRob Herring (Arm)1-10/+0
The vendorless compatible strings are deprecated and weren't retained when the binding was converted to schema. As a result, they are listed as undocumented when running "make dt_compatible_check". Rather than add them back to the schema, let's just drop them as they are unnecessary. Furthermore, they are unnecessary as the SPI matching will strip the vendor prefix on compatible string and match that against the spi_device_id table. Signed-off-by: Rob Herring (Arm) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-03iio: adc: xilinx-ams: use device_* to iterate over device child nodesJavier Carrasco1-10/+5
Use `device_for_each_child_node_scoped()` in `ams_parse_firmware()` to explicitly state device child node access, and simplify the child node handling as it is not required outside the loop. Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Mike Leach <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-03iio: adc: ad4695: implement calibration supportDavid Lechner1-2/+156
The AD4695 has a calibration feature that allows the user to compensate for variations in the analog front end. This implements this feature in the driver using the standard `calibgain` and `calibbias` attributes. Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-09-03iio: adc: ad4695: add 2nd regmap for 16-bit registersDavid Lechner1-15/+68
The AD4695 and similar chips have some multibyte registers that have to be read/written in a single operation. So we need to add a 2nd regmap for these registers. These registers are removed from the 8-bit regmap allowable ranges and AD4695_MAX_REG is dropped since it would be ambiguous now. debugfs register access is also updated to automatically use the correct regmap depending on the register address. Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-17iio: adc: ad4695: implement triggered bufferDavid Lechner1-3/+247
This implements buffered reads for the ad4695 driver using the typical triggered buffer implementation, including adding a soft timestamp channel. The chip has 4 different modes for doing conversions. The driver is using the advanced sequencer mode since that is the only mode that allows individual configuration of all aspects each channel (e.g. bipolar config currently and oversampling to be added in the future). Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20240813-iio-adc-ad4695-buffered-read-v2-1-9bb19fc1924b@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-17iio: adc: ad7173: fix GPIO device infoDumitru Ceclan1-3/+0
Models AD4114/5/6 have .higher_gpio_bits = true. This is not correct as the only models that have the GPIO bits to a higher position are AD4111/2. Fix by removing the higher_gpio_bits = true from the AD4114/5/6 models. Fixes: 13d12e3ad12d ("iio: adc: ad7173: Add support for AD411x devices") Signed-off-by: Dumitru Ceclan <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-10iio: adc: pac1921: add missing error return in probe()Dan Carpenter1-2/+2
This error path was intended to return, and not just print an error. The current code will lead to an error pointer dereference. Fixes: 371f778b83cd ("iio: adc: add support for pac1921") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Matteo Martelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-10iio: adc: stm32-dfsdm: add scaling support to dfsdmOlivier Moysan2-1/+105
Add scaling support to STM32 DFSDM. When used in an analog context, a DFSDM filter typically converts the data from a sigma delta modulator. The IIO device associated to the DFSDM filter provides these data as raw data. The IIO device can provide scaling information (voltage and offset) to allow conversion of raw data into physical values. With the new binding based on IIO backend framework, the sigma delta modulators are defined as backends providing scaling information. The scaling is not supported with legacy binding. Signed-off-by: Olivier Moysan <[email protected]> Acked-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-10iio: add iio backend support to sd modulatorOlivier Moysan2-1/+97
The legacy sd modulator driver registers the sigma delta modulator as an IIO channel provider. This implementation is not convenient when the SD modulator has to be cascaded with another IIO device. The scaling information is distributed across devices, which makes it difficult to report consistent scaling data on IIO devices. The solution is to expose these cascaded IIO devices as an aggregate device, which report global scaling information. Add IIO backend support to SD modulator to allow scaling information management. Signed-off-by: Olivier Moysan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-10iio: adc: stm32-dfsdm: adopt generic channels bindingsOlivier Moysan1-36/+154
Move to generic channels binding to ease new backend framework adoption and prepare the convergence with MDF IP support on STM32MP2 SoC family. Legacy binding: DFSDM is an IIO channel consumer. SD modulator is an IIO channels provider. The channel phandles are provided in DT through io-channels property and channel indexes through st,adc-channels property. New binding: DFSDM is an IIO channel provider. The channel indexes are given by reg property in channel child node. This new binding is intended to be used with SD modulator IIO backends. It does not support SD modulator legacy IIO devices. The st,adc-channels property presence is used to discriminate between legacy and backend bindings. The support of the DFSDM legacy channels and SD modulator IIO devices is kept for backward compatibility. Signed-off-by: Olivier Moysan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-06iio: adc: ad7124: fix DT configuration parsingDumitru Ceclan1-2/+1
The cfg pointer is set before reading the channel number that the configuration should point to. This causes configurations to be shifted by one channel. For example setting bipolar to the first channel defined in the DT will cause bipolar mode to be active on the second defined channel. Fix by moving the cfg pointer setting after reading the channel number. Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels") Signed-off-by: Dumitru Ceclan <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-06iio: adc: ad_sigma_delta: fix irq_flags on irq requestNuno Sa1-1/+1
With commit 7b0c9f8fa3d2 ("iio: adc: ad_sigma_delta: Add optional irq selection"), we can get the irq line from struct ad_sigma_delta_info instead of the spi device. However, in devm_ad_sd_probe_trigger(), when getting the irq_flags with irq_get_trigger_type() we are still using the spi device irq instead of the one used for devm_request_irq(). Fixes: 7b0c9f8fa3d2 ("iio: adc: ad_sigma_delta: Add optional irq selection") Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ads1119: Fix IRQ flagsFrancesco Dolcini1-1/+1
Remove IRQF_TRIGGER_FALLING flag from irq request, this should come from the platform firmware and should not be hard-coded into the driver. Add IRQF_ONESHOT flag to the irq request, the interrupt should not be re-activated in interrupt context, it should be done only after the device irq handler run. Fixes: a9306887eba4 ("iio: adc: ti-ads1119: Add driver") Signed-off-by: Francesco Dolcini <[email protected]> Reviwed-by: João Paulo Gonçalves <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7124: set initial ADC mode to idleDumitru Ceclan1-0/+3
During setup the st->adc_control is 0, which corresponds to a continuous conversion mode. The reset value for channel 1 is to enable it. The combined effect of these two is that the ADC will start conversions for channel 1 without them being read. This is not neccessarily a problem, but it is an unexpected behavior. Set the ADC state to idle during setup to avoid this. Signed-off-by: Dumitru Ceclan <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7124: reduce the number of SPI transfersDumitru Ceclan1-19/+12
The ad7124_init_config_vref() function writes the AD7124_ADC_CONTROL register for each channel that is configured to use the internal reference. The ad7124_write_config()function performs 7 SPI transfers for configuring 2 registers: config_x and filter_x. Reduce the number of SPI transfers: -during the probe by only setting the st->adc_control value in ad7124_init_config_vref() and writing to the device only at the end of ad7124_setup(). -in ad7124_write_config() by grouping writes to the same register. Signed-off-by: Dumitru Ceclan <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7124: fix config comparisonDumitru Ceclan1-11/+15
The ad7124_find_similar_live_cfg() computes the compare size by substracting the address of the cfg struct from the address of the live field. Because the live field is the first field in the struct, the result is 0. Also, the memcmp() call is made from the start of the cfg struct, which includes the live and cfg_slot fields, which are not relevant for the comparison. Fix by grouping the relevant fields with struct_group() and use the size of the group to compute the compare size; make the memcmp() call from the address of the group. Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels") Signed-off-by: Dumitru Ceclan <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7124: fix chip ID mismatchDumitru Ceclan1-0/+1
The ad7124_soft_reset() function has the assumption that the chip will assert the "power-on reset" bit in the STATUS register after a software reset without any delay. The POR bit =0 is used to check if the chip initialization is done. A chip ID mismatch probe error appears intermittently when the probe continues too soon and the ID register does not contain the expected value. Fix by adding a 200us delay after the software reset command is issued. Fixes: b3af341bbd96 ("iio: adc: Add ad7124 support") Signed-off-by: Dumitru Ceclan <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad9467: add digital interface test to debugfsNuno Sa1-0/+188
One useful thing to do (in case of problems) in this high speed devices with digital interfaces is to try different test patterns to see if the interface is working properly (and properly calibrated). Hence add this to debugfs. On top of this, for some test patterns, the backend may have a matching validator block which can be helpful in identifying possible issues. For the other patterns some test equipment must be used so one can look into the signal and see how it looks like. Hence, we also add the backend debugfs interface with iio_backend_debugfs_add(). Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-8-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad9467: add backend test mode helpersNuno Sa1-25/+42
Group the backend configurations to be done in preparing and stopping calibration in two new helpers analogous to ad9467_testmode_set(). This is in preparation for adding support for debugFS test_mode where we need similar configurations as in the calibration process. Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-7-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: adi-axi-adc: implement backend debugfs interfaceNuno Sa1-0/+41
Implement debugfs options to read/write registers and print the channel status into a buffer (so we may know better the cause for errors) . Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-6-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: adi-axi-adc: split axi_adc_chan_status()Nuno Sa1-5/+14
Add a new axi_adc_read_chan_status() helper so we get the raw register value out of it. This is in preparation of a future change where we really want to look into dedicated bits of the register. Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-5-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: adi-axi-adc: support modified prbs23Nuno Sa1-0/+4
Add support for configuring the prbs23 sequence. Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-4-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: backend: introduce struct iio_backend_infoNuno Sa1-1/+6
Instead of only passing the backend ops when calling devm_iio_backend_register(), pass an info like structure that will contains the ops and additional information. Fow now, the backend name is being added as that will be used by the debugFS interface introduced in a later patch. It also opens the door for further customizations passed by backends. All users of devm_iio_backend_register() were updated accordingly. Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-1-4cb62852f0d0@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: aspeed: Use of_property_present()Rob Herring (Arm)1-2/+1
Use of_property_present() to test for property presence rather than of_find_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_find_property() leaks the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) <[email protected]> Acked-by: Andrew Jeffery <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7768-1: use device_* to iterate over device child nodesJavier Carrasco1-4/+1
Drop the manual access to the fwnode of the device to iterate over its child nodes. `device_for_each_child_node` macro provides direct access to the child nodes, and given that they are only required within the loop, the scoped variant of the macro can be used. Use the `device_for_each_child_node_scoped` macro to iterate over the direct child nodes of the device. Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7380: enable sequencer for single-ended partsJulien Stephan1-45/+130
ad7386/7/8(-4) single-ended parts have a 2:1 mux in front of each ADC. >From an IIO point of view, all inputs are exported, i.e ad7386/7/8 export 4 channels and ad7386-4/7-4/8-4 export 8 channels. First inputs of muxes correspond to the first half of IIO channels (i.e 0-1 or 0-3) and second inputs correspond to second half (i.e 2-3 or 4-7) Currently, the driver supports only sampling first half OR second half of the IIO channels. To enable sampling all channels simultaneously, these parts have an internal sequencer that automatically cycles through the mux entries. When enabled, the maximum throughput is divided by two. Moreover, the ADCs need additional settling time, so we add an extra CS toggle to correctly propagate setting, and an additional spi transfer to read the second half. Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20240731-ad7380-add-single-ended-chips-v2-6-cd63bf05744c@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7380: add support for single-ended partsJulien Stephan1-42/+309
Adding ad7386/7/8 (16/14/12 bits) unsigned, dual simultaneous sampling, single-ended compatible parts, and the corresponding ad7386-4/7-4/8-4 4 channels. These parts have a 2:1 multiplexer in front of each ADC. They also include additional configuration registers that allow for either manual selection or automatic switching (sequencer mode), of the multiplexer inputs. This commit focus on integrating manual selection. Sequencer mode will be implemented later. >From an IIO point of view, all inputs are exported, i.e ad7386/7/8 export 4 channels and ad7386-4/7-4/8-4 export 8 channels. Inputs AinX0 of multiplexers correspond to the first half of IIO channels (i.e 0-1 or 0-3) and inputs AinX1 correspond to second half (i.e 2-3 or 4-7). Example for AD7386/7/8 (2 channels parts): IIO | AD7386/7/8 | +---------------------------- | | _____ ______ | | | | | | voltage0 | AinA0 --|--->| | | | | | | mux |----->| ADCA |--- voltage2 | AinA1 --|--->| | | | | | |_____| |_____ | | | _____ ______ | | | | | | voltage1 | AinB0 --|--->| | | | | | | mux |----->| ADCB |--- voltage3 | AinB1 --|--->| | | | | | |_____| |______| | | | +---------------------------- When switching channel, the ADC require an additional settling time. According to the datasheet, data is valid on the third CS low. We already have an extra toggle before each read (either direct reads or buffered reads) to sample correct data, so we just add a single CS toggle at the end of the register write. Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20240731-ad7380-add-single-ended-chips-v2-5-cd63bf05744c@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7380: prepare driver for single-ended parts supportJulien Stephan1-1/+10
ad738x family contains single-ended parts that have a 2:1 mux in front of ADC, so the number of IIO channels is different from the number of simultaneous channels that can be sampled. To prepare the support for single-ended parts, introduce a new num_simultaneous_channels variable. For currently supported parts, num_simultaneous_channels is equal to num_channels minus 1 (the timestamps channel) Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20240731-ad7380-add-single-ended-chips-v2-4-cd63bf05744c@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ad7380: add missing trailing commasJulien Stephan1-4/+4
Add missing trailing commas in iio_scan_type structures Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20240731-ad7380-add-single-ended-chips-v2-3-cd63bf05744c@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: Add support for AD4000Marcelo Schmitt3-0/+735
Add support for AD4000 series of low noise, low power, high speed, successive approximation register (SAR) ADCs. Reviewed-by: Nuno Sa <[email protected]> Reviewed-by: David Lechner <[email protected]> Signed-off-by: Marcelo Schmitt <[email protected]> Link: https://patch.msgid.link/356109ac61182f16f2379d5d0cadccfe017f505b.1720810545.git.marcelo.schmitt@analog.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: ti-tsc2046: use devm_regulator_get_enable_read_voltage()David Lechner1-47/+7
Use devm_regulator_get_enable_read_voltage() to replace tsc2046_adc_configure_regulator() which does the same thing. Signed-off-by: David Lechner <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/20240725-iio-regulator-refactor-round-4-v1-1-55e9dc1de325@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: add support for pac1921Matteo Martelli3-0/+1275
Add support for Microchip PAC1921 Power/Current monitor. Implemented features: * capture of bus voltage, sense voltage, current and power measurements in free-run integration mode * support for both raw and triggered buffer reading * support for overflow events * scale attributes to control voltage and current gains * oversampling ratio attribute to control the number of integration samples * sampling rate attribute that reflects the integration period * userspace attribute and DT parameter to control shunt resistor * simple power management support Limitations: * operation mode fixed to free-run integration * READ/INT pin and OUT pin not supported * no controls for measurement resolutions and filters Signed-off-by: Matteo Martelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
2024-08-03iio: adc: mcp3564: use devm_regulator_get_enable_read_voltage()David Lechner1-38/+16
This makes use of the new devm_regulator_get_enable_read_voltage() helper function to reduce boilerplate code in the MCP3564 ADC driver. The error message is slightly changed since there are fewer error return paths. Setting adc->vref_mv is consolidated into a single place to make the logic easier to follow. A use_internal_vref_attr local variable is added to make it more obvious what the difference between the two iio info structures is. The return value of the "Unknown Vref" dev_err_probe() is hard-coded to -ENODEV instead of ret since it was getting a bit far from where ret was set and logically that is the only value it could have. Signed-off-by: David Lechner <[email protected]> Reviewed-by: Marius Cristea <[email protected]> Link: https://patch.msgid.link/20240723-iio-regulator-refactor-round-3-v2-1-ae9291201785@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>