sysclk: refactoring
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <display_refresh_rate.h>
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include "emc_mc_defs.h"
|
||||
#include <registers.h>
|
||||
#include <notification.h>
|
||||
|
||||
#define MAX(A, B) std::max(A, B)
|
||||
@@ -97,7 +97,7 @@ std::atomic<uint64_t> 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;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <sysclk.h>
|
||||
|
||||
#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"
|
||||
|
||||
BIN
dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp
vendored
BIN
dist/atmosphere/contents/00FF0000636C6BFF/exefs.nsp
vendored
Binary file not shown.
Reference in New Issue
Block a user