-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/atxmega: Add periph power management #16212
Conversation
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.
lgtm. I have one suggestion regarding style, but that is opinionated, so feel free to ignore. If you take the suggestion, squash right away.
Let me know when I should start testing. Sorry for the long stall.
cpu/atxmega/periph/pm.c
Outdated
void pm_periph_enable(pwr_reduction_t pwr, bool enable) | ||
{ | ||
uint8_t mask = _device_mask(pwr); | ||
uint8_t *reg = _register_addr(pwr); | ||
|
||
if (enable) { | ||
*reg &= ~mask; /* Clear to Enable */ | ||
} | ||
else { | ||
*reg |= mask; | ||
} | ||
} |
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 have the feeling that the function call overhead here is greater than the implementation. So if this would be provided as static inline
instead, I think ROM would be reduced.
If that is the case, would you mind to split this into pm_periph_enable()
and pm_periph_disable()
, as this would make reading the code much easier.
If not, maybe you could name the C function to e.g. pm_periph_set_enabled()
and provide a static inline pm_periph_enable()
and static inline pm_periph_disable()
as wrapper? The compiler will optimize the wrappers out, so this would come with no cost.
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 splitted the method as suggested. I built with/without static and noted that flash savings were higher using the method as not static. Because of that I preferred left two non static methods.
The current xmega don't have a way to disable peripherals that are not in used. Add peripheral management to allow enable only the mcu blocks that will be used by application. This saves power on active and sleep modes. By default, at clock initialization, all peripherals are now disabled and each drive must activate at initialization phase. The periph_timer and periph_uart were updated with this new feature. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
The periph_pm requires new field to control the power management feature. Add missing config at periph_conf for timers and uart. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Testing with
|
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.
ACK. Thanks
Contribution description
The current xmega don't have a way to disable peripherals that are not in used. Add peripheral management to allow enable only the mcu blocks that will be used by application. This saves power on active and sleep modes. By default, at clock initialization, all peripherals are now disabled and each drive must activate at initialization phase.
The periph_timer and periph_uart were updated with this new feature.
Testing procedure
Tests were conducted with atxmega128-a1u-xpro board in:
Issues/PRs references
This is part of #15703.
CC: @maribu @benpicco