-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stm32: pm: Enable to driver JTAG port pns to analog when not required #63495
Merged
fabiobaltieri
merged 5 commits into
zephyrproject-rtos:main
from
erwango:dev/stm32_pm_jtag_analog
Jan 26, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
54c6a4c
boards: nucleo_wba52cg: Enable flash and debug using OpenOCD
erwango afbfb29
west.yml: hal_stm32: Use SW/JTAG signals description
erwango 31a8dbf
soc: stm32: PM: Disable jtag port pins if no debug
erwango 432ed28
dts: stm32u5: Add SW/JTAG debug port node
erwango 8fbf9bd
include: pinctrl.h: Make PINCTRL_SKIP_SLEEP available with CONFIG_PM
erwango File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") | ||
|
||
set(OPENOCD "/local/mcu/tools/openocd/src/openocd" CACHE FILEPATH "" FORCE) | ||
set(OPENOCD_DEFAULT_PATH /local/mcu/tools/openocd/tcl) | ||
|
||
include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: Serial Wire - JTAG Connector | ||
|
||
compatible: "swj-connector" | ||
|
||
include: pinctrl-device.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2023 STMicroelectronics | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/drivers/pinctrl.h> | ||
#include <zephyr/init.h> | ||
|
||
#define SWJ_NODE DT_NODELABEL(swj_port) | ||
|
||
PINCTRL_DT_DEFINE(SWJ_NODE); | ||
|
||
const struct pinctrl_dev_config *swj_pcfg = PINCTRL_DT_DEV_CONFIG_GET(SWJ_NODE); | ||
|
||
/* | ||
* Serial Wire / JTAG port pins are enabled as part of SoC default configuration. | ||
* When debug access is not needed and in case power consumption performance is | ||
* expected, configure matching pins to analog in order to save power. | ||
*/ | ||
|
||
static int swj_to_analog(void) | ||
{ | ||
int err; | ||
|
||
/* Set Serial Wire / JTAG port pins to analog mode */ | ||
err = pinctrl_apply_state(swj_pcfg, PINCTRL_STATE_SLEEP); | ||
erwango marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (err < 0) { | ||
__ASSERT(0, "SWJ pinctrl setup failed"); | ||
return err; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* Run this routine as the earliest pin configuration in the target, | ||
* to avoid potential conflicts with devices accessing SWJ-DG pins for | ||
* their own needs. | ||
*/ | ||
SYS_INIT(swj_to_analog, PRE_KERNEL_1, CONFIG_SWJ_ANALOG_PRIORITY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the dtsi is the best place to put that since the pins can be used for something else than debug.
For example, in the nucleo_wba55cg.dts, PA15, PB3 and PB4 are used for SPI1. Depending on the order of initialization, I think it could result in drivers not functioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so we should make sure this is done before configuring any other device and change priority