move soctherm poll to bpmp

This commit is contained in:
souldbminersmwc committed 2026-08-25 15:59:52 -04:00
1 parent ba75b02c52
commit 49244b3baf
8 files changed
+95 -48

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) Souldbminer, Lightos and Horizon OC Contributors
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <cstdint>
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using s8 = std::int8_t;
using s16 = std::int16_t;
using s32 = std::int32_t;
+10 -1
View File
@@ -20,6 +20,7 @@
#include "libc_platform.hpp"
#include "regs.hpp"
#include "sensors.hpp"
#include <hocclk/bpmp.h>
@@ -34,7 +35,7 @@ namespace {
extern "C" void main() {
InitializeLibc();
printf("[hoc-bpmpfw] Starting bpmpfw\n");
printf("[hoc-bpmpfw]: Starting bpmpfw\n");
HocClkBpmpSharedInfo &info = SharedInfo();
memset(&info, 0, sizeof(info));
@@ -42,6 +43,14 @@ extern "C" void main() {
info.magic = HOCCLK_BPMP_MAGIC; // written last
for (;;) {
const u32 temp1 = MMIO32(SocthermBase + SocthermSensorTemp1);
const u32 temp2 = MMIO32(SocthermBase + SocthermSensorTemp2);
info.tempCpu = TranslateSocthermTemp(static_cast<u16>(temp1 >> 16));
info.tempGpu = TranslateSocthermTemp(static_cast<u16>(temp1));
info.tempMem = TranslateSocthermTemp(static_cast<u16>(temp2 >> 16));
info.tempPllx = TranslateSocthermTemp(static_cast<u16>(temp2));
usleep(250000); // 250ms
}
}
+10 -5
View File
@@ -16,11 +16,7 @@
*/
#pragma once
#include <cstdint>
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
#include "defs.hpp"
#define MMIO32(addr) (*reinterpret_cast<volatile u32 *>(addr))
@@ -39,6 +35,15 @@ constexpr u32 HaltUsec = (0u << 24);
MMIO32(FlowCtlrBase + FlowCtlrHaltCopEvents) = HaltModeWaitEvent | HaltUsec | (usec & 0xFFFFFFu);
}
constexpr u32 TmrBase = 0x60005000;
constexpr u32 TimerUsCntr1Us = 0x10;
[[maybe_unused]] inline void usleep(u32 us) {
const u32 start = MMIO32(TmrBase + TimerUsCntr1Us);
while ((MMIO32(TmrBase + TimerUsCntr1Us) - start) <= us)
;
}
constexpr u32 UartBBase = 0x70006040;
constexpr u32 UartThr = 0x00;
constexpr u32 UartLsr = 0x14;
+34
View File
@@ -0,0 +1,34 @@
/*
* Copyright (c) Souldbminer, Lightos and Horizon OC Contributors
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "regs.hpp"
constexpr u32 SocthermBase = 0x700E2000;
constexpr u32 SocthermSensorTemp1 = 0x1C8;
constexpr u32 SocthermSensorTemp2 = 0x1CC;
inline s32 TranslateSocthermTemp(u16 val) {
s32 t = ((val >> 8) & 0xFF) * 1000;
if (val & (1u << 7)) {
t += 500;
}
if (val & (1u << 0)) {
t = -t;
}
return t;
}