@@ -1323,6 +1323,30 @@ impl CrosEc {
13231323 "Writing GPU EEPROM {}" ,
13241324 if dry_run { " (DRY RUN)" } else { "" }
13251325 ) ;
1326+ let mut force_power = false ;
1327+
1328+ let info = EcRequestExpansionBayStatus { } . send_command ( self ) ?;
1329+ println ! ( " Enabled: {}" , info. module_enabled( ) ) ;
1330+ println ! ( " No fault: {}" , !info. module_fault( ) ) ;
1331+ println ! ( " Door closed: {}" , info. hatch_switch_closed( ) ) ;
1332+
1333+ match info. expansion_bay_board ( ) {
1334+ Ok ( board) => println ! ( " Board: {:?}" , board) ,
1335+ Err ( err) => println ! ( " Board: {:?}" , err) ,
1336+ }
1337+
1338+ if let Ok ( ExpansionBayBoard :: DualInterposer ) = info. expansion_bay_board ( ) {
1339+ /* Force power to the GPU if we are writing the EEPROM */
1340+ let res = self . set_gpio ( "gpu_3v_5v_en" , true ) ;
1341+ if let Err ( err) = res {
1342+ println ! ( " Failed to set ALW power to GPU off {:?}" , err) ;
1343+ return Err ( err) ;
1344+ }
1345+ println ! ( "Forcing Power to GPU" ) ;
1346+ os_specific:: sleep ( 100_000 ) ;
1347+ force_power = true ;
1348+ }
1349+
13261350 // Need to program the EEPROM 32 bytes at a time.
13271351 let chunk_size = 32 ;
13281352
@@ -1358,6 +1382,15 @@ impl CrosEc {
13581382 }
13591383 }
13601384 println ! ( ) ;
1385+
1386+ if force_power {
1387+ let res = self . set_gpio ( "gpu_3v_5v_en" , false ) ;
1388+ if let Err ( err) = res {
1389+ println ! ( " Failed to set ALW power to GPU off {:?}" , err) ;
1390+ return Err ( err) ;
1391+ }
1392+ } ;
1393+
13611394 Ok ( ( ) )
13621395 }
13631396
@@ -1564,6 +1597,19 @@ impl CrosEc {
15641597 . send_command ( self )
15651598 }
15661599
1600+ pub fn set_gpio ( & self , name : & str , value : bool ) -> EcResult < ( ) > {
1601+ const MAX_LEN : usize = 32 ;
1602+ let mut request = EcRequestGpioSetV0 {
1603+ name : [ 0 ; MAX_LEN ] ,
1604+ value : value as u8 ,
1605+ } ;
1606+
1607+ let end = MAX_LEN . min ( name. len ( ) ) ;
1608+ request. name [ ..end] . copy_from_slice ( & name. as_bytes ( ) [ ..end] ) ;
1609+
1610+ request. send_command ( self ) ?;
1611+ Ok ( ( ) )
1612+ }
15671613 pub fn get_gpio ( & self , name : & str ) -> EcResult < bool > {
15681614 const MAX_LEN : usize = 32 ;
15691615 let mut request = EcRequestGpioGetV0 { name : [ 0 ; MAX_LEN ] } ;
0 commit comments