RTIO PLL fixes #183
|
@ -340,6 +340,7 @@ class GenericSatellite(SoCCore):
|
||||||
self.crg = self.ps7 # HACK for eem_7series to find the clock
|
self.crg = self.ps7 # HACK for eem_7series to find the clock
|
||||||
self.submodules.rtio_crg = RTIOClockMultiplier(rtio_clk_freq)
|
self.submodules.rtio_crg = RTIOClockMultiplier(rtio_clk_freq)
|
||||||
self.csr_devices.append("rtio_crg")
|
self.csr_devices.append("rtio_crg")
|
||||||
|
self.rustc_cfg["has_rtio_crg"] = None
|
||||||
|
|
||||||
data_pads = [platform.request("sfp", i) for i in range(4)]
|
data_pads = [platform.request("sfp", i) for i in range(4)]
|
||||||
|
|
||||||
|
|
|
@ -431,6 +431,7 @@ class _SatelliteBase(SoCCore):
|
||||||
|
|
||||||
self.submodules.rtio_crg = RTIOClockMultiplier(self.sys_clk_freq)
|
self.submodules.rtio_crg = RTIOClockMultiplier(self.sys_clk_freq)
|
||||||
self.csr_devices.append("rtio_crg")
|
self.csr_devices.append("rtio_crg")
|
||||||
|
self.rustc_cfg["has_rtio_crg"] = None
|
||||||
fix_serdes_timing_path(self.platform)
|
fix_serdes_timing_path(self.platform)
|
||||||
|
|
||||||
def add_rtio(self, rtio_channels):
|
def add_rtio(self, rtio_channels):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use log::{info, warn};
|
use log::{info, warn, error};
|
||||||
use libboard_zynq::timer::GlobalTimer;
|
use libboard_zynq::timer::GlobalTimer;
|
||||||
use embedded_hal::blocking::delay::DelayMs;
|
use embedded_hal::blocking::delay::DelayMs;
|
||||||
use libconfig::Config;
|
use libconfig::Config;
|
||||||
|
@ -84,22 +84,18 @@ fn init_rtio(timer: &mut GlobalTimer, _clk: RtioClock) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
unsafe {
|
||||||
unsafe {
|
pl::csr::rtio_crg::pll_reset_write(1);
|
||||||
pl::csr::rtio_crg::pll_reset_write(1);
|
#[cfg(has_rtio_crg_clock_sel)]
|
||||||
#[cfg(has_rtio_crg_clock_sel)]
|
pl::csr::rtio_crg::clock_sel_write(clock_sel);
|
||||||
pl::csr::rtio_crg::clock_sel_write(clock_sel);
|
pl::csr::rtio_crg::pll_reset_write(0);
|
||||||
pl::csr::rtio_crg::pll_reset_write(0);
|
}
|
||||||
}
|
timer.delay_ms(1);
|
||||||
timer.delay_ms(1);
|
let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 };
|
||||||
let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 };
|
if locked {
|
||||||
if locked {
|
info!("RTIO PLL locked");
|
||||||
info!("RTIO PLL locked");
|
} else {
|
||||||
break;
|
error!("RTIO PLL failed to lock");
|
||||||
} else {
|
|
||||||
warn!("RTIO PLL failed to lock, retrying...");
|
|
||||||
timer.delay_ms(500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -392,7 +392,7 @@ fn drtiosat_process_errors() {
|
||||||
|
|
||||||
|
|
||||||
#[cfg(has_rtio_crg)]
|
#[cfg(has_rtio_crg)]
|
||||||
fn init_rtio_crg(timer: GlobalTimer) {
|
fn init_rtio_crg(timer: &mut GlobalTimer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::rtio_crg::pll_reset_write(0);
|
csr::rtio_crg::pll_reset_write(0);
|
||||||
}
|
}
|
||||||
|
@ -401,10 +401,13 @@ fn init_rtio_crg(timer: GlobalTimer) {
|
||||||
if !locked {
|
if !locked {
|
||||||
error!("RTIO clock failed");
|
error!("RTIO clock failed");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
info!("RTIO PLL locked");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(has_rtio_crg))]
|
#[cfg(not(has_rtio_crg))]
|
||||||
fn init_rtio_crg(_timer: GlobalTimer) { }
|
fn init_rtio_crg(_timer: &mut GlobalTimer) { }
|
||||||
|
|
||||||
fn hardware_tick(ts: &mut u64, timer: &mut GlobalTimer) {
|
fn hardware_tick(ts: &mut u64, timer: &mut GlobalTimer) {
|
||||||
let now = timer.get_time();
|
let now = timer.get_time();
|
||||||
|
@ -477,7 +480,7 @@ pub extern fn main_core0() -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::drtio_transceiver::txenable_write(0xffffffffu32 as _);
|
csr::drtio_transceiver::txenable_write(0xffffffffu32 as _);
|
||||||
}
|
}
|
||||||
init_rtio_crg(timer);
|
init_rtio_crg(&mut timer);
|
||||||
|
|
||||||
#[cfg(has_drtio_routing)]
|
#[cfg(has_drtio_routing)]
|
||||||
let mut repeaters = [repeater::Repeater::default(); csr::DRTIOREP.len()];
|
let mut repeaters = [repeater::Repeater::default(); csr::DRTIOREP.len()];
|
||||||
|
|
Loading…
Reference in New Issue