From 1134a38584f2e84d7eb2a2de3fcc11ee2f280df5 Mon Sep 17 00:00:00 2001 From: Maciej Gibowicz Date: Tue, 7 Sep 2021 10:41:36 +0200 Subject: [PATCH] [EGD-4875] Add internal load resistor switching To reduce the power consumption, we disconnect internal load resistor --- module-bsp/board/linux/lpm/LinuxLPM.cpp | 6 ++++++ module-bsp/board/linux/lpm/LinuxLPM.h | 3 +++ module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp | 10 ++++++++++ module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp | 3 +++ module-bsp/bsp/lpm/bsp_lpm.hpp | 3 +++ module-sys/SystemManager/PowerManager.cpp | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/module-bsp/board/linux/lpm/LinuxLPM.cpp b/module-bsp/board/linux/lpm/LinuxLPM.cpp index 37073b4a2b0bdc350329ce73b0152b8ec30a0708..1f6b83b3ee56b5a99ec98246b0c4d661c3c231bb 100644 --- a/module-bsp/board/linux/lpm/LinuxLPM.cpp +++ b/module-bsp/board/linux/lpm/LinuxLPM.cpp @@ -45,4 +45,10 @@ namespace bsp void LinuxLPM::DisableDcdcPowerSaveMode() {} + void LinuxLPM::DisconnectInternalLoadResistor() + {} + + void LinuxLPM::ConnectInternalLoadResistor() + {} + } // namespace bsp diff --git a/module-bsp/board/linux/lpm/LinuxLPM.h b/module-bsp/board/linux/lpm/LinuxLPM.h index fe5f93b94fd3d0a371d66bb39c51b400e64ebf61..d8c8752d7c2e67a774ac648fc129ffbc7b225da2 100644 --- a/module-bsp/board/linux/lpm/LinuxLPM.h +++ b/module-bsp/board/linux/lpm/LinuxLPM.h @@ -22,6 +22,9 @@ namespace bsp void EnableDcdcPowerSaveMode() final; void DisableDcdcPowerSaveMode() final; + + void DisconnectInternalLoadResistor() final; + void ConnectInternalLoadResistor() final; }; } // namespace bsp diff --git a/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp b/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp index 9520c414ed5845484eb2be0e0af2bf724b694639..87e0a3174329d6e86d499732b957ef6bf2db617e 100644 --- a/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp +++ b/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp @@ -133,4 +133,14 @@ namespace bsp gpio_2->WritePin(static_cast(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 1); } + void RT1051LPM::DisconnectInternalLoadResistor() + { + DCDC->REG1 &= ~DCDC_REG1_REG_RLOAD_SW_MASK; + } + + void RT1051LPM::ConnectInternalLoadResistor() + { + DCDC->REG1 |= DCDC_REG1_REG_RLOAD_SW_MASK; + } + } // namespace bsp diff --git a/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp b/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp index 35e2b79eb17c170725baf972275a2c34ff9eb462..7bb3f208b116dd52dcd175e78561c14ba108f7f1 100644 --- a/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp +++ b/module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp @@ -25,6 +25,9 @@ namespace bsp void EnableDcdcPowerSaveMode() final; void DisableDcdcPowerSaveMode() final; + void DisconnectInternalLoadResistor() final; + void ConnectInternalLoadResistor() final; + private: std::shared_ptr gpio_1; std::shared_ptr gpio_2; diff --git a/module-bsp/bsp/lpm/bsp_lpm.hpp b/module-bsp/bsp/lpm/bsp_lpm.hpp index 56343e88f578cc5a9f23dd6f443cab5366424afc..850da968ff9b2c357ce82e459495c9fd347f1ad5 100644 --- a/module-bsp/bsp/lpm/bsp_lpm.hpp +++ b/module-bsp/bsp/lpm/bsp_lpm.hpp @@ -45,6 +45,9 @@ namespace bsp virtual void EnableDcdcPowerSaveMode() = 0; virtual void DisableDcdcPowerSaveMode() = 0; + virtual void DisconnectInternalLoadResistor() = 0; + virtual void ConnectInternalLoadResistor() = 0; + protected: CpuFrequencyHz currentFrequency = CpuFrequencyHz::Level_6; }; diff --git a/module-sys/SystemManager/PowerManager.cpp b/module-sys/SystemManager/PowerManager.cpp index 2f9fec3198e3edab00be8ccbc763ca6d965170fb..1158702ac7424bf1f1dfe1ddc08545eaa7043f83 100644 --- a/module-sys/SystemManager/PowerManager.cpp +++ b/module-sys/SystemManager/PowerManager.cpp @@ -120,6 +120,8 @@ namespace sys const auto freq = lowPowerControl->GetCurrentFrequencyLevel(); if (freq == bsp::CpuFrequencyHz::Level_1) { + // connect internal the load resistor + lowPowerControl->ConnectInternalLoadResistor(); // turn off power save mode for DCDC inverter lowPowerControl->DisableDcdcPowerSaveMode(); // Switch DCDC to full throttle during oscillator switch @@ -182,6 +184,9 @@ namespace sys // turn on power save mode for DCDC inverter lowPowerControl->EnableDcdcPowerSaveMode(); + + // disconnect internal the load resistor + lowPowerControl->DisconnectInternalLoadResistor(); } isFrequencyLoweringInProgress = true;