Skip to content

Commit

Permalink
Show core temperatures of Rockchip RK3588 SoC
Browse files Browse the repository at this point in the history
  • Loading branch information
segabor committed Mar 14, 2024
1 parent 4feac8e commit 4746338
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions linux/LibSensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ static int tempDriverPriority(const sensors_chip_name* chip) {
const char* prefix;
int priority;
} tempDrivers[] = {
{ "coretemp", 0 },
{ "via_cputemp", 0 },
{ "cpu_thermal", 0 },
{ "k10temp", 0 },
{ "zenpower", 0 },
{ "coretemp", 0 },
{ "via_cputemp", 0 },
{ "cpu_thermal", 0 },
{ "k10temp", 0 },
{ "zenpower", 0 },
/* Rockchip RK3588 */
{ "littlecore_thermal", 0 },
{ "bigcore0_thermal", 0 },
{ "bigcore1_thermal", 0 },
/* Low priority drivers */
{ "acpitz", 1 },
{ "acpitz", 1 },
};

for (size_t i = 0; i < ARRAYSIZE(tempDrivers); i++)
Expand Down Expand Up @@ -167,6 +171,7 @@ void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, uns
int n = 0;
for (const sensors_chip_name* chip = sym_sensors_get_detected_chips(NULL, &n); chip; chip = sym_sensors_get_detected_chips(NULL, &n)) {
const int priority = tempDriverPriority(chip);
// printf("chip prefix: %s, path: %s, prio: %d\n", chip->prefix, chip->path, priority);
if (priority < 0)
continue;

Expand Down Expand Up @@ -208,6 +213,33 @@ void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, uns
if (r != 0)
continue;

/* Map temperature values to Rockchip cores
*
* littlecore -> cores 1..4
* bigcore0 -> cores 5,6
* bigcore1 -> cores 7,8
*/
if (existingCPUs == 8 && String_eq(chip->prefix, "littlecore_thermal")) {
data[1] = temp;
data[2] = temp;
data[3] = temp;
data[4] = temp;
coreTempCount+=4;
continue;
}
if (existingCPUs == 8 && String_eq(chip->prefix, "bigcore0_thermal")) {
data[5] = temp;
data[6] = temp;
coreTempCount+=2;
continue;
}
if (existingCPUs == 8 && String_eq(chip->prefix, "bigcore1_thermal")) {
data[7] = temp;
data[8] = temp;
coreTempCount+=2;
continue;
}

/* If already set, e.g. Ryzen reporting platform temperature for each die, use the bigger one */
if (isNaN(data[tempID])) {
data[tempID] = temp;
Expand Down

0 comments on commit 4746338

Please sign in to comment.