From 005de7024bc3a56de24df2b999e5d1d786b3ceba Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 21 Feb 2020 17:03:39 +0100 Subject: [PATCH] cpu/saml1x: enable buck voltage regulator Switch from the on-chip LDO to the on-chip buck voltage regulator. --- cpu/saml1x/cpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cpu/saml1x/cpu.c b/cpu/saml1x/cpu.c index ddf1bad220..7874b6a951 100644 --- a/cpu/saml1x/cpu.c +++ b/cpu/saml1x/cpu.c @@ -30,6 +30,16 @@ #define _NVMCTRL NVMCTRL #endif +/* As long as FDPLL is not used, we can default to + * always using the buck converter. + * + * An external inductor needs to be present on the board, + * so the feature can only be enabled by the board configuration. + */ +#ifndef USE_VREG_BUCK +#define USE_VREG_BUCK (0) +#endif + static void _gclk_setup(int gclk, uint32_t reg) { GCLK->GENCTRL[gclk].reg = reg; @@ -97,6 +107,11 @@ void cpu_init(void) /* initialize the Cortex-M core */ cortexm_init(); + /* not compatible with 96 MHz FDPLL */ + if (USE_VREG_BUCK) { + sam0_set_voltage_regulator(SAM0_VREG_BUCK); + } + /* turn on only needed APB peripherals */ MCLK->APBAMASK.reg = MCLK_APBAMASK_MCLK | MCLK_APBAMASK_OSCCTRL