@@ -14,7 +14,7 @@ use crate::chromium_ec::command::EcRequestRaw;
1414use crate :: chromium_ec:: commands:: * ;
1515use crate :: chromium_ec:: * ;
1616use crate :: smbios;
17- use crate :: util:: { Platform , PlatformFamily } ;
17+ use crate :: util:: PlatformFamily ;
1818
1919/// Maximum length of strings in memmap
2020const EC_MEMMAP_TEXT_MAX : u16 = 8 ;
@@ -475,92 +475,27 @@ pub fn print_thermal(ec: &CrosEc) {
475475 let temps = ec. read_memory ( EC_MEMMAP_TEMP_SENSOR , 0x0F ) . unwrap ( ) ;
476476 let fans = ec. read_memory ( EC_MEMMAP_FAN , 0x08 ) . unwrap ( ) ;
477477
478- let platform = smbios:: get_platform ( ) ;
479478 let family = smbios:: get_family ( ) ;
480- let remaining_sensors = match platform {
481- Some ( Platform :: IntelGen11 ) | Some ( Platform :: IntelGen12 ) | Some ( Platform :: IntelGen13 ) => {
482- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
483- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
484- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
485- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
486- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
487- if matches ! (
488- platform,
489- Some ( Platform :: IntelGen12 ) | Some ( Platform :: IntelGen13 )
490- ) {
491- println ! ( " F57397_VCCGT: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
492- }
493- 2
494- }
495-
496- Some ( Platform :: IntelCoreUltra1 ) | Some ( Platform :: IntelCoreUltra3 ) => {
497- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
498- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
499- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
500- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
501- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
502- 3
503- }
504-
505- Some ( Platform :: Framework12IntelGen13 ) => {
506- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
507- println ! ( " F75303_Skin: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
508- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
509- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
510- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
511- println ! ( " Charger IC {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
512- 2
513- }
514-
515- Some (
516- Platform :: Framework13Amd7080
517- | Platform :: Framework13AmdAi300
518- | Platform :: Framework16Amd7080
519- | Platform :: Framework16AmdAi300 ,
520- ) => {
521- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
522- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
523- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
524- println ! ( " APU: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
525- if family == Some ( PlatformFamily :: Framework16 ) {
526- println ! ( " dGPU VR: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
527- println ! ( " dGPU VRAM: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
528- println ! ( " dGPU AMB: {:>4}" , TempSensor :: from( temps[ 6 ] ) ) ;
529- println ! ( " dGPU temp: {:>4}" , TempSensor :: from( temps[ 7 ] ) ) ;
530- 0
531- } else {
532- 4
533- }
534- }
535479
536- Some ( Platform :: FrameworkDesktopAmdAiMax300 ) => {
537- println ! ( " F75303_APU: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
538- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
539- println ! ( " F75303_AMB: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
540- println ! ( " APU: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
541- println ! ( " Virtual: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
542- 3
543- }
544-
545- _ => {
546- println ! ( " Temp 0: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
547- println ! ( " Temp 1: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
548- println ! ( " Temp 2: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
549- println ! ( " Temp 3: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
550- println ! ( " Temp 4: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
551- println ! ( " Temp 5: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
552- println ! ( " Temp 6: {:>4}" , TempSensor :: from( temps[ 6 ] ) ) ;
553- println ! ( " Temp 7: {:>4}" , TempSensor :: from( temps[ 7 ] ) ) ;
554- 0
555- }
556- } ;
557-
558- // Just in case EC has more sensors than we know about, print them
559- for ( i, temp) in temps. iter ( ) . enumerate ( ) . take ( 8 ) . skip ( 8 - remaining_sensors) {
480+ let mut sensors = vec ! [ ] ;
481+ for ( i, temp) in temps. iter ( ) . enumerate ( ) {
560482 let temp = TempSensor :: from ( * temp) ;
561- if temp ! = TempSensor :: NotPresent {
562- println ! ( " Temp {}: {:>4}" , i , temp ) ;
483+ if temp = = TempSensor :: NotPresent {
484+ continue ;
563485 }
486+ // All our EC firmware supports reporting the sensor name
487+ let name = ec
488+ . get_temp_sensor_name ( i as u8 )
489+ . unwrap_or_else ( |_| format ! ( "Temp {}" , i) ) ;
490+ sensors. push ( ( name, temp) ) ;
491+ }
492+ let width = sensors
493+ . iter ( )
494+ . map ( |( name, _) | name. len ( ) + 1 )
495+ . max ( )
496+ . unwrap_or ( 13 ) ;
497+ for ( name, temp) in sensors {
498+ println ! ( " {:<width$} {:>4}" , format!( "{name}:" ) , temp) ;
564499 }
565500
566501 for i in 0 ..EC_FAN_SPEED_ENTRIES {
@@ -578,11 +513,11 @@ pub fn print_thermal(ec: &CrosEc) {
578513
579514 let fan = u16:: from_le_bytes ( [ fans[ i * 2 ] , fans[ 1 + i * 2 ] ] ) ;
580515 if fan == EC_FAN_SPEED_STALLED_DEPRECATED {
581- println ! ( " {name:<11 } {:>4} RPM (Stalled)" , fan) ;
516+ println ! ( " {name:<width$ } {:>4} RPM (Stalled)" , fan) ;
582517 } else if fan == EC_FAN_SPEED_NOT_PRESENT {
583- info ! ( " {name:<11 } Not present" ) ;
518+ info ! ( " {name:<width$ } Not present" ) ;
584519 } else {
585- println ! ( " {name:<11 } {:>4} RPM" , fan) ;
520+ println ! ( " {name:<width$ } {:>4} RPM" , fan) ;
586521 }
587522 }
588523}
0 commit comments