mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 00/16] iio: adc: xilinx-xadc: Add I2C interface support for System Management Wizard
@ 2026-11-10  5:01 Dileep Kumar Nagavarapu
  2026-11-10  5:01 ` [PATCH v5 01/16] iio: adc: xilinx-xadc: Correct write edge in CFG Dileep Kumar Nagavarapu
                   ` (15 more replies)
  0 siblings, 16 replies; 24+ messages in thread
From: Dileep Kumar Nagavarapu @ 2026-11-10  5:01 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Michal Simek, Conall O'Griofa
  Cc: linux-iio, linux-arm-kernel, linux-kernel, git, Dileep Kumar Nagavarapu

The existing driver only supported AXI memory-mapped access to the System
Management Wizard IP. This series extends the driver to support I2C-based
access, which is particularly useful for System Controller usecases.

Key Changes:
- Split the xilinx-xadc-core.c file into two files(xilinx-xadc-core.c and
  xilinx-xadc-platform.c)
- Add required helper functions and callbacks
- Add channel configuration via callback mechanism
- New I2C driver for UltraScale+ System Management Wizard for basic
  voltage and temperature monitoring

Note: We are working on x86 platform support where fixed channel
configuration is used(no DT support). The .setup_channels() function
pointer introduced in patch 2/4 enables different channel configuration
approaches for various platforms.

This series was originally posted by Sai Krishna Potthuri.

Link:https://lore.kernel.org/all/20260323074505.3853353-1-sai.krishna.potthuri@amd.com/

I will be maintaining the series going forward and posting updated
revisions.

Changes in v5:
-> 4/16
    (Comments from Jonathan Cameron)
    - Retained the unused register field macros for register field
      documentation
-> 5/16
    (Comments from Jonathan Cameron)
    - Define TCKRATE and power-down mode constants as field values
      instead of shifted bit masks
    - Split the combined alarm masks into their individual register fields
    - Update the sequencer mode definitions according to the documented
      field encoding
-> (Comments from Jonathan Cameron and Joshua Crofts)
    - Introduced a new patch for mutex handling as patch 7/16 in v5;
      patches 7/15 through 15/15 in v4 are now patches 8/16 through
      16/16 in v5
    - Convert mutex locking to guard() helpers and remove goto-based
      cleanup
-> 8/16
    (Comments from Jonathan Cameron)
    - Retained explicit == 0 comparisons for auxiliary scan mode
      field checks
-> 10/6
    (Comments from Jonathan Cameron and Joshua Crofts)
    - Updated the patch title and commit message to reflect both added and
      removed header files
    - Added linux/bitmap.h explicitly for for_each_set_bit() in
      xilinx-xadc-events.c instead of relying on an indirect include
-> 13/16
    (Comments from Jonathan Cameron)
    - Added an early return when no IRQ is available to reduce indentation
      in xadc_setup_buffer_and_triggers()
    - Moved device_get_match_data() to the caller and passed the XADC type
      directly to xadc_device_setup()
-> 16/16
    (Comments from Jonathan Cameron)
    - Moved interface-specific properties (info, has_adc_b) into struct
      xadc_ops to avoid explicit XADC type checks
    - Added has_adc_b to struct xadc_ops to indicate whether the device
      has an ADC B, in place of checking the device type. UltraScale
      System Monitor devices have only one ADC, so has_adc_b is
      false for them
    - Reworked the I2C DRP packet definitions using an enum for the byte
      offsets and packet size
    - Simplified I2C DRP data handling using get/put_unaligned_le16() and
      removed unnecessary bitfield operations
    - Added short-transfer checks for I2C transactions
    - Added xadc_common_init() helper to initialize operations, mutex, and
      spinlock
    - Updated the I2C of match table terminator

Changes in v4:
-> Updated the sign-off email from uppercase letters to all lowercase
   letters
-> Dropped the commit message related to the binding YAML schema
   format from the cover letter, since it was sent separately
