From 0a9f412c51dccbff39d1dc4a46c3a3b8226b2015 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Wed, 26 Aug 2026 20:40:09 +0200 Subject: [PATCH] ldr: add erista rext timings --- .../pcv/erista/calculate_timings_erista.cpp | 31 +++++++++++++++++++ .../source/oc/pcv/erista/pcv_erista_mtc.cpp | 8 ----- .../source/oc/pcv/mariko/timing_tables.cpp | 4 +-- .../source/oc/pcv/mariko/timing_tables.hpp | 11 ++----- .../loader/source/oc/pcv/pcv_common.hpp | 5 +++ 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/calculate_timings_erista.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/calculate_timings_erista.cpp index 7562a721..c9094c8b 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/calculate_timings_erista.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/calculate_timings_erista.cpp @@ -18,6 +18,36 @@ namespace ams::ldr::hoc::pcv::erista { + /* Dumped from bpmp fw mtc table (l4t). */ + const RextPatch g_rext_table[] = { + {1'633'000, 0x17}, {1'728'000, 0x17}, {1'795'200, 0x19}, + {1'862'400, 0x1A}, {1'894'400, 0x1A}, {1'932'800, 0x1A}, + {1'958'400, 0x1A}, {1'996'800, 0x1A}, {2'035'200, 0x1A}, + {2'064'000, 0x19}, {2'099'200, 0x19}, {2'131'200, 0x1A}, + {2'163'200, 0x1A}, {2'188'800, 0x1A}, {2'227'200, 0x1A}, + {2'265'600, 0x1B}, {2'291'200, 0x1B}, {2'329'600, 0x1A}, + {2'361'600, 0x1A}, + }; + + const RextPatch *LookupRext(u32 freq) { + for (u32 i = 0; i < std::size(g_rext_table); i++) { + if (g_rext_table[i].freq >= freq) { + return &g_rext_table[i]; + } + } + return nullptr; + } + + void GetRext(u32 freq) { + if (auto r = LookupRext(freq)) { + rext = r->rext; + return; + } + + /* > 3200 */ + rext = 0x1E; + } + void SwitchLatency(volatile u32 &latency, u32 index, u32 latencyStep) { latency += index * latencyStep; } @@ -117,6 +147,7 @@ namespace ams::ldr::hoc::pcv::erista { WL = WL_1331; HandleLatency(freq); + GetRext(freq); CalculateMrw2(); tR2P = CEIL((RL * 0.426) - 2.0); diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/pcv_erista_mtc.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/pcv_erista_mtc.cpp index 7a4a1b4d..d1aefb8d 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/pcv_erista_mtc.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/erista/pcv_erista_mtc.cpp @@ -66,14 +66,6 @@ namespace ams::ldr::hoc::pcv::erista { refresh_raw = MIN(refresh_raw, static_cast(0xFFFF)); } - if (table->rate_khz > 3200000) { - rext = 30; - } else if (table->rate_khz >= 2133001) { - rext = 28; - } else { - rext = 26; - } - u32 trefbw = refresh_raw + 0x40; trefbw = MIN(trefbw, static_cast(0x3FFF)); diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.cpp index 117fa995..dea73cfc 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.cpp @@ -19,7 +19,7 @@ namespace ams::ldr::hoc::pcv::mariko { - const ReplacePatch g_rext_table[] = { + const RextPatch g_rext_table[] = { {2'133'000, 0x1A}, {2'166'000, 0x19}, {2'200'000, 0x19}, {2'233'000, 0x19}, {2'266'000, 0x1A}, {2'300'000, 0x1B}, {2'333'000, 0x1B}, {2'366'000, 0x1B}, {2'400'000, 0x1B}, @@ -35,7 +35,7 @@ namespace ams::ldr::hoc::pcv::mariko { const u32 g_rext_table_size = sizeof(g_rext_table) / sizeof(g_rext_table[0]); - const ReplacePatch *FindRext(u32 freq) { + const RextPatch *FindRext(u32 freq) { for (u32 i = 0; i < g_rext_table_size; i++) { if (g_rext_table[i].freq >= freq) { return &g_rext_table[i]; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.hpp index 1fe42bd9..a1aa7f0a 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/mariko/timing_tables.hpp @@ -19,13 +19,8 @@ namespace ams::ldr::hoc::pcv::mariko { - struct ReplacePatch { - u32 freq; - u32 rext; - }; - - extern const ReplacePatch g_rext_table[]; - extern const u32 g_rext_table_size; - const ReplacePatch *FindRext(u32 freq); + extern const RextPatch g_rext_table[]; + extern const u32 g_rext_table_size; + const RextPatch *FindRext(u32 freq); } diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_common.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_common.hpp index bdda0361..49a60aa3 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_common.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_common.hpp @@ -187,6 +187,11 @@ namespace ams::ldr::hoc::pcv { }; static_assert(sizeof(SharedClkBus) == 0x58); + struct RextPatch { + u32 freq; + u32 rext; + }; + constexpr u32 CpuClkOSLimit = 1785'000; constexpr u32 GpuClkOsLimit = 921'600; constexpr u32 EmcClkOSLimit = 1600'000;