File tree 3 files changed +52
-0
lines changed
3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ config STM32_ENABLE_DEBUG_SLEEP_STOP
39
39
effectivly destroys the use-case of `west attach`. Also
40
40
SEGGER RTT and similar technologies need this.
41
41
42
+ config SWJ_ANALOG_PRIORITY
43
+ int "SWJ DP port to analog routine initialization priority"
44
+ default 49
45
+ help
46
+ Initialization priority of the routine within the PRE_KERNEL1 level.
47
+ This priority must be greater than GPIO_INIT_PRIORITY and lower than
48
+ UART_INIT_PRIORITY.
49
+
42
50
choice POWER_SUPPLY_CHOICE
43
51
prompt "STM32 power supply configuration"
44
52
default POWER_SUPPLY_LDO
Original file line number Diff line number Diff line change @@ -11,3 +11,7 @@ zephyr_linker_sources_ifdef(CONFIG_STM32_CCM SECTIONS ccm.ld)
11
11
12
12
zephyr_sources_ifdef(CONFIG_STM32_BACKUP_SRAM stm32_backup_sram.c)
13
13
zephyr_linker_sources_ifdef(CONFIG_STM32_BACKUP_SRAM SECTIONS stm32_backup_sram.ld)
14
+
15
+ if (NOT CONFIG_DEBUG AND CONFIG_PM)
16
+ zephyr_sources_ifdef(CONFIG_DT_HAS_SWJ_CONNECTOR_ENABLED pm_debug_swj.c)
17
+ endif ()
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023 STMicroelectronics
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <zephyr/drivers/pinctrl.h>
8
+ #include <zephyr/init.h>
9
+
10
+ #define SWJ_NODE DT_NODELABEL(swj_port)
11
+
12
+ PINCTRL_DT_DEFINE (SWJ_NODE );
13
+
14
+ const struct pinctrl_dev_config * swj_pcfg = PINCTRL_DT_DEV_CONFIG_GET (SWJ_NODE );
15
+
16
+ /*
17
+ * Serial Wire / JTAG port pins are enabled as part of SoC default configuration.
18
+ * When debug access is not needed and in case power consumption performance is
19
+ * expected, configure matching pins to analog in order to save power.
20
+ */
21
+
22
+ static int swj_to_analog (void )
23
+ {
24
+ int err ;
25
+
26
+ /* Set Serial Wire / JTAG port pins to analog mode */
27
+ err = pinctrl_apply_state (swj_pcfg , PINCTRL_STATE_SLEEP );
28
+ if (err < 0 ) {
29
+ __ASSERT (0 , "SWJ pinctrl setup failed" );
30
+ return err ;
31
+ }
32
+
33
+ return 0 ;
34
+ }
35
+
36
+ /* Run this routine as the earliest pin configuration in the target,
37
+ * to avoid potential conflicts with devices accessing SWJ-DG pins for
38
+ * their own needs.
39
+ */
40
+ SYS_INIT (swj_to_analog , PRE_KERNEL_1 , CONFIG_SWJ_ANALOG_PRIORITY );
You can’t perform that action at this time.
0 commit comments