From 5bbc6eef9f3d2bab9794ab98d4718d0b070f4ad2 Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Wed, 19 Mar 2025 15:21:41 -0700 Subject: [PATCH] soc: atmel: samx7x: implement main oscillator bypass mode Enable support for using an external clock as the main clock. When bypass mode is enabled, the external crystal oscillator is bypassed, and the main clock is directly driven by an external clock signal. Signed-off-by: Perry Hung --- soc/atmel/sam/common/Kconfig | 12 ++++++++++++ soc/atmel/sam/samx7x/soc.c | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/soc/atmel/sam/common/Kconfig b/soc/atmel/sam/common/Kconfig index 760288ce486..e6c4e2744d1 100644 --- a/soc/atmel/sam/common/Kconfig +++ b/soc/atmel/sam/common/Kconfig @@ -32,6 +32,18 @@ config SOC_ATMEL_SAM_EXT_MAINCK Says n here will use the internal fast RC oscillator running at 12 MHz. +config SOC_ATMEL_SAM_EXT_MAINCK_BYPASS + bool "Use bypass mode for external crystal oscillator" + depends on SOC_ATMEL_SAM_EXT_MAINCK + help + When bypass mode is enabled, the external crystal oscillator is bypassed, + and the main clock is directly driven by an external clock signal. + + Says y here if you want to use an external clock signal directly instead + of the crystal oscillator. + + Says n here to use the external crystal oscillator normally. + menu "PLL A" config SOC_ATMEL_SAM_PLLA_MULA diff --git a/soc/atmel/sam/samx7x/soc.c b/soc/atmel/sam/samx7x/soc.c index 72360cc1411..60586491710 100644 --- a/soc/atmel/sam/samx7x/soc.c +++ b/soc/atmel/sam/samx7x/soc.c @@ -57,7 +57,9 @@ static ALWAYS_INLINE void clock_init(void) * this optimization is not deemed * critical now. */ - soc_pmc_switch_mainck_to_xtal(false, 0xff); + bool bypass = IS_ENABLED(CONFIG_SOC_ATMEL_SAM_EXT_MAINCK_BYPASS); + + soc_pmc_switch_mainck_to_xtal(bypass, 0xff); } /*