Skip to content

Commit 26325c1

Browse files
kiram9JohnAZoidberg
authored andcommitted
turn on bay power when programming dGPU eeprom
For fresh expansion bay modules that are unprogrammed, we need to turn on the power to program them if they are not preprogrammed with dummy values. Signed-off-by: Kieran Levin <ktl@frame.work>
1 parent ae3fdc5 commit 26325c1

1 file changed

Lines changed: 42 additions & 3 deletions

File tree

  • framework_lib/src/chromium_ec

framework_lib/src/chromium_ec/mod.rs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,35 @@ impl CrosEc {
13261326
"Writing GPU EEPROM {}",
13271327
if dry_run { " (DRY RUN)" } else { "" }
13281328
);
1329+
let mut force_power = false;
1330+
1331+
let info = EcRequestExpansionBayStatus {}.send_command(self)?;
1332+
println!(" Enabled: {}", info.module_enabled());
1333+
println!(" No fault: {}", !info.module_fault());
1334+
println!(" Door closed: {}", info.hatch_switch_closed());
1335+
1336+
match info.expansion_bay_board() {
1337+
Ok(board) => println!(" Board: {:?}", board),
1338+
Err(err) => println!(" Board: {:?}", err),
1339+
}
1340+
1341+
if let Ok(ExpansionBayBoard::DualInterposer) = info.expansion_bay_board() {
1342+
/* Force power to the GPU if we are writing the EEPROM */
1343+
let res = self.set_gpio("gpu_3v_5v_en", true);
1344+
if let Err(err) = res {
1345+
error!("Failed to set ALW power to GPU off {:?}", err);
1346+
return Err(err);
1347+
}
1348+
println!("Forcing Power to GPU");
1349+
os_specific::sleep(100_000);
1350+
force_power = true;
1351+
}
1352+
13291353
// Need to program the EEPROM 32 bytes at a time.
13301354
let chunk_size = 32;
13311355

13321356
let chunks = data.len() / chunk_size;
1357+
let mut return_val: EcResult<()> = Ok(());
13331358
for chunk_no in 0..chunks {
13341359
let offset = chunk_no * chunk_size;
13351360
// Current chunk might be smaller if it's the last
@@ -1356,12 +1381,26 @@ impl CrosEc {
13561381
// Don't read too fast, wait 100ms before writing more to allow for page erase/write cycle.
13571382
os_specific::sleep(100_000);
13581383
if let Err(err) = res {
1359-
println!(" Failed to write chunk: {:?}", err);
1360-
return Err(err);
1384+
error!("Failed to write chunk: {:?}", err);
1385+
return_val = Err(err);
1386+
break;
13611387
}
13621388
}
13631389
println!();
1364-
Ok(())
1390+
1391+
if force_power {
1392+
let res = self.set_gpio("gpu_3v_5v_en", false);
1393+
if let Err(err) = res {
1394+
error!("Failed to set ALW power to GPU off {:?}", err);
1395+
return if return_val.is_err() {
1396+
return_val
1397+
} else {
1398+
Err(err)
1399+
};
1400+
}
1401+
};
1402+
1403+
return_val
13651404
}
13661405

13671406
pub fn read_gpu_descriptor(&self) -> EcResult<Vec<u8>> {

0 commit comments

Comments
 (0)