From f7b26381651320ad8e5ce212b46a668e6b8ed8fd Mon Sep 17 00:00:00 2001 From: Aaron Ye Date: Wed, 30 Oct 2024 14:48:15 +0800 Subject: [PATCH] soc: ambiq: enable the TPIU clock source This commit enables the TPIU clock source in Apollo3 and Apollo4 soc initialization if LOG_BACKEND_SWO is used. Signed-off-by: Aaron Ye --- soc/ambiq/apollo3x/soc.c | 6 ++++++ soc/ambiq/apollo4x/soc.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/soc/ambiq/apollo3x/soc.c b/soc/ambiq/apollo3x/soc.c index bae475e814f..33bf6568d37 100644 --- a/soc/ambiq/apollo3x/soc.c +++ b/soc/ambiq/apollo3x/soc.c @@ -28,4 +28,10 @@ void soc_early_init_hook(void) #ifdef CONFIG_PM ambiq_power_init(); #endif + +#ifdef CONFIG_LOG_BACKEND_SWO + /* Select HFRC/8 (6MHz) for the TPIU clock source */ + MCUCTRL->TPIUCTRL_b.CLKSEL = MCUCTRL_TPIUCTRL_CLKSEL_HFRCDIV8; + MCUCTRL->TPIUCTRL_b.ENABLE = MCUCTRL_TPIUCTRL_ENABLE_EN; +#endif } diff --git a/soc/ambiq/apollo4x/soc.c b/soc/ambiq/apollo4x/soc.c index b434e20f0ee..5338a2e2f5f 100644 --- a/soc/ambiq/apollo4x/soc.c +++ b/soc/ambiq/apollo4x/soc.c @@ -23,4 +23,10 @@ void soc_early_init_hook(void) #ifdef CONFIG_PM ambiq_power_init(); #endif + +#ifdef CONFIG_LOG_BACKEND_SWO + /* Select HFRC 48MHz for the TPIU clock source */ + MCUCTRL->DBGCTRL_b.CM4CLKSEL = MCUCTRL_DBGCTRL_CM4CLKSEL_HFRC48; + MCUCTRL->DBGCTRL_b.CM4TPIUENABLE = MCUCTRL_DBGCTRL_CM4TPIUENABLE_EN; +#endif }