pm: adds a c/file-based power management configuration to select required implementations#7648
pm: adds a c/file-based power management configuration to select required implementations#7648roberthartung wants to merge 113 commits intoRIOT-OS:masterfrom
Conversation
|
This might be nicer than the submodule version.
|
|
@kaspar030 sounds nice. Will make the changes once I am back from vacation! |
|
@kaspar030 And same for using include path order to resolve header files include. |
periph_spi_common is doing something similar. grep |
|
@kaspar030 Almost finished. If I provide my own configuration for pm, the pm_conf.h will be empty. Is there a better way? Or should we just place an empty pm_conf.h in that case with according comments? Additionally, I cannot build for native: EDIT: Nevermind, can build native now .. for some reason.. |
f22d8b3 to
29895aa
Compare
|
@kaspar030 @cladmi I just pushed a shortened version. I really like this one! |
haukepetersen
left a comment
There was a problem hiding this comment.
Sorry for jumping the ship so late and being quiet so far. I very much like the direction of this PR, but there are still things I don't like and which can be further simplified.
For one, I am not too much a fan of introducing all these pm specific pm_conf.h header files. I actually think we can do without, by switching the paradigm of the config parameters from NEEDS to PROVIDE.
For pm_off and pm_reboot this would simplify things -> the fallback implementation (pm_reboot() in cpu/ARCH/pm.c and pm_off() in drivers/periph_common/pm.c) are simply guarded with:
#ifndef PROVIDES_PM_OFF
...
#endifThis define should simply reside in periph_cpu.h (or any shared file like periph_cpu_common.h if valid for a complete family of CPUs).
Next, the pm_off() in sys/pm_layered/pm.c is guarded with
#ifndef PROVIDES_PM_LAYERED_OFF
...
#endifNow a CPU that does not use pm_layered simply does nothing if it wants to use the default implementation in periph_common.
Next, the pm_layered module does define PROVIDES_PM_OFF, so if a CPU uses pm_layered, it would automatically use the pm_off function provided by pm_layered.
The only 'hack' that has to be done here, is to conditionally include the pm_layered.h header in pm.h.
Does this make sense? I could draft a quick branch if it would be easier to understand, should I proceed here?
| * Select the required implementations from the common CPUs or fallbacks | ||
| * @{ | ||
| */ | ||
| #define NEEDS_ARM7_PM_REBOOT |
There was a problem hiding this comment.
might be nitpicky, but I would definitely prefer NEEDS_PM_ARM7_REBOOT to keep pm as prefix and make clear that this is a pm specific option
| } | ||
| #endif | ||
|
|
||
| #if defined(NEEDS_CORTEXM_PM_REBOOT) |
There was a problem hiding this comment.
Question: why is pm_reboot guarded, if it is always used anyway? There is no case in the source tree, where the pm_reboot function provided by the architecture is not used... So isn't this a case of 'add the guard once we encounter a case where its needed' instead of 'adding it now because sometime in the future it might be needed'?
There was a problem hiding this comment.
Because one could define their own implementation. For all *_common CPUs I added guards around their implementations.
cpu/mips32r2_common/periph/pm.c
Outdated
| #ifndef FEATURES_PERIPH_PM | ||
| #ifdef NEEDS_MIPS32R2_PM_FALLBACK | ||
| #define NEEDS_MIPS32R2_PM_OFF | ||
| #define NEEDS_MIPS32R2_PM_OFF |
@haukepetersen I know what you mean but can we cover the same functionality? Especially when mixing different fallback implementations? e.g. can we cover the cases in |
|
Couldn't resist to try it out: #7726 |
Yes, just tried it in #7726. The |
|
Have you tried to run buildtest on the default example? |
|
I did just Murdock do that job for me -> fails all the way :-) Looking into it now. |
|
Closed in favor of #7726. @roberthartung Thanks a lot for trying this out! |
Supersedes #7597 and porposes an alternative for the submodule/buildsystem-based version.
I just ran the buildtest by now, but didnt test any hardware yet!
@kaspar030 @MichelRottleuthner @haukepetersen Feedback appreciated!