Skip to content

Conversation

vai-tomme
Copy link
Contributor

@vai-tomme vai-tomme commented Aug 22, 2025

PR Description

Support for performing oneshot sequence as laid out in section "jesd204b serial data interface" and sync procedure of datasheet rev C [1] for device. In addition to the already implemented sysref_enable step, the other steps are also required for a sync to take place.

Feature is here implemented for subclass 1 operation with jesd-fsm enabled.

[1] https://www.analog.com/media/en/technical-documentation/data-sheets/ad9171.pdf

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 tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

Testing

Tested with zcu102 + ad9171-fmc-ebz combination and branch xilinx-v2023.2 with these patches applied.
For testing, custom built hdl with jesd mode 3 and configured devicetree accordingly since prebuilt hdl and dt for ad9171 eval board is not readily available.

devicetree settings for zynqmp-zcu102-rev10-ad9171-fmc-ebz-mode3.dts

&dac0_ad9172 {
        adi,dac-rate-khz = <4423680>; /* 4.4 GSPS */
        adi,jesd-link-mode = <3>;

        adi,jesd-subclass = <1>;
        adi,dac-interpolation = <6>;
        adi,channel-interpolation = <2>;
        adi,clock-output-divider = <4>;
        adi,syncoutb-signal-type-lvds-enable;
        adi,sysref-mode = <1>; /*  oneshot sysref mode */ 
        adi,sysref-error-window = <4>;
};

Add devicetree property for setting allowed sysref jitter.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
@gastmaier
Copy link
Contributor

gastmaier commented Aug 28, 2025

Hi @vai-tomme, thank you for the contribution! Please ignore the modpost error, was fixed on #2920 (1)!
But please go in the Files changed tab and apply the CI commented suggestion for your touched lines.
Minor kernel style stuff, using u* instead of uint*_t, direct null check if (!var)

(1) a cleaner run can be then created by either closing and opening the pr, or pushing a commit, to update the base branch head.

@vai-tomme
Copy link
Contributor Author

Hi @gastmaier, thanks! I updated one occurance of uint8 to u8, but I kept the h == NULL style since that is the style used througout the file for that particular driver.
Please let me know if you still prefer me to update the null checks to the more direct variant.

@vai-tomme
Copy link
Contributor Author

Update description with further details about testing. Please let me know if more information or any changes still required

Copy link
Contributor

@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.

Please just do kernel style null and error checking where you can


ad917x_jesd_set_sysref_enable(&st->dac_h, !!st->jesd_subclass);

if (lnk->subclass == JESD204_SUBCLASS_1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to suggest to add a devicetree entry to oneshot_sync, but I see that for ad9081 it is done as well


if (lnk->subclass == JESD204_SUBCLASS_1) {
ret = ad917x_jesd_oneshot_sync(&st->dac_h, st->sysref_err_win);
if (ret != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!ret)

Copy link
Contributor Author

@vai-tomme vai-tomme Sep 26, 2025

Choose a reason for hiding this comment

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

updated as suggested, assuming if (ret) format was proposed here


*done = (mode & AD917X_SYNC_ROTATION_DONE);

return API_ERROR_OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return API_ERROR_OK;
return 0;

We avoid the api defines at the linux driver layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now returning 0.

if (err != API_ERROR_OK)
return err;

*done = (mode & AD917X_SYNC_ROTATION_DONE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure if having *done brings much value. Why not just

if (!(mode & AD917X_SYNC_ROTATION_DONE))
    return API_SOME_ERROR;

return API_ERROR_OK; //or 0 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does provide chance to differentiate between error handling read request and the actual done value.
Similar approach is used also in other locations in this driver, see e.g. ad917x_jesd_get_sysref_enable.
I propose keeping done value and following current approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't see the point tbh. Put the logs inside the API and you have the same effect. That's pretty much the reason you have for having done as an output parameter. To print an error log, nothing else.

Having said the above, I don't really have strong feelings it so up to you.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm ok, since we this API it would not be straight to have the logs inside. Does not make it better though :)

@vai-tomme
Copy link
Contributor Author

Addressed comments up til now.

Support for performing oneshot sequence as laid out in
section "jesd204b serial data interface" and sync procedure
of datasheet rev C [1] for device. In addition to the already implemented
sysref_enable step, the other steps are also required for a sync to take
place.

Feature is here implemented for subclass 1 operation with jesd-fsm
enabled.

[1] https://www.analog.com/media/en/technical-documentation/data-sheets/ad9171.pdf
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Still don't agree with that done argument but as I said, up to you :)

@vai-tomme
Copy link
Contributor Author

Please just do kernel style null and error checking where you can

@gastmaier now implemented, please check!

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.

3 participants