diff --git a/drivers/gpio/gpio_gecko.c b/drivers/gpio/gpio_gecko.c index 6e209f4c33c..9e211639c64 100644 --- a/drivers/gpio/gpio_gecko.c +++ b/drivers/gpio/gpio_gecko.c @@ -283,24 +283,6 @@ DEVICE_AND_API_INIT(gpio_gecko_common, DT_GPIO_GECKO_COMMON_NAME, static int gpio_gecko_common_init(struct device *dev) { - /* Serial Wire Output (SWO) pin is controlled by GPIO module, configure - * if enabled. - */ -#if defined(DT_GPIO_GECKO_SWO_LOCATION) - struct soc_gpio_pin pin_swo = PIN_SWO; - -#if defined(_GPIO_ROUTEPEN_MASK) - /* Enable Serial wire output pin */ - GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN; - /* Set SWO location */ - GPIO->ROUTELOC0 = - DT_GPIO_GECKO_SWO_LOCATION << _GPIO_ROUTELOC0_SWVLOC_SHIFT; -#else - GPIO->ROUTE = GPIO_ROUTE_SWOPEN | (DT_GPIO_GECKO_SWO_LOCATION << 8); -#endif - soc_gpio_configure(&pin_swo); -#endif /* defined(DT_GPIO_GECKO_SWO_LOCATION) */ - gpio_gecko_common_data.count = 0; IRQ_CONNECT(GPIO_EVEN_IRQn, DT_GPIO_GECKO_COMMON_EVEN_PRI, gpio_gecko_common_isr, DEVICE_GET(gpio_gecko_common), 0); diff --git a/soc/arm/silabs_exx32/common/soc.c b/soc/arm/silabs_exx32/common/soc.c index 6a8a274646b..a0c48b7ccfd 100644 --- a/soc/arm/silabs_exx32/common/soc.c +++ b/soc/arm/silabs_exx32/common/soc.c @@ -70,12 +70,7 @@ static ALWAYS_INLINE void clock_init(void) /* Enable the High Frequency Peripheral Clock */ CMU_ClockEnable(cmuClock_HFPER, true); -#ifdef CONFIG_LOG_BACKEND_SWO - /* Select HFCLK as the debug trace clock */ - CMU->DBGCLKSEL = CMU_DBGCLKSEL_DBG_HFCLK; -#endif - -#ifdef CONFIG_GPIO_GECKO +#if defined(CONFIG_GPIO_GECKO) || defined(CONFIG_LOG_BACKEND_SWO) CMU_ClockEnable(cmuClock_GPIO, true); #endif } @@ -99,6 +94,27 @@ static ALWAYS_INLINE void dcdc_init(void) } #endif +#ifdef CONFIG_LOG_BACKEND_SWO +static void swo_init(void) +{ + struct soc_gpio_pin pin_swo = PIN_SWO; + + /* Select HFCLK as the debug trace clock */ + CMU->DBGCLKSEL = CMU_DBGCLKSEL_DBG_HFCLK; + +#if defined(_GPIO_ROUTEPEN_MASK) + /* Enable Serial wire output pin */ + GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN; + /* Set SWO location */ + GPIO->ROUTELOC0 = + DT_GPIO_GECKO_SWO_LOCATION << _GPIO_ROUTELOC0_SWVLOC_SHIFT; +#else + GPIO->ROUTE = GPIO_ROUTE_SWOPEN | (DT_GPIO_GECKO_SWO_LOCATION << 8); +#endif + soc_gpio_configure(&pin_swo); +} +#endif /* CONFIG_LOG_BACKEND_SWO */ + /** * @brief Perform basic hardware initialization * @@ -132,6 +148,11 @@ static int silabs_exx32_init(struct device *arg) */ NMI_INIT(); +#ifdef CONFIG_LOG_BACKEND_SWO + /* Configure SWO debug output */ + swo_init(); +#endif + /* restore interrupt state */ irq_unlock(oldLevel); return 0; diff --git a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b index 03c7829e9b3..3536735a905 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b +++ b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b @@ -3,12 +3,12 @@ # Copyright (c) 2018 Christian Taedcke # SPDX-License-Identifier: Apache-2.0 -if GPIO || LOG_BACKEND_SWO +if GPIO config GPIO_GECKO default y -endif # GPIO || LOG_BACKEND_SWO +endif # GPIO if SERIAL diff --git a/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h b/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h index b38a4a740d2..2bd549b9944 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h +++ b/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h @@ -16,7 +16,6 @@ #include #include -#ifdef CONFIG_GPIO_GECKO /* Serial Wire Output (SWO) */ #if (DT_GPIO_GECKO_SWO_LOCATION == 0) #define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1} @@ -29,6 +28,5 @@ #elif (DT_GPIO_GECKO_SWO_LOCATION >= 4) #error ("Invalid SWO pin location") #endif -#endif /* CONFIG_GPIO_GECKO */ #endif /* _SILABS_EFM32PG12B_SOC_PINMAP_H_ */ diff --git a/soc/arm/silabs_exx32/efr32fg1p/Kconfig.defconfig.efr32fg1p b/soc/arm/silabs_exx32/efr32fg1p/Kconfig.defconfig.efr32fg1p index 7bedce3dd1a..d0690d61dee 100644 --- a/soc/arm/silabs_exx32/efr32fg1p/Kconfig.defconfig.efr32fg1p +++ b/soc/arm/silabs_exx32/efr32fg1p/Kconfig.defconfig.efr32fg1p @@ -3,12 +3,12 @@ # Copyright (c) 2018 Christian Taedcke # SPDX-License-Identifier: Apache-2.0 -if GPIO || LOG_BACKEND_SWO +if GPIO config GPIO_GECKO default y -endif # GPIO || LOG_BACKEND_SWO +endif # GPIO if SERIAL diff --git a/soc/arm/silabs_exx32/efr32fg1p/soc_pinmap.h b/soc/arm/silabs_exx32/efr32fg1p/soc_pinmap.h index af2b1a4b02b..02ae374a166 100644 --- a/soc/arm/silabs_exx32/efr32fg1p/soc_pinmap.h +++ b/soc/arm/silabs_exx32/efr32fg1p/soc_pinmap.h @@ -16,7 +16,6 @@ #include #include -#ifdef CONFIG_GPIO_GECKO /* Serial Wire Output (SWO) */ #if (DT_GPIO_GECKO_SWO_LOCATION == 0) #define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1} @@ -29,6 +28,5 @@ #elif (DT_GPIO_GECKO_SWO_LOCATION >= 4) #error ("Invalid SWO pin location") #endif -#endif /* CONFIG_GPIO_GECKO */ #endif /* _SILABS_EFR32FG1P_SOC_PINMAP_H_ */ diff --git a/soc/arm/silabs_exx32/efr32mg12p/Kconfig.defconfig.efr32mg12p b/soc/arm/silabs_exx32/efr32mg12p/Kconfig.defconfig.efr32mg12p index 4830507a9c0..e0dd217c758 100644 --- a/soc/arm/silabs_exx32/efr32mg12p/Kconfig.defconfig.efr32mg12p +++ b/soc/arm/silabs_exx32/efr32mg12p/Kconfig.defconfig.efr32mg12p @@ -3,12 +3,12 @@ # Copyright (c) 2018 Diego Sueiro # SPDX-License-Identifier: Apache-2.0 -if GPIO || LOG_BACKEND_SWO +if GPIO config GPIO_GECKO default y -endif # GPIO || LOG_BACKEND_SWO +endif # GPIO if SERIAL diff --git a/soc/arm/silabs_exx32/efr32mg12p/soc_pinmap.h b/soc/arm/silabs_exx32/efr32mg12p/soc_pinmap.h index 19353ad5338..020b8355cac 100644 --- a/soc/arm/silabs_exx32/efr32mg12p/soc_pinmap.h +++ b/soc/arm/silabs_exx32/efr32mg12p/soc_pinmap.h @@ -15,7 +15,6 @@ #include -#ifdef CONFIG_GPIO_GECKO /* Serial Wire Output (SWO) */ #if (DT_GPIO_GECKO_SWO_LOCATION == 0) #define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1} @@ -28,6 +27,5 @@ #elif (DT_GPIO_GECKO_SWO_LOCATION >= 4) #error ("Invalid SWO pin location") #endif -#endif /* CONFIG_GPIO_GECKO */ #endif /* _SOC_PINMAP_H_ */