From 26874030fc5751f1b638acad8c19e7bede4ca040 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 25 Jul 2020 11:15:33 +0800 Subject: [PATCH] retry RTIO PLL lock --- src/runtime/src/main.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index 06494cad..6691dee7 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -112,22 +112,21 @@ fn init_rtio(timer: &mut GlobalTimer, cfg: &config::Config) { 0 }; - unsafe { - pl::csr::rtio_crg::pll_reset_write(1); - pl::csr::rtio_crg::clock_sel_write(clock_sel); - } - - timer.delay_ms(2); - - unsafe { - pl::csr::rtio_crg::pll_reset_write(0); - } - - timer.delay_ms(2); - - let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 }; - if !locked { - panic!("RTIO PLL failed to lock"); + loop { + unsafe { + pl::csr::rtio_crg::pll_reset_write(1); + pl::csr::rtio_crg::clock_sel_write(clock_sel); + pl::csr::rtio_crg::pll_reset_write(0); + } + timer.delay_ms(1); + let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 }; + if locked { + info!("RTIO PLL locked"); + break; + } else { + warn!("RTIO PLL failed to lock, retrying..."); + timer.delay_ms(500); + } } unsafe {