diff --git a/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts index b49ea348e8b..f89f1c09170 100644 --- a/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts +++ b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts @@ -69,3 +69,8 @@ location = <15>; status = "ok"; }; + +&gpio { + location-swo = <0>; + status = "ok"; +}; diff --git a/dts/arm/silabs/efm32pg12b.dtsi b/dts/arm/silabs/efm32pg12b.dtsi index 69b4b857540..688dd45cf97 100644 --- a/dts/arm/silabs/efm32pg12b.dtsi +++ b/dts/arm/silabs/efm32pg12b.dtsi @@ -117,7 +117,7 @@ status = "disabled"; }; - gpio@4000a400 { + gpio: gpio@4000a400 { compatible = "silabs,efm32-gpio"; reg = <0x4000a400 0xf00>; interrupts = <1 2 11 2>; diff --git a/dts/bindings/gpio/silabs,efm32-gpio.yaml b/dts/bindings/gpio/silabs,efm32-gpio.yaml index 437ea5e80f9..2ec35e9308d 100644 --- a/dts/bindings/gpio/silabs,efm32-gpio.yaml +++ b/dts/bindings/gpio/silabs,efm32-gpio.yaml @@ -31,4 +31,9 @@ properties: description: Human readable string describing the device (used by Zephyr for API name) generation: define + location-swo: + type: int + category: optional + description: Serial Wire Output (SWO) PIN location + generation: define ... diff --git a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b index 4fa8b4c9e39..4304a9b2e14 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b +++ b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b @@ -8,12 +8,12 @@ if SOC_SERIES_EFM32PG12B -if GPIO +if GPIO || LOG_BACKEND_SWO config GPIO_GECKO default y -endif # GPIO +endif # GPIO || LOG_BACKEND_SWO if SERIAL diff --git a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.series b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.series index 036682a6498..c34b2ace4d5 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/Kconfig.series +++ b/soc/arm/silabs_exx32/efm32pg12b/Kconfig.series @@ -8,6 +8,7 @@ config SOC_SERIES_EFM32PG12B bool "EFM32PG12B Series MCU" select HAS_SILABS_GECKO + select HAS_SWO select CPU_CORTEX_M4 select CPU_HAS_FPU select SOC_FAMILY_EXX32 diff --git a/soc/arm/silabs_exx32/efm32pg12b/dts_fixup.h b/soc/arm/silabs_exx32/efm32pg12b/dts_fixup.h index ef6ec11355a..7e54a999752 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/dts_fixup.h +++ b/soc/arm/silabs_exx32/efm32pg12b/dts_fixup.h @@ -16,6 +16,7 @@ #define DT_GPIO_GECKO_COMMON_EVEN_PRI DT_SILABS_EFM32_GPIO_4000A400_IRQ_GPIO_EVEN_PRIORITY #define DT_GPIO_GECKO_COMMON_ODD_IRQ DT_SILABS_EFM32_GPIO_4000A400_IRQ_GPIO_ODD #define DT_GPIO_GECKO_COMMON_ODD_PRI DT_SILABS_EFM32_GPIO_4000A400_IRQ_GPIO_ODD_PRIORITY +#define DT_GPIO_GECKO_SWO_LOCATION DT_SILABS_EFM32_GPIO_4000A400_LOCATION_SWO #define DT_GPIO_GECKO_PORTA_NAME DT_SILABS_EFM32_GPIO_PORT_4000A000_LABEL #define DT_GPIO_GECKO_PORTB_NAME DT_SILABS_EFM32_GPIO_PORT_4000A030_LABEL diff --git a/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h b/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h index 43e3d87cca4..0bb76d18fff 100644 --- a/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h +++ b/soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h @@ -16,6 +16,21 @@ #include #include +#ifdef CONFIG_GPIO_GECKO +/* Serial Wire Output (SWO) */ +#if (DT_GPIO_GECKO_SWO_LOCATION == 0) +#define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1} +#elif (DT_GPIO_GECKO_SWO_LOCATION == 1) +#define PIN_SWO {gpioPortB, 13, gpioModePushPull, 1} +#elif (DT_GPIO_GECKO_SWO_LOCATION == 2) +#define PIN_SWO {gpioPortD, 15, gpioModePushPull, 1} +#elif (DT_GPIO_GECKO_SWO_LOCATION == 3) +#define PIN_SWO {gpioPortC, 11, gpioModePushPull, 1} +#elif (DT_GPIO_GECKO_SWO_LOCATION >= 4) +#error ("Invalid SWO pin location") +#endif +#endif /* CONFIG_GPIO_GECKO */ + #ifdef CONFIG_USART_GECKO_0 #if (DT_SILABS_GECKO_USART_USART_0_GPIO_LOC == 0) #define PIN_USART0_TXD {gpioPortA, 0, gpioModePushPull, 1}