Skip to content

Commit d6ae06c

Browse files
authored
Add send_hardware_nmi to Grapefruit (#1987)
This is another small improvement for #1983
1 parent 38953d2 commit d6ae06c

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

app/grapefruit/app.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ max-sizes = {flash = 131072, ram = 16384 }
178178
stacksize = 2600
179179
start = true
180180
task-slots = ["sys", {spi = "spi2_driver"}, "auxflash", "jefe", "packrat"]
181+
uses = ["fmc_nor_psram_bank_1"]
181182

182183
[tasks.thermal]
183184
name = "task-thermal"

drv/grapefruit-seq-server/src/main.rs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,17 @@ impl<S: SpiServer + Clone> idl::InOrderSequencerImpl for ServerImpl<S> {
350350
&mut self,
351351
_: &RecvMessage,
352352
) -> Result<(), RequestError<core::convert::Infallible>> {
353+
let ptr = reg::sgpio::OUT1;
354+
// SAFETY: the FPGA must be loaded, and these registers are in our FMC
355+
// region, so we can access them.
356+
unsafe {
357+
let orig = ptr.read_volatile();
358+
ptr.write_volatile(
359+
(orig & !reg::sgpio::out1::MGMT_ASSERT_NMI_BTN_L) & 0xFFFF,
360+
);
361+
hl::sleep_for(1000);
362+
ptr.write_volatile(orig);
363+
}
353364
Ok(())
354365
}
355366

@@ -371,6 +382,87 @@ impl<S: SpiServer> NotificationHandler for ServerImpl<S> {
371382
}
372383
}
373384

