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 {
4040 SecurityGet = 20 ,
4141 SecuritySet = 21 ,
4242 FanTach = 22 ,
43+ UsbcMuxInfo = 23 ,
4344}
4445
4546const CMD_SPI_FLAG_READ : u8 = 1 << 0 ;
@@ -328,6 +329,16 @@ impl<A: Access> Ec<A> {
328329 self . command ( Cmd :: SecuritySet , & mut data)
329330 }
330331
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+
331342 /// Read fan tachometer by fan index
332343 pub unsafe fn fan_tach ( & mut self , index : u8 ) -> Result < u16 , Error > {
333344 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
300300 Ok ( ( ) )
301301}
302302
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+
303310fn parse_color ( s : & str ) -> Result < ( u8 , u8 , u8 ) , String > {
304311 let r = u8:: from_str_radix ( & s[ 0 ..2 ] , 16 ) ;
305312 let g = u8:: from_str_radix ( & s[ 2 ..4 ] , 16 ) ;
@@ -364,6 +371,9 @@ enum SubCommand {
364371 Security {
365372 state : Option < String > ,
366373 } ,
374+ UsbcMuxInfo {
375+ port : u8 ,
376+ } ,
367377}
368378
369379#[ derive( clap:: ArgEnum , Clone ) ]
@@ -652,5 +662,14 @@ fn main() {
652662 } ,
653663 }
654664 } ,
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+ } ,
655674 }
656675}
You can’t perform that action at this time.
0 commit comments