temperature: Add support for AMD Excavator

Read current temperature from SMU via root complex.
This commit is contained in:
Jonathan Teh 2024-09-26 23:52:56 +01:00
parent 97922cc4cf
commit 5cdeebea33
2 changed files with 12 additions and 0 deletions

View File

@ -103,6 +103,14 @@ int get_cpu_temperature(void)
return cpu_temp_offset + 0.125f * (float)((regl >> 21) & 0x7FF);
} else if (cpuid_info.version.extendedFamily == 6 && (cpuid_info.version.extendedModel == 6 || cpuid_info.version.extendedModel == 7)) { // Target family 15h (Excavator)
pci_config_write32(0, 0, 0, AMD_SMU_INDEX_ADDR_REG, AMD_F15_M60H_TEMP_CTRL_OFFSET);
regl = pci_config_read32(0, 0, 0, AMD_SMU_INDEX_DATA_REG);
int raw_temp = ((regl >> 21) & 0x7FF) / 8;
return (raw_temp > 0) ? raw_temp : 0;
} else if (cpuid_info.version.extendedFamily > 0) { // Target K10 to K15 (Bulldozer)
regl = pci_config_read32(0, 24, 3, AMD_TEMP_REG_K10);

View File

@ -14,6 +14,10 @@
#define AMD_TEMP_REG_K8 0xE4
#define AMD_TEMP_REG_K10 0xA4
#define AMD_SMU_INDEX_ADDR_REG 0xB8
#define AMD_SMU_INDEX_DATA_REG 0xBC
#define AMD_F15_M60H_TEMP_CTRL_OFFSET 0xD8200CA4
// Temp Registers on AMD ZEN System Management Network
#define SMN_SMUIO_THM 0x00059800
#define SMN_THM_TCON_CUR_TMP (SMN_SMUIO_THM + 0x00)