1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

27 Commits

Author SHA1 Message Date
Marian Buschsieweke
20e218680c
cpu/samd5x/cpu.c: reformat code
This formats the code to improve readability and apply the coding
convention. This is a whitespace only change that will not change
generated binaries.
2024-09-17 22:07:46 +02:00
Dylan Laduranty
41c003d670 cpu/samd5x: avoid the use of bitfield in cpu init
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2024-06-27 21:51:13 +02:00
Urs Gompper
5479c7eb96 cpu/samd5x: add conditional enabling of freqm peripheral 2023-11-23 20:53:14 +01:00
Gunar Schorcht
b859da8495 cpu/samd5x: change FDPLL1 frequency to 100 MHz
The only peripheral that currently uses the FDPLL1 is SDHC. However, the SDHC IP can only be clocked at up to 150 MHz. Therefore, 100 MHz is currently used as the frequency of the FDPLL1. If another peripheral device requires 200 MHz in the future, this must be realized via different clock generators.
2023-06-20 12:48:54 +02:00
Dylan Laduranty
6607ed10f6 cpu/samd5x: add support for FDPLL1 running at 200MHz
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-05-16 16:04:17 +02:00
Dylan Laduranty
f790d9fe36 cpu/samd5x: replace fdpll0_init by two generic functions
These functions can be used to set both FDPLL0 and FDPLL1 by using an extra argument 'idx' (index) and allow to set the ONDEMAND bit using the 'flags' argument

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-05-16 16:03:15 +02:00
Dylan Laduranty
af2fa99470 cpu/samd5x: remove duplicate USE_VREG_BUCK
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-05-16 15:54:18 +02:00
Benjamin Valentin
124b849503 cpu: call early_init() 2023-01-08 22:26:12 +01:00
Bas Stottelaar
ab6188cea3 cpu/*: add missing include of assert.h 2020-10-22 11:13:08 +02:00
Benjamin Valentin
548f59d380 cpu/samd5x: remove RTC workaround
This is no longer needed.
2020-07-31 22:00:09 +02:00
Benjamin Valentin
93b43e5753 cpu/samd5x: make SAM0_GCLK_TIMER configurable 2020-06-20 00:25:54 +02:00
Benjamin Valentin
fba3aab2f3 cpu/samd5x: rename GCLK defines
Now that the GCLK defines are not always at a fixed frequency, rename
them to better reflect this.
2020-06-20 00:25:54 +02:00
Benjamin Valentin
b5f407f9a4 cpu/samd5x: enable buck voltage regulator when possible
When an external oscillator is used and the internal fast oscillators
are off, we can enable the buck converter if the board supports it.
2020-06-20 00:25:53 +02:00
Benjamin Valentin
849c76578a cpu/samd5x: allow to use XOSC as clock source
Allow to run the main clock and all peripheral clocks off XOSC.
This is necessary if we want to use the buck voltage regulator.
2020-06-20 00:10:08 +02:00
73c8911e62
cpu/samd5x: Add DMA peripheral to init 2020-06-12 20:04:05 +02:00
Benjamin Valentin
49fda3e900 cpu/samd5x: don't run DFLL on-demand
The DFLL on samd5x has a hardware bug that requires a special
re-enabling sequence when it is disabled and then re-enabled again.

When running the clock on-demand, the hardware handles the disabling
and re-enabling so that sequence does not get executed.

To reproduce, run `tests/periph_uart` on `same54-xpro`.

Without this patch the test will get seemingly stuck on `sleep_test()`.
(In fact it keeps running, but the DFLL has the wrong frequency so the
UART baudrate is wrong).

In this test, on `same54-xpro` only UART0 is sourced from DFLL.
So if the UART is disabled the DFLL will be turned off as well.
2020-04-02 20:11:41 +02:00
Benjamin Valentin
f6139ae346 cpu/samd5x: work around errata when (re-)initializing DFLL
When a previously disabled DFLL gets enabled again, the frequency will
be incorrect. Follow the procedure outlined in the errata sheet, section 2.8.3
to work around the issue.

This fixes wake from standby.
2020-04-01 15:41:20 +02:00
Dylan Laduranty
6bba4188fc
Merge pull request #13764 from benpicco/cpu/saml11/use_buck_converter
cpu/saml1x: select buck voltage regulator when possible
2020-04-01 14:47:47 +02:00
Benjamin Valentin
895eb943d8 cpu/sam0_common: add cpu_pm_cb_enter()/leave()
This allows to implement needed work-arounds surrounding sleep on
a per-MCU basis.
2020-03-31 17:18:58 +02:00
Benjamin Valentin
d12abe6a2b cpu/samd5x: disable RTC on init to prevent undefined RTC state
When changing the clock configuration while the RTC is running, the
RTC may end up in an undefined state that leaves it unresponsive.

The RTC is not reset to stay persistent across reboots/hibernate, so
it will not be reset on init.
Instead, disable the RTC while configuring the clocks, rtc_init() will
take care of re-enabling it.

@dylad introduced this workaround for saml21, samd5x needs it too.

To reproduce, set the CLOCK_CORECLOCK of a samd5x board (e.g. same54-xpro)
to 48 MHz.
Run any RTC application. The CPU will be stuck in _wait_syncbusy() after
a reboot.
This patch will fix this. (You will need to power-cycle the board if the
RTC has entered the stuck state as it will never be reset.)
2020-03-31 15:34:55 +02:00
Benjamin Valentin
b7b52c4c57 cpu/samd5x: use ONDEMAND bit to run clocks on demand
Set the ONDEMAND bit so clocks are only run if they have a user configured.

This saves 390 µA on same54-xpro.

 examples/default:

    before: 3.88 mA
    after : 3.49 mA

 examples/gnrc_networking: (with REB215-XPRO EXT3)

    before: 13.29 mA
    after : 12.9  mA
2020-02-19 16:56:35 +01:00
Benjamin Valentin
38b6ee56f3 cpu/sam0: use defines for GCLK IDs
Give the clocks explicit names to better identify their meaning.
2020-02-04 21:16:54 +01:00
Benjamin Valentin
1496149bba cpu/sam0: don't hard-code peripheral clocks
Instead of hard-coding the peripheral clocks to CLOCK_CORECLOCK
introduce helper functions to return the frequency of the individual
GCLKs and use those for baud-rate calculations.

This requires the GCLK to be part of the peripheral's config struct.
While this is already the case for most peripherals, this also adds
it for those where it wasn't used before.

As it defaults to 0 (CLOCK_CORECLOCK) no change is to be expected.
2020-02-04 21:06:21 +01:00
Benjamin Valentin
736e5e5a35 cpu/samd5x: allow more flexible selection of CLOCK_CORECLOCK
There are some constraints to the oscillators on the samd5x.

 - DFLL is fixed to run at 48 MHz
 - DPLL can run at 96 to 200 MHz

Always use DFLL for frequencies <= 48 MHz.
For frequencies >= 96 MHz, use DPLL directly.
For frequencies < 96 MHz, clock DPLL at twice the desired frequency
and use a divider.
2019-09-27 10:49:43 +02:00
Marian Buschsieweke
df27dbef7a
cpu: Moved stdio_init() into cpu_init()
- Removed stdio_init() from newlib's _init(), as this is too late in the boot
  process to allow DEBUG()ing during periph_init()
- Added stdio_init() to the various cpu_init() routines of the ARM CPUs just
  before periph_init()
2019-09-06 16:54:23 +02:00
Benjamin Valentin
f29ca155d8 cpu/samd5x: fix CPU init
There were still some things wrong with samd5x CPU init which only
showed up when used in conjunction with RIOTBOOT, that is cpu_init()
was called twice.

 - gclk_connect() should block until the GCLK is ready.
 - DPLL should be disabled dring configuration.
 - make sure not to use DPLL for MCLK when re-configuring DPLL
 - All APBxMASK bits should be in a defined state.
 - always enable 1kHz oscilator output.
2019-06-20 11:29:05 +02:00
Benjamin Valentin
f375b00ff3 cpu/samd5x: add support for samd5x/same5x MCUs
This adds supoprt for the Atmel SAMD51 & SAME54 SoC.
The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals
with the samd2x Cortex-M0+ and saml1x Cortex-M23 parts.
2019-06-06 16:47:11 +02:00