Skip to content

Commit 8f0aa32

Browse files
mnkpnashif
authored andcommitted
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 <[email protected]>
1 parent 825aab3 commit 8f0aa32

File tree

8 files changed

+33
-36
lines changed

8 files changed

+33
-36
lines changed

drivers/gpio/gpio_gecko.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -283,24 +283,6 @@ DEVICE_AND_API_INIT(gpio_gecko_common, DT_GPIO_GECKO_COMMON_NAME,
283283

284284
static int gpio_gecko_common_init(struct device *dev)
285285
{
286-
/* Serial Wire Output (SWO) pin is controlled by GPIO module, configure
287-
* if enabled.
288-
*/
289-
#if defined(DT_GPIO_GECKO_SWO_LOCATION)
290-
struct soc_gpio_pin pin_swo = PIN_SWO;
291-
292-
#if defined(_GPIO_ROUTEPEN_MASK)
293-
/* Enable Serial wire output pin */
294-
GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN;
295-
/* Set SWO location */
296-
GPIO->ROUTELOC0 =
297-
DT_GPIO_GECKO_SWO_LOCATION << _GPIO_ROUTELOC0_SWVLOC_SHIFT;
298-
#else
299-
GPIO->ROUTE = GPIO_ROUTE_SWOPEN | (DT_GPIO_GECKO_SWO_LOCATION << 8);
300-
#endif
301-
soc_gpio_configure(&pin_swo);
302-
#endif /* defined(DT_GPIO_GECKO_SWO_LOCATION) */
303-
304286
gpio_gecko_common_data.count = 0;
305287
IRQ_CONNECT(GPIO_EVEN_IRQn, DT_GPIO_GECKO_COMMON_EVEN_PRI,
306288
gpio_gecko_common_isr, DEVICE_GET(gpio_gecko_common), 0);

soc/arm/silabs_exx32/common/soc.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ static ALWAYS_INLINE void clock_init(void)
7070
/* Enable the High Frequency Peripheral Clock */
7171
CMU_ClockEnable(cmuClock_HFPER, true);
7272

73-
#ifdef CONFIG_LOG_BACKEND_SWO
74-
/* Select HFCLK as the debug trace clock */
75-
CMU->DBGCLKSEL = CMU_DBGCLKSEL_DBG_HFCLK;
76-
#endif
77-
78-
#ifdef CONFIG_GPIO_GECKO
73+
#if defined(CONFIG_GPIO_GECKO) || defined(CONFIG_LOG_BACKEND_SWO)
7974
CMU_ClockEnable(cmuClock_GPIO, true);
8075
#endif
8176
}
@@ -99,6 +94,27 @@ static ALWAYS_INLINE void dcdc_init(void)
9994
}
10095
#endif
10196

97+
#ifdef CONFIG_LOG_BACKEND_SWO
98+
static void swo_init(void)
99+
{
100+
struct soc_gpio_pin pin_swo = PIN_SWO;
101+
102+
/* Select HFCLK as the debug trace clock */
103+
CMU->DBGCLKSEL = CMU_DBGCLKSEL_DBG_HFCLK;
104+
105+
#if defined(_GPIO_ROUTEPEN_MASK)
106+
/* Enable Serial wire output pin */
107+
GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN;
108+
/* Set SWO location */
109+
GPIO->ROUTELOC0 =
110+
DT_GPIO_GECKO_SWO_LOCATION << _GPIO_ROUTELOC0_SWVLOC_SHIFT;
111+
#else
112+
GPIO->ROUTE = GPIO_ROUTE_SWOPEN | (DT_GPIO_GECKO_SWO_LOCATION << 8);
113+
#endif
114+
soc_gpio_configure(&pin_swo);
115+
}
116+
#endif /* CONFIG_LOG_BACKEND_SWO */
117+
102118
/**
103119
* @brief Perform basic hardware initialization
104120
*
@@ -132,6 +148,11 @@ static int silabs_exx32_init(struct device *arg)
132148
*/
133149
NMI_INIT();
134150

151+
#ifdef CONFIG_LOG_BACKEND_SWO
152+
/* Configure SWO debug output */
153+
swo_init();
154+
#endif
155+
135156
/* restore interrupt state */
136157
irq_unlock(oldLevel);
137158
return 0;

soc/arm/silabs_exx32/efm32pg12b/Kconfig.defconfig.efm32pg12b

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Copyright (c) 2018 Christian Taedcke
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if GPIO || LOG_BACKEND_SWO
6+
if GPIO
77

88
config GPIO_GECKO
99
default y
1010

11-
endif # GPIO || LOG_BACKEND_SWO
11+
endif # GPIO
1212

1313
if SERIAL
1414

soc/arm/silabs_exx32/efm32pg12b/soc_pinmap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <soc.h>
1717
#include <em_gpio.h>
1818

19-
#ifdef CONFIG_GPIO_GECKO
2019
/* Serial Wire Output (SWO) */
2120
#if (DT_GPIO_GECKO_SWO_LOCATION == 0)
2221
#define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1}
@@ -29,6 +28,5 @@
2928
#elif (DT_GPIO_GECKO_SWO_LOCATION >= 4)
3029
#error ("Invalid SWO pin location")
3130
#endif
32-
#endif /* CONFIG_GPIO_GECKO */
3331

3432
#endif /* _SILABS_EFM32PG12B_SOC_PINMAP_H_ */

soc/arm/silabs_exx32/efr32fg1p/Kconfig.defconfig.efr32fg1p

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Copyright (c) 2018 Christian Taedcke
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if GPIO || LOG_BACKEND_SWO
6+
if GPIO
77

88
config GPIO_GECKO
99
default y
1010

11-
endif # GPIO || LOG_BACKEND_SWO
11+
endif # GPIO
1212

1313
if SERIAL
1414

soc/arm/silabs_exx32/efr32fg1p/soc_pinmap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <soc.h>
1717
#include <em_gpio.h>
1818

19-
#ifdef CONFIG_GPIO_GECKO
2019
/* Serial Wire Output (SWO) */
2120
#if (DT_GPIO_GECKO_SWO_LOCATION == 0)
2221
#define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1}
@@ -29,6 +28,5 @@
2928
#elif (DT_GPIO_GECKO_SWO_LOCATION >= 4)
3029
#error ("Invalid SWO pin location")
3130
#endif
32-
#endif /* CONFIG_GPIO_GECKO */
3331

3432
#endif /* _SILABS_EFR32FG1P_SOC_PINMAP_H_ */

soc/arm/silabs_exx32/efr32mg12p/Kconfig.defconfig.efr32mg12p

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Copyright (c) 2018 Diego Sueiro
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if GPIO || LOG_BACKEND_SWO
6+
if GPIO
77

88
config GPIO_GECKO
99
default y
1010

11-
endif # GPIO || LOG_BACKEND_SWO
11+
endif # GPIO
1212

1313
if SERIAL
1414

soc/arm/silabs_exx32/efr32mg12p/soc_pinmap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include <em_gpio.h>
1717

18-
#ifdef CONFIG_GPIO_GECKO
1918
/* Serial Wire Output (SWO) */
2019
#if (DT_GPIO_GECKO_SWO_LOCATION == 0)
2120
#define PIN_SWO {gpioPortF, 2, gpioModePushPull, 1}
@@ -28,6 +27,5 @@
2827
#elif (DT_GPIO_GECKO_SWO_LOCATION >= 4)
2928
#error ("Invalid SWO pin location")
3029
#endif
31-
#endif /* CONFIG_GPIO_GECKO */
3230

3331
#endif /* _SOC_PINMAP_H_ */

0 commit comments

Comments
 (0)