-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: gpio: stm32: keep track of clock enabling per pin #78725
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
drivers: gpio: stm32: keep track of clock enabling per pin #78725
Conversation
|
Hello @jbr-ia, and thank you very much for your first pull request to the Zephyr project! |
drivers/gpio/gpio_stm32.c
Outdated
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 think this clarification would be useful.
| /* Release clock only if pin is disconnected */ | |
| /* Decrement GPIO usage count only if pin is now disconnected after being connected */ |
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 think that is indeed a better comment. The pull-request is updated.
drivers/gpio/gpio_stm32.h
Outdated
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.
| /* keep track of pins that have enabled the clock*/ | |
| /* keep track of pins that are connected & need GPIO clock to be enabled */ |
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.
Thanks, I have updated the pull-request.
The driver enables the clock of a gpio-port if any of the pins use the port. This is done by calling pm_device_runtime_get when a pin is used and pm_device_runtime_put when the pin is not used anymore. These calls needs to be balanced. But if a single pin was configured as GPIO_DISCONNECTED multiple times, every time pm_device_runtime_put was called. This caused the clock of the port to be stopped and therefore also other pins on the same port stopped working. This commit fixes this by keeping track of which pin on a port has requested the clock and only call pm_device_runtime_get or pm_device_runtime_put when the clock-request for the specific pin changes. Fixes zephyrproject-rtos#77698 Signed-off-by: Jeroen Broersen <jbroersen@interact.nl>
40e788f to
2a4f467
Compare
|
Hi @jbr-ia! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
The driver enables the clock of a gpio-port if any of the pins use the port. This is done by calling pm_device_runtime_get when a pin is used and pm_device_runtime_put when the pin is not used anymore.
These calls needs to be balanced. But if a single pin was configured as GPIO_DISCONNECTED multiple times, every time pm_device_runtime_put was called.
This caused the clock of the port to be stopped and therefore also other pins on the same port stopped working.
This commit fixes this by keeping track of which pin on a port has requested the clock and only call pm_device_runtime_get or pm_device_runtime_put when the clock-request for the specific pin changes.
Fixes #77698