Skip to content

Commit b7207a6

Browse files
Merge pull request #18 from FrameworkComputer/dvt2-boardid
chromium_ec: Properly decode DVT2 dGPU board IDs
2 parents b812ab8 + 1250929 commit b7207a6

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

framework_lib/src/chromium_ec/commands.rs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::fmt;
2+
13
use num_derive::FromPrimitive;
24

35
use super::{command::*, input_deck::INPUT_DECK_SLOTS};
@@ -280,7 +282,13 @@ pub enum ExpansionByStates {
280282
pub enum ExpansionBayBoard {
281283
DualInterposer,
282284
SingleInterposer,
283-
Invalid,
285+
UmaFans,
286+
}
287+
288+
#[derive(Debug)]
289+
pub enum ExpansionBayIssue {
290+
NoModule,
291+
BadConnection(u8, u8),
284292
}
285293

286294
// pub to disable unused warnings
@@ -322,12 +330,17 @@ impl EcResponseExpansionBayStatus {
322330
pub fn hatch_switch_closed(&self) -> bool {
323331
self.state & (ExpansionByStates::HatchSwitchClosed as u8) != 0
324332
}
325-
pub fn expansion_bay_board(&self) -> Option<ExpansionBayBoard> {
333+
pub fn expansion_bay_board(&self) -> Result<ExpansionBayBoard, ExpansionBayIssue> {
326334
match (self.board_id_1, self.board_id_0) {
327-
(BOARD_VERSION_12, BOARD_VERSION_12) => Some(ExpansionBayBoard::DualInterposer),
328-
(BOARD_VERSION_11, BOARD_VERSION_15) => Some(ExpansionBayBoard::SingleInterposer),
329-
(BOARD_VERSION_15, BOARD_VERSION_15) => None,
330-
_ => Some(ExpansionBayBoard::Invalid),
335+
(BOARD_VERSION_12, BOARD_VERSION_12) => Ok(ExpansionBayBoard::DualInterposer),
336+
(BOARD_VERSION_13, BOARD_VERSION_15) => Ok(ExpansionBayBoard::UmaFans),
337+
(BOARD_VERSION_11, BOARD_VERSION_15) => Ok(ExpansionBayBoard::SingleInterposer),
338+
(BOARD_VERSION_15, BOARD_VERSION_15) => Err(ExpansionBayIssue::NoModule),
339+
// Invalid board IDs. Something wrong, could be interposer not connected
340+
_ => Err(ExpansionBayIssue::BadConnection(
341+
self.board_id_1,
342+
self.board_id_0,
343+
)),
331344
}
332345
}
333346
}
@@ -391,6 +404,18 @@ impl EcResponseGetHwDiag {
391404
)
392405
}
393406
}
407+
impl fmt::Display for EcResponseGetHwDiag {
408+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
409+
let (left_fan, right_fan) = self.fan_fault();
410+
write!(
411+
f,
412+
"BIOS Done: {}, Fan Fault Left: {}, Right: {}",
413+
self.bios_complete != 0,
414+
left_fan,
415+
right_fan
416+
)
417+
}
418+
}
394419

395420
impl EcRequest<EcResponseGetHwDiag> for EcRequestGetHwDiag {
396421
fn command_id() -> EcCommands {

0 commit comments

Comments
 (0)