Skip to content
Open
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
9 changes: 7 additions & 2 deletions Cargo.lock

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

42 changes: 23 additions & 19 deletions app/medusa/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ size = 256

[tasks.hiffy]
name = "task-hiffy"
priority = 7
priority = 5
max-sizes = {flash = 32768, ram = 32768}
stacksize = 2048
start = true
Expand Down Expand Up @@ -87,20 +87,20 @@ interrupts = {"spi1.irq" = "spi-irq"}

[tasks.monorail]
name = "task-monorail-server"
priority = 6
priority = 7
max-sizes = {flash = 262144, ram = 8192}
features = ["mgmt", "medusa", "vlan", "use-spi-core", "h753", "spi2"]
stacksize = 4096
start = true
task-slots = ["ecp5_front_io", "sys", { seq = "sequencer" }]
task-slots = ["front_io", "sys"]
uses = ["spi2"]
notifications = ["spi-irq", "wake-timer"]
interrupts = {"spi2.irq" = "spi-irq"}

[tasks.net]
name = "task-net"
stacksize = 6040
priority = 5
priority = 6
features = ["mgmt", "h753", "medusa", "vlan", "vpd-mac", "use-spi-core", "spi3"]
max-sizes = {flash = 131072, ram = 65536, sram1_mac = 16384}
sections = {eth_bulk = "sram1_mac"}
Expand All @@ -116,20 +116,20 @@ task-slots = ["sys", "packrat", { seq = "sequencer" }, "jefe"]

[tasks.sequencer]
name = "drv-medusa-seq-server"
priority = 4
priority = 5
stacksize = 4096
start = true
task-slots = [
"sys",
"i2c_driver",
"auxflash",
"packrat",
{front_io = "ecp5_front_io"}]
"front_io"]

[tasks.transceivers]
name = "drv-transceivers-server"
features = ["vlan"]
priority = 6
priority = 7
max-sizes = {flash = 65536, ram = 16384}
stacksize = 4096
start = true
Expand All @@ -145,11 +145,15 @@ notifications = ["socket", "timer"]

[tasks.front_io]
name = "drv-front-io-server"
priority = 5
priority = 4
max-sizes = {flash = 65536, ram = 16384}
stacksize = 4096
start = true
task-slots = ["sequencer"]
task-slots = [
"sys",
"auxflash",
"i2c_driver",
"ecp5_front_io"]
notifications = ["timer"]

[tasks.packrat]
Expand Down Expand Up @@ -205,7 +209,7 @@ task-slots = ["sys"]

[tasks.udpecho]
name = "task-udpecho"
priority = 6
priority = 7
max-sizes = {flash = 16384, ram = 8192}
stacksize = 4096
start = true
Expand All @@ -215,7 +219,7 @@ notifications = ["socket"]

[tasks.udpbroadcast]
name = "task-udpbroadcast"
priority = 6
priority = 7
max-sizes = {flash = 16384, ram = 8192}
stacksize = 4096
start = true
Expand Down Expand Up @@ -357,14 +361,14 @@ refdes = "U16"
[[config.i2c.controllers]]
controller = 2
[config.i2c.controllers.ports.F]
name = "front_io0"
name = "front_io"
description = "Front I/O Board"
scl.pin = 1 # I2C_FRONT_IO0_SCL
sda.pin = 0 # I2C_FRONT_IO0_SDA
af = 4

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b1010_000
device = "at24csw080"
description = "Front IO board FRUID"
Expand All @@ -375,7 +379,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b1110_011
device = "pca9538"
description = "Front IO GPIO expander"
Expand All @@ -386,7 +390,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b0001_010
device = "pca9956b"
name = "front_leds_left"
Expand All @@ -398,7 +402,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b0001_011
device = "pca9956b"
name = "front_leds_right"
Expand All @@ -410,7 +414,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b0011_011
device = "tps546b24a"
description = "Front IO V3P3_SYS_A2 rail"
Expand All @@ -423,7 +427,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b0011_001
device = "tps546b24a"
description = "Front IO V3P3_QSFP0_A0 rail"
Expand All @@ -436,7 +440,7 @@ refdes = [
]

[[config.i2c.devices]]
bus = "front_io0"
bus = "front_io"
address = 0b0011_010
device = "tps546b24a"
description = "Front IO V3P3_QSFP1_A0 rail"
Expand Down
19 changes: 12 additions & 7 deletions app/sidecar/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,16 @@ notifications = ["socket", "timer"]

[tasks.front_io]
name = "drv-front-io-server"
priority = 5
priority = 4
max-sizes = {flash = 65536, ram = 16384}
stacksize = 4096
start = true
task-slots = ["sequencer"]
task-slots = [
"auxflash",
"ecp5_front_io",
"ecp5_mainboard",
"i2c_driver",
"sys"]
notifications = ["timer"]

[tasks.packrat]
Expand All @@ -279,22 +284,22 @@ notifications = ["task-faulted"]

[tasks.sequencer]
name = "drv-sidecar-seq-server"
priority = 4
priority = 5
stacksize = 4096
start = true
task-slots = [
"sys",
"i2c_driver",
"auxflash",
"packrat",
{mainboard = "ecp5_mainboard"},
{front_io = "ecp5_front_io"}]
"front_io",
{mainboard = "ecp5_mainboard"}]
notifications = ["timer"]