-> Dropped the MAINTAINERS entry from this patch series
-> Split the previous 1/6 "Modernize driver code" patch into 10 smaller,
   single-concern patches (2/15 - 10/15) as per the Joshua Crofts and
   radhey review comments.
   the combined result is equivalent to v3's patch 1/6:
    2/15 - Fix coding style issues
    3/15 - Use kernel integer types
    4/15 - Drop unnecessary masking and dead code
    5/15 - Use bitfield helpers and bit macros
    6/15 - Use guard()/scoped_guard() for spinlock locking
    7/15 - Simplify common coding patterns
    8/15 - Add unit suffixes to macro names
    9/15 - Drop unused header files
    10/15 - Add clarifying comments
    11/15 - Refine Zynq read/write error handling on timeout/interrupt
-> Patches 2/6 - 5/6 from v3 carry forward and renumbered to
    11/15 - 15/15.
-> 1/15
    - Reworded the commit message and subject
    - Added stable@vger.kernel.org to after the Signed-off-by block
    - Added Co-developed-by: Conall O'Griofa immediately before
      his Signed-off-by line
    (Comments from David Lechner)
    - Moved patch 6/6 "Correct Write edge in CFG" to 1/15
    - Updated the Fixes tag and explaining a commit message
      for write edge configuration issue.
-> 3/15
    (Comments from Joshua Crofts)
    - Included <linux/types.h> header
-> 5/15
    - Dropped unused macros
-> 8/15
    - Reformatted the XADC_ZYNQ_TCK_RATE_MAX_HZ,
      XADC_ZYNQ_IGAP_DEFAULT_CYCLES, and XADC_ZYNQ_PCAP_RATE_MAX_HZ
      macro definitions to use the standard "#define NAME<TAB>VALUE"
      style, instead of the single-line run-together form.
-> 9/15
    - Replaced #include <linux/kernel.h> with the required headers
      array_size.h, bitops.h, and container_of.h
-> 11/15
    - Changed the timeout errno from -EIO to -ETIMEDOUT in both
      xadc_zynq_read_adc_reg() and xadc_zynq_write_adc_reg(), for
      a more precise error code on wait_for_completion timeout.
    - Kept propagating an interrupted wait's error instead of
      forcing ret = 0 (success) in both functions
    - Added xadc_read_reg after the
      wait_for_completion_interruptible_timeout, Now DFIFO read
      unconditional so it always runs immediately after the wait
      completes, regardless of whether it timed out, was
      interrupted, or succeeded — avoiding a stale response word
      being left for the next transaction.
-> 12/15
    - Reordered dev/xadc declarations in
      xadc_setup_buffer_and_triggers() (reverse christmas tree).
    - Dropped the unused dev parameter from xadc_device_configure(),
      keeping the header prototype and definition in sync.
    - Added a commit-message note that the bipolar_mask computation
      is also moved to run immediately after xadc_parse_dt().
    - Removed the error handling from xadc_zynq_write_adc_reg()
      in patch 2/6 of v3 and moved it to a separate error handling
      patch 11/15 in v4.
-> 13/15
    - Changed the new xilinx-xadc-platform.c SPDX identifier from
      GPL-2.0 to GPL-2.0-only, for consistency with core.c and
      the header.
    - Tab-aligned XADC_MAX_SAMPLERATE_SPS, XADC_FLAGS_BUFFERED, and
      XADC_FLAGS_IRQ_OPTIONAL to match the XADC_AXI_* block below
      them.
    (Comments from Uwe Kleine-König)
    - Removed <linux/mod_devicetable.h> header file
-> 14/15(Comments from David Lechner)
    - Added a commit message explaining the export of xadc_parse_dt()
