diff --git a/emulation/soc/renode.svd b/emulation/soc/renode.svd index 9c08587cc..abb9485fc 100644 --- a/emulation/soc/renode.svd +++ b/emulation/soc/renode.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -408,11 +408,36 @@ console, others reserved based on build]]> + + DEBUG + + 0x0018 + 0x00 + 32 + + + wfi + 0 + [0:0] + 0 + + + + wakeup + 1 + [1:1] + 1 + + + + EV_STATUS - 0x0018 + 0x001c 0x00 32 @@ -478,7 +503,7 @@ Writes to this register have no effect.]]> EV_PENDING - 0x001c + 0x0020 0x00 32 @@ -552,7 +577,7 @@ edge.]]> EV_ENABLE - 0x0020 + 0x0024 0x00 32 @@ -617,7 +642,7 @@ register to disable individual events.]]> 0 - 0x24 + 0x28 registers @@ -1137,7 +1162,7 @@ register to disable individual events.]]> GIT_MAJOR +``v0.0.0``, so this value is ``0``.]]> 0x0008 0x00 32 @@ -1153,9 +1178,9 @@ register to disable individual events.]]> GIT_MINOR +``v0.0.0``, so this value is ``0``.]]> 0x000c - 0x08 + 0x00 32 @@ -1169,7 +1194,7 @@ register to disable individual events.]]> GIT_REVISION +``v0.0.0``, so this value is ``0``.]]> 0x0010 0x00 32 @@ -1185,10 +1210,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0xeffda53c + 0x9e77f50e 32 @@ -1205,7 +1230,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x1c + 0x00 32 @@ -2586,6 +2611,13 @@ Configured to currently override power to `on` at boot to ease system setup.]]>< 10 + + disable_wfi + 11 + [11:11] + 11 + + @@ -3284,7 +3316,7 @@ inject too fast.]]> SEED1 0x0000 - 0x45bc8216 + 0x56f38707 32 @@ -3299,7 +3331,7 @@ inject too fast.]]> SEED0 0x0004 - 0x5762a598 + 0x400f5344 32 diff --git a/precursors/soc.svd b/precursors/soc.svd index 9c08587cc..877033b9d 100644 --- a/precursors/soc.svd +++ b/precursors/soc.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -408,11 +408,36 @@ console, others reserved based on build]]> + + DEBUG + + 0x0018 + 0x00 + 32 + + + wfi + 0 + [0:0] + 0 + + + + wakeup + 1 + [1:1] + 1 + + + + EV_STATUS - 0x0018 + 0x001c 0x00 32 @@ -478,7 +503,7 @@ Writes to this register have no effect.]]> EV_PENDING - 0x001c + 0x0020 0x00 32 @@ -552,7 +577,7 @@ edge.]]> EV_ENABLE - 0x0020 + 0x0024 0x00 32 @@ -617,7 +642,7 @@ register to disable individual events.]]> 0 - 0x24 + 0x28 registers @@ -1137,7 +1162,7 @@ register to disable individual events.]]> GIT_MAJOR +``v0.8.1``, so this value is ``0``.]]> 0x0008 0x00 32 @@ -1153,7 +1178,7 @@ register to disable individual events.]]> GIT_MINOR +``v0.8.1``, so this value is ``8``.]]> 0x000c 0x08 32 @@ -1169,9 +1194,9 @@ register to disable individual events.]]> GIT_REVISION +``v0.8.1``, so this value is ``1``.]]> 0x0010 - 0x00 + 0x01 32 @@ -1185,10 +1210,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0xeffda53c + 0xcf5b40e6 32 @@ -1205,7 +1230,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x1c + 0x00 32 @@ -1219,7 +1244,7 @@ beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> GIT_DIRTY 0x001c - 0x01 + 0x00 32 @@ -2586,6 +2611,13 @@ Configured to currently override power to `on` at boot to ease system setup.]]>< 10 + + disable_wfi + 11 + [11:11] + 11 + + @@ -3284,7 +3316,7 @@ inject too fast.]]> SEED1 0x0000 - 0x45bc8216 + 0x178b8559 32 @@ -3299,7 +3331,7 @@ inject too fast.]]> SEED0 0x0004 - 0x5762a598 + 0x1c2378e2 32 diff --git a/precursors/soc_csr.bin b/precursors/soc_csr.bin index 55ee505c9..af692e96e 100644 Binary files a/precursors/soc_csr.bin and b/precursors/soc_csr.bin differ diff --git a/services/llio/src/api.rs b/services/llio/src/api.rs index ee0bf142d..023ad9afd 100644 --- a/services/llio/src/api.rs +++ b/services/llio/src/api.rs @@ -186,6 +186,9 @@ pub(crate) enum Opcode { PowerBoostMode, //(bool), PowerCrypto, PowerCryptoStatus, + WfiOverride, + DebugPowerdown, + DebugWakeup, EcSnoopAllow, //(bool), EcReset, EcPowerOn, diff --git a/services/llio/src/lib.rs b/services/llio/src/lib.rs index 3021f7ab8..b48667158 100644 --- a/services/llio/src/lib.rs +++ b/services/llio/src/lib.rs @@ -444,6 +444,13 @@ impl Llio { Message::new_blocking_scalar(Opcode::PowerCrypto.to_usize().unwrap(), arg, 0, 0, 0) ).map(|_| ()) } + // setting this to true turns off WFI capabilities, forcing power always on + pub fn wfi_override(&self, ena: bool) -> Result<(), xous::Error> { + let arg = if ena { 1 } else { 0 }; + send_message(self.conn, + Message::new_blocking_scalar(Opcode::WfiOverride.to_usize().unwrap(), arg, 0, 0, 0) + ).map(|_| ()) + } pub fn crypto_power_status(&self) -> Result<(bool, bool, bool), xous::Error> { // sha, engine, override status let response = send_message(self.conn, Message::new_blocking_scalar(Opcode::PowerCryptoStatus.to_usize().unwrap(), 0, 0, 0, 0) @@ -487,6 +494,23 @@ impl Llio { Err(xous::Error::InternalError) } } + pub fn gpio_data_direction(&self, dir: u8) -> Result<(), xous::Error> { + send_message(self.conn, + Message::new_scalar(Opcode::GpioDataDrive.to_usize().unwrap(), dir as usize, 0, 0, 0) + ).map(|_| ()) + } + pub fn gpio_debug_powerdown(&self, ena: bool) -> Result<(), xous::Error> { + let arg = if ena { 1 } else { 0 }; + send_message(self.conn, + Message::new_scalar(Opcode::DebugPowerdown.to_usize().unwrap(), arg, 0, 0, 0) + ).map(|_| ()) + } + pub fn gpio_debug_wakeup(&self, ena: bool) -> Result<(), xous::Error> { + let arg = if ena { 1 } else { 0 }; + send_message(self.conn, + Message::new_scalar(Opcode::DebugWakeup.to_usize().unwrap(), arg, 0, 0, 0) + ).map(|_| ()) + } } diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs index 47327fbde..1c5e4a21c 100644 --- a/services/llio/src/main.rs +++ b/services/llio/src/main.rs @@ -290,6 +290,28 @@ mod implementation { self.power_csr.rmwf(utra::power::POWER_CRYPTO_ON, 0); } } + // apparently "override" is a reserved keyword in Rust??? + pub fn wfi_override(&mut self, override_: bool) { + if override_ { + self.power_csr.rmwf(utra::power::POWER_DISABLE_WFI, 1); + } else { + self.power_csr.rmwf(utra::power::POWER_DISABLE_WFI, 0); + } + } + pub fn debug_powerdown(&mut self, ena: bool) { + if ena { + self.power_csr.rmwf(utra::gpio::DEBUG_WFI, 1); + } else { + self.power_csr.rmwf(utra::gpio::DEBUG_WFI, 0); + } + } + pub fn debug_wakeup(&mut self, ena: bool) { + if ena { + self.power_csr.rmwf(utra::gpio::DEBUG_WAKEUP, 1); + } else { + self.power_csr.rmwf(utra::gpio::DEBUG_WAKEUP, 0); + } + } pub fn power_crypto_status(&self) -> (bool, bool, bool, bool) { let sha = if self.power_csr.rf(utra::power::CLK_STATUS_SHA_ON) == 0 {false} else {true}; let engine = if self.power_csr.rf(utra::power::CLK_STATUS_ENGINE_ON) == 0 {false} else {true}; @@ -616,6 +638,14 @@ fn xmain() -> ! { Some(Opcode::GpioIntEna) => msg_scalar_unpack!(msg, d, _, _, _, { llio.gpio_int_ena(d as u32); }), + Some(Opcode::DebugPowerdown) => msg_scalar_unpack!(msg, arg, _, _, _, { + let ena = if arg == 0 {false} else {true}; + llio.debug_powerdown(ena); + }), + Some(Opcode::DebugWakeup) => msg_scalar_unpack!(msg, arg, _, _, _, { + let ena = if arg == 0 {false} else {true}; + llio.debug_wakeup(ena); + }), Some(Opcode::UartMux) => msg_scalar_unpack!(msg, mux, _, _, _, { llio.set_uart_mux(mux.into()); }), @@ -651,6 +681,14 @@ fn xmain() -> ! { } xous::return_scalar(msg.sender, 0).expect("couldn't confirm crypto power was set"); }), + Some(Opcode::WfiOverride) => msg_blocking_scalar_unpack!(msg, override_, _, _, _, { + if override_ == 0 { + llio.wfi_override(false); + } else { + llio.wfi_override(true); + } + xous::return_scalar(msg.sender, 0).expect("couldn't confirm wfi override was updated"); + }), Some(Opcode::PowerCryptoStatus) => msg_blocking_scalar_unpack!(msg, _, _, _, _, { let (_, sha, engine, force) = llio.power_crypto_status(); let mut ret = 0; diff --git a/services/shellchat/src/cmds/sleep.rs b/services/shellchat/src/cmds/sleep.rs index 65339ca71..e2c343667 100644 --- a/services/shellchat/src/cmds/sleep.rs +++ b/services/shellchat/src/cmds/sleep.rs @@ -68,7 +68,7 @@ impl<'a> ShellCmdApi<'a> for Sleep { use core::fmt::Write; let mut ret = String::<1024>::new(); - let helpstring = "sleep [now] [current] [ship] [kill] [coldboot] [killbounce] [sus] [stress] [crypton] [cryptoff]"; + let helpstring = "sleep [now] [current] [ship] [kill] [coldboot] [killbounce] [sus] [stress] [crypton] [cryptoff] [wfioff] [wfion] [debugwfi]"; let mut tokens = args.as_str().unwrap().split(' '); @@ -190,6 +190,20 @@ impl<'a> ShellCmdApi<'a> for Sleep { xous::create_thread_1(kill_thread, 1).unwrap(); } } + "wfioff" => { + env.llio.wfi_override(true).unwrap(); + write!(ret, "Overriding WFI signal, forcing always ON").unwrap(); + } + "wfion" => { + env.llio.wfi_override(false).unwrap(); + write!(ret, "Allowing WFI auto-control by kernel").unwrap(); + } + "debugwfi" => { + env.llio.gpio_data_direction(0x3).unwrap(); // set bits 0 and 1 to output + env.llio.gpio_debug_powerdown(true).unwrap(); + env.llio.gpio_debug_wakeup(true).unwrap(); + write!(ret, "Connecting CRG powerdown to GPIO0, wakeup interrupt to GPIO1").unwrap(); + } _ => write!(ret, "{}", helpstring).unwrap(), } } else { diff --git a/svd2utra/examples/soc.svd b/svd2utra/examples/soc.svd index 9c08587cc..abb9485fc 100644 --- a/svd2utra/examples/soc.svd +++ b/svd2utra/examples/soc.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -408,11 +408,36 @@ console, others reserved based on build]]> + + DEBUG + + 0x0018 + 0x00 + 32 + + + wfi + 0 + [0:0] + 0 + + + + wakeup + 1 + [1:1] + 1 + + + + EV_STATUS - 0x0018 + 0x001c 0x00 32 @@ -478,7 +503,7 @@ Writes to this register have no effect.]]> EV_PENDING - 0x001c + 0x0020 0x00 32 @@ -552,7 +577,7 @@ edge.]]> EV_ENABLE - 0x0020 + 0x0024 0x00 32 @@ -617,7 +642,7 @@ register to disable individual events.]]> 0 - 0x24 + 0x28 registers @@ -1137,7 +1162,7 @@ register to disable individual events.]]> GIT_MAJOR +``v0.0.0``, so this value is ``0``.]]> 0x0008 0x00 32 @@ -1153,9 +1178,9 @@ register to disable individual events.]]> GIT_MINOR +``v0.0.0``, so this value is ``0``.]]> 0x000c - 0x08 + 0x00 32 @@ -1169,7 +1194,7 @@ register to disable individual events.]]> GIT_REVISION +``v0.0.0``, so this value is ``0``.]]> 0x0010 0x00 32 @@ -1185,10 +1210,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0xeffda53c + 0x9e77f50e 32 @@ -1205,7 +1230,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x1c + 0x00 32 @@ -2586,6 +2611,13 @@ Configured to currently override power to `on` at boot to ease system setup.]]>< 10 + + disable_wfi + 11 + [11:11] + 11 + + @@ -3284,7 +3316,7 @@ inject too fast.]]> SEED1 0x0000 - 0x45bc8216 + 0x56f38707 32 @@ -3299,7 +3331,7 @@ inject too fast.]]> SEED0 0x0004 - 0x5762a598 + 0x400f5344 32