mbox series

[v2,0/8] iio: adc: ad_sigma_delta: Add sequencer support

Message ID 20220318162722.51215-1-alexandru.tachici@analog.com (mailing list archive)
Headers show
Series iio: adc: ad_sigma_delta: Add sequencer support | expand

Message

Alexandru Tachici March 18, 2022, 4:27 p.m. UTC
From: Alexandru Tachici <alexandru.tachici@analog.com>

Some sigma-delta chips support sampling of multiple
channels in continuous mode.

When the operating with more than one channel enabled,
the channel sequencer cycles through the enabled channels
in sequential order, from first channel to the last one.
If a channel is disabled, it is skipped by the sequencer.

If more than one channel is used in continuous mode,
instruct the device to append the status to the SPI transfer
(1 extra byte) every time we receive a sample.
All sigma-delta chips possessing a sampling sequencer have
this ability. Inside the status register there will be
the number of the converted channel. In this way, even
if the CPU won't keep up with the sampling rate, it won't
send to userspace wrong channel samples.

1. Removed the 1 byte .shift from channel spec in AD7124,
it confuses userspace apps (no need to shift right).

2. Add update_scan_mode to AD7124, it is required in order
to enable/disable multiple channels at once

3. Add update_scan_mode to AD7192, it is required in order
to enable/disable multiple channels at once

4. Add sequencer support for sigma_delta library.

5. Add sigma_delta_info values and callbacks for sequencer
support in AD7124.

6. Add sigma_delta_info values and callbacks for sequencer
support in AD7192.

7. Add disable_all() callback in AD7124 driver. Need this to
disable channels in ad_sd_buffer_postdisable.

8. Add disable_all() callback in AD7192 driver. Need this to
disable channels in ad_sd_buffer_postdisable.

Alexandru Tachici (8):
  iio: adc: ad7124: Remove shift from scan_type
  iio: adc: ad7124: Add update_scan_mode
  iio: adc: ad7192: Add update_scan_mode
  iio: adc: ad_sigma_delta: Add sequencer support
  iio: adc: ad7124: add sequencer support
  iio: adc: ad7192: add sequencer support
  iio: adc: ad7124: add disable_all() callback
  iio: adc: ad7192: add disable_all() callback

Changelog V1 -> V2:
  - changed commits descriptions
  - in ad_sd_buffer_postenable: switched from kzalloc to krealloc and added
  space for the timestamp too.
  - added a fast path that avoids the extra copies created during sample number tracking
  for scans with (active_slots == 1) in ad_sd_trigger_handler
  - in ad7192_update_scan_mode(), use for_each_set_bit() instead of a simple for()
  - in ad_sd_init(), initialize num_slots to 1 if set on 0.
  - added disable_all() callback in ad_sigma_delta_info that should disable all channels
  It is always called in ad_sd_buffer_postdisable
  - in ad_sd_buffer_postenable(), use ad_sigma_delta_set_channel() only for devices
  with only one sequencer slot. For the ones with .num_slots > 1, update_scan_mode
  will already have enabled the required channels
  - add checks in ad_sd_init() for disable_all() and update_scan_mode() when
  num_slots > 1 (these are needed for normal operation of the sequencer)
  - in ad7124_update_scan_mode call set_channel on each channel

 drivers/iio/adc/ad7124.c               |  62 +++++++++++-
 drivers/iio/adc/ad7192.c               |  40 +++++++-
 drivers/iio/adc/ad_sigma_delta.c       | 134 +++++++++++++++++++++++--
 include/linux/iio/adc/ad_sigma_delta.h |  33 ++++++
 4 files changed, 254 insertions(+), 15 deletions(-)

--
2.25.1