Skip to content

Commit 5a6cf52

Browse files
scottwcpgnashif
authored andcommitted
soc: mec172x: Add hardware debug configuration
Add configuration items to select various ARM debug options such as SWD only, SWD plus SWV, or SWD plus ETM. The default is SWD only. Signed-off-by: Scott Worley <[email protected]>
1 parent e6f5c5e commit 5a6cf52

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

soc/arm/microchip_mec/mec172x/Kconfig.soc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,49 @@ config SOC_MEC172X_PROC_CLK_DIV
2626
and main 96 MHz clock (MCK):
2727
HCLK = MCK / PROC_CLK_DIV
2828
Allowed divider values: 1, 3, 4, 16, and 48.
29+
30+
choice
31+
prompt "MEC172x debug interface general configuration"
32+
default SOC_MEC172X_DEBUG_WITHOUT_TRACING
33+
depends on SOC_SERIES_MEC172X
34+
help
35+
Select Debug SoC interface support for MEC172X SoC family
36+
37+
config SOC_MEC172X_DEBUG_DISABLED
38+
bool "Disable debug support"
39+
help
40+
Debug port is disabled, JTAG/SWD cannot be enabled. JTAG_RST#
41+
pin is ignored. All other JTAG pins can be used as GPIOs
42+
or other non-JTAG alternate functions.
43+
44+
config SOC_MEC172X_DEBUG_WITHOUT_TRACING
45+
bool "Debug support via Serial wire debug"
46+
help
47+
JTAG port in SWD mode. I2C09 and ADC00-03 can be used.
48+
49+
config SOC_MEC172X_DEBUG_AND_TRACING
50+
bool "Debug support via Serial wire debug with tracing enabled"
51+
help
52+
JTAG port is enabled in SWD mode. Refer to tracing options
53+
to see if ADC00-03 can be used or not.
54+
endchoice
55+
56+
choice
57+
prompt "MEC172X debug interface trace configuration"
58+
default SOC_MEC172X_DEBUG_AND_ETM_TRACING
59+
depends on SOC_MEC172X_DEBUG_AND_TRACING
60+
help
61+
Select tracing mode for debug interface
62+
63+
config SOC_MEC172X_DEBUG_AND_ETM_TRACING
64+
bool "Debug support via Serial wire debug"
65+
help
66+
JTAG port in SWD mode and ETM as tracing method.
67+
I2C09 can be used, but ADC00-03 cannot.
68+
69+
config SOC_MEC172X_DEBUG_AND_SWV_TRACING
70+
bool "debug support via Serial Wire Debug and Viewer"
71+
help
72+
JTAG port in SWD mode and SWV as tracing method.
73+
I2C09 cannot be used. ADC00-03 can be used.
74+
endchoice

soc/arm/microchip_mec/mec172x/soc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,38 @@
1212
#include <zephyr/arch/cpu.h>
1313
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
1414

15+
/* Enable SWD and ETM debug interface and pins.
16+
* NOTE: ETM TRACE pins exposed on MEC172x EVB J30 12,14,16,18,20.
17+
*/
18+
static void configure_debug_interface(void)
19+
{
20+
struct ecs_regs *ecs = (struct ecs_regs *)(DT_REG_ADDR(DT_NODELABEL(ecs)));
21+
22+
#ifdef CONFIG_SOC_MEC172X_DEBUG_DISABLED
23+
ecs->ETM_CTRL = 0;
24+
ecs->DEBUG_CTRL = 0;
25+
#elif defined(CONFIG_SOC_MEC172X_DEBUG_WITHOUT_TRACING)
26+
ecs->ETM_CTRL = 0;
27+
ecs->DEBUG_CTRL = (MCHP_ECS_DCTRL_DBG_EN | MCHP_ECS_DCTRL_MODE_SWD);
28+
#elif defined(CONFIG_SOC_MEC172X_DEBUG_AND_TRACING)
29+
30+
#if defined(CONFIG_SOC_MEC172X_DEBUG_AND_ETM_TRACING)
31+
ecs->ETM_CTRL = 1u;
32+
ecs->DEBUG_CTRL = (MCHP_ECS_DCTRL_DBG_EN | MCHP_ECS_DCTRL_MODE_SWD);
33+
#elif defined(CONFIG_SOC_MEC172X_DEBUG_AND_SWV_TRACING)
34+
ecs->ETM_CTRL = 0;
35+
ecs->DEBUG_CTRL = (MCHP_ECS_DCTRL_DBG_EN | MCHP_ECS_DCTRL_MODE_SWD_SWV);
36+
#endif /* CONFIG_SOC_MEC172X_DEBUG_AND_ETM_TRACING */
37+
38+
#endif /* CONFIG_SOC_MEC172X_DEBUG_DISABLED */
39+
}
40+
1541
static int soc_init(const struct device *dev)
1642
{
1743
ARG_UNUSED(dev);
1844

45+
configure_debug_interface();
46+
1947
return 0;
2048
}
2149

0 commit comments

Comments
 (0)