Skip to content

Commit

Permalink
soc: arm: atmel: sam4s: Setup external crystal only once
Browse files Browse the repository at this point in the history
If the SoC uses an external main clock it should not be set both
in the bootloader and the application.

Skip if the internal RC oscillator is disabled.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
  • Loading branch information
pdgendt committed Dec 13, 2023
1 parent e268a6c commit 3eb9dca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soc/arm/atmel_sam/sam4s/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ static ALWAYS_INLINE void clock_init(void)
#endif /* CONFIG_SOC_ATMEL_SAM4S_EXT_SLCK */

#ifdef CONFIG_SOC_ATMEL_SAM4S_EXT_MAINCK
/* Skip if the internal oscillator is already disabled (for example in a bootloader) */
if (!(PMC->PMC_SR & PMC_SR_MOSCRCS)) {
goto osc_end;
}

/*
* Setup main external crystal oscillator.
*/
Expand Down Expand Up @@ -120,6 +125,8 @@ static ALWAYS_INLINE void clock_init(void)
}
#endif /* CONFIG_SOC_ATMEL_SAM4S_EXT_MAINCK */

osc_end:

/*
* Setup PLLA
*/
Expand Down

0 comments on commit 3eb9dca

Please sign in to comment.