Skip to content

Commit

Permalink
Merge pull request #18 from FrameworkComputer/dvt2-boardid
Browse files Browse the repository at this point in the history
chromium_ec: Properly decode DVT2 dGPU board IDs
  • Loading branch information
JohnAZoidberg authored Oct 31, 2023
2 parents b812ab8 + 1250929 commit b7207a6
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt;

use num_derive::FromPrimitive;

use super::{command::*, input_deck::INPUT_DECK_SLOTS};
Expand Down Expand Up @@ -280,7 +282,13 @@ pub enum ExpansionByStates {
pub enum ExpansionBayBoard {
DualInterposer,
SingleInterposer,
Invalid,
UmaFans,
}

#[derive(Debug)]
pub enum ExpansionBayIssue {
NoModule,
BadConnection(u8, u8),
}

// pub to disable unused warnings
Expand Down Expand Up @@ -322,12 +330,17 @@ impl EcResponseExpansionBayStatus {
pub fn hatch_switch_closed(&self) -> bool {
self.state & (ExpansionByStates::HatchSwitchClosed as u8) != 0
}
pub fn expansion_bay_board(&self) -> Option<ExpansionBayBoard> {
pub fn expansion_bay_board(&self) -> Result<ExpansionBayBoard, ExpansionBayIssue> {
match (self.board_id_1, self.board_id_0) {
(BOARD_VERSION_12, BOARD_VERSION_12) => Some(ExpansionBayBoard::DualInterposer),
(BOARD_VERSION_11, BOARD_VERSION_15) => Some(ExpansionBayBoard::SingleInterposer),
(BOARD_VERSION_15, BOARD_VERSION_15) => None,
_ => Some(ExpansionBayBoard::Invalid),
(BOARD_VERSION_12, BOARD_VERSION_12) => Ok(ExpansionBayBoard::DualInterposer),
(BOARD_VERSION_13, BOARD_VERSION_15) => Ok(ExpansionBayBoard::UmaFans),
(BOARD_VERSION_11, BOARD_VERSION_15) => Ok(ExpansionBayBoard::SingleInterposer),
(BOARD_VERSION_15, BOARD_VERSION_15) => Err(ExpansionBayIssue::NoModule),
// Invalid board IDs. Something wrong, could be interposer not connected
_ => Err(ExpansionBayIssue::BadConnection(
self.board_id_1,
self.board_id_0,
)),
}
}
}
Expand Down Expand Up @@ -391,6 +404,18 @@ impl EcResponseGetHwDiag {
)
}
}
impl fmt::Display for EcResponseGetHwDiag {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (left_fan, right_fan) = self.fan_fault();
write!(
f,
"BIOS Done: {}, Fan Fault Left: {}, Right: {}",
self.bios_complete != 0,
left_fan,
right_fan
)
}
}

impl EcRequest<EcResponseGetHwDiag> for EcRequestGetHwDiag {
fn command_id() -> EcCommands {
Expand Down

0 comments on commit b7207a6

Please sign in to comment.