@@ -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 ;
@@ -477,92 +477,27 @@ pub fn print_thermal(ec: &CrosEc) {
477477 let temps = ec. read_memory ( EC_MEMMAP_TEMP_SENSOR , 0x0F ) . unwrap ( ) ;
478478 let fans = ec. read_memory ( EC_MEMMAP_FAN , 0x08 ) . unwrap ( ) ;
479479
480- let platform = smbios:: get_platform ( ) ;
481480 let family = smbios:: get_family ( ) ;
482- let remaining_sensors = match platform {
483- Some ( Platform :: IntelGen11 ) | Some ( Platform :: IntelGen12 ) | Some ( Platform :: IntelGen13 ) => {
484- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
485- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
486- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
487- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
488- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
489- if matches ! (
490- platform,
491- Some ( Platform :: IntelGen12 ) | Some ( Platform :: IntelGen13 )
492- ) {
493- println ! ( " F57397_VCCGT: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
494- }
495- 2
496- }
497-
498- Some ( Platform :: IntelCoreUltra1 ) | Some ( Platform :: IntelCoreUltra3 ) => {
499- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
500- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
501- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
502- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
503- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
504- 3
505- }
506-
507- Some ( Platform :: Framework12IntelGen13 ) => {
508- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
509- println ! ( " F75303_Skin: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
510- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
511- println ! ( " Battery: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
512- println ! ( " PECI: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
513- println ! ( " Charger IC {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
514- 2
515- }
516-
517- Some (
518- Platform :: Framework13Amd7080
519- | Platform :: Framework13AmdAi300
520- | Platform :: Framework16Amd7080
521- | Platform :: Framework16AmdAi300 ,
522- ) => {
523- println ! ( " F75303_Local: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
524- println ! ( " F75303_CPU: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
525- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
526- println ! ( " APU: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
527- if family == Some ( PlatformFamily :: Framework16 ) {
528- println ! ( " dGPU VR: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
529- println ! ( " dGPU VRAM: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
530- println ! ( " dGPU AMB: {:>4}" , TempSensor :: from( temps[ 6 ] ) ) ;
531- println ! ( " dGPU temp: {:>4}" , TempSensor :: from( temps[ 7 ] ) ) ;
532- 0
533- } else {
534- 4
535- }
536- }
537481
538- Some ( Platform :: FrameworkDesktopAmdAiMax300 ) => {
539- println ! ( " F75303_APU: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
540- println ! ( " F75303_DDR: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
541- println ! ( " F75303_AMB: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
542- println ! ( " APU: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
543- println ! ( " Virtual: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
544- 3
545- }
546-
547- _ => {
548- println ! ( " Temp 0: {:>4}" , TempSensor :: from( temps[ 0 ] ) ) ;
549- println ! ( " Temp 1: {:>4}" , TempSensor :: from( temps[ 1 ] ) ) ;
550- println ! ( " Temp 2: {:>4}" , TempSensor :: from( temps[ 2 ] ) ) ;
551- println ! ( " Temp 3: {:>4}" , TempSensor :: from( temps[ 3 ] ) ) ;
552- println ! ( " Temp 4: {:>4}" , TempSensor :: from( temps[ 4 ] ) ) ;
553- println ! ( " Temp 5: {:>4}" , TempSensor :: from( temps[ 5 ] ) ) ;
554- println ! ( " Temp 6: {:>4}" , TempSensor :: from( temps[ 6 ] ) ) ;
555- println ! ( " Temp 7: {:>4}" , TempSensor :: from( temps[ 7 ] ) ) ;
556- 0
557- }
558- } ;
559-
560- // Just in case EC has more sensors than we know about, print them
561- for ( i, temp) in temps. iter ( ) . enumerate ( ) . take ( 8 ) . skip ( 8 - remaining_sensors) {
482+ let mut sensors = vec ! [ ] ;
483+ for ( i, temp) in temps. iter ( ) . enumerate ( ) {
562484 let temp = TempSensor :: from ( * temp) ;
563- if temp ! = TempSensor :: NotPresent {
564- println ! ( " Temp {}: {:>4}" , i , temp ) ;
485+ if temp = = TempSensor :: NotPresent {
486+ continue ;
565487 }
488+ // All our EC firmware supports reporting the sensor name
489+ let name = ec
490+ . get_temp_sensor_name ( i as u8 )
491+ . unwrap_or_else ( |_| format ! ( "Temp {}" , i) ) ;
492+ sensors. push ( ( name, temp) ) ;
493+ }
494+ let width = sensors
495+ . iter ( )
496+ . map ( |( name, _) | name. len ( ) + 1 )
497+ . max ( )
498+ . unwrap_or ( 13 ) ;
499+ for ( name, temp) in sensors {
500+ println ! ( " {:<width$} {:>4}" , format!( "{name}:" ) , temp) ;
566501 }
567502
568503 for i in 0 ..EC_FAN_SPEED_ENTRIES {
@@ -580,11 +515,11 @@ pub fn print_thermal(ec: &CrosEc) {
580515
581516 let fan = u16:: from_le_bytes ( [ fans[ i * 2 ] , fans[ 1 + i * 2 ] ] ) ;
582517 if fan == EC_FAN_SPEED_STALLED_DEPRECATED {
583- println ! ( " {name:<11 } {:>4} RPM (Stalled)" , fan) ;
518+ println ! ( " {name:<width$ } {:>4} RPM (Stalled)" , fan) ;
584519 } else if fan == EC_FAN_SPEED_NOT_PRESENT {
585- info ! ( " {name:<11 } Not present" ) ;
520+ info ! ( " {name:<width$ } Not present" ) ;
586521 } else {
587- println ! ( " {name:<11 } {:>4} RPM" , fan) ;
522+ println ! ( " {name:<width$ } {:>4} RPM" , fan) ;
588523 }
589524 }
590525
0 commit comments