Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iio: adc: ad4695: add new regmap callbacks, timing improvements
@ 2024-11-13 20:52 Trevor Gamblin
  2024-11-13 20:52 ` [PATCH v2 1/3] iio: adc: ad4695: fix buffered read, single sample timings Trevor Gamblin
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Trevor Gamblin @ 2024-11-13 20:52 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
	David Lechner, Jonathan Cameron
  Cc: Jonathan Cameron, linux-iio, linux-kernel, Trevor Gamblin

The AD4695 driver currently operates all SPI reads/writes at the speed
appropriate for register access, rather than the max rate for the bus.
Data reads should ideally operate at the latter speed, but making this
change universally makes it possible for data to be corrupted during use
and for unexpected behavior to occur on driver subsequent driver
binds/unbinds. To solve this, introduce custom regmap bus callbacks for
the driver that explicitly set a lower speed only for these operations.

The first patch in this series is a fix introduced after discovering the
corresponding issue during testing of the callbacks. This is a timing
fix that ensures the AD4695 datasheet's timing specs are met, as before
the busy signal would sometimes fail to toggle again following the end
of the conversion sequence. Adding an extra delay in the form of a blank
transfer before every CS deassert in ad4695_buffer_preenable() allows
this requirement to be met. The patch also makes similar changes in
ad4695_read_one_sample() (while also tidying that function somewhat) to
make sure that single reads are still functional with the regmap change.

The second patch is an improvement that increases the robustness of the
exit message in ad4695_exit_conversion_mode(), this time by adding a
delay before the actual exit command. This helps avoid the possibility
that the exit message will be read as data, causing corruption on some
buffered reads.

For additional context, see:
https://lore.kernel.org/linux-iio/20241028163907.00007e12@Huawei.com/

Suggested-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
Changes in v2:
- Link to v1: https://lore.kernel.org/r/20241111-tgamblin-ad4695_improvements-v1-0-698af4512635@baylibre.com

  [PATCH 1/3]
  - Fix bugs with transfer timings and sequencing in
    ad4695_buffer_preenable() and ad4695_read_one_sample() by adjusting
    xfer structs and simplifying
  - Add clearer comments explaining why the temperature channel is
    handled as-is with the advanced sequencer
  - Add David's Co-Developed-by tag

  [PATCH 2/3]
  - No change

  [PATCH 3/3]
  - Fix bug where ad4695_regmap_config was passed twice to
    devm_regmap_init() in ad4695_probe(), instead of passing
    ad4695_regmap_config once and ad4695_regmap16_config the second time

---
Trevor Gamblin (3):
      iio: adc: ad4695: fix buffered read, single sample timings
      iio: adc: ad4695: make ad4695_exit_conversion_mode() more robust
      iio: adc: ad4695: add custom regmap bus callbacks

 drivers/iio/adc/Kconfig  |   2 +-
 drivers/iio/adc/ad4695.c | 208 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 165 insertions(+), 45 deletions(-)
---
base-commit: 2d5404caa8c7bb5c4e0435f94b28834ae5456623
change-id: 20241111-tgamblin-ad4695_improvements-7a32a6268c26

Best regards,
-- 
Trevor Gamblin <tgamblin@baylibre.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-20  2:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 20:52 [PATCH v2 0/3] iio: adc: ad4695: add new regmap callbacks, timing improvements Trevor Gamblin
2024-11-13 20:52 ` [PATCH v2 1/3] iio: adc: ad4695: fix buffered read, single sample timings Trevor Gamblin
2024-11-24 12:52   ` Jonathan Cameron
2024-11-25 20:32     ` Trevor Gamblin
2024-11-13 20:52 ` [PATCH v2 2/3] iio: adc: ad4695: make ad4695_exit_conversion_mode() more robust Trevor Gamblin
2025-01-18 17:12   ` Jonathan Cameron
2025-01-20  2:46     ` Trevor Gamblin
2024-11-13 20:53 ` [PATCH v2 3/3] iio: adc: ad4695: add custom regmap bus callbacks Trevor Gamblin
2024-11-13 20:58 ` [PATCH v2 0/3] iio: adc: ad4695: add new regmap callbacks, timing improvements David Lechner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox