File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -358,4 +358,12 @@ impl PdController {
358358 base_ver, app_ver
359359 ) ;
360360 }
361+
362+ pub fn reset_device ( & self ) -> EcResult < ( ) > {
363+ self . ccgx_write (
364+ ControlRegisters :: ResetRequest ,
365+ & [ HPI_RESET_SIGNATURE as u8 , HPI_RESET_DEV_CMD ] ,
366+ ) ?;
367+ Ok ( ( ) )
368+ }
361369}
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ struct ClapCli {
8383 #[ arg( long) ]
8484 pd_info : bool ,
8585
86+ /// Reset a specific PD controller (for debugging only)
87+ #[ arg( long) ]
88+ pd_reset : Option < u8 > ,
89+
8690 /// Show details about connected DP or HDMI Expansion Cards
8791 #[ arg( long) ]
8892 dp_hdmi_info : bool ,
@@ -376,6 +380,7 @@ pub fn parse(args: &[String]) -> Cli {
376380 autofanctrl : args. autofanctrl ,
377381 pdports : args. pdports ,
378382 pd_info : args. pd_info ,
383+ pd_reset : args. pd_reset ,
379384 dp_hdmi_info : args. dp_hdmi_info ,
380385 dp_hdmi_update : args
381386 . dp_hdmi_update
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ pub struct Cli {
156156 pub pdports : bool ,
157157 pub privacy : bool ,
158158 pub pd_info : bool ,
159+ pub pd_reset : Option < u8 > ,
159160 pub dp_hdmi_info : bool ,
160161 pub dp_hdmi_update : Option < String > ,
161162 pub audio_card_info : bool ,
@@ -999,6 +1000,17 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
9991000 smbios_info ( ) ;
10001001 } else if args. pd_info {
10011002 print_pd_details ( & ec) ;
1003+ } else if let Some ( pd) = args. pd_reset {
1004+ println ! ( "Resetting PD {}..." , pd) ;
1005+ print_err ( match pd {
1006+ 0 => PdController :: new ( PdPort :: Left01 , ec. clone ( ) ) . reset_device ( ) ,
1007+ 1 => PdController :: new ( PdPort :: Right23 , ec. clone ( ) ) . reset_device ( ) ,
1008+ 2 => PdController :: new ( PdPort :: Back , ec. clone ( ) ) . reset_device ( ) ,
1009+ _ => {
1010+ error ! ( "PD {} does not exist" , pd) ;
1011+ Ok ( ( ) )
1012+ }
1013+ } ) ;
10021014 } else if args. dp_hdmi_info {
10031015 #[ cfg( feature = "hidapi" ) ]
10041016 print_dp_hdmi_details ( true ) ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ pub fn parse(args: &[String]) -> Cli {
7070 autofanctrl : false ,
7171 pdports : false ,
7272 pd_info : false ,
73+ pd_reset : None ,
7374 dp_hdmi_info : false ,
7475 dp_hdmi_update : None ,
7576 audio_card_info : false ,
@@ -518,6 +519,22 @@ pub fn parse(args: &[String]) -> Cli {
518519 } else if arg == "--pd-info" {
519520 cli. pd_info = true ;
520521 found_an_option = true ;
522+ } else if arg == "--pd-reset" {
523+ cli. pd_reset = if args. len ( ) > i + 1 {
524+ if let Ok ( pd) = args[ i + 1 ] . parse :: < u8 > ( ) {
525+ Some ( pd)
526+ } else {
527+ println ! (
528+ "Invalid value for --pd-reset: '{}'. Must be 0 or 1." ,
529+ args[ i + 1 ] ,
530+ ) ;
531+ None
532+ }
533+ } else {
534+ println ! ( "--pd-reset requires specifying the PD controller" ) ;
535+ None
536+ } ;
537+ found_an_option = true ;
521538 } else if arg == "--privacy" {
522539 cli. privacy = true ;
523540 found_an_option = true ;
You can’t perform that action at this time.
0 commit comments