-> 15/15
    - Fixed missing spaces before opening parens in the commit
      message ("DRP(Dynamic" and 'string("xlnx,...")').
    - Consolidated the four redundant deferred-init rationale
      bullets into a single explanation.
    - Fixed the Kconfig typo "can also be build" -> "built" in the
      new XILINX_XADC_I2C entry.
    - Changed write_buffer/read_buffer from char to u8 in
      xadc_i2c_read_transaction()/xadc_i2c_write_transaction().
    - Added named defines for the DRP packet byte offsets
      (XADC_I2C_DRP_DATA_LOW etc.) instead of bare 0/1/2/3
      literals.
    - Dropped the redundant "xadc->clk = NULL;" in xadc_i2c_probe().
    - Fixed the devm_mutex_init(xadc->mutex) build error to
      devm_mutex_init(dev, &xadc->mutex).
    - Added the missing MODULE_IMPORT_NS("IIO_XADC").
    - Added Dileep Kumar Nagavarapu to MODULE_AUTHOR alongside
      Sai Krishna Potthuri.

Changes in v3:
-> 1/6 - Modernized the driver code with latest kernel coding styles
         and guidelines.
       - Restored one-variable-per-line declarations where no
         functional change  was intended.
       - Added unit suffixes to timing and clock-rate constants.
       - Replaced GENMASK() and FIELD_PREP() in appropriate places.
       - Added guard(spinlock_irq) helper to manage the spinlock
         automatically on scope exit.
       - Added MAINTAINERS entry for XILINX XADC driver.
-> 2/6 - Refactored the xadc_setup_buffer_and_triggers function
         with only two arguments.
       - Added xadc_device_setup() and xadc_device_configure() to handle
         device initialization and configuration separately.
-> 3/6 - Added IIO_XADC namespace to all exported symbols and
         imported the namespace in platform specific modulue.
       - Spliting the driver with modrern driver changes.
-> 4/6 - Added .setup_channels() to handle custom channel setup
         and configuration.
-> 5/6 - Replaced mutex initialization with devm_mutex_init()
       - Removed unused i2c_set_clientdata() usage.
       - Added comments describing the DRP packet layout used
         for I2C  transactions.
       - Added comment for hardware initialization check from xadc i2c
         write and read functions.
       - Wrapped Kconfig help text to conform to kernel style guidelines.
       - Switched device setup error handling to dev_err_probe().
-> 6/6 - Removed write edge default configuration in XADCIF_CFG register.
-> Dropped the binding to YAML conversion patch as this is already sent by
   Pramod Maurya and is in discussion.

Changes in v2:
-> 1/4 - Split the xilinx-xadc-core.c file into two files
         xilinx-xadc-core.c and xilinx-xadc-platform.c(comments from Andy).
-> 2/4 - Referred as .setup_channels instead of setup_channels.
-> 3/4 - Created separate functions for i2c read and write.
       - Created separate file for i2c interface handling.
-> 4/4(comments from Krzysztof)
       - Removed $defs and use it directly under xlnx,channels.
       - Documented the error information in the commit message due to
         vendor prefix properties.


