Skip to content
Permalink
Browse files

soc: sam0: Make init code common between all samd2x SoCs

The init routines are the same for SAMD20, SAMD21 and SAMR21, so
move them into common/ to not have three copies of the same code.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
  • Loading branch information...
benpicco authored and nashif committed Mar 25, 2019
1 parent 9f69878 commit 86bd319d1f0044bb825a583045b8ae5e53d53e61
@@ -3,4 +3,4 @@
# Copyright (c) 2017 Google LLC.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(${SOC_SERIES})
add_subdirectory(common)
@@ -0,0 +1,8 @@
# Makefile - Atmel SAM0 MCU family
#
# Copyright (c) 2019 ML!PA Consulting GmbH
# SPDX-License-Identifier: Apache-2.0

zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMD20 soc_samd2x.c)
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMD21 soc_samd2x.c)
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMR21 soc_samd2x.c)
@@ -55,8 +55,13 @@ static void xosc32k_init(void)

static void osc32k_init(void)
{
#ifdef FUSES_OSC32K_CAL_ADDR
u32_t fuse = *(u32_t *)FUSES_OSC32K_CAL_ADDR;
u32_t calib = (fuse & FUSES_OSC32K_CAL_Msk) >> FUSES_OSC32K_CAL_Pos;
#else
u32_t fuse = *(u32_t *)FUSES_OSC32KCAL_ADDR;
u32_t calib = (fuse & FUSES_OSC32KCAL_Msk) >> FUSES_OSC32KCAL_Pos;
#endif

SYSCTRL->OSC32K.reg = SYSCTRL_OSC32K_CALIB(calib) |
SYSCTRL_OSC32K_STARTUP(0x6u) |
@@ -108,7 +113,9 @@ static void dfll_init(void)
}

SYSCTRL->DFLLCTRL.reg |= SYSCTRL_DFLLCTRL_MODE |
#ifdef SYSCTRL_DFLLCTRL_WAITLOCK
SYSCTRL_DFLLCTRL_WAITLOCK |
#endif
SYSCTRL_DFLLCTRL_QLDIS;
while (!SYSCTRL->PCLKSR.bit.DFLLRDY) {
}
@@ -126,7 +133,7 @@ static void dfll_init(void)
static void osc8m_init(void)
{
/* Turn off the prescaler */
SYSCTRL->OSC8M.bit.PRESC = SYSCTRL_OSC8M_PRESC_0_Val;
SYSCTRL->OSC8M.bit.PRESC = SYSCTRL_OSC8M_PRESC(0);
SYSCTRL->OSC8M.bit.ONDEMAND = 0;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 86bd319

Please sign in to comment.
You can’t perform that action at this time.