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

drivers: clocks: sam0: Fix devicetree usage of GCLK and MCLK #82183

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

Conversation

nandojve
Copy link
Member

@nandojve nandojve commented Nov 27, 2024

Some platforms require special clock selection options. This could be made using the already defined assigned-clocks from Linux devicetree. This can be used on Atmel SAM0 SoC to enable peripherals clocks in distinct places like PM and MCLK. Old devices had defined the peripheral clock enable bit at PM. On the newer devices this was extracted on a dedicated memory section called Master Clock (MCLK). This change excludes the dedicated bindings in favor of a generic approach that cover all cases. It uses the assigned-clocks and assigned-clock-names properties to generalize those conditions.

With this, the clocks are very flexible now and this gives the liberty to developer to customize the clock source from a generic clock or configure the direct connections. The drivers that require those properties were reworked to use the new solution. Some drivers still access direct the properties and should be reworked in the future.

Note:
1- This changes is a step necessary to have proper clock drivers for these SoCs.
2- This was splitted from #81819 and should be merged first.

Comment on lines +118 to +120
GCLK->PCHCTRL[cfg->gclk_id].reg = GCLK_PCHCTRL_CHEN
| GCLK_PCHCTRL_GEN(cfg->gclk_gen)
;
Copy link
Member

Choose a reason for hiding this comment

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

Formatting looks off here?

@@ -9,7 +12,6 @@ toolchain:
flash: 256
ram: 32
supported:
- adc
Copy link
Member

Choose a reason for hiding this comment

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

Were these ADC changes meant to into this commit? If so, please add some details on why in the commit message.

Comment on lines +63 to +69
assigned-clocks:
type: phandle-array
description: Assigned-clock information

assigned-clock-names:
type: string-array
description: Name of each assigned-clock
Copy link
Member

Choose a reason for hiding this comment

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

The commit message says "already defined" properties - but these properties are new in Zephyr and not mentioned in the Devicetree Specification (v0.4).

I would like to hear @danieldegrasse opinion on the use of these and possible conflict with the upcoming clock controller rework.

Copy link
Member

Choose a reason for hiding this comment

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

This looks similar to Linux clock DT description

Some platforms require special clock selection options. This could be
made using the already defined assigned-clocks from Linux clocks.

  See https://github.com/devicetree-org/dt-schema/blob/93ee8008959e362548168eaa7bdc20c115f3d586/dtschema/schemas/clock/clock.yaml#L24

This introduces the assigned-clocks and assigned-clock-names properties
to generalize those conditions in Zephyr.

Signed-off-by: Gerson Fernando Budke <[email protected]>
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.

Now the clocks properties is complemented by the assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.

All peripherals drivers were reworked with the newer solution.

In addition, some peripherals were set the default status to disabled.
It is expected that developer will define at board the pinctrl and
select the correct clock entry. When this is correct the peripheral
should be at the board yaml in the supported list. Because of this a
few boards exclude now some peripheral like adc. This avoid that CI
will collect invalid board to run tests.

Signed-off-by: Gerson Fernando Budke <[email protected]>
@nandojve
Copy link
Member Author

nandojve commented Dec 1, 2024

  • rebase
  • more context in commit messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport v4.0-branch Backport to the v4.0-branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants