Skip to content

Staging/koror support#3094

Draft
stefpopa wants to merge 12 commits intomainfrom
staging/koror_support
Draft

Staging/koror support#3094
stefpopa wants to merge 12 commits intomainfrom
staging/koror_support

Conversation

@stefpopa
Copy link
Collaborator

PR Description

This PR adds initial Linux kernel driver support for the Analog Devices ADRV904X (Koror) family of wideband transceivers.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

@gastmaier
Copy link
Collaborator

gastmaier commented Jan 27, 2026

Can drivers/iio/adc/adrv904x/initdata.c and drivers/iio/adc/adrv904x/initdata.h are API files right?
can they placed under any of the rules below?

local api_match="(public/include|public/src|private/include|private/src|navassa/common|adrv902x/common|adrv903x/common|adrv903x/platforms)/"

the rules are at https://github.com/analogdevicesinc/linux/blob/ci/ci/build.sh#L35
feel free to adjust if needed, but focus on 'containerizing' the API code.

The license.pdf is a no no, please remove

All files should have unix endings, even api ones, csv, etc, use dos2unix to convert

I will now take a look on the build_gcc_arm

@gastmaier
Copy link
Collaborator

The api is generating calls to __aeabi_uldivmod(), only compatible with arm64 due to u64 operations.
please check if you can do it in 32 bits, divide first, find gcd (lib/math/gcd.c), etc.
and provide back to the api unit
If not possible, please isolate the 64bit bits into defines, so we don't have to blacklist the whole driver as 'arm64-compatible only'

thanks!

@gastmaier
Copy link
Collaborator

0001-API-dirty-adrv904x-use-math64-and-gcd.patch
Attached should do the trick, please read commit message body.

@stefpopa stefpopa force-pushed the staging/koror_support branch 3 times, most recently from 3c1012d to a37e455 Compare January 28, 2026 13:49
@stefpopa
Copy link
Collaborator Author

@gastmaier thank you for your review. See the changelog below:

  • Moved initdata.c/initdata.h to devices/adrv904x/private/src/ per API directory structure requirements
  • Updated Makefile with new paths and include directory
  • Updated adrv904x.c include path (now resolved via Makefile)
  • Removed License.pdf
  • Fixed CRLF line endings in initdata.c
  • added your arm32 build patch which to which I added a platform abstraction layer in adi_library_types.h, as per a request made by Sean Harte
  • Added kernel math64/gcd includes
  • Created ADI_LIBRARY_DIV_* and ADI_LIBRARY_GCD wrapper macros

@stefpopa stefpopa force-pushed the staging/koror_support branch from 5fb6eed to fa6d679 Compare January 28, 2026 15:26
@gastmaier
Copy link
Collaborator

gastmaier commented Jan 28, 2026

Hi,

is adrv904x/platforms API right? so I added to the
https://github.com/analogdevicesinc/linux/blob/ci/ci/build.sh#L35
as a broad

"(public/include|public/src|private/include|private/src|iio/adc/.*/common|iio/adc/.*/platforms)/"

rule

@gastmaier
Copy link
Collaborator

gastmaier commented Jan 28, 2026

Adding new comment to fixup my last comment, you did fix the line endings at
fa6d679

but checkpatch checks per commit

What you can do, if you don't want to force push, is to create a fixup commit with

git commit -s --fixup 7c27e7ba145863d1d069fd9bf8b1d34c5d890511 -m "optional extra msg"

Those commits are intentionally auto squashed during the ci
https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---autosquash

@stefpopa stefpopa force-pushed the staging/koror_support branch from fa6d679 to 1405cc2 Compare January 29, 2026 08:29
@stefpopa
Copy link
Collaborator Author

Hi,

is adrv904x/platforms API right? so I added to the https://github.com/analogdevicesinc/linux/blob/ci/ci/build.sh#L35 as a broad

"(public/include|public/src|private/include|private/src|iio/adc/.*/common|iio/adc/.*/platforms)/"

rule

Yes, adrv904x/platforms contains the platform abstraction layer (adi_library_types.h, adi_library.c). Thanks for adding the board rule!

@stefpopa
Copy link
Collaborator Author

stefpopa commented Feb 3, 2026

@gastmaier Thank you again for the review! Could you take another look and let me know if there are any remaining topics?
@nunojsa I would love to have your opinion on this PR.

@stefpopa
Copy link
Collaborator Author

