mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Michal Simek" <michal.simek@amd.com>,
	"Conall O'Griofa" <conall.ogriofa@amd.com>
Cc: <linux-iio@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <git@amd.com>,
	Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
Subject: [PATCH v6 00/16] iio: adc: xilinx-xadc: Add I2C interface support for System Management Wizard
Date: Wed, 25 Nov 2026 22:40:14 +0530	[thread overview]
Message-ID: <20261125171045.1246381-1-dileepkumar.nagavarapu@amd.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="yes", Size: 14635 bytes --]

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 v6:
-> Moved patch 12/16 in v5 to 2/16 in v6
-> Renumbered patches 2/16-11/16 in v5 to 3/16-12/16 in v6
-> Added Reviewed-by tags to the patches 3/16, 4/16 and 5/16
-> 2/16
    (Comments from Andy Shevchenko)
    - Reordered wait_for_completion_interruptible_timeout() return-value
      checks to handle generic errors before the timeout condition
    (Comments from Sashiko)
    - Added the Fixes tag and Cc
-> 6/16
    (Comments from Sashiko)
    - Replaced the open-coded register field preparation with
      FIELD_PREP() in xadc_zynq_setup and xadc_preenable
    (Comments from Jonathan Cameron)
    - Dropped unused _OFFSET definitions after converting the
      corresponding bitfield operations to FIELD_PREP() and
      FIELD_GET()
-> 8/16
    (Comments from Andy Shevchenko)
    - Added blank lines around guard() declarations to make the lock
      scope clearly visible
    - Removed return variables and returned the helper result directly
-> 10/16
    (Comments from Andy Shevchenko)
    - Used units.h multipliers for frequency and sample-rate constants
    - Used _Hz suffix for frequency-related macros
    - Simplified the sample-rate check to avoid an unnecessary division
-> 13/16
    (Comments from Andy Shevchenko)
    - Useed scan_type.format (IIO_SCAN_FORMAT_SIGNED_INT / _UNSIGNED_INT)
      instead of the deprecated scan_type.sign. This covers the bipolar
      mask loop in xadc_device_configure() and the other users of .sign
      in xadc_read_raw(), the two channel macros and xadc_parse_dt()
    - Handled -EPROBE_DEFER explicitly right after
      platform_get_irq_optional() and restructure the optional-IRQ
      check, instead of the single combined condition
    - Replaced "irq <= 0" with "irq < 0" in
      xadc_setup_buffer_and_triggers(), because 
      platform_get_irq_optional() never returns 0
-> 14/16
    (Comments from Sashiko)
    - Restored code that was missed when splitting the original driver
      into core and platform files
-> 16/16
    (Comments from Andy Shevchenko)
    - Reordered struct xadc_i2c to remove the 3-byte hole after
      hw_initialized
    - Replaced -ENODEV with -ENODATA when device_get_match_data() returns
      NULL in xadc_i2c_probe()
    - Dropped the unneeded blank line before MODULE_LICENSE()
    (Comments from Sashiko)
    - Moved xadc_common_init() from xilinx-xadc-platform.c to
      xilinx-xadc-core.c
    - Removed expose the sampling_frequency attribute when the interface
      has no get_dclk_rate() callback, since it could only return
      -EOPNOTSUPP
    - Dropped the XADC_REG_THRESHOLD() reads from xadc_hardware_init(),
      since the threshold cache is only used by the event callbacks,
      which the I2C iio_info does not provide
    - Reworded the commit message to state that the I2C path supports
      only the internal System Monitor channels and does not program
      the channel sequencer, instead of mirroring the platform
      sequencer setup

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: Refine Zynq read/write error handling on
    timeout/interrupt
  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: 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            |  944 +++-----------
 drivers/iio/adc/xilinx-xadc-events.c          |   79 +-
 drivers/iio/adc/xilinx-xadc-i2c.c             |  235 ++++
 ...inx-xadc-core.c => xilinx-xadc-platform.c} | 1084 +++--------------
 drivers/iio/adc/xilinx-xadc.h                 |  135 +-
 7 files changed, 698 insertions(+), 1808 deletions(-)
 create mode 100644 drivers/iio/adc/xilinx-xadc-i2c.c
 copy drivers/iio/adc/{xilinx-xadc-core.c => xilinx-xadc-platform.c} (33%)


base-commit: 1390ca4953a7400ca932cb49635f02c727f885a6
-- 
2.34.1


             reply	other threads:[~2026-11-25 17:11 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125171045.1246381-1-dileepkumar.nagavarapu@amd.com \
    --to=dileepkumar.nagavarapu@amd.com \
    --cc=andy@kernel.org \
    --cc=conall.ogriofa@amd.com \
    --cc=dlechner@baylibre.com \
    --cc=git@amd.com \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®