Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: iio: adc : Add ad4695 support #2433

Merged
merged 13 commits into from
Oct 21, 2024
Merged

drivers: iio: adc : Add ad4695 support #2433

merged 13 commits into from
Oct 21, 2024

Commits on Oct 17, 2024

  1. cleanup: Add conditional guard support

    Adds:
    
     - DEFINE_GUARD_COND() / DEFINE_LOCK_GUARD_1_COND() to extend existing
       guards with conditional lock primitives, eg. mutex_trylock(),
       mutex_lock_interruptible().
    
       nb. both primitives allow NULL 'locks', which cause the lock to
           fail (obviously).
    
     - extends scoped_guard() to not take the body when the the
       conditional guard 'fails'. eg.
    
         scoped_guard (mutex_intr, &task->signal_cred_guard_mutex) {
    	...
         }
    
       will only execute the body when the mutex is held.
    
     - provides scoped_cond_guard(name, fail, args...); which extends
       scoped_guard() to do fail when the lock-acquire fails.
    
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Link: https://lkml.kernel.org/r/20231102110706.460851167%40infradead.org
    Peter Zijlstra authored and RaduSabau1 committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    59073df View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2024

  1. iio: locking: introduce __cleanup() based direct mode claiming infras…

    …tructure
    
    Allows use of:
    
           iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
           }
    
    to automatically call iio_device_release_direct_mode() based on scope.
    Typically seen in combination with local device specific locks which
    are already have automated cleanup options via guard(mutex)(&st->lock)
    and scoped_guard(). Using both together allows most error handling to
    be automated.
    
    Reviewed-by: Nuno Sa <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Jonathan Cameron <[email protected]>
    jic23 authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    9f0a75d View commit details
    Browse the repository at this point in the history
  2. iio: introduce struct iio_scan_type

    This gives the channel scan_type a named type so that it can be used
    to simplify code in later commits.
    
    Signed-off-by: David Lechner <[email protected]>
    Reviewed-by: Nuno Sa <[email protected]>
    Link: https://lore.kernel.org/r/20240530-iio-add-support-for-multiple-scan-types-v3-1-cbc4acea2cfa@baylibre.com
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    85b1944 View commit details
    Browse the repository at this point in the history
  3. iio: buffer: use struct iio_scan_type to simplify code

    By using struct iio_scan_type, we can simplify the code by removing
    lots of duplicate pointer dereferences. This make the code a bit easier
    to read.
    
    This also prepares for a future where channels may have more than one
    scan_type.
    
    Signed-off-by: David Lechner <[email protected]>
    Reviewed-by: Nuno Sa <[email protected]>
    Link: https://lore.kernel.org/r/20240530-iio-add-support-for-multiple-scan-types-v3-2-cbc4acea2cfa@baylibre.com
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    6d550e4 View commit details
    Browse the repository at this point in the history
  4. iio: add support for multiple scan types per channel

    This adds new fields to the iio_channel structure to support multiple
    scan types per channel. This is useful for devices that support multiple
    resolution modes or other modes that require different data formats of
    the raw data.
    
    To make use of this, drivers need to implement the new callback
    get_current_scan_type() to resolve the scan type for a given channel
    based on the current state of the driver. There is a new scan_type_ext
    field in the iio_channel structure that should be used to store the
    scan types for any channel that has more than one. There is also a new
    flag has_ext_scan_type that acts as a type discriminator for the
    scan_type/ext_scan_type union. A union is used so that we don't grow
    the size of the iio_channel structure and also makes it clear that
    scan_type and ext_scan_type are mutually exclusive.
    
    The buffer code is the only code in the IIO core code that is using the
    scan_type field. This patch updates the buffer code to use the new
    iio_channel_validate_scan_type() function to ensure it is returning the
    correct scan type for the current state of the device when reading the
    sysfs attributes. The buffer validation code is also update to validate
    any additional scan types that are set in the scan_type_ext field. Part
    of that code is refactored to a new function to avoid duplication.
    
    Some userspace tools may need to be updated to re-read the scan type
    after writing any other attribute. During testing, we noticed that we
    had to restart iiod to get it to re-read the scan type after enabling
    oversampling on the ad7380 driver.
    
    Signed-off-by: David Lechner <[email protected]>
    Reviewed-by: Nuno Sa <[email protected]>
    Link: https://lore.kernel.org/r/20240530-iio-add-support-for-multiple-scan-types-v3-3-cbc4acea2cfa@baylibre.com
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    517e627 View commit details
    Browse the repository at this point in the history
  5. iio: core: add accessors 'masklength'

    'masklength' is supposed to be an IIO private member. However, drivers
    (often in trigger handlers) need to access it to iterate over the
    enabled channels for example (there are other reasons). Hence, a couple
    of new accessors are being added:
    
     * iio_for_each_active_channel() - Iterates over the active channels;
     * iio_get_masklength() - Get length of the channels mask.
    
    The goal of these new accessors is to annotate 'masklength' as private
    as soon as all drivers accessing it are converted to use the new
    helpers.
    
    Signed-off-by: Nuno Sa <[email protected]>
    Reviewed-by: Alexandru Ardelean <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jonathan Cameron <[email protected]>
    nunojsa authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    d4f8da0 View commit details
    Browse the repository at this point in the history
  6. regulator: devres: add API for reference voltage supplies

    A common use case for regulators is to supply a reference voltage to an
    analog input or output device. This adds a new devres API to get,
    enable, and get the voltage in a single call. This allows eliminating
    boilerplate code in drivers that use reference supplies in this way.
    
    Signed-off-by: David Lechner <[email protected]>
    Link: https://lore.kernel.org/r/20240429-regulator-get-enable-get-votlage-v2-1-b1f11ab766c1@baylibre.com
    Signed-off-by: Mark Brown <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    5215365 View commit details
    Browse the repository at this point in the history
  7. regulator: devres: fix devm_regulator_get_enable_read_voltage() return

    The devm_regulator_get_enable_read_voltage() function is supposed to
    return the voltage that the regulator is currently set to. However, it
    currently returns 0.
    
    Fixes: b250c20 ("regulator: devres: add API for reference voltage supplies")
    Signed-off-by: David Lechner <[email protected]>
    Link: https://lore.kernel.org/r/20240506-regulator-devm_regulator_get_enable_read_voltage-fixes-v1-1-356cdd152067@baylibre.com
    Signed-off-by: Mark Brown <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    b059e3b View commit details
    Browse the repository at this point in the history
  8. dt-bindings: iio: adc: add AD4695 and similar ADCs

    Add device tree bindings for AD4695 and similar ADCs.
    
    Reviewed-by: Conor Dooley <[email protected]>
    Signed-off-by: David Lechner <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    168fe8f View commit details
    Browse the repository at this point in the history
  9. iio: adc: ad4695: Add driver for AD4695 and similar ADCs

    This is a new driver for Analog Devices Inc. AD4695 and similar ADCs.
    The initial driver supports initializing the chip including configuring
    all possible LDO and reference voltage sources as well as any possible
    voltage input channel wiring configuration.
    
    Only the 4-wire SPI wiring mode where the CNV pin is tied to the CS pin
    is supported at this time. And reading sample data from the ADC can only
    be done in direct mode for now.
    
    Co-developed-by: Ramona Gradinariu <[email protected]>
    Signed-off-by: Ramona Gradinariu <[email protected]>
    Signed-off-by: David Lechner <[email protected]>
    Reviewed-by: Nuno Sa <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    506eede View commit details
    Browse the repository at this point in the history
  10. Documentation: iio: Document ad4695 driver

    The Analog Devices Inc. AD4695 (and similar chips) are complex ADCs that
    will benefit from a detailed driver documentation.
    
    This documents the current features supported by the driver.
    
    Signed-off-by: David Lechner <[email protected]>
    Signed-off-by: Jonathan Cameron <[email protected]>
    dlech authored and RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    9ecb8bc View commit details
    Browse the repository at this point in the history
  11. iio: adc: Kconfig.adi : imply AD4695

    Imply Ad4695 in Kconfig.adi file in the IIO subsystem.
    
    Signed-off-by: RaduSabau1 <[email protected]>
    RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    2069b36 View commit details
    Browse the repository at this point in the history
  12. arch: arm: boot: dts : Add AD4696 devicetree

    Add devicetree for ad469x_fmcz/zed project
    
    Signed-off-by: RaduSabau1 <[email protected]>
    RaduSabau1 committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    2391e6e View commit details
    Browse the repository at this point in the history