@@ -1323,6 +1323,31 @@ 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+ match info. expansion_bay_board ( ) {
1333+ Ok ( board) =>
1334+ 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+
1350+
13261351 // Need to program the EEPROM 32 bytes at a time.
13271352 let chunk_size = 32 ;
13281353
@@ -1358,6 +1383,15 @@ impl CrosEc {
13581383 }
13591384 }
13601385 println ! ( ) ;
1386+
1387+ if force_power {
1388+ let res = self . set_gpio ( "gpu_3v_5v_en" , false ) ;
1389+ if let Err ( err) = res {
1390+ println ! ( " Failed to set ALW power to GPU off {:?}" , err) ;
1391+ return Err ( err) ;
1392+ }
1393+ } ;
1394+
13611395 Ok ( ( ) )
13621396 }
13631397
@@ -1564,6 +1598,16 @@ impl CrosEc {
15641598 . send_command ( self )
15651599 }
15661600
1601+ pub fn set_gpio ( & self , name : & str , value : bool ) -> EcResult < ( ) > {
1602+ const MAX_LEN : usize = 32 ;
1603+ let mut request = EcRequestGpioSetV0 { name : [ 0 ; MAX_LEN ] , value : value as u8 } ;
1604+
1605+ let end = MAX_LEN . min ( name. len ( ) ) ;
1606+ request. name [ ..end] . copy_from_slice ( & name. as_bytes ( ) [ ..end] ) ;
1607+
1608+ request. send_command ( self ) ?;
1609+ Ok ( ( ) )
1610+ }
15671611 pub fn get_gpio ( & self , name : & str ) -> EcResult < bool > {
15681612 const MAX_LEN : usize = 32 ;
15691613 let mut request = EcRequestGpioGetV0 { name : [ 0 ; MAX_LEN ] } ;
0 commit comments