Commit 72a1c809 authored by Thomas Schranz's avatar Thomas Schranz Committed by Dan Kalowsky
Browse files

soc: sam0: samd5x: xosc32 configurable startup time

Adds Kconfig option to configure the startup time of the external
32KHz crystal oscillator.

Signed-off-by: default avatarThomas Schranz <electronics@wandfluh.com>
(cherry picked from commit cd20154b)
parent c861286b
Loading
Loading
Loading
Loading
+8 −0
Changes for soc/atmel/sam0/common/Kconfig.samd5x: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+8 −3
Changes for soc/atmel/sam0/common/soc_samd5x.c: 8 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -18,13 +18,18 @@
#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)
				;

	while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) {
	}