Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions build/fpga-regmap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ fn write_reg_fields(
writeln!(
output,
"
{prefix} #[derive(Copy, Clone, Eq, PartialEq)]
{prefix} use hubpack::SerializedSize;
{prefix} use serde::{{Deserialize, Serialize}};

{prefix} #[allow(dead_code)]
{prefix} #[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, SerializedSize)]
{prefix} pub enum {encode_name} {{"
)
.unwrap();
Expand Down Expand Up @@ -233,7 +236,8 @@ fn write_reg_fields(
{prefix} type Error = u8;
{prefix} fn try_from(x: u8) -> Result<Self, Self::Error> {{
{prefix} use crate::{parent_chain}::{encode_name}::*;
{prefix} let x_masked = x & {inst_name};
{prefix} let position = {inst_name}.trailing_zeros();
{prefix} let x_masked = (x & {inst_name}) >> position;
{prefix} match x_masked {{"
)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions drv/gimlet-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static-cell = { path = "../../lib/static-cell" }

cfg-if = { workspace = true }
cortex-m = { workspace = true }
hubpack = { workspace = true }
idol-runtime.workspace = true
num-traits = { workspace = true }
zerocopy = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions drv/minibar-seq-api/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
`minibar_controller_hvc_a.bit` and `minibar_regs.{adoc, json}` are generated at
[this commit](https://github.com/oxidecomputer/quartz/commit/c649d37c5f9a96c8a7d615c2165bf1344d1c8364)
`minibar_controller_hvc_a.bit` and `minibar_regs.json` are generated at
[this commit](https://github.com/oxidecomputer/quartz/commit/ba03a69ad4aa1940fe60d631797e8da17589beac)
Binary file modified drv/minibar-seq-api/minibar_controller_hcv_a.bit
Binary file not shown.
8 changes: 4 additions & 4 deletions drv/minibar-seq-api/minibar_regs.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
"sw_access": "rw",
"se_onread": null,
"se_onwrite": null,
"desc": "fpga_to_vbus_sled_hsc_en pin control"
"desc": "fpga_to_vbus_sled_hsc_en pin software control"
},
{
"type": "field",
Expand Down Expand Up @@ -470,7 +470,7 @@
},
{
"type": "reg",
"inst_name": "vbus_sled",
"inst_name": "VBUS_SLED",
"addr_offset": 21,
"regwidth": 8,
"min_accesswidth": 8,
Expand Down Expand Up @@ -607,7 +607,7 @@
},
{
"type": "reg",
"inst_name": "v12_pcie",
"inst_name": "V12_PCIE",
"addr_offset": 24,
"regwidth": 8,
"min_accesswidth": 8,
Expand Down Expand Up @@ -682,7 +682,7 @@
},
{
"type": "reg",
"inst_name": "v3p3_pcie",
"inst_name": "V3P3_PCIE",
"addr_offset": 25,
"regwidth": 8,
"min_accesswidth": 8,
Expand Down
7 changes: 4 additions & 3 deletions drv/minibar-seq-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ impl From<FpgaError> for MinibarSeqError {
}
}

mod reg_map {
pub mod reg_map {
include!(concat!(env!("OUT_DIR"), "/minibar_regs.rs"));
}

// exporting for ease of use with minibar-ignition-server and minibar-seq-server
pub use crate::reg_map::Addr;
pub use crate::reg_map::Reg;
pub use crate::reg_map::MINIBAR_BITSTREAM_CHECKSUM;
pub use reg_map::Addr;
pub use reg_map::Reg;

use crate as drv_minibar_seq_api;
include!(concat!(env!("OUT_DIR"), "/client_stub.rs"));
2 changes: 1 addition & 1 deletion drv/minibar-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]

hubpack.workspace = true
idol-runtime.workspace = true
num-traits.workspace = true
serde.workspace = true
Expand Down
109 changes: 109 additions & 0 deletions drv/minibar-seq-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ enum Trace {
ControllerSha(u32),
FpgaInitComplete,
FpgaWriteError(FpgaError),
FpgaReadError(FpgaError),
PcieRefclkPdCleared,
DeviceState(DeviceState),
SledPowerGoodTimeout,
SledPowerGoodLost,
SledPowerFault,
UnknownPowerStatus(u8),
}
ringbuf!(Trace, 32, Trace::None);

Expand Down Expand Up @@ -109,6 +114,28 @@ impl ServerImpl {
) -> bool {
ident.checksum.get() == ServerImpl::short_bitstream_checksum()
}

pub fn sled_power_control(&self, enable: bool) -> Result<(), FpgaError> {
let op = if enable {
WriteOp::BitSet
} else {
WriteOp::BitClear
};
self.fpga_user.write(
op,
Addr::POWER_CTRL,
Reg::POWER_CTRL::VBUS_SLED_EN,
)
}

pub fn get_sled_power_status(
&self,
) -> Result<Reg::VBUS_SLED::StateEncoded, FpgaError> {
let raw: u8 = self.fpga_user.read(Addr::VBUS_SLED)?;

Reg::VBUS_SLED::StateEncoded::try_from(raw)
.map_err(|_| FpgaError::InvalidValue)
}
}

impl idl::InOrderSequencerImpl for ServerImpl {
Expand All @@ -126,6 +153,45 @@ impl idl::InOrderSequencerImpl for ServerImpl {

Ok(state == DeviceState::RunningUserDesign)
}

fn sled_power_status(
&mut self,
_: &RecvMessage,
) -> Result<Reg::VBUS_SLED::StateEncoded, RequestError<MinibarSeqError>>
{
self.get_sled_power_status()
.map_err(MinibarSeqError::from)
.map_err(RequestError::from)
}

fn sled_powered(
&mut self,
_: &RecvMessage,
) -> Result<bool, RequestError<MinibarSeqError>> {
let state = self
.get_sled_power_status()
.map_err(MinibarSeqError::from)?;

Ok(state == Reg::VBUS_SLED::StateEncoded::Enabled)
}

fn sled_power_enable(
&mut self,
_: &RecvMessage,
) -> Result<(), RequestError<MinibarSeqError>> {
self.sled_power_control(true)
.map_err(MinibarSeqError::from)
.map_err(RequestError::from)
}

fn sled_power_disable(
&mut self,
_: &RecvMessage,
) -> Result<(), RequestError<MinibarSeqError>> {
self.sled_power_control(false)
.map_err(MinibarSeqError::from)
.map_err(RequestError::from)
}
}

impl NotificationHandler for ServerImpl {
Expand All @@ -140,6 +206,49 @@ impl NotificationHandler for ServerImpl {
let start = sys_get_timer().now;
let finish = sys_get_timer().now;

// check for sled power problems (e.g., power good lost or a fault)
let byte: Result<u8, FpgaError> = self.fpga_user.read(Addr::VBUS_SLED);
match byte {
Ok(byte) => {
let mut power_issue = false;
let status = match Reg::VBUS_SLED::StateEncoded::try_from(byte)
{
Ok(s) => s,
Err(e) => {
ringbuf_entry!(Trace::UnknownPowerStatus(e));
power_issue = true;
Reg::VBUS_SLED::StateEncoded::Enabled
}
};

use Reg::VBUS_SLED::StateEncoded::*;
match status {
TimedOut => {
ringbuf_entry!(Trace::SledPowerGoodTimeout);
power_issue = true;
}
Aborted => {
ringbuf_entry!(Trace::SledPowerGoodLost);
power_issue = true;
}
Disabled | RampingUp | Enabled => (),
};

if byte & Reg::VBUS_SLED::FAULT_PIN != 0 {
ringbuf_entry!(Trace::SledPowerFault);
power_issue = true;
}

// Disable power if there is a problem.
if power_issue {
let _ = self
.sled_power_control(false)
.map_err(|e| ringbuf_entry!(Trace::FpgaWriteError(e)));
}
}
Err(e) => ringbuf_entry!(Trace::FpgaReadError(e)),
}

// We now know when we were notified and when any work was completed.
// Note that the assumption here is that `start` < `finish` and that
// this won't hold if the system time rolls over. But, the system timer
Expand Down
2 changes: 2 additions & 0 deletions drv/sidecar-front-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ edition = "2021"

[dependencies]
cfg-if = { workspace = true }
hubpack = { workspace = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
transceiver-messages = { workspace = true }
vsc7448-pac = { workspace = true, optional = true }
zerocopy = { workspace = true }
Expand Down
33 changes: 33 additions & 0 deletions idl/minibar-seq.idol
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,38 @@ Interface(
err: CLike("MinibarSeqError"),
),
),

"sled_power_status": (
args: {},
reply: Result(
ok: "drv_minibar_seq_api::reg_map::Reg::VBUS_SLED::StateEncoded",
err: CLike("MinibarSeqError"),
),
encoding: Hubpack
),

"sled_powered": (
args: {},
reply: Result(
ok: "bool",
err: CLike("MinibarSeqError"),
),
),

"sled_power_enable": (
args: {},
reply: Result(
ok: "()",
err: CLike("MinibarSeqError"),
),
),

"sled_power_disable": (
args: {},
reply: Result(
ok: "()",
err: CLike("MinibarSeqError"),
),
),
},
)