Dileep Kumar Nagavarapu (16):
  iio: adc: xilinx-xadc: Correct write edge in CFG
  iio: adc: xilinx-xadc: Fix coding style issues
  iio: adc: xilinx-xadc: Use kernel integer types
  iio: adc: xilinx-xadc: Drop unnecessary masking and dead code
  iio: adc: xilinx-xadc: Use bitfield helpers and bit macros
  iio: adc: xilinx-xadc: Use guard()/scoped_guard() for spinlock locking
  iio: adc: xilinx-xadc: Use guard() for mutex locking
  iio: adc: xilinx-xadc: Simplify common coding patterns
  iio: adc: xilinx-xadc: Add unit suffixes to macro names
  iio: adc: xilinx-xadc: Include appropriate header files
  iio: adc: xilinx-xadc: Add clarifying comments
  iio: adc: xilinx-xadc: Refine Zynq read/write error handling on
    timeout/interrupt
  iio: adc: xilinx-xadc: Add helper functions for the device setup
  iio: adc: xilinx-xadc: Split driver into core and platform files
  iio: adc: xilinx-xadc: Add .setup_channels() to struct xadc_ops
  iio: adc: xilinx-xadc: Add I2C interface support

 drivers/iio/adc/Kconfig                       |   23 +-
 drivers/iio/adc/Makefile                      |    6 +-
 drivers/iio/adc/xilinx-xadc-core.c            |  909 +++-----------
 drivers/iio/adc/xilinx-xadc-events.c          |   79 +-
 drivers/iio/adc/xilinx-xadc-i2c.c             |  242 ++++
 ...inx-xadc-core.c => xilinx-xadc-platform.c} | 1095 +++--------------
 drivers/iio/adc/xilinx-xadc.h                 |  125 +-
 7 files changed, 688 insertions(+), 1791 deletions(-)
 create mode 100644 drivers/iio/adc/xilinx-xadc-i2c.c
 copy drivers/iio/adc/{xilinx-xadc-core.c => xilinx-xadc-platform.c} (34%)


base-commit: 1390ca4953a7400ca932cb49635f02c727f885a6
-- 
2.34.1


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

end of thread, other threads:[~2026-11-10 16:34 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  5:01 [PATCH v5 00/16] iio: adc: xilinx-xadc: Add I2C interface support for System Management Wizard Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 01/16] iio: adc: xilinx-xadc: Correct write edge in CFG Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 02/16] iio: adc: xilinx-xadc: Fix coding style issues Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 03/16] iio: adc: xilinx-xadc: Use kernel integer types Dileep Kumar Nagavarapu
2026-11-10 11:15   ` Joshua Crofts
2026-11-10  5:01 ` [PATCH v5 04/16] iio: adc: xilinx-xadc: Drop unnecessary masking and dead code Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 05/16] iio: adc: xilinx-xadc: Use bitfield helpers and bit macros Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 06/16] iio: adc: xilinx-xadc: Use guard()/scoped_guard() for spinlock locking Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 07/16] iio: adc: xilinx-xadc: Use guard() for mutex locking Dileep Kumar Nagavarapu
2026-11-10 16:13   ` Andy Shevchenko
2026-11-10  5:01 ` [PATCH v5 08/16] iio: adc: xilinx-xadc: Simplify common coding patterns Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 09/16] iio: adc: xilinx-xadc: Add unit suffixes to macro names Dileep Kumar Nagavarapu
2026-11-10 16:18   ` Andy Shevchenko
2026-11-10  5:01 ` [PATCH v5 10/16] iio: adc: xilinx-xadc: Include appropriate header files Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 11/16] iio: adc: xilinx-xadc: Add clarifying comments Dileep Kumar Nagavarapu
2026-11-10  5:01 ` [PATCH v5 12/16] iio: adc: xilinx-xadc: Refine Zynq read/write error handling on timeout/interrupt Dileep Kumar Nagavarapu
2026-11-10 16:21   ` Andy Shevchenko
2026-11-10  5:01 ` [PATCH v5 13/16] iio: adc: xilinx-xadc: Add helper functions for the device setup Dileep Kumar Nagavarapu
2026-11-10 16:25   ` Andy Shevchenko
2026-11-10  5:01 ` [PATCH v5 14/16] iio: adc: xilinx-xadc: Split driver into core and platform files Dileep Kumar Nagavarapu
2026-11-10 16:29   ` Andy Shevchenko
2026-11-10  5:02 ` [PATCH v5 15/16] iio: adc: xilinx-xadc: Add .setup_channels() to struct xadc_ops Dileep Kumar Nagavarapu
2026-11-10  5:02 ` [PATCH v5 16/16] iio: adc: xilinx-xadc: Add I2C interface support Dileep Kumar Nagavarapu
2026-11-10 16:34   ` Andy Shevchenko

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

all inboxes | Powered by JetHome®