File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ enum Cmd {
40
40
SecurityGet = 20 ,
41
41
SecuritySet = 21 ,
42
42
FanTach = 22 ,
43
+ UsbcMuxInfo = 23 ,
43
44
}
44
45
45
46
const CMD_SPI_FLAG_READ : u8 = 1 << 0 ;
@@ -328,6 +329,16 @@ impl<A: Access> Ec<A> {
328
329
self . command ( Cmd :: SecuritySet , & mut data)
329
330
}
330
331
332
+ /// Get USB-C mux info
333
+ pub unsafe fn usbc_mux_info ( & mut self , port : u8 ) -> Result < u16 , Error > {
334
+ let mut data = [ port, 0 , 0 ] ;
335
+ self . command ( Cmd :: UsbcMuxInfo , & mut data) ?;
336
+ Ok (
337
+ ( data[ 1 ] as u16 ) |
338
+ ( ( data[ 2 ] as u16 ) << 8 )
339
+ )
340
+ }
341
+
331
342
/// Read fan tachometer by fan index
332
343
pub unsafe fn fan_tach ( & mut self , index : u8 ) -> Result < u16 , Error > {
333
344
let mut data = [
Original file line number Diff line number Diff line change @@ -300,6 +300,13 @@ unsafe fn security_set(ec: &mut Ec<Box<dyn Access>>, state: SecurityState) -> Re
300
300
Ok ( ( ) )
301
301
}
302
302
303
+ unsafe fn usbc_mux_info ( ec : & mut Ec < Box < dyn Access > > , port : u8 ) -> Result < ( ) , Error > {
304
+ let info = ec. usbc_mux_info ( port) ?;
305
+ println ! ( "{:04X}" , info) ;
306
+
307
+ Ok ( ( ) )
308
+ }
309
+
303
310
fn parse_color ( s : & str ) -> Result < ( u8 , u8 , u8 ) , String > {
304
311
let r = u8:: from_str_radix ( & s[ 0 ..2 ] , 16 ) ;
305
312
let g = u8:: from_str_radix ( & s[ 2 ..4 ] , 16 ) ;
@@ -364,6 +371,9 @@ enum SubCommand {
364
371
Security {
365
372
state : Option < String > ,
366
373
} ,
374
+ UsbcMuxInfo {
375
+ port : u8 ,
376
+ } ,
367
377
}
368
378
369
379
#[ derive( clap:: ArgEnum , Clone ) ]
@@ -652,5 +662,14 @@ fn main() {
652
662
} ,
653
663
}
654
664
} ,
665
+ SubCommand :: UsbcMuxInfo { port } => {
666
+ match unsafe { usbc_mux_info ( & mut ec, port) } {
667
+ Ok ( ( ) ) => ( ) ,
668
+ Err ( err) => {
669
+ eprintln ! ( "failed to get usbc_mux_info {}: {:X?}" , port, err) ;
670
+ process:: exit ( 1 ) ;
671
+ } ,
672
+ }
673
+ } ,
655
674
}
656
675
}
You can’t perform that action at this time.
0 commit comments