[tasks.thermal]
name = "task-thermal"
features = ["sidecar"]
priority = 5
priority = 6
max-sizes = {flash = 32768, ram = 16384 }
stacksize = 4000
start = true
Expand Down Expand Up @@ -322,7 +327,7 @@ task-slots = ["i2c_driver"]
[tasks.ignition]
name = "drv-ignition-server"
features = ["sequencer"]
priority = 5
priority = 6
max-sizes = {flash = 16384, ram = 8192}
stacksize = 2048
start = true
Expand Down
29 changes: 28 additions & 1 deletion drv/front-io-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use counters::Count;
use derive_idol_err::IdolError;
use drv_fpga_api::FpgaError;
use hubpack::SerializedSize;
use serde::{Deserialize, Serialize};
use userlib::*;

#[cfg(feature = "controller")]
Expand All @@ -26,7 +28,8 @@ pub enum FrontIOError {
NotPresent,
InvalidPhysicalToLogicalMap,
InvalidModuleResult,
SeqError,
PowerNotGood,
PowerFault,

#[idol(server_death)]
ServerRestarted,
Expand All @@ -38,6 +41,30 @@ impl From<FpgaError> for FrontIOError {
}
}

#[derive(
Copy,
Clone,
Debug,
Count,
Eq,
PartialEq,
Deserialize,
Serialize,
SerializedSize,
)]
pub enum FrontIOStatus {
/// Start state
Init,
/// No board detected
NotPresent,
/// Begin configuring the FPGAs
ReadyForFpgaInit,
/// Confirming that the PHY oscillator is behaving
WaitForOscGood,
/// Board is present and fully operational
Ready,
}

include!(concat!(
env!("OUT_DIR"),
"/sidecar_qsfp_x32_controller_regs.rs"
Expand Down
10 changes: 8 additions & 2 deletions drv/front-io-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ serde.workspace = true
zerocopy.workspace = true
zerocopy-derive.workspace = true

drv-fpga-api = { path = "../fpga-api" }
drv-fpga-user-api = { path = "../fpga-user-api" }
drv-front-io-api = { path = "../front-io-api", features = ["phy_smi", "transceivers"] }
drv-sidecar-seq-api = { path = "../sidecar-seq-api" }
drv-front-io-api = { path = "../front-io-api", features = ["controller", "phy_smi", "transceivers"] }
drv-i2c-api = { path = "../i2c-api" }
drv-i2c-devices = { path = "../i2c-devices" }
drv-sidecar-mainboard-controller = { path = "../../drv/sidecar-mainboard-controller" }
drv-stm32xx-sys-api = { path = "../stm32xx-sys-api", features = ["family-stm32h7"] }
multitimer = { path = "../../lib/multitimer" }
ringbuf = { path = "../../lib/ringbuf" }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }

[build-dependencies]
build-util = { path = "../../build/util" }
build-i2c = { path = "../../build/i2c" }
idol = { workspace = true }

# This section is here to discourage RLS/rust-analyzer from doing test builds,
Expand Down
2 changes: 2 additions & 0 deletions drv/front-io-server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
build_util::expose_target_board();
build_util::build_notifications()?;

build_i2c::codegen(build_i2c::Disposition::Devices)?;

let board = build_util::env_var("HUBRIS_BOARD")?;
if board != "sidecar-b"
&& board != "sidecar-c"
Expand Down
6 changes: 6 additions & 0 deletions drv/front-io-server/src/bsp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// This file should never be included; if it is, the build configuration is bad
compile_error!("no BSP for the given target board");
60 changes: 60 additions & 0 deletions drv/front-io-server/src/bsp/medusa_a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use drv_fpga_api::FpgaError;
use drv_fpga_user_api::power_rail::PowerRailStatus;
use drv_front_io_api::FrontIOError;
use drv_stm32xx_sys_api as sys_api;
use userlib::task_slot;

task_slot!(SYS, sys);

pub struct Bsp {
sys: sys_api::Sys,
en_pin: sys_api::PinSet,
pg_pin: sys_api::PinSet,
}

impl Bsp {
pub fn new() -> Result<Self, FrontIOError> {
let sys = sys_api::Sys::from(SYS.get_task_id());
let en_pin = sys_api::Port::J.pin(2); // SP_TO_V12_QSFP_OUT_EN
let pg_pin = sys_api::Port::J.pin(1); // OUTPUT_HS_TO_SP_PG

sys.gpio_configure_output(
en_pin,
sys_api::OutputType::PushPull,
sys_api::Speed::Low,
sys_api::Pull::None,
);

sys.gpio_configure_input(pg_pin, sys_api::Pull::None);

Ok(Self {
sys,
en_pin,
pg_pin,
})
}

// PowerRailStatus is a FPGA concept baked into the Sidecar Mainboard design. Since we don't
// have an FPGA here, we simplify things to just being enabled or disabled
pub fn power_rail_status(&self) -> Result<PowerRailStatus, FpgaError> {
let status = if self.sys.gpio_read(self.en_pin) != 0 {
PowerRailStatus::Enabled
} else {
PowerRailStatus::Disabled
};
Ok(status)
}

pub fn power_good(&self) -> bool {
self.sys.gpio_read(self.pg_pin) != 0
}

pub fn set_power_enable(&self, enabled: bool) -> Result<(), FrontIOError> {
self.sys.gpio_set_to(self.en_pin, enabled);
Ok(())
}
}
Loading
Loading