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

Backport axi-pwmgen driver #2602

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

Conversation

ukleinek
Copy link
Contributor

Trevor Gamblin mainlined the axi-pwmgen driver (Linux commit and a few followup improvements.) This MR updates the ADI vendor tree to use a backport of that driver. It contains several #ifdefs that intend to make updating to a newer Linux base version easy. Compared to the previous implementation the rounding behavior is different. So the consumer drivers that invest some math to get a deterministic PWM waveform are adapted (and improved) to continue to work with the new driver. I don't expect the other drivers to break. If I'm wrong here, please tell me that I can fix the fallout.

Note that comments about the PWM driver introduced in these commits only become true with the update of the axi-pwmgen driver in the last commit, the math however already works with the old driver under the assumption that its input clock is less than 500 MHz.

An unrelated drive-by simplification is also included.

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)

Uwe Kleine-König added 3 commits September 30, 2024 16:58
The driver's probe function had an open-coded variant of
devm_clk_get_enabled(). Replace it by the actual function with the same
semantics.

Signed-off-by: Uwe Kleine-König <[email protected]>
With knowing the input clock of the PWM hardware unit, the optimal period
can be calculated such that the sample frequency is configured as the
highest possible value not bigger than the requested value. Do that with
some commentary that explains the calculation.

Note that currently the initial claim about the axi-pwmgen driver's
implemented period isn't true. But it's true for the mainline driver and
soon for the driver in this tree as well.

Signed-off-by: Uwe Kleine-König <[email protected]>
With knowing the input clock of the PWM hardware unit, the optimal period
can be calculated such that the sample frequency is configured as the
highest possible value not bigger than the requested value. Do that with
some commentary that explains the calculation.

Note that currently the initial claim about the axi-pwmgen driver's
implemented period isn't true. But it's true for the mainline driver and
soon for the driver in this tree as well.

Signed-off-by: Uwe Kleine-König <[email protected]>
@ukleinek
Copy link
Contributor Author

Fixed a typo in two commit logs noticed by checkpatch. I'd like to see the other checkpatch issues ignored. It wails about LINUX_VERSION_CODE which for this backported driver is there on purpose.

Backporting involved several changes. These were marked using some cpp
magic to simplify updates to newer kernel version and for documentation
purposes.

The relevant semantical changes are:

 - The apply callback uses round down now to match the policy upstream.

 - The compatible string changed. All devicetrees are updated
   accordingly.

 - The v1 hardware revision isn't supported any more.
   The v1 documentation isn't in the public documentations any more, so
   this is expected to be ok.

Signed-off-by: Uwe Kleine-König <[email protected]>
@ukleinek
Copy link
Contributor Author

One more push after test feedback by Trevor Gamblin. Thanks!

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.

1 participant