385+
/// Register map for SGPIO registers
386+
#[allow(unused)]
387+
mod reg {
388+
pub const BASE: *mut u32 = 0x60000000 as *mut _;
389+
390+
pub const SGPIO: *mut u32 = BASE.wrapping_add(0xc0);
391+
pub mod sgpio {
392+
use super::*;
393+
pub const OUT0: *mut u32 = SGPIO.wrapping_add(0x0);
394+
pub const IN0: *mut u32 = SGPIO.wrapping_add(0x1);
395+
pub const OUT1: *mut u32 = SGPIO.wrapping_add(0x2);
396+
pub const IN1: *mut u32 = SGPIO.wrapping_add(0x3);
397+
pub mod out0 {
398+
pub const HAWAII_HEARTBEAT: u32 = 1 << 14;
399+
pub const MB_SCM_HPM_STBY_RDY: u32 = 1 << 14;
400+
pub const HPM_BMC_GPIOY3: u32 = 1 << 11;
401+
pub const MGMT_SMBUS_DATA: u32 = 1 << 10;
402+
pub const MGMT_SMBUS_CLK: u32 = 1 << 9;
403+
pub const GPIO_OUTPUT_9: u32 = 1 << 8;
404+
pub const GPIO_OUTPUT_8: u32 = 1 << 7;
405+
pub const GPIO_OUTPUT_7: u32 = 1 << 6;
406+
pub const GPIO_OUTPUT_6: u32 = 1 << 5;
407+
pub const BMC_READY: u32 = 1 << 4;
408+
pub const HPM_BMC_GPIOL5: u32 = 1 << 3;
409+
pub const HPM_BMC_GPIOL4: u32 = 1 << 2;
410+
pub const HPM_BMC_GPIOH3: u32 = 1 << 1;
411+
pub const MGMT_ASSERT_LOCAL_LOCK: u32 = 1 << 0;
412+
}
413+
pub mod in0 {
414+
pub const BMC_SCM_FPGA_UART_RX: u32 = 1 << 15;
415+
pub const MGMT_SYS_MON_PWR_GOOD: u32 = 1 << 14;
416+
pub const MGMT_SYS_MON_NMI_BTN_L: u32 = 1 << 13;
417+
pub const MGMT_SYS_MON_PWR_BTN_L: u32 = 1 << 12;
418+
pub const MGMT_SYS_MON_RST_BTN_L: u32 = 1 << 11;
419+
pub const DEBUG_INPUT1: u32 = 1 << 10;
420+
pub const MGMT_AC_LOSS_L: u32 = 1 << 9;
421+
pub const MGMT_SYS_MON_ATX_PWR_OK: u32 = 1 << 8;
422+
pub const MGMT_SYS_MON_P1_THERMTRIP_L: u32 = 1 << 7;
423+
pub const MGMT_SYS_MON_P0_THERMTRIP_L: u32 = 1 << 6;
424+
pub const MGMT_SYS_MON_P1_PROCHOT_L: u32 = 1 << 5;
425+
pub const MGMT_SYS_MON_P0_PROCHOT_L: u32 = 1 << 4;
426+
pub const MGMT_SYS_MON_RESET_L: u32 = 1 << 3;
427+
pub const P1_PRESENT_L: u32 = 1 << 2;
428+
pub const P0_PRESENT_L: u32 = 1 << 1;
429+
pub const MGMT_SYS_MON_POST_COMPLETE: u32 = 1 << 0;
430+
}
431+
pub mod out1 {
432+
pub const BMC_SCM_FPGA_UART_TX: u32 = 1 << 14;
433+
pub const MGMT_ASSERT_NMI_BTN_L: u32 = 1 << 13;
434+
pub const MGMT_ASSERT_PWR_BTN_L: u32 = 1 << 12;
435+
pub const MGMT_ASSERT_RST_BTN_L: u32 = 1 << 11;
436+
pub const JTAG_TRST_N: u32 = 1 << 10;
437+
pub const GPIO_OUTPUT_5: u32 = 1 << 9;
438+
pub const GPIO_OUTPUT_4: u32 = 1 << 8;
439+
pub const GPIO_OUTPUT_3: u32 = 1 << 7;
440+
pub const GPIO_OUTPUT_2: u32 = 1 << 6;
441+
pub const GPIO_OUTPUT_1: u32 = 1 << 5;
442+
pub const MGMT_ASSERT_CLR_CMOS: u32 = 1 << 4;
443+
pub const MGMT_ASSERT_P1_PROCHOT: u32 = 1 << 3;
444+
pub const MGMT_ASSERT_P0_PROCHOT: u32 = 1 << 2;
445+
pub const MGMT_SOC_RESET_L: u32 = 1 << 1;
446+
pub const MGMT_ASERT_WARM_RST_BTN_L: u32 = 1 << 0;
447+
}
448+
pub mod in1 {
449+
pub const MGMT_SMBUS_ALERT_L: u32 = 1 << 15;
450+
pub const HPM_BMC_GPIOI7: u32 = 1 << 14;
451+
pub const ESPI_BOOT_SEL: u32 = 1 << 13;
452+
pub const I2C_BMC_MB_ALERT_S: u32 = 1 << 12;
453+
pub const GPIO_INPUT_6: u32 = 1 << 8;
454+
pub const GPIO_INPUT_5: u32 = 1 << 7;
455+
pub const GPIO_INPUT_4: u32 = 1 << 6;
456+
pub const GPIO_INPUT_3: u32 = 1 << 5;
457+
pub const GPIO_INPUT_2: u32 = 1 << 4;
458+
pub const GPIO_INPUT_1: u32 = 1 << 3;
459+
pub const HPM_BMC_GPIOM5: u32 = 1 << 2;
460+
pub const HPM_BMC_GPIOM4: u32 = 1 << 1;
461+
pub const HPM_BMC_GPIOM3: u32 = 1 << 0;
462+
}
463+
}
464+
}
465+
374466
mod idl {
375467
use drv_cpu_seq_api::{SeqError, StateChangeReason};
376468
include!(concat!(env!("OUT_DIR"), "/server_stub.rs"));

0 commit comments

Comments
 (0)