mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-13 07:48:30 +00:00
rework power management scheme to use susres API
This commit is contained in:
parent
b0ec2929d7
commit
8536b4fda4
2 changed files with 2 additions and 51 deletions
|
|
@ -3,8 +3,6 @@ pub mod keyboard;
|
|||
// TRNG server is only needed for baosec; dabao can cheat and use the kernel TRNG port
|
||||
#[cfg(feature = "board-baosec")]
|
||||
mod baosec_hw;
|
||||
// only baosec has power management facilities
|
||||
#[cfg(feature = "board-baosec")]
|
||||
pub mod power;
|
||||
pub mod rtc;
|
||||
pub mod trng; // not public - for internal use only
|
||||
pub mod susres;
|
||||
pub mod trng;
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
use bao1x_api::PowerOp;
|
||||
|
||||
pub fn start_power_service(sid: xous::SID) {
|
||||
std::thread::spawn(move || {
|
||||
power_service(sid);
|
||||
});
|
||||
}
|
||||
|
||||
fn power_service(sid: xous::SID) {
|
||||
let mut clk_mgr = bao1x_hal::clocks::ClockManager::new().unwrap();
|
||||
let measured = clk_mgr.measured_freqs();
|
||||
log::info!("computed frequencies:");
|
||||
log::info!(" vco: {}", clk_mgr.vco_freq);
|
||||
log::info!(" fclk: {}", clk_mgr.fclk);
|
||||
log::info!(" aclk: {}", clk_mgr.aclk);
|
||||
log::info!(" hclk: {}", clk_mgr.hclk);
|
||||
log::info!(" iclk: {}", clk_mgr.iclk);
|
||||
log::info!(" pclk: {}", clk_mgr.pclk);
|
||||
log::info!(" per: {}", clk_mgr.perclk);
|
||||
log::info!("measured frequencies:");
|
||||
for (name, freq) in measured {
|
||||
log::info!(" {}: {} MHz", name, freq);
|
||||
}
|
||||
|
||||
let hal = bao1x_hal_service::Hal::new();
|
||||
|
||||
let mut msg_opt = None;
|
||||
loop {
|
||||
xous::reply_and_receive_next(sid, &mut msg_opt).unwrap();
|
||||
let msg = msg_opt.as_mut().unwrap();
|
||||
let opcode: PowerOp =
|
||||
num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(PowerOp::Invalid);
|
||||
log::debug!("{:?}", opcode);
|
||||
match opcode {
|
||||
PowerOp::Wfi => {
|
||||
log::info!("triggering wfi...");
|
||||
clk_mgr.wfi();
|
||||
log::info!("recovered from wfi!");
|
||||
hal.set_preemption(true);
|
||||
log::info!("preemption turned on!");
|
||||
}
|
||||
PowerOp::Invalid => {
|
||||
log::error!("Unrecognized opcode: {:?}, ignoring!", opcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue