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 v4.0-branch] soc: sam0: samd5x: xosc32 configurable startup time #83103

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions soc/atmel/sam0/common/Kconfig.samd5x
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ config SOC_ATMEL_SAMD5X_XOSC32K
startup. This can then be selected as the main clock source
for the SOC.

config SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
depends on SOC_ATMEL_SAMD5X_XOSC32K
hex "Startup time external 32 kHz crystal oscillator"
range 0x0 0x6
default 0x1
help
Selects the startup time for the external 32 kHz crystal oscillator.

choice
prompt "Main clock source"
default SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN
Expand Down
11 changes: 8 additions & 3 deletions soc/atmel/sam0/common/soc_samd5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
#define SAM0_DFLL_FREQ_HZ (48000000U)
#define SAM0_DPLL_FREQ_MIN_HZ (96000000U)
#define SAM0_DPLL_FREQ_MAX_HZ (200000000U)
#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP

#if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN
static void osc32k_init(void)
{
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN
| OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_RUNSTDBY
| OSC32KCTRL_XOSC32K_STARTUP(0) | OSC32KCTRL_XOSC32K_CGM_XT;
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE
| OSC32KCTRL_XOSC32K_XTALEN
| OSC32KCTRL_XOSC32K_CGM_XT
| OSC32KCTRL_XOSC32K_EN32K
| OSC32KCTRL_XOSC32K_RUNSTDBY
| OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME)
;

Check notice on line 33 in soc/atmel/sam0/common/soc_samd5x.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/atmel/sam0/common/soc_samd5x.c:33 -#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP +#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP #if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN static void osc32k_init(void) { - OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE - | OSC32KCTRL_XOSC32K_XTALEN - | OSC32KCTRL_XOSC32K_CGM_XT - | OSC32KCTRL_XOSC32K_EN32K - | OSC32KCTRL_XOSC32K_RUNSTDBY - | OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME) - ; + OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN | + OSC32KCTRL_XOSC32K_CGM_XT | OSC32KCTRL_XOSC32K_EN32K | + OSC32KCTRL_XOSC32K_RUNSTDBY | + OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME);

Check notice on line 33 in soc/atmel/sam0/common/soc_samd5x.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/atmel/sam0/common/soc_samd5x.c:33 -#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP +#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP #if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN static void osc32k_init(void) { - OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE - | OSC32KCTRL_XOSC32K_XTALEN - | OSC32KCTRL_XOSC32K_CGM_XT - | OSC32KCTRL_XOSC32K_EN32K - | OSC32KCTRL_XOSC32K_RUNSTDBY - | OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME) - ; + OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN | + OSC32KCTRL_XOSC32K_CGM_XT | OSC32KCTRL_XOSC32K_EN32K | + OSC32KCTRL_XOSC32K_RUNSTDBY | + OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME);
while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) {
}

Expand Down
Loading