Friendly reminder: please don't forget to review this PR.
Thank you!

Copy link
Collaborator

@gastmaier gastmaier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have documentation on the dt bindings .yaml? How will you document how to use?

Please resolve the clang/gcc analyzer caught issues, they are not static analyzer and are mostly always correct, either directly correct, or surface deeper structure issues.

The issues are, for convenience, shown as annotations, in the changed files; you can also now filter the commits shows in the gui, so de-select the api and fw commits, and focus on your files.

Thanks!

break;
}

ret = adrv904x_gainindex_to_gain(phy, chan->channel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ret value is never read.
should you error check? or discard explicitly

Same in all locations

adrv904x_add_debugfs_entry(phy, "bist_tone", DBGFS_BIST_TONE);

for (i = 0; i < phy->adrv904x_debugfs_entry_index; i++)
d = debugfs_create_file(phy->debugfs_entry[i].propname, 0644,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also d is never read.

case OBS_SAMPL_CLK:
phy->orx_iqRate_kHz = phy->kororDevice->initExtract.jesdSetting.framerSetting[1].iqRate_kHz;
init.ops = &bb_clk_ops;
clk_priv->rate = phy->orx_iqRate_kHz;;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean-up double column

Comment on lines 1684 to 1688
adrv904x_TxLinkSamplingRateFind(phy->kororDevice,
ADI_ADRV904X_DEFRAMER_0,
&rate);
init.ops = &bb_clk_ops;
clk_priv->rate = rate;
Copy link
Collaborator

@gastmaier gastmaier Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error checking before storing value? Does rate really get a value on all branches?
If deframerSel selects more than one, it never writes iqRate_kHz.
But in general just always error check.
do you have a wrapper to convert recoveryAction like device->common.errPtr->errDebugInfo.highestPriorityAction, in a more palatable format?

@stefpopa stefpopa force-pushed the staging/koror_support branch from 1405cc2 to db3c42e Compare February 12, 2026 15:41
@stefpopa
Copy link
Collaborator Author

changelog v3:
Resolved clang/gcc analyzer issues in adrv904x.c:

Fixed unused/overwritten values:

  • Changed ret = -EINVAL; to return -EINVAL; (value was never returned)
  • Added error check for adi_adrv904x_HwReset() return value before overwriting with PreMcsInit() call
  • Removed unused return value assignment from adrv904x_gainindex_to_gain()
  • Fixed uninitialized rate variable by adding error check for adrv904x_TxLinkSamplingRateFind()

Fixed unused variables:

  • Removed unused variable d from debugfs_create_file() call
  • Added __maybe_unused to clk_priv (used only in dev_dbg)
  • Added __maybe_unused to dev variables (used only in dev_dbg calls)

Fixed syntax issues:

  • Removed double semicolon in orx_iqRate_kHz assignment

Added dt-bindings documentation:

  • Created Documentation/devicetree/bindings/iio/adc/adi,adrv9040.yaml

@stefpopa stefpopa force-pushed the staging/koror_support branch 2 times, most recently from ef097a1 to 3e64a1d Compare February 13, 2026 11:02
@gastmaier
Copy link
Collaborator

For the

gcc_fanalayzer: the frame size of 1088 bytes is larger than 1024 bytes

warnings,
could the api providers kindly allocate the buffers instead of putting in the stack?

@stefpopa stefpopa marked this pull request as draft February 23, 2026 08:19
Add Koror API 2.15.0.5.

Signed-off-by: George Mois <george.mois@analog.com>
Add binaries to be used with the ADRV904X driver.

New adrv904x firmware to reflect the two available use cases,
without ORX (default profile) and with ORX (NLS profile)

Signed-off-by: George Mois <george.mois@analog.com>
Signed-off-by: Andrei Dragomir <andrei.dragomir@analog.com>
Signed-off-by: Stefan Popa <stefan.popa@analog.com>
@stefpopa stefpopa force-pushed the staging/koror_support branch 2 times, most recently from d5f3f58 to d1c095e Compare February 23, 2026 16:37
@stefpopa
Copy link
Collaborator Author

v4

  • Fix MODULE_LICENSE string: "GPL v2" → "GPL"
  • Fix spurious trailing semicolons after closing braces in four JESD204 state handlers
  • Replace pr_err with dev_err/dev_dbg in JESD204 device init and link init callbacks
  • Replace dev_err with dev_dbg for per-link status logging in clks_enable
  • Replace bare -1 return codes with proper errno values (-ENOMEM, -EIO)
  • Fix devm_clk_get error path: propagate PTR_ERR instead of silently ignoring it
  • Check return value of adrv904x_gainindex_to_gain() in read_raw
  • Remove variable shadowing of ret inside TX_SAMPL_CLK case block
  • Migrate of_property_read_string to device_property_read_string for firmware-agnostic property access
  • Add struct adrv904x_chip_info with per-compatible .data in of_device_id table; use device_get_match_data() instead of spi_get_device_id()->driver_data
  • Migrate clock provider: devm_clk_register → devm_clk_hw_register, of_clk_add_provider → devm_of_clk_add_hw_provider with clk_hw_onecell_data; remove manual of_clk_del_provider calls from error paths and remove()
  • Remove redundant indio_dev->dev.parent assignment and simplify indio_dev->name
  • Remove switch on device ID — only one device variant exists
  • Fix IS_ERR_OR_NULL checks and EXPORT_SYMBOL placement in adrv904x_conv.c
  • Rename indexed chip info table to single named adrv9040_axiadc_chip_info in adrv904x_conv.c
  • Replace struct clk_onecell_data with struct clk_hw_onecell_data * in adrv904x_rf_phy; replace int spi_device_id with const struct adrv904x_chip_info *chip_info

@stefpopa stefpopa force-pushed the staging/koror_support branch 4 times, most recently from 545c194 to 2e6cda5 Compare February 25, 2026 10:05
danmois and others added 10 commits February 25, 2026 12:50
Add the ADRV9040 initial driver including:
- Core driver implementation with JESD204 support
- IIO channel definitions and read/write operations
- Clock framework integration
- Linux platform abstraction layer

Add support for observation receiver (ORX) channels including:
- Add OBS_SAMPL_CLK clock for ORX sampling rate
- Differentiate between RX and OBS_RX channels in read_raw
- Add axi-adrv904x-obs compatible string support

Signed-off-by: George Mois <george.mois@analog.com>
Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Add dts file for adrv904x (Koror).

Signed-off-by: George Mois <george.mois@analog.com>
New adrv904x dts to implement the use case with ORX in NLS mode

Signed-off-by: AndrDragomir <andrei.dragomir@analog.com>
Direct 64-bit division on ARM32 causes undefined references to
__aeabi_uldivmod and __aeabi_ldivmod. Add platform abstraction
wrappers in adi_library_types.h for division operations and use
them throughout the driver.

Use GCD reduction before squaring in scale_with_squared_ratio()
to prevent overflow in power threshold calculations.

Co-authored-by: Jorge Marques <jorge.marques@analog.com>
Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Add device tree bindings documentation for the Analog Devices ADRV904X
RF transceiver family. The ADRV904X is a highly integrated RF transceiver
supporting 8 transmitter and 8 receiver channels with observation receivers,
designed for cellular infrastructure applications.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Disable VLA and frame-size warnings for ADI vendor API files that
trigger build failures when compiled with -Werror.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
…e_dpd

The prototype for adi_adrv904x_WBBufSegConfigGet() in
adi_adrv904x_dfe_dpd.h is conditionally compiled under
in adi_adrv904x_dfe_dpd.c lacks the same guard.

When ADI_LIBRARY_RM_FLOATS is defined the compiler sees no prior
declaration for the function and emits -Wmissing-prototypes, which
is promoted to an error by -Werror, breaking the build.

Wrap the function definition with the same guard as its prototype.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Fix variable length array compilation errors in ADI vendor API code
that trigger build failures with -Werror=vla. The VLAs were caused by
using const local variables as array dimensions in RxGainTableLoad and
RxGainTableChecksumRead, which the compiler cannot evaluate as constant
expressions in C90 mode.

Replace the local const variables LINE_BUFFER_SIZE and HEADER_BUFFER_SIZE
with file-scope #define macros so the array sizes are true compile-time
constants.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
adrv904x_dfe_vswr.c defines adrv904x_VswrPlaybackDatNumOfSamplesInit
but does not include its own header adrv904x_dfe_vswr.h, where the
function prototype is declared. This causes a -Werror=missing-prototypes
build failure since the compiler sees the definition before any
declaration.

Add the missing self-include to fix the build error.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
@stefpopa stefpopa force-pushed the staging/koror_support branch from 2e6cda5 to 8f0c2f0 Compare February 25, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants