make sleep mode work

This commit is contained in:
souldbminersmwc committed 2026-08-24 21:42:25 -04:00
1 parent bd468f087d
commit a3b8400477
7 files changed
+609 -13

No files matched your search

@@ -68,17 +68,25 @@ Result SmcCopyToIram(uintptr_t dest, const void *src, u32 size) {
}
bool IsPatchedExosphere() {
constexpr u64 EvpPhysBase = 0x6000F000;
constexpr u64 EvpCopResetVector = 0x200;
static bool checked = false;
static bool patched = false;
SecmonArgs args = {};
args.X[0] = 0xF0000002;
args.X[1] = EvpPhysBase + EvpCopResetVector;
args.X[2] = 0;
args.X[3] = 0;
svcCallSecureMonitor(&args);
if (!checked) {
constexpr u64 EvpPhysBase = 0x6000F000;
constexpr u64 EvpCopResetVector = 0x200;
return args.X[0] == 0;
SecmonArgs args = {};
args.X[0] = 0xF0000002;
args.X[1] = EvpPhysBase + EvpCopResetVector;
args.X[2] = 0;
args.X[3] = 0;
svcCallSecureMonitor(&args);
patched = (args.X[0] == 0);
checked = true;
}
return patched;
}
u32 SmcReadWriteRegister(u64 phys_addr, u32 mask, u32 value) {
@@ -30,6 +30,7 @@
#include <i2c.h>
#include "../board/board.hpp"
#include "../bpmp/bpmp.hpp"
#include "../display/aula.hpp"
#include "../display/display_refresh_rate.hpp"
#include "../file/config.hpp"
@@ -40,6 +41,7 @@
#include "../hos/process_management.hpp"
#include "../i2c/i2cDrv.h"
#include "../ipc/ipc_service.hpp"
#include "../mapping/mem_map.hpp"
#include "../soc/gm20b.hpp"
#include "../util/lockable_mutex.h"
#include "clock_manager.hpp"
@@ -355,6 +357,22 @@ namespace clockManager {
if (++tick > 10) {
tick = 0;
// Restart BPMP after sleep.
if (IsPatchedExosphere()) {
constexpr u32 FlowCtlrPhysBase = 0x60007000;
constexpr u32 FlowCtlrHaltCopEvents = 0x004;
constexpr u32 HaltCopEventsModeShift = 29;
constexpr u32 HaltCopEventsModeStop = 2;
u32 haltReg = SmcReadWriteRegister(FlowCtlrPhysBase + FlowCtlrHaltCopEvents, 0, 0);
if ((haltReg >> HaltCopEventsModeShift) == HaltCopEventsModeStop) {
Result rc = bpmp::StartBpmfwExecution();
if (R_FAILED(rc)) {
fileUtils::LogLine("[bpmp] restart after sleep failed: 0x%x", rc);
}
}
}
if (config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) {
I2c_Bq24193_SetFastChargeCurrentLimit(config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent));
}