From addd2de4d91c0f23c2da38ca22f7377e039d8f26 Mon Sep 17 00:00:00 2001 From: souldbminersmwc Date: Thu, 23 Apr 2026 18:50:51 -0400 Subject: [PATCH] hocclk: add CPU LUT and add copyright --- .../sysmodule/src/board/board_volt.cpp | 20 +++++++++++++++---- .../sysmodule/src/board/board_volt.hpp | 2 -- .../hoc-clk/sysmodule/src/board/bq24193.cpp | 19 ++++++++++++++++++ .../hoc-clk/sysmodule/src/board/bq24193.hpp | 19 ++++++++++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp index 90ed6a0c..7d6b16c9 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp @@ -32,6 +32,7 @@ namespace board { GpuVoltData voltData = {}; + u32 cpuVoltTable[32] = {}; // 32LUT u64 cldvfs; CpuDfllData cachedTune; @@ -373,14 +374,25 @@ namespace board { /* Assuming mariko. */ const u32 vmax = 800; - constexpr u32 VoltageTableOffset = 312; - if (!std::memcmp(&buffer[index + VoltageTableOffset], &vmax, sizeof(vmax))) { - std::memcpy(voltData.voltTable, &buffer[index + VoltageTableOffset], sizeof(voltData.voltTable)); - voltData.voltTableAddress = base + memoryInfo.addr + VoltageTableOffset + index; + constexpr u32 GpuVoltageTableOffset = 312; + if (!std::memcmp(&buffer[index + GpuVoltageTableOffset], &vmax, sizeof(vmax))) { + std::memcpy(voltData.voltTable, &buffer[index + GpuVoltageTableOffset], sizeof(voltData.voltTable)); + voltData.voltTableAddress = base + memoryInfo.addr + GpuVoltageTableOffset + index; } + constexpr u32 CpuVoltageTableOffset = 0xB8; + std::memcpy(cpuVoltTable, &buffer[index + CpuVoltageTableOffset], sizeof(cpuVoltTable)); // TODO: verify the CPU table + svcCloseHandle(handle); handle = INVALID_HANDLE; + + for(int i = 0; i < (int)std::size(cpuVoltTable); ++i) { + fileUtils::LogLine("[dvfs] cpu volt %d: %u mV", i, cpuVoltTable[i]); + } + + for(int i = 0; i < (int)std::size(voltData.voltTable); ++i) { + fileUtils::LogLine("[dvfs] gpu volt %d: %u mV", i, voltData.voltTable[i]); + } return; } } diff --git a/Source/hoc-clk/sysmodule/src/board/board_volt.hpp b/Source/hoc-clk/sysmodule/src/board/board_volt.hpp index 58022141..b8906534 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_volt.hpp +++ b/Source/hoc-clk/sysmodule/src/board/board_volt.hpp @@ -26,8 +26,6 @@ namespace board { u64 voltTableAddress; u32 ramVmin; }; - - /* TODO: Find out what component this actually targets. */ struct UnkRegulator { u32 voltageMin; u32 voltageStep; diff --git a/Source/hoc-clk/sysmodule/src/board/bq24193.cpp b/Source/hoc-clk/sysmodule/src/board/bq24193.cpp index b49ac8a5..85d1df37 100644 --- a/Source/hoc-clk/sysmodule/src/board/bq24193.cpp +++ b/Source/hoc-clk/sysmodule/src/board/bq24193.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors + * + * Copyright (c) CtCaer + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "bq24193.hpp" namespace bq24193 { diff --git a/Source/hoc-clk/sysmodule/src/board/bq24193.hpp b/Source/hoc-clk/sysmodule/src/board/bq24193.hpp index af626a50..575577c6 100644 --- a/Source/hoc-clk/sysmodule/src/board/bq24193.hpp +++ b/Source/hoc-clk/sysmodule/src/board/bq24193.hpp @@ -1,3 +1,22 @@ +/* + * Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors + * + * Copyright (c) CtCaer + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "board.hpp" #include