mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
map clock sources to API files, cleanup irqs on boot
- clock freq/voltage now in API definitions - IRQ is disabled (or re-disabled) on all exit paths
This commit is contained in:
parent
46b5c6f17d
commit
d1f5aa19a8
3 changed files with 17 additions and 7 deletions
|
|
@ -24,9 +24,9 @@ use platform::*;
|
||||||
use utralib::*;
|
use utralib::*;
|
||||||
use ux_api::minigfx::{DrawStyle, FrameBuffer, Point, Rectangle};
|
use ux_api::minigfx::{DrawStyle, FrameBuffer, Point, Rectangle};
|
||||||
|
|
||||||
use crate::delay;
|
|
||||||
use crate::platform::usb::glue;
|
use crate::platform::usb::glue;
|
||||||
use crate::secboot::boot_or_die;
|
use crate::secboot::boot_or_die;
|
||||||
|
use crate::{delay, platform::irq::disable_all_irqs};
|
||||||
|
|
||||||
static UART_RX: Mutex<RefCell<VecDeque<u8>>> = Mutex::new(RefCell::new(VecDeque::new()));
|
static UART_RX: Mutex<RefCell<VecDeque<u8>>> = Mutex::new(RefCell::new(VecDeque::new()));
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -98,6 +98,7 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
||||||
let boot_wait = one_way.get_decoded::<BootWaitCoding>().expect("internal error");
|
let boot_wait = one_way.get_decoded::<BootWaitCoding>().expect("internal error");
|
||||||
|
|
||||||
if boot_wait == BootWaitCoding::Disable && current_key.is_none() {
|
if boot_wait == BootWaitCoding::Disable && current_key.is_none() {
|
||||||
|
disable_all_irqs();
|
||||||
// this should diverge, rest of code is not run
|
// this should diverge, rest of code is not run
|
||||||
boot_or_die();
|
boot_or_die();
|
||||||
}
|
}
|
||||||
|
|
@ -284,6 +285,7 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
disable_all_irqs();
|
||||||
// when we get to this point, there's only two options...
|
// when we get to this point, there's only two options...
|
||||||
crate::secboot::boot_or_die();
|
crate::secboot::boot_or_die();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,10 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
|
||||||
// setup the dabao 'boot' read pin for reading. This also connects the USB port temporarily.
|
// setup the dabao 'boot' read pin for reading. This also connects the USB port temporarily.
|
||||||
setup_dabao_boot_pin(&iox);
|
setup_dabao_boot_pin(&iox);
|
||||||
|
|
||||||
// we're running at 0.8V, setup the RAMs for that
|
// setup the RAMs for our trim voltage
|
||||||
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(800);
|
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(
|
||||||
|
bao1x_api::offsets::dabao::CPU_VDD_LDO_BOOT_MV,
|
||||||
|
);
|
||||||
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
||||||
for item in trim_table {
|
for item in trim_table {
|
||||||
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
||||||
|
|
@ -142,7 +144,9 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
|
||||||
setup_dabao_boot_pin(&iox);
|
setup_dabao_boot_pin(&iox);
|
||||||
|
|
||||||
// we're running at 0.8V, setup the RAMs for that
|
// we're running at 0.8V, setup the RAMs for that
|
||||||
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(800);
|
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(
|
||||||
|
bao1x_api::offsets::dabao::CPU_VDD_LDO_BOOT_MV,
|
||||||
|
);
|
||||||
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
||||||
for item in trim_table {
|
for item in trim_table {
|
||||||
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
||||||
|
|
@ -165,7 +169,9 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
|
||||||
sramtrm.wo(utra::coresub_sramtrm::SFR_VEXRAM, 0x1);
|
sramtrm.wo(utra::coresub_sramtrm::SFR_VEXRAM, 0x1);
|
||||||
|
|
||||||
// we should be in 0.9v mode, setup SRAM trimmings for that
|
// we should be in 0.9v mode, setup SRAM trimmings for that
|
||||||
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(900);
|
let trim_table = bao1x_hal::sram_trim::get_sram_trim_for_voltage(
|
||||||
|
bao1x_api::offsets::baosec::CPU_VDD_LDO_BOOT_MV,
|
||||||
|
);
|
||||||
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
let mut rbist = CSR::new(utra::rbist_wrp::HW_RBIST_WRP_BASE as *mut u32);
|
||||||
for item in trim_table {
|
for item in trim_table {
|
||||||
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
rbist.wo(utra::rbist_wrp::SFRCR_TRM, item.raw_value());
|
||||||
|
|
@ -221,8 +227,9 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
|
||||||
|
|
||||||
// set the clock
|
// set the clock
|
||||||
let fclk_freq = match board_type {
|
let fclk_freq = match board_type {
|
||||||
BoardTypeCoding::Baosec => bao1x_hal::board::DEFAULT_FCLK_FREQUENCY,
|
BoardTypeCoding::Baosec => bao1x_api::offsets::baosec::DEFAULT_FCLK_FREQUENCY,
|
||||||
BoardTypeCoding::Dabao | BoardTypeCoding::Oem => SAFE_FCLK_FREQUENCY,
|
BoardTypeCoding::Oem => SAFE_FCLK_FREQUENCY,
|
||||||
|
BoardTypeCoding::Dabao => bao1x_api::offsets::dabao::DEFAULT_FCLK_FREQUENCY,
|
||||||
};
|
};
|
||||||
let perclk = unsafe { init_clock_asic(fclk_freq) };
|
let perclk = unsafe { init_clock_asic(fclk_freq) };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ pub fn shutdown() {
|
||||||
if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB {
|
if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB {
|
||||||
let usb = &mut *core::ptr::addr_of_mut!(*usb_ref);
|
let usb = &mut *core::ptr::addr_of_mut!(*usb_ref);
|
||||||
crate::irq::disable_all_irqs();
|
crate::irq::disable_all_irqs();
|
||||||
|
crate::println!("Stopping USB...");
|
||||||
usb.stop();
|
usb.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue