Skip to content

iio: adc: adrv902x: add init cal and status attrs - #3526

Open
RaulGeo289 wants to merge 1 commit into
mainfrom
staging/initial_calibrations_madura
Open

iio: adc: adrv902x: add init cal and status attrs#3526
RaulGeo289 wants to merge 1 commit into
mainfrom
staging/initial_calibrations_madura

Conversation

@RaulGeo289

@RaulGeo289 RaulGeo289 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

This PR implements the initial calibration IIO attributes and the
status functions for both initial and tracking calibrations.

adi_adrv9025_InitCalsDetailedStatusGet() gives the error code, how
many microseconds the last calibration took, what ran last time,
and what calibrations ran since power up. The last two are
per-channel bitmasks, decoded against
adi_adrv9025_InitCalibrations_e, which can be found in
adi_adrv9025_cals_types.h.

adi_adrv9025_TrackingCalAllStateGet() gives a 32-bit mask with one
bit per calibration instance, flagging which ones are in the error
state, plus the state of each of the 32 tracking calibrations
(8 types across 4 channels).

adi_adrv9025_InitCalsCheckCompleteGet() can be used to verify if
the init calibrations are completed. It returns a running flag,
which is 0 when the ARM has completed the calibrations or never
ran them and 1 while they are currently running, and separately a
3-bit ARM error code.

When the calibration is successful, the error code should always
be 0.

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

@RaulGeo289 RaulGeo289 changed the title iio: adc: adrv9025: add init cal and status attrs iio: adc: adrv902x: add init cal and status attrs Sep 8, 2026
Expose the remaining init calibrations and the calibration status
readbacks through sysfs so a run can be configured and inspected
from userspace without a debugger.

New writable init-cal enables:

  calibrate_orx_qec_en       ADI_ADRV9025_ORX_QEC_INIT
  calibrate_orx_lo_delay_en  ADI_ADRV9025_ORX_LO_DELAY
  calibrate_adc_en           ADI_ADRV9025_ADC_TUNER
  calibrate_orx_adc_en       ADI_ADRV9025_ORX_TIA

New read-only status attributes:

  init_cals_complete_check   adi_adrv9025_InitCalsCheckCompleteGet()
  init_cals_all_status       adi_adrv9025_InitCalsDetailedStatusGet()
  tracking_cals_all_status   adi_adrv9025_TrackingCalAllStateGet()

All seven are registered for both adrv9026 and adrv9029.

Signed-off-by: Georgian Raul <Raul.Georgian@analog.com>
@RaulGeo289
RaulGeo289 force-pushed the staging/initial_calibrations_madura branch from d8550db to 3656416 Compare September 8, 2026 09:10
@RaulGeo289
RaulGeo289 marked this pull request as draft September 8, 2026 09:10
@RaulGeo289
RaulGeo289 marked this pull request as ready for review September 8, 2026 10:31

@stefpopa stefpopa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few minor comments from my side.

break;

case ADRV9025_INIT_CALS_COMPLETE_CHECK:
uint8_t status;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Variables declared mid-block violate kernel style. Move all declarations to the top of the switch case


case ADRV9025_INIT_CALS_COMPLETE_CHECK:
uint8_t status;
uint8_t ARMflag;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same comment as above


break;
case ADRV9025_INIT_STATUS_ALL:
adi_adrv9025_InitCalStatus_t initStatus;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same comment, move declaration to the top of the switch case.


static IIO_DEVICE_ATTR(tracking_cals_all_status, 0644, adrv9025_phy_show,
NULL, ADRV9025_TRACKING_STATUS_ALL);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like wrong permissions. init_cals_all_status and tracking_cals_all_status are declared with mode 0644 but pass NULL for the store function. Probably it should be 0444

case ADRV9025_INIT_CALS_COMPLETE_CHECK:
uint8_t status;
uint8_t ARMflag;
ret = adi_adrv9025_InitCalsCheckCompleteGet(phy->madDevice, &status, &ARMflag);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The naming of the ARMflag is inconsistent, as it uses CamelCase. The kernel preferred style is arm_flag.

break;

case ADRV9025_TRACKING_STATUS_ALL:
adi_adrv9025_TrackingCalState_t st;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

another mid-block declaration. Move declaration to the top or wrap each case body in braces to create a new scope.


ret = adi_adrv9025_TrackingCalAllStateGet(phy->madDevice, &st);
if (ret)
adrv9025_dev_err(phy);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm... Should you return ret or return adrv9025_dev_err(phy)?

if (ret) {
    adrv9025_dev_err(phy);
    return ret;
}

or

if (ret)
    return adrv9025_dev_err(phy);

please check this everywhere in the code.

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.

2 participants