File tree 6 files changed +64
-0
lines changed
6 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ pub enum EcCommands {
42
42
ConsoleRead = 0x0098 ,
43
43
ChargeState = 0x00A0 ,
44
44
ChargeCurrentLimit = 0x00A1 ,
45
+ HibernationDelay = 0x00A8 ,
45
46
/// List the features supported by the firmware
46
47
GetFeatures = 0x000D ,
47
48
/// Force reboot, causes host reboot as well
Original file line number Diff line number Diff line change @@ -438,6 +438,26 @@ impl EcRequest<()> for EcRequestCurrentLimitV1 {
438
438
}
439
439
}
440
440
441
+ #[ repr( C , packed) ]
442
+ pub struct EcRequesetHibernationDelay {
443
+ /// Seconds in G3 after EC turns off, 0 to read current
444
+ pub seconds : u32 ,
445
+ }
446
+
447
+ #[ repr( C , packed) ]
448
+ pub struct EcResponseHibernationDelay {
449
+ pub time_g3 : u32 ,
450
+ pub time_remaining : u32 ,
451
+ /// How long to wait in G3 until turn off
452
+ pub hibernation_delay : u32 ,
453
+ }
454
+
455
+ impl EcRequest < EcResponseHibernationDelay > for EcRequesetHibernationDelay {
456
+ fn command_id ( ) -> EcCommands {
457
+ EcCommands :: HibernationDelay
458
+ }
459
+ }
460
+
441
461
/// Supported features
442
462
#[ derive( Debug , FromPrimitive ) ]
443
463
pub enum EcFeatureCode {
Original file line number Diff line number Diff line change @@ -1147,6 +1147,19 @@ impl CrosEc {
1147
1147
Ok ( ( ) )
1148
1148
}
1149
1149
1150
+ pub fn set_ec_hib_delay ( & self , seconds : u32 ) -> EcResult < ( ) > {
1151
+ EcRequesetHibernationDelay { seconds } . send_command ( self ) ?;
1152
+ Ok ( ( ) )
1153
+ }
1154
+
1155
+ pub fn get_ec_hib_delay ( & self ) -> EcResult < u32 > {
1156
+ let res = EcRequesetHibernationDelay { seconds : 0 } . send_command ( self ) ?;
1157
+ debug ! ( "Time in G3: {:?}" , { res. time_g3 } ) ;
1158
+ debug ! ( "Time remaining: {:?}" , { res. time_remaining } ) ;
1159
+ println ! ( "EC Hibernation Delay: {:?}s" , { res. hibernation_delay } ) ;
1160
+ Ok ( res. hibernation_delay )
1161
+ }
1162
+
1150
1163
/// Check features supported by the firmware
1151
1164
pub fn get_features ( & self ) -> EcResult < ( ) > {
1152
1165
let data = EcRequestGetFeatures { } . send_command ( self ) ?;
Original file line number Diff line number Diff line change @@ -213,6 +213,11 @@ struct ClapCli {
213
213
#[ arg( long) ]
214
214
reboot_ec : Option < RebootEcArg > ,
215
215
216
+ /// Get or set EC hibernate delay (S5 to G3)
217
+ #[ clap( value_enum) ]
218
+ #[ arg( long) ]
219
+ ec_hib_delay : Option < Option < u32 > > ,
220
+
216
221
/// Hash a file of arbitrary data
217
222
#[ arg( long) ]
218
223
hash : Option < std:: path:: PathBuf > ,
@@ -398,6 +403,7 @@ pub fn parse(args: &[String]) -> Cli {
398
403
stylus_battery : args. stylus_battery ,
399
404
console : args. console ,
400
405
reboot_ec : args. reboot_ec ,
406
+ ec_hib_delay : args. ec_hib_delay ,
401
407
hash : args. hash . map ( |x| x. into_os_string ( ) . into_string ( ) . unwrap ( ) ) ,
402
408
driver : args. driver ,
403
409
pd_addrs,
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ pub struct Cli {
187
187
pub stylus_battery : bool ,
188
188
pub console : Option < ConsoleArg > ,
189
189
pub reboot_ec : Option < RebootEcArg > ,
190
+ pub ec_hib_delay : Option < Option < u32 > > ,
190
191
pub hash : Option < String > ,
191
192
pub pd_addrs : Option < ( u16 , u16 ) > ,
192
193
pub pd_ports : Option < ( u8 , u8 ) > ,
@@ -868,6 +869,11 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
868
869
Err ( err) => println ! ( "Failed: {:?}" , err) ,
869
870
} ,
870
871
}
872
+ } else if let Some ( delay) = & args. ec_hib_delay {
873
+ if let Some ( delay) = delay {
874
+ print_err ( ec. set_ec_hib_delay ( * delay) ) ;
875
+ }
876
+ print_err ( ec. get_ec_hib_delay ( ) ) ;
871
877
} else if args. test {
872
878
println ! ( "Self-Test" ) ;
873
879
let result = selftest ( & ec) ;
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ pub fn parse(args: &[String]) -> Cli {
100
100
stylus_battery : false ,
101
101
console : None ,
102
102
reboot_ec : None ,
103
+ ec_hib_delay : None ,
103
104
hash : None ,
104
105
// This is the only driver that works on UEFI
105
106
driver : Some ( CrosEcDriverType :: Portio ) ,
@@ -462,6 +463,23 @@ pub fn parse(args: &[String]) -> Cli {
462
463
None
463
464
} ;
464
465
found_an_option = true ;
466
+ } else if arg == "--reboot-ec" {
467
+ cli. ec_hib_delay = if args. len ( ) > i + 1 {
468
+ if let Ok ( delay) = args[ i + 1 ] . parse :: < u32 > ( ) {
469
+ if delay == 0 {
470
+ println ! ( "Invalid value for --ec-hib-delay: {}. Must be >0" , delay) ;
471
+ None
472
+ } else {
473
+ Some ( Some ( delay) )
474
+ }
475
+ } else {
476
+ println ! ( "Invalid value for --fp-brightness. Must be amount in seconds >0" ) ;
477
+ None
478
+ }
479
+ } else {
480
+ Some ( None )
481
+ } ;
482
+ found_an_option = true ;
465
483
} else if arg == "-t" || arg == "--test" {
466
484
cli. test = true ;
467
485
found_an_option = true ;
You can’t perform that action at this time.
0 commit comments