[EGD-5661] Add power management for filesystem

Add peripheral control (USDHC and PLL2 clocks)
for file system support.
This will save energy and extend battery life.
This commit is contained in:
Maciej Gibowicz
2021-04-21 14:45:03 +02:00
committed by Maciej Gibowicz
parent d967db0a48
commit fa61bb38cd
7 changed files with 98 additions and 4 deletions

View File

@@ -33,6 +33,7 @@
#include <time/ScopedTime.hpp>
#include "Timers/TimerFactory.hpp"
#include <service-appmgr/StartupType.hpp>
#include <purefs/vfs_subsystem.hpp>
const inline size_t systemManagerStack = 4096 * 2;
@@ -642,6 +643,12 @@ namespace sys
deviceManager->RegisterNewDevice(powerManager->getExternalRamDevice());
cpuSentinel = std::make_shared<sys::CpuSentinel>(
service::name::system_manager, this, [this](bsp::CpuFrequencyHz newFrequency) {
UpdateResourcesAfterCpuFrequencyChange(newFrequency);
});
powerManager->RegisterNewSentinel(cpuSentinel);
return ReturnCodes::Success;
}
@@ -773,6 +780,16 @@ namespace sys
return MessageNone{};
}
void SystemManager::UpdateResourcesAfterCpuFrequencyChange(bsp::CpuFrequencyHz newFrequency)
{
if (newFrequency == bsp::CpuFrequencyHz::Level_1) {
purefs::subsystem::disk_mgr()->pm_control(purefs::blkdev::pm_state::suspend);
}
else {
purefs::subsystem::disk_mgr()->pm_control(purefs::blkdev::pm_state::active);
}
}
std::vector<std::shared_ptr<Service>> SystemManager::servicesList;
std::vector<std::shared_ptr<app::Application>> SystemManager::applicationsList;
cpp_freertos::MutexStandard SystemManager::serviceDestroyMutex;