From afb16d204594bbc180bb0741295b4ad8ff53ee23 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:34:38 +0100 Subject: [PATCH] Remove lazy rl_dbi stuff --- .../oc/erista/calculate_timings_erista.cpp | 6 ++--- .../source/oc/mariko/calculate_timings.cpp | 2 +- .../loader/source/oc/mtc_timing_value.hpp | 23 ++++++++----------- .../stratosphere/loader/source/oc/pcv/pcv.hpp | 1 - .../loader/source/oc/pcv/pcv_erista.cpp | 2 +- .../loader/source/oc/pcv/pcv_mariko.cpp | 2 +- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/erista/calculate_timings_erista.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/erista/calculate_timings_erista.cpp index e9385ef0..721c1a92 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/erista/calculate_timings_erista.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/erista/calculate_timings_erista.cpp @@ -20,9 +20,9 @@ namespace ams::ldr::hoc::pcv::erista { void CalculateTimings(double tCK_avg) { - tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL_DBI - (C.t6_tRTW * 3) + finetRTW; - tWTPDEN = CEIL(((1.803 / tCK_avg) + MAX(RL_DBI + (2.694 / tCK_avg), static_cast(tW2P))) + (BL / 2)); - tW2R = FLOOR(MAX((5.020 / tCK_avg) + 1.130, WL - MAX(-CEIL(0.258 * (WL - RL_DBI)), 1.964)) * 1.964) + WL - CEIL(tWTR / tCK_avg) + finetWTR; + tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL - (C.t6_tRTW * 3) + finetRTW; + tWTPDEN = CEIL(((1.803 / tCK_avg) + MAX(RL + (2.694 / tCK_avg), static_cast(tW2P))) + (BL / 2)); + tW2R = FLOOR(MAX((5.020 / tCK_avg) + 1.130, WL - MAX(-CEIL(0.258 * (WL - RL)), 1.964)) * 1.964) + WL - CEIL(tWTR / tCK_avg) + finetWTR; pdex2rw = CEIL((CEIL(12.335 - tCK_avg) + (7.430 / tCK_avg) - CEIL(tCK_avg * 11.361))); tCLKSTOP = FLOOR(MIN(8.488 / tCK_avg, 23.0)) + 8.0; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp index 832795c1..78f8e1f3 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp @@ -43,7 +43,7 @@ namespace ams::ldr::hoc::pcv::mariko { u32 wlIndex = 0; for (u32 i = 0; i < std::size(rlMapDBI); ++i) { - if (rlMapDBI[i] == RL_DBI) { + if (rlMapDBI[i] == RL) { rlIndex = i; break; } diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp index 6158557f..b6a72cc6 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp @@ -34,12 +34,9 @@ namespace ams::ldr::hoc { const u32 BL = 16; /* Base latency for read and write (tWRL). */ - const u32 RL = C.mem_burst_read_latency - 4; /* (This is a lazy fix for now) */ + const u32 RL = C.mem_burst_read_latency; const u32 WL = C.mem_burst_write_latency; - /* Switch uses RL_DBI, todo: get rid of non DBI_RL. */ - const u32 RL_DBI = RL + 4; - /* Precharge to Precharge Delay. (tCK) */ const u32 tPPD = 4; @@ -90,7 +87,7 @@ namespace ams::ldr::hoc { const u32 tFAW = static_cast(tRRD * 4.0); const double tRPab = tRPpb + 3; - const u32 tR2P = CEIL((RL_DBI * 0.426) - 2.0); + const u32 tR2P = CEIL((RL * 0.426) - 2.0); inline u32 tR2W; inline u32 rext; @@ -131,16 +128,16 @@ namespace ams::ldr::hoc { const u32 tFAW = static_cast(tRRD * 4.0); const double tRPab = tRPpb + 3; - const u32 tR2P = CEIL((RL_DBI * 0.426) - 2.0); - const u32 tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL_DBI - (C.t6_tRTW * 3) + finetRTW; - const u32 tRTM = FLOOR((10.0 + RL_DBI) + (3.502 / tCK_avg)) + FLOOR(7.489 / tCK_avg); - const u32 tRATM = CEIL((tRTM - 10.0) + (RL_DBI * 0.426)); + const u32 tR2P = CEIL((RL * 0.426) - 2.0); + const u32 tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL - (C.t6_tRTW * 3) + finetRTW; + const u32 tRTM = FLOOR((10.0 + RL) + (3.502 / tCK_avg)) + FLOOR(7.489 / tCK_avg); + const u32 tRATM = CEIL((tRTM - 10.0) + (RL * 0.426)); inline u32 rext; - const u32 rdv = RL_DBI + FLOOR((5.105 / tCK_avg) + 17.017); + const u32 rdv = RL + FLOOR((5.105 / tCK_avg) + 17.017); const u32 qpop = rdv - 14; const u32 quse_width = CEIL(((4.897 / tCK_avg) - FLOOR(2.538 / tCK_avg)) + 3.782); - const u32 quse = FLOOR(RL_DBI + ((5.082 / tCK_avg) + FLOOR(2.560 / tCK_avg))) - CEIL(4.820 / tCK_avg); + const u32 quse = FLOOR(RL + ((5.082 / tCK_avg) + FLOOR(2.560 / tCK_avg))) - CEIL(4.820 / tCK_avg); const u32 einput_duration = FLOOR(9.936 / tCK_avg) + 5.0 + quse_width; const u32 einput = quse - CEIL(9.928 / tCK_avg); const u32 qrst_duration = FLOOR(8.399 - tCK_avg); @@ -149,8 +146,8 @@ namespace ams::ldr::hoc { const u32 ibdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(1, quse - qrst_duration - 2.0); const u32 qsafe = (einput_duration + 3) + MAX(MIN(qrstLow * rdv, qrst_duration + qrst_duration), einput); const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5; - const u32 tWTPDEN = CEIL(((1.803 / tCK_avg) + MAX(RL_DBI + (2.694 / tCK_avg), static_cast(tW2P))) + (BL / 2)); - const u32 tW2R = FLOOR(MAX((5.020 / tCK_avg) + 1.130, WL - MAX(-CEIL(0.258 * (WL - RL_DBI)), 1.964)) * 1.964) + WL - CEIL(tWTR / tCK_avg) + finetWTR; + const u32 tWTPDEN = CEIL(((1.803 / tCK_avg) + MAX(RL + (2.694 / tCK_avg), static_cast(tW2P))) + (BL / 2)); + const u32 tW2R = FLOOR(MAX((5.020 / tCK_avg) + 1.130, WL - MAX(-CEIL(0.258 * (WL - RL)), 1.964)) * 1.964) + WL - CEIL(tWTR / tCK_avg) + finetWTR; const u32 tWTM = CEIL(WL + ((7.570 / tCK_avg) + 8.753)); const u32 tWATM = (tWTM + (FLOOR(WL / 0.816) * 2.0)) - 4.0; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index 3975b5b9..112d2e4f 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -202,7 +202,6 @@ namespace ams::ldr::hoc::pcv { { }, }; - constexpr u32 CpuVoltOfficial = 1235; constexpr u32 CpuVminOfficial = 825; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.cpp index 364b3fde..9cbfa54e 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.cpp @@ -285,7 +285,7 @@ namespace ams::ldr::hoc::pcv::erista { // WRITE_PARAM_ALL_REG(table, emc_tr_rdv, rdv); // ams::ldr::hoc::pcv::mariko::CalculateMrw2(); // table->emc_mrw2 = (table->emc_mrw2 & ~0xFFu) | static_cast(mrw2); - // table->dram_timings.rl = RL_DBI; + // table->dram_timings.rl = RL; /* This needs some clean up. */ constexpr double MC_ARB_DIV = 4.0; 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 947941a3..716975cb 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp @@ -568,7 +568,7 @@ namespace ams::ldr::hoc::pcv::mariko { table->dram_timings.t_rp = tRFCpb; table->dram_timings.t_rfc = tRFCab; - table->dram_timings.rl = RL_DBI; + table->dram_timings.rl = RL; table->emc_mrw2 = (table->emc_mrw2 & ~0xFFu) | static_cast(mrw2); table->emc_cfg_2 = 0x11083D;