soc: gecko: Enable SWO output during SoC initialization

Enable SWO debug output during system initialization and not as part of
GPIO driver initialization. After the modification the logger output
becomes available earlier during the boot process. Also, it's not
necessary anymore to build full GPIO driver only to enable SWO. This may
be critical when building small images.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit is contained in:
Piotr Mienkowski 2019-11-08 02:32:14 +01:00 committed by Anas Nashif
commit 8f0aa32ad5
8 changed files with 33 additions and 36 deletions

View file

@ -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);

View file

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

View file

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

View file

@ -16,7 +16,6 @@
#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}
@ -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_ */

View file

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

View file

@ -16,7 +16,6 @@
#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}
@ -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_ */

View file

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

View file

@ -15,7 +15,6 @@
#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}
@ -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_ */