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: rtc: sam0: Add RTC calendar driver and clock fixes #81819

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

Conversation

nandojve
Copy link
Member

This introduces the RTC clock calendar mode on a new RTC driver. At moment the MODE2 is fully implemented and tested with SAMD20, SAMR21 and SAME54 variants to cover all possible situations.

This driver imposes challenges in clock selection. The SAM family requires, in some situations, generic clock matrix configuration to use peripherals and or different oscillators. These generic clocks should be defined by product depending of developer application and it applies to the 1 KHz clock source. Currently in the SoC common initialization are reserved a few generic channels for specific use. The remaining channels after this change can be defined by developer. In the future when a proper clock driver/manager is in place this could be 100% defined at devicetree. To allow such configuration this introduces the Linux assigned-clock property.

@nandojve nandojve added this to the v4.1.0 milestone Nov 23, 2024
@nandojve nandojve requested a review from galak as a code owner November 23, 2024 20:09
@zephyrbot zephyrbot added area: UART Universal Asynchronous Receiver-Transmitter area: Timer Timer area: ADC Analog-to-Digital Converter (ADC) area: Clock Control platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) area: RTC Real Time Clock area: Devicetree labels Nov 23, 2024
Some platforms require special clock selection options. This could be
made using the already defined assigned-clocks. This introduces the
assigned-clocks and assigned-clock-names properties to generalize those
conditions.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add properties to differentiate the timer counter operating modes. This
properties are necessary to spetialize the driver to be used as a normal
16/32-bit counter or to provide the clock/calendar functions.

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.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Configure the Generic Clock Generator to be used as source to RTC.
The index 4 is now reserved to RTC.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Atmel sam0 rtc calendar driver.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add configurations to allow use of RTC driver and tests.

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

  • Rebase
  • Tried to fix all building issues

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

Given the size of this PR, it might make sense to split into one PR reworking the clocking, and follow-up with a PR for adding the RTC.

By the way, did you see #72102 ?

@nandojve
Copy link
Member Author

nandojve commented Nov 26, 2024

Hi @henrikbrixandersen ,

Given the size of this PR, it might make sense to split into one PR reworking the clocking, and follow-up with a PR for adding the RTC.

Yes, I already considered this and will do it.

By the way, did you see #72102 ?

I know Daniel is working on the management but I'm not following at moment.

The main issue with sam0 it that developer should define clock generators and then connect the peripherals to some of that lines. The assigned-clock property makes live easy to the developer assign the lines in the board file. What I made was basic clock configuration which can be improved later. Current these devices don't have clock drivers, only some helpers to enable/disable clock sources. In this case, I consider the step a preparation to clock driver/management and can be reworked. At least, this gives freedom to developers to define their own clock lines and associate until a better solution will be in place.

@nandojve
Copy link
Member Author

Can someone have an idea why I can not reproduce the issue with the ./scripts/ci/check_compliance.py locally ?

@bjarki-andreasen
Copy link
Collaborator

Can someone have an idea why I can not reproduce the issue with the ./scripts/ci/check_compliance.py locally ?

This is what CI runs:

  ./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e ClangFormat \
  -c origin/${BASE_REF}..

probably one or more of those flags are needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) area: Clock Control area: Devicetree area: RTC Real Time Clock area: Timer Timer area: UART Universal Asynchronous Receiver-Transmitter platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants