Skip to content

Commit cd23e90

Browse files
Merge pull request #135 from FrameworkComputer/charger-ic
--thermal: Add Framework 12 charger IC temp and unknown sensors
2 parents a62ad50 + b80e2cb commit cd23e90

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

framework_lib/src/power.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const EC_FAN_SPEED_ENTRIES: usize = 4;
7676
const EC_FAN_SPEED_STALLED_DEPRECATED: u16 = 0xFFFE;
7777
const EC_FAN_SPEED_NOT_PRESENT: u16 = 0xFFFF;
7878

79-
#[derive(Debug)]
79+
#[derive(Debug, PartialEq)]
8080
enum TempSensor {
8181
Ok(u8),
8282
NotPresent,
@@ -311,7 +311,7 @@ pub fn print_thermal(ec: &CrosEc) {
311311
let fans = ec.read_memory(EC_MEMMAP_FAN, 0x08).unwrap();
312312

313313
let platform = smbios::get_platform();
314-
match platform {
314+
let remaining_sensors = match platform {
315315
Some(Platform::IntelGen11) | Some(Platform::IntelGen12) | Some(Platform::IntelGen13) => {
316316
println!(" F75303_Local: {:>4}", TempSensor::from(temps[0]));
317317
println!(" F75303_CPU: {:>4}", TempSensor::from(temps[1]));
@@ -324,6 +324,7 @@ pub fn print_thermal(ec: &CrosEc) {
324324
) {
325325
println!(" F57397_VCCGT: {:>4}", TempSensor::from(temps[5]));
326326
}
327+
2
327328
}
328329

329330
Some(Platform::IntelCoreUltra1) => {
@@ -332,6 +333,7 @@ pub fn print_thermal(ec: &CrosEc) {
332333
println!(" Battery: {:>4}", TempSensor::from(temps[2]));
333334
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[3]));
334335
println!(" PECI: {:>4}", TempSensor::from(temps[4]));
336+
3
335337
}
336338

337339
Some(Platform::Framework12IntelGen13) => {
@@ -340,6 +342,8 @@ pub fn print_thermal(ec: &CrosEc) {
340342
println!(" F75303_Local: {:>4}", TempSensor::from(temps[2]));
341343
println!(" Battery: {:>4}", TempSensor::from(temps[3]));
342344
println!(" PECI: {:>4}", TempSensor::from(temps[4]));
345+
println!(" Charger IC {:>4}", TempSensor::from(temps[5]));
346+
2
343347
}
344348

345349
Some(
@@ -356,6 +360,9 @@ pub fn print_thermal(ec: &CrosEc) {
356360
println!(" dGPU VRAM: {:>4}", TempSensor::from(temps[5]));
357361
println!(" dGPU AMB: {:>4}", TempSensor::from(temps[6]));
358362
println!(" dGPU temp: {:>4}", TempSensor::from(temps[7]));
363+
0
364+
} else {
365+
4
359366
}
360367
}
361368

@@ -364,6 +371,7 @@ pub fn print_thermal(ec: &CrosEc) {
364371
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[1]));
365372
println!(" F75303_AMB: {:>4}", TempSensor::from(temps[2]));
366373
println!(" APU: {:>4}", TempSensor::from(temps[3]));
374+
4
367375
}
368376

369377
_ => {
@@ -375,17 +383,26 @@ pub fn print_thermal(ec: &CrosEc) {
375383
println!(" Temp 5: {:>4}", TempSensor::from(temps[5]));
376384
println!(" Temp 6: {:>4}", TempSensor::from(temps[6]));
377385
println!(" Temp 7: {:>4}", TempSensor::from(temps[7]));
386+
0
387+
}
388+
};
389+
390+
// Just in case EC has more sensors than we know about, print them
391+
for (i, temp) in temps.iter().enumerate().take(8).skip(8 - remaining_sensors) {
392+
let temp = TempSensor::from(*temp);
393+
if temp != TempSensor::NotPresent {
394+
println!(" Temp {}: {:>4}", i, temp);
378395
}
379396
}
380397

381398
for i in 0..EC_FAN_SPEED_ENTRIES {
382399
let fan = u16::from_le_bytes([fans[i * 2], fans[1 + i * 2]]);
383400
if fan == EC_FAN_SPEED_STALLED_DEPRECATED {
384-
println!(" Fan Speed: {:>4} RPM (Stalled)", fan);
401+
println!(" Fan Speed: {:>4} RPM (Stalled)", fan);
385402
} else if fan == EC_FAN_SPEED_NOT_PRESENT {
386403
info!(" Fan Speed: Not present");
387404
} else {
388-
println!(" Fan Speed: {:>4} RPM", fan);
405+
println!(" Fan Speed: {:>4} RPM", fan);
389406
}
390407
}
391408
}

0 commit comments

Comments
 (0)