From 9b9e72b9aa8b29c58e687764ed804b6bd4be8637 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Wed, 17 Dec 2025 21:37:38 +0100 Subject: [PATCH] Add true cpu cap --- .../stratosphere/loader/source/oc/customize.cpp | 9 ++++++--- .../stratosphere/loader/source/oc/customize.hpp | 1 + .../stratosphere/loader/source/oc/pcv/pcv.hpp | 15 +++++++++++++++ .../loader/source/oc/pcv/pcv_mariko.cpp | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp index dbe3bb68..ac230ad2 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp @@ -29,9 +29,6 @@ namespace ams::ldr::oc { -//volatile EristaMtcTable EristaMtcTablePlaceholder = { .rev = ERISTA_MTC_MAGIC, }; -//volatile MarikoMtcTable MarikoMtcTablePlaceholder = { .rev = MARIKO_MTC_MAGIC, }; - volatile CustomizeTable C = { .mtcConf = AUTO_ADJ_BL, @@ -70,6 +67,12 @@ volatile CustomizeTable C = { .marikoCpuHighVmin = 750, .marikoCpuMaxVolt = 1120, +/* Supported values: 2397000, 2499000, 2601000, 2703000. */ +/* 2499000 should be used with caution. */ +/* 2601000 exceeds pmic limit on most consoles. */ +/* 2703000 is potentially dangerous and not advised. */ +.marikoCpuMaxClock = 2397000, + .eristaCpuBoostClock = 1785000, // Default boost clock .marikoCpuBoostClock = 1963000, // Default boost clock diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp index 7e47b98d..645cfa6f 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp @@ -86,6 +86,7 @@ typedef struct CustomizeTable { u32 marikoCpuLowVmin; u32 marikoCpuHighVmin; u32 marikoCpuMaxVolt; + u32 marikoCpuMaxClock; u32 eristaCpuBoostClock; u32 marikoCpuBoostClock; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index e5a207d0..9347551d 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -60,6 +60,21 @@ namespace ams::ldr::oc::pcv { constexpr s32 CpuVoltageSecondaryPatchOffsets[] = { -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static_assert(sizeof(CpuVoltageSecondaryPatchValues) == sizeof(CpuVoltageSecondaryPatchOffsets), "Invalid secondary CpuVoltagePatch size"); + constexpr u32 CapCpuClock() { + constexpr u32 AllowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, }; + + u32 cpuCap = AllowedCpuMaxFrequencies[0]; + + for (u32 freq : AllowedCpuMaxFrequencies) { + if (C.marikoCpuMaxClock >= freq) { + cpuCap = freq; + } else { + break; + } + } + return cpuCap; + } + constexpr cvb_entry_t GpuCvbTableDefault[] = { // GPUB01_NA_CVB_TABLE { 76800, {}, { 610000, } }, diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp index 8746f212..998fa80e 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp @@ -98,8 +98,9 @@ namespace ams::ldr::oc::pcv::mariko { R_UNLESS(entry->min_mv == 250'000, ldr::ResultInvalidCpuFreqVddEntry()); R_UNLESS(entry->step_mv == 5000, ldr::ResultInvalidCpuFreqVddEntry()); R_UNLESS(entry->max_mv == 1525'000, ldr::ResultInvalidCpuFreqVddEntry()); + if (C.marikoCpuUVHigh) { - PATCH_OFFSET(ptr, GetDvfsTableLastEntry(C.marikoCpuDvfsTableSLT)->freq); + PATCH_OFFSET(ptr, CapCpuClock()); } else { PATCH_OFFSET(ptr, GetDvfsTableLastEntry(C.marikoCpuDvfsTable)->freq); }