Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging/adf4030 support #2651

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Staging/adf4030 support #2651

wants to merge 3 commits into from

Conversation

mhennerich
Copy link
Contributor

PR Description

New Linux IIO driver for Analog Devices ADF4030 10-Channel Precision Synchronizer IC.

The ADF4030 provides for 10 bidirectional synchronized clock (BSYNC) channels and
accepts a reference clock input (REFIN) signal as a frequency reference for
generating an output clock on any BSYNC channels that are configured as an output.
The hallmark feature of the ADF4030 is the ability to time align the clock edges
of any one or more BSYNC channels to <5 ps (at the device pins) with respect to
the BSYNC channel selected as the reference BSYNC channel.

https://www.analog.com/en/products/adf4030.html

PR Type

  • New feature (a change that adds new functionality)

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)


adi,extended-name:
description: Extended name for the channel.
$ref: /schemas/types.yaml#/definitions/string
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is questionable..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well it's handy, and avoids possible mix up.

properties:
reg:
description: Channel number.
$ref: /schemas/types.yaml#/definitions/uint32
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs some constrains. I guess some of the other properties also need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK


adi,rcm:
description: RCM value for the channel.
$ref: /schemas/types.yaml#/definitions/uint32
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of these properties need a better description. Right now, the description is more or less the same what one can infer from the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You will always need the datasheet to properly set those and the naming follows the datasheet.
But I agree some more text doesn't harm. Will fix.

description: Number of iterations for auto alignment.

adi,bsync-autoalign-threshold-fs:
description: Threshold for auto alignment in femtoseconds.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dunno the three above properties pass the binding check. They have no standard suffix and we're not defining a type for them.

Not sure why it does not fail in the check

drivers/iio/frequency/adf4030.c Show resolved Hide resolved
.shared = true,
.private = BSYNC_ALIGN_ITER,
},
{},
Copy link
Collaborator

Choose a reason for hiding this comment

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

The above four (at least) need an ABI doc. But I guess we can do it when upstreaming...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ABI documentation sysfs-bus-iio-frequency-adf4030

Yeah - the wiki page already has a link for it ...
https://wiki.analog.com/resources/tools-software/linux-drivers/iio-synchronizer/adf4030

drivers/iio/frequency/adf4030.c Show resolved Hide resolved
drivers/iio/frequency/adf4030.c Show resolved Hide resolved
drivers/iio/frequency/adf4030.c Outdated Show resolved Hide resolved
@mhennerich mhennerich force-pushed the staging/adf4030-support branch from dbed104 to 6e2a7c7 Compare December 5, 2024 11:35
nunojsa and others added 3 commits December 5, 2024 12:37
Initial support...

Signed-off-by: Nuno Sa <[email protected]>
Add dt-bindings for the Analog Devices ADF4030 Precision Synchronizer IC.

Signed-off-by: Michael Hennerich <[email protected]>
Automatically imply ADF4030.

Signed-off-by: Nuno Sa <[email protected]>
@mhennerich mhennerich force-pushed the staging/adf4030-support branch from 6e2a7c7 to ea7284a Compare December 5, 2024 11:51
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.

Looks mostly good to me...

Is there any strong reason to merge this right now or can we wait till we upstream this driver?

return dev_err_probe(&spi->dev, ret,
"Failed to start JESD204 FSM\n");

return devm_add_action_or_reset(&spi->dev, adf4030_stop_jesd204,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We now have devm_jesd204_fsm_start()


fwnode_property_read_u32(child, "adi,rcm", &st->channels[cnt].rcm);
cnt++;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should validate the properties that have constrains in the bindings to make sure dt values that we get are sane...

st->clk_out_names,
ARRAY_SIZE(st->clk_out_names));
if (ret < 0)
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still treating it as mandatory because we error out in case the property is not there. I guess we could do it in the same way as here:

https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/iio/frequency/adf4350.c#L467

dev_err(&st->spi->dev,
"Failed to compute R and N dividers for Fref=%u Hz amd VCO=%u Hz\n",
ref_input_freq_hz, vco_out_freq_hz);
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

dev_err_probe()

100, 1000);
if (ret) {
dev_err(&st->spi->dev, "PLL calibration failed\n");
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

if (ret)
return ret;

regmap_read(st->regmap, ADF4030_REG(0x8F), &regval);
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing error handling....

dev_err(&st->spi->dev, "Autoalign failed FSM_BUSY\n");
return ret;
}
regmap_read(st->regmap, ADF4030_REG(0x90), &regval);
Copy link
Collaborator

Choose a reason for hiding this comment

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

same...

vco_period_in_fs = DIV_U64_ROUND_CLOSEST(vco_period_in_fs, 512);
tdc_offset = div64_s64(delay_in_fs, vco_period_in_fs);

/* Check regmap_bulk_write() */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it not work? Otherwise I guess we should remove the comment

drivers/iio/frequency/adf4030.c Show resolved Hide resolved
.name = "duty_cycle",
.read = adf4030_ext_info_read,
.write = adf4030_ext_info_write,
.shared = false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to use the proper IIO_ENUMS.... This is the reason for CI failures

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