soc: silabs_exx32: Add SWO logger support

By default, after reset SWO signal is not connected to GPIO pin. This
commit adds required initialization code to enable support for SWO
logger. Not all SoC series support the feature.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit is contained in:
Piotr Mienkowski 2018-12-27 08:12:05 +01:00 committed by Carles Cufí
commit 8bed2d5e27
16 changed files with 83 additions and 6 deletions

View file

@ -60,6 +60,11 @@
status = "ok";
};
&gpio {
location-swo = <0>;
status = "ok";
};
&flash0 {
/*
* If the chosen node has no zephyr,code-partition property, the

View file

@ -73,3 +73,8 @@
location = <17>;
status = "ok";
};
&gpio {
location-swo = <0>;
status = "ok";
};

View file

@ -285,6 +285,24 @@ 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);

View file

@ -57,7 +57,7 @@
label = "USART_1";
};
gpio@4000a400 {
gpio: gpio@4000a400 {
compatible = "silabs,efr32xg1-gpio";
reg = <0x4000a400 0xc00>;
interrupts = <9 2 17 2>;

View file

@ -111,7 +111,7 @@
status = "disabled";
};
gpio@4000a400 {
gpio: gpio@4000a400 {
compatible = "silabs,efr32mg-gpio";
reg = <0x4000a400 0xc00>;
interrupts = <9 2 17 2>;

View file

@ -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
...

View file

@ -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
...

View file

@ -66,6 +66,11 @@ static ALWAYS_INLINE void clkInit(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
CMU_ClockEnable(cmuClock_GPIO, true);
#endif

View file

@ -8,12 +8,12 @@
if SOC_SERIES_EFR32FG1P
if GPIO
if GPIO || LOG_BACKEND_SWO
config GPIO_GECKO
default y
endif # GPIO
endif # GPIO || LOG_BACKEND_SWO
if SERIAL

View file

@ -8,6 +8,7 @@
config SOC_SERIES_EFR32FG1P
bool "EFR32FG1P Series MCU"
select HAS_SILABS_GECKO
select HAS_SWO
select CPU_CORTEX_M4
select CPU_HAS_FPU
select SOC_FAMILY_EXX32

View file

@ -16,6 +16,7 @@
#define DT_GPIO_GECKO_COMMON_EVEN_PRI DT_SILABS_EFR32XG1_GPIO_4000A400_IRQ_GPIO_EVEN_PRIORITY
#define DT_GPIO_GECKO_COMMON_ODD_IRQ DT_SILABS_EFR32XG1_GPIO_4000A400_IRQ_GPIO_ODD
#define DT_GPIO_GECKO_COMMON_ODD_PRI DT_SILABS_EFR32XG1_GPIO_4000A400_IRQ_GPIO_ODD_PRIORITY
#define DT_GPIO_GECKO_SWO_LOCATION DT_SILABS_EFR32XG1_GPIO_4000A400_LOCATION_SWO
#define DT_GPIO_GECKO_PORTA_NAME DT_SILABS_EFR32XG1_GPIO_PORT_4000A000_LABEL
#define DT_GPIO_GECKO_PORTB_NAME DT_SILABS_EFR32XG1_GPIO_PORT_4000A030_LABEL

View file

@ -16,6 +16,21 @@
#include <soc.h>
#include <em_gpio.h>
#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_LOCATION == 0)
#define PIN_USART0_TXD {gpioPortA, 0, gpioModePushPull, 1}

View file

@ -8,12 +8,12 @@
if SOC_SERIES_EFR32MG12P
if GPIO
if GPIO || LOG_BACKEND_SWO
config GPIO_GECKO
default y
endif # GPIO
endif # GPIO || LOG_BACKEND_SWO
if SERIAL

View file

@ -13,6 +13,7 @@ config SOC_SERIES_EFR32MG12P
select SYS_POWER_LOW_POWER_STATE_SUPPORTED
select CPU_HAS_SYSTICK
select HAS_SILABS_GECKO
select HAS_SWO
select SOC_GECKO_CMU
select SOC_GECKO_EMU
select SOC_GECKO_GPIO

View file

@ -16,6 +16,7 @@
#define DT_GPIO_GECKO_COMMON_EVEN_PRI DT_SILABS_EFR32MG_GPIO_4000A400_IRQ_GPIO_EVEN_PRIORITY
#define DT_GPIO_GECKO_COMMON_ODD_IRQ DT_SILABS_EFR32MG_GPIO_4000A400_IRQ_GPIO_ODD
#define DT_GPIO_GECKO_COMMON_ODD_PRI DT_SILABS_EFR32MG_GPIO_4000A400_IRQ_GPIO_ODD_PRIORITY
#define DT_GPIO_GECKO_SWO_LOCATION DT_SILABS_EFR32MG_GPIO_4000A400_LOCATION_SWO
#define DT_GPIO_GECKO_PORTA_NAME DT_SILABS_EFR32MG_GPIO_PORT_4000A000_LABEL
#define DT_GPIO_GECKO_PORTB_NAME DT_SILABS_EFR32MG_GPIO_PORT_4000A030_LABEL

View file

@ -15,6 +15,21 @@
#include <em_gpio.h>
#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_UART_GECKO
#ifdef CONFIG_USART_GECKO_0
#if (DT_SILABS_GECKO_USART_USART_0_LOCATION == 0)