From: Tomas Borquez <tomasborquez13@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev,
"Tomas Borquez" <tomasborquez13@gmail.com>
Subject: [RFC PATCH 0/3] ad9832: driver cleanup
Date: Fri, 5 Dec 2025 17:27:40 -0300 [thread overview]
Message-ID: <20251205202743.10530-1-tomasborquez13@gmail.com> (raw)
This series is a general cleanup of ad9832, with the purpose of
graduating it from staging. The main changes are removing legacy
platform_data support, converting to IIO channels with read/write_raw
callbacks, and adding devicetree support.
I'm sending this as an RFC because I have some concerns about the ABI
design and would appreciate guidance before putting more time into this.
Patch 1 removes the legacy platform_data support as suggested by
Jonathan [1]. The driver now initializes to a safe state and lets
userspace configure frequencies/phases via sysfs.
Patch 2 converts frequency and phase configuration from custom sysfs
attributes to proper IIO channels using read_raw/write_raw callbacks
(This is the main area where I'd like feedback).
Patch 3 adds devicetree bindings documentation.
Design Concerns:
1) Channel Organization and ABI Break
The device has 2 frequency registers and 4 phase registers. Since both
frequency and phase must use IIO_ALTVOLTAGE since there's no better fit
(as far as I know), I've organized channels as:
out_altvoltage0_frequency (FREQ0)
out_altvoltage1_frequency (FREQ1)
out_altvoltage2_phase (PHASE0)
out_altvoltage3_phase (PHASE1)
out_altvoltage4_phase (PHASE2)
out_altvoltage5_phase (PHASE3)
The old ABI used out_altvoltage0_frequency0, out_altvoltage0_frequency1,
out_altvoltage0_phase0, etc.
The new approach felt cleaner but I'm open to alternatives and better
ways of mapping them. Is this channel mapping reasonable, or would a
different organization be preferred? And is the ABI break okay?
2) Scale Attributes
The frequency scale is 1 Hz and phase scale is 2*PI/4096 radians.
I cannot use info_mask_shared_by_type for IIO_CHAN_INFO_SCALE because
all channels share IIO_ALTVOLTAGE.
So instead I'm using IIO_CONST_ATTR for the scales:
out_altvoltage_frequency_scale = "1"
out_altvoltage_phase_scale = "0.0015339808"
Is there a better approach here? Or should I just document the units and
skip scale attributes entirely?
3) Remaining Custom Attributes
Other controls remain as custom sysfs attributes:
- out_altvoltage_frequencysymbol: select active frequency register
- out_altvoltage_phasesymbol: select active phase register
- out_altvoltage_pincontrol_en: hardware pin control enable
- out_altvoltage_out_enable: output enable
I'm not sure if these map cleanly to IIO interfaces. Should these be
documented in ABI or is there a preferred way to handle them?
4) Implementation Notes
- read_raw uses explicit address switching rather than channel index
arithmetic for clarity, though phase values could alternatively be
accessed via st->phase[chan->channel - 2] and directly in freq with
st->freq[chan->channel].
- I'm unsure if mutex guards on cached reads are necessary.
Link: https://lore.kernel.org/linux-iio/20250628161040.3d21e2c4@jic23-huawei/ [1]
Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
Tomas Borquez (3):
staging: iio: ad9832: remove platform_data support
staging: iio: ad9832: convert to iio channels
dt-bindings: iio: add analog devices ad9832/ad9835
.../bindings/iio/frequency/adi,ad9832.yaml | 65 +++++
drivers/staging/iio/frequency/ad9832.c | 264 +++++++++++-------
drivers/staging/iio/frequency/ad9832.h | 33 ---
3 files changed, 233 insertions(+), 129 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/frequency/adi,ad9832.yaml
delete mode 100644 drivers/staging/iio/frequency/ad9832.h
--
2.43.0
next reply other threads:[~2025-12-05 20:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 20:27 Tomas Borquez [this message]
2025-12-05 20:27 ` [RFC PATCH 1/3] staging: iio: ad9832: remove platform_data support Tomas Borquez
2025-12-06 16:24 ` Andy Shevchenko
2025-12-07 12:46 ` Jonathan Cameron
2025-12-05 20:27 ` [RFC PATCH 2/3] staging: iio: ad9832: convert to iio channels Tomas Borquez
2025-12-06 16:17 ` Jonathan Cameron
2025-12-05 20:27 ` [RFC PATCH 3/3] dt-bindings: iio: add analog devices ad9832/ad9835 Tomas Borquez
2025-12-06 16:26 ` Jonathan Cameron
2025-12-06 16:09 ` [RFC PATCH 0/3] ad9832: driver cleanup Jonathan Cameron
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=20251205202743.10530-1-tomasborquez13@gmail.com \
--to=tomasborquez13@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).