@@ -33,7 +33,7 @@ use crate::capsule_content::{
3333use crate :: ccgx:: device:: { FwMode , PdController , PdPort } ;
3434#[ cfg( feature = "hidapi" ) ]
3535use crate :: ccgx:: hid:: { check_ccg_fw_version, find_devices, DP_CARD_PID , HDMI_CARD_PID } ;
36- use crate :: ccgx:: { self , SiliconId :: * } ;
36+ use crate :: ccgx:: { self , MainPdVersions , PdVersions , SiliconId :: * } ;
3737use crate :: chromium_ec;
3838use crate :: chromium_ec:: commands:: DeckStateMode ;
3939use crate :: chromium_ec:: commands:: FpLedBrightnessLevel ;
@@ -59,8 +59,7 @@ use crate::touchpad::print_touchpad_fw_ver;
5959use crate :: touchscreen;
6060#[ cfg( feature = "uefi" ) ]
6161use crate :: uefi:: enable_page_break;
62- use crate :: util;
63- use crate :: util:: { Config , Platform , PlatformFamily } ;
62+ use crate :: util:: { self , Config , Platform , PlatformFamily } ;
6463#[ cfg( feature = "hidapi" ) ]
6564use hidapi:: HidApi ;
6665use sha2:: { Digest , Sha256 , Sha384 , Sha512 } ;
@@ -398,11 +397,8 @@ fn print_versions(ec: &CrosEc) {
398397 }
399398
400399 println ! ( "PD Controllers" ) ;
401-
402- if let Ok ( pd_versions) = ccgx:: get_pd_controller_versions ( ec) {
403- let right = & pd_versions. controller01 ;
404- let left = & pd_versions. controller23 ;
405- // let active_mode =
400+ let ccgx_pd_vers = ccgx:: get_pd_controller_versions ( ec) ;
401+ if let Ok ( PdVersions :: RightLeft ( ( right, left) ) ) = ccgx_pd_vers {
406402 if let Some ( Platform :: IntelGen11 ) = smbios:: get_platform ( ) {
407403 if right. main_fw . base != right. backup_fw . base {
408404 println ! ( " Right (01)" ) ;
@@ -476,10 +472,43 @@ fn print_versions(ec: &CrosEc) {
476472 left. main_fw. app, left. active_fw
477473 ) ;
478474 }
475+ } else if let Ok ( PdVersions :: Single ( pd) ) = ccgx_pd_vers {
476+ if pd. main_fw . app != pd. backup_fw . app {
477+ println ! (
478+ " Main: {}{}" ,
479+ pd. main_fw. app,
480+ active_mode( & pd. active_fw, FwMode :: MainFw )
481+ ) ;
482+ println ! (
483+ " Backup: {}{}" ,
484+ pd. backup_fw. app,
485+ active_mode( & pd. active_fw, FwMode :: BackupFw )
486+ ) ;
487+ } else {
488+ println ! ( " Version: {} ({:?})" , pd. main_fw. app, pd. active_fw) ;
489+ }
479490 } else if let Ok ( pd_versions) = power:: read_pd_version ( ec) {
480491 // As fallback try to get it from the EC. But not all EC versions have this command
481- println ! ( " Right (01): {}" , pd_versions. controller01. app) ;
482- println ! ( " Left (23): {}" , pd_versions. controller23. app) ;
492+ debug ! ( " Fallback to PD Host command" ) ;
493+ match pd_versions {
494+ MainPdVersions :: RightLeft ( ( controller01, controller23) ) => {
495+ if let Some ( Platform :: IntelGen11 ) = smbios:: get_platform ( ) {
496+ println ! ( " Right (01): {}" , controller01. base) ;
497+ println ! ( " Left (23): {}" , controller23. base) ;
498+ } else {
499+ println ! ( " Right (01): {}" , controller01. app) ;
500+ println ! ( " Left (23): {}" , controller23. app) ;
501+ }
502+ }
503+ MainPdVersions :: Single ( version) => {
504+ println ! ( " Version: {}" , version. app) ;
505+ }
506+ MainPdVersions :: Many ( versions) => {
507+ for ( i, version) in versions. into_iter ( ) . enumerate ( ) {
508+ println ! ( " PD {}: {}" , i, version. app) ;
509+ }
510+ }
511+ }
483512 } else {
484513 println ! ( " Unknown" )
485514 }
@@ -527,7 +556,7 @@ fn print_versions(ec: &CrosEc) {
527556 }
528557
529558 #[ cfg( target_os = "linux" ) ]
530- {
559+ if smbios :: get_platform ( ) . and_then ( Platform :: which_cpu_vendor ) != Some ( util :: CpuVendor :: Amd ) {
531560 println ! ( "CSME" ) ;
532561 if let Ok ( csme) = csme:: csme_from_sysfs ( ) {
533562 info ! ( " Enabled: {}" , csme. enabled) ;
@@ -638,8 +667,8 @@ fn compare_version(device: Option<HardwareDeviceType>, version: String, ec: &Cro
638667 }
639668 }
640669 Some ( HardwareDeviceType :: PD0 ) => {
641- if let Ok ( pd_versions ) = ccgx:: get_pd_controller_versions ( ec) {
642- let ver = pd_versions . controller01 . active_fw_ver ( ) ;
670+ if let Ok ( PdVersions :: RightLeft ( ( pd01 , _pd23 ) ) ) = ccgx:: get_pd_controller_versions ( ec) {
671+ let ver = pd01 . active_fw_ver ( ) ;
643672 println ! ( "Comparing PD0 version {:?}" , ver) ;
644673
645674 if ver. contains ( & version) {
@@ -650,8 +679,8 @@ fn compare_version(device: Option<HardwareDeviceType>, version: String, ec: &Cro
650679 }
651680 }
652681 Some ( HardwareDeviceType :: PD1 ) => {
653- if let Ok ( pd_versions ) = ccgx:: get_pd_controller_versions ( ec) {
654- let ver = pd_versions . controller23 . active_fw_ver ( ) ;
682+ if let Ok ( PdVersions :: RightLeft ( ( _pd01 , pd23 ) ) ) = ccgx:: get_pd_controller_versions ( ec) {
683+ let ver = pd23 . active_fw_ver ( ) ;
655684 println ! ( "Comparing PD1 version {:?}" , ver) ;
656685
657686 if ver. contains ( & version) {
0 commit comments