diff --git a/Source/sys-clk/sysmodule/src/emc_mc_defs.h b/Source/sys-clk/common/include/registers.h similarity index 100% rename from Source/sys-clk/sysmodule/src/emc_mc_defs.h rename to Source/sys-clk/common/include/registers.h diff --git a/Source/sys-clk/common/include/sysclk/clock_manager.h b/Source/sys-clk/common/include/sysclk/clock_manager.h index eec46155..008bde70 100644 --- a/Source/sys-clk/common/include/sysclk/clock_manager.h +++ b/Source/sys-clk/common/include/sysclk/clock_manager.h @@ -41,10 +41,11 @@ typedef struct int32_t power[SysClkPowerSensor_EnumMax]; uint32_t PartLoad[SysClkPartLoad_EnumMax]; uint32_t voltages[HocClkVoltage_EnumMax]; + u16 speedos[HorizonOCSpeedo_EnumMax]; uint32_t perfConfId; u8 maxDisplayFreq; u8 fps; - u16 speedos[HorizonOCSpeedo_EnumMax]; + u8 dramID; } SysClkContext; typedef struct diff --git a/Source/sys-clk/overlay/Makefile b/Source/sys-clk/overlay/Makefile index a182c49c..e1f0527e 100644 --- a/Source/sys-clk/overlay/Makefile +++ b/Source/sys-clk/overlay/Makefile @@ -38,7 +38,7 @@ include ${TOPDIR}/lib/libultrahand/ultrahand.mk # version control constants #--------------------------------------------------------------------------------- #TARGET_VERSION := $(shell git describe --dirty --always --tags) -APP_VERSION := 0.25 +APP_VERSION := 0.26 TARGET_VERSION := $(APP_VERSION) #--------------------------------------------------------------------------------- diff --git a/Source/sys-clk/sysmodule/perms.json b/Source/sys-clk/sysmodule/perms.json index 5f347129..5200583d 100644 --- a/Source/sys-clk/sysmodule/perms.json +++ b/Source/sys-clk/sysmodule/perms.json @@ -57,6 +57,24 @@ "is_io": true } }, + { + "type": "map", + "value": { + "address": "0x700E2000", + "size": "0x1000", + "is_ro": false, + "is_io": true + } + }, + { + "type": "map", + "value": { + "address": "0x7000F800", + "size": "0x400", + "is_ro": false, + "is_io": true + } + }, { "type": "syscalls", "value": { @@ -145,7 +163,7 @@ "svcUnmapTransferMemory": "0x52", "svcCreateInterruptEvent": "0x53", "svcQueryPhysicalAddress": "0x54", - "svcQueryIoMapping": "0x55", + "svcQueryMemoryMapping": "0x55", "svcCreateDeviceAddressSpace": "0x56", "svcAttachDeviceAddressSpace": "0x57", "svcDetachDeviceAddressSpace": "0x58", diff --git a/Source/sys-clk/sysmodule/src/board.cpp b/Source/sys-clk/sysmodule/src/board.cpp index 27324e36..c5cf72fb 100644 --- a/Source/sys-clk/sysmodule/src/board.cpp +++ b/Source/sys-clk/sysmodule/src/board.cpp @@ -39,7 +39,7 @@ #include #include #include -#include "emc_mc_defs.h" +#include #include #define MAX(A, B) std::max(A, B) @@ -97,7 +97,7 @@ std::atomic idletick3{systemtickfrequency}; u32 cpu0, cpu1, cpu2, cpu3, cpuAvg; u16 cpuSpeedo0, cpuSpeedo2, socSpeedo0; // CPU, GPU, SOC u16 cpuIDDQ, gpuIDDQ, socIDDQ; - +u8 g_dramID = 0; const char* Board::GetModuleName(SysClkModule module, bool pretty) { @@ -239,10 +239,10 @@ void Board::Initialize() threadCreate(&gpuLThread, gpuLoadThread, NULL, NULL, 0x1000, 0x3F, -2); threadStart(&gpuLThread); - threadCreate(&cpuCore0Thread, CheckCore, &idletick0, NULL, 0x1000, 0x10, 0); - threadCreate(&cpuCore1Thread, CheckCore, &idletick1, NULL, 0x1000, 0x10, 1); - threadCreate(&cpuCore2Thread, CheckCore, &idletick2, NULL, 0x1000, 0x10, 2); - threadCreate(&cpuCore3Thread, CheckCore, &idletick3, NULL, 0x1000, 0x10, 3); + threadCreate(&cpuCore0Thread, CheckCore, &idletick0, NULL, 0x500, 0x10, 0); + threadCreate(&cpuCore1Thread, CheckCore, &idletick1, NULL, 0x500, 0x10, 1); + threadCreate(&cpuCore2Thread, CheckCore, &idletick2, NULL, 0x500, 0x10, 2); + threadCreate(&cpuCore3Thread, CheckCore, &idletick3, NULL, 0x500, 0x10, 3); threadCreate(&miscThread, miscThreadFunc, NULL, NULL, 0x1000, 0x3F, 3); threadStart(&cpuCore0Thread); @@ -266,6 +266,7 @@ void Board::Initialize() DisplayRefresh_Initialize(&cfg); } + FetchHardwareInfos(); } @@ -767,16 +768,23 @@ HorizonOCConsoleType Board::GetConsoleType() { return g_consoleType; } +u8 Board::GetDramID() { + return g_dramID; +} + void Board::FetchHardwareInfos() { fuseReadSpeedos(); - u64 sku = 0; + u64 sku = 0, dramID = 0; Result rc = splInitialize(); ASSERT_RESULT_OK(rc, "splInitialize"); rc = splGetConfig(SplConfigItem_HardwareType, &sku); ASSERT_RESULT_OK(rc, "splGetConfig"); + rc = splGetConfig(SplConfigItem_DramId, &dramID); + ASSERT_RESULT_OK(rc, "splGetConfig"); + splExit(); switch(sku) @@ -792,6 +800,8 @@ void Board::FetchHardwareInfos() } g_consoleType = (HorizonOCConsoleType)sku; + g_dramID = (u8)dramID; + } /* diff --git a/Source/sys-clk/sysmodule/src/board.h b/Source/sys-clk/sysmodule/src/board.h index 0119b36c..4fbf1bfe 100644 --- a/Source/sys-clk/sysmodule/src/board.h +++ b/Source/sys-clk/sysmodule/src/board.h @@ -61,6 +61,7 @@ class Board static HorizonOCConsoleType GetConsoleType(); static std::uint32_t GetVoltage(HocClkVoltage voltage); static u8 GetFanRotationLevel(); + static u8 GetDramID(); static void UpdateShadowRegs(u32 tRCD_i, u32 tRP_i, u32 tRAS_i, u32 tRRD_i, u32 tRFC_i, u32 tRTW_i, u32 tWTR_i, u32 tREFpb_i, u32 ramFreq, u32 rlAdd, u32 wlAdd, bool hpMode); protected: static void FetchHardwareInfos(); diff --git a/Source/sys-clk/sysmodule/src/clock_manager.cpp b/Source/sys-clk/sysmodule/src/clock_manager.cpp index 18925452..a1248e8b 100644 --- a/Source/sys-clk/sysmodule/src/clock_manager.cpp +++ b/Source/sys-clk/sysmodule/src/clock_manager.cpp @@ -107,13 +107,20 @@ ClockManager::ClockManager() this->context->speedos[HorizonOCSpeedo_GPU] = Board::getGPUSpeedo(); this->context->speedos[HorizonOCSpeedo_SOC] = Board::getSOCSpeedo(); + this->context->dramID = Board::GetDramID(); } void ClockManager::FixCpuBug() { Board::SetHz(SysClkModule_CPU, 1785000000); // this will just set to the max when kip is unloaded so idgaf + Board::SetHz(SysClkModule_CPU, 1887000000); Board::SetHz(SysClkModule_CPU, 1963000000); Board::SetHz(SysClkModule_CPU, 2091000000); + Board::SetHz(SysClkModule_CPU, 2193000000); + Board::SetHz(SysClkModule_CPU, 2295000000); Board::SetHz(SysClkModule_CPU, 2397000000); + Board::SetHz(SysClkModule_CPU, 2499000000); + Board::SetHz(SysClkModule_CPU, 2601000000); + Board::SetHz(SysClkModule_CPU, 2703000000); // i am just replicating what the user would manually do to fix the bug. if 2703 is unstable it will reset to 1020 due to how fast this runs Board::SetHz(SysClkModule_CPU, 1020000000); ResetToStockClocks(); u32 targetHz = 0; @@ -414,10 +421,6 @@ void ClockManager::Tick() Result rc = apmExtGetCurrentPerformanceConfiguration(&mode); ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration"); - if(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)) { - I2c_Bq24193_SetFastChargeCurrentLimit(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)); - } - if(this->config->GetConfigValue(HocClkConfigValue_HandheldTDP) && opMode == AppletOperationMode_Handheld) { if(Board::GetConsoleType() == HorizonOCConsoleType_Hoag) { if(Board::GetPowerMw(SysClkPowerSensor_Now) < -(int)this->config->GetConfigValue(HocClkConfigValue_LiteTDPLimit)) { @@ -456,6 +459,9 @@ void ClockManager::Tick() if (this->RefreshContext() || this->config->Refresh()) { + if(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)) { + I2c_Bq24193_SetFastChargeCurrentLimit(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)); + } std::uint32_t targetHz = 0; std::uint32_t maxHz = 0; std::uint32_t nearestHz = 0; @@ -965,25 +971,25 @@ void ClockManager::UpdateRamTimings() { return; } - if(this->config->GetConfigValue(KipConfigValue_marikoEmcMaxClock) != initialConfigValues[KipConfigValue_marikoEmcMaxClock] || - this->config->GetConfigValue(KipConfigValue_mem_burst_read_latency) != initialConfigValues[KipConfigValue_mem_burst_read_latency] || - this->config->GetConfigValue(KipConfigValue_mem_burst_write_latency) != initialConfigValues[KipConfigValue_mem_burst_write_latency] - ) { - writeNotification("Horizon OC\nCritical values changed!\nUnable to write timings"); - return; - } - u32 t1_tRCD = this->config->GetConfigValue(KipConfigValue_t1_tRCD); - u32 t2_tRP = this->config->GetConfigValue(KipConfigValue_t2_tRP); - u32 t3_tRAS = this->config->GetConfigValue(KipConfigValue_t3_tRAS); - u32 t4_tRRD = this->config->GetConfigValue(KipConfigValue_t4_tRRD); - u32 t5_tRFC = this->config->GetConfigValue(KipConfigValue_t5_tRFC); - u32 t6_tRTW = this->config->GetConfigValue(KipConfigValue_t6_tRTW); - u32 t7_tWTR = this->config->GetConfigValue(KipConfigValue_t7_tWTR); - u32 t8_tREFI = this->config->GetConfigValue(KipConfigValue_t8_tREFI); - u64 ramFreq = this->config->GetConfigValue(KipConfigValue_marikoEmcMaxClock); - u32 rlAdd = this->config->GetConfigValue(KipConfigValue_mem_burst_read_latency); - u32 wlAdd = this->config->GetConfigValue(KipConfigValue_mem_burst_write_latency); - bool hpMode = (bool)this->config->GetConfigValue(KipConfigValue_hpMode); + // if(this->config->GetConfigValue(KipConfigValue_marikoEmcMaxClock) != initialConfigValues[KipConfigValue_marikoEmcMaxClock] || + // this->config->GetConfigValue(KipConfigValue_mem_burst_read_latency) != initialConfigValues[KipConfigValue_mem_burst_read_latency] || + // this->config->GetConfigValue(KipConfigValue_mem_burst_write_latency) != initialConfigValues[KipConfigValue_mem_burst_write_latency] + // ) { + // writeNotification("Horizon OC\nCritical values changed!\nUnable to write timings"); + // return; + // } + u32 t1_tRCD = initialConfigValues[KipConfigValue_t1_tRCD]; + u32 t2_tRP = initialConfigValues[KipConfigValue_t2_tRP]; + u32 t3_tRAS = initialConfigValues[KipConfigValue_t3_tRAS]; + u32 t4_tRRD = initialConfigValues[KipConfigValue_t4_tRRD]; + u32 t5_tRFC = initialConfigValues[KipConfigValue_t5_tRFC]; + u32 t6_tRTW = initialConfigValues[KipConfigValue_t6_tRTW]; + u32 t7_tWTR = initialConfigValues[KipConfigValue_t7_tWTR]; + u32 t8_tREFI = initialConfigValues[KipConfigValue_t8_tREFI]; + u64 ramFreq = initialConfigValues[KipConfigValue_marikoEmcMaxClock]; + u32 rlAdd = initialConfigValues[KipConfigValue_mem_burst_read_latency]; + u32 wlAdd = initialConfigValues[KipConfigValue_mem_burst_write_latency]; + bool hpMode = (bool)initialConfigValues[KipConfigValue_hpMode]; Board::UpdateShadowRegs(t1_tRCD, t2_tRP, t3_tRAS, t4_tRRD, t5_tRFC, t6_tRTW, t7_tWTR, t8_tREFI, ramFreq, rlAdd, wlAdd, hpMode); } diff --git a/Source/sys-clk/sysmodule/src/clock_manager.h b/Source/sys-clk/sysmodule/src/clock_manager.h index 2cc57e5e..5e2e791c 100644 --- a/Source/sys-clk/sysmodule/src/clock_manager.h +++ b/Source/sys-clk/sysmodule/src/clock_manager.h @@ -73,7 +73,7 @@ class ClockManager void calculateGpuVmin(void); protected: bool IsAssignableHz(SysClkModule module, std::uint32_t hz); - std::uint32_t GetMaxAllowedHz(SysClkModule module, SysClkProfile profile); + inline std::uint32_t GetMaxAllowedHz(SysClkModule module, SysClkProfile profile); std::uint32_t GetNearestHz(SysClkModule module, std::uint32_t inHz, std::uint32_t maxHz); bool ConfigIntervalTimeout(SysClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t* lastLogNs); void RefreshFreqTableRow(SysClkModule module); diff --git a/Source/sys-clk/sysmodule/src/file_utils.h b/Source/sys-clk/sysmodule/src/file_utils.h index a0c61cf5..f93ba16b 100644 --- a/Source/sys-clk/sysmodule/src/file_utils.h +++ b/Source/sys-clk/sysmodule/src/file_utils.h @@ -35,7 +35,7 @@ #include #define FILE_CONFIG_DIR "/config/" TARGET -#define FILE_FLAG_CHECK_INTERVAL_NS 5000000000ULL +#define FILE_FLAG_CHECK_INTERVAL_NS (10000ULL * 1000000000ULL) #define FILE_CONTEXT_CSV_PATH FILE_CONFIG_DIR "/context.csv" #define FILE_LOG_FLAG_PATH FILE_CONFIG_DIR "/log.flag" #define FILE_LOG_FILE_PATH FILE_CONFIG_DIR "/log.txt" diff --git a/dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp b/dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp index e7afe641..2b270c08 100644 Binary files a/dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp and b/dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp differ