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 }