added siphaser to zc706 satellite, small fixes
This commit is contained in:
parent
b678408105
commit
9022064cf1
@ -456,6 +456,7 @@ class Satellite(SoCCore):
|
|||||||
self.submodules.si5324_rst_n = gpio.GPIOOut(platform.request("si5324").rst_n)
|
self.submodules.si5324_rst_n = gpio.GPIOOut(platform.request("si5324").rst_n)
|
||||||
self.csr_devices.append("si5324_rst_n")
|
self.csr_devices.append("si5324_rst_n")
|
||||||
self.rustc_cfg["has_si5324"] = None
|
self.rustc_cfg["has_si5324"] = None
|
||||||
|
self.rustc_cfg["has_siphaser"] = None
|
||||||
|
|
||||||
rtio_clk_period = 1e9/self.drtio_transceiver.rtio_clk_freq
|
rtio_clk_period = 1e9/self.drtio_transceiver.rtio_clk_freq
|
||||||
# Constrain TX & RX timing for the first transceiver channel
|
# Constrain TX & RX timing for the first transceiver channel
|
||||||
|
@ -33,9 +33,6 @@ pub mod logger;
|
|||||||
#[cfg(has_si5324)]
|
#[cfg(has_si5324)]
|
||||||
pub mod si5324;
|
pub mod si5324;
|
||||||
|
|
||||||
#[cfg(has_siphaser)]
|
|
||||||
pub mod siphaser;
|
|
||||||
|
|
||||||
use core::{cmp, str};
|
use core::{cmp, str};
|
||||||
use libboard_zynq::slcr;
|
use libboard_zynq::slcr;
|
||||||
use libregister::RegisterW;
|
use libregister::RegisterW;
|
||||||
|
@ -279,16 +279,18 @@ pub mod siphaser {
|
|||||||
use pl::csr;
|
use pl::csr;
|
||||||
|
|
||||||
pub fn select_recovered_clock(i2c: &mut I2c, rc: bool, timer: &mut GlobalTimer) -> Result<()> {
|
pub fn select_recovered_clock(i2c: &mut I2c, rc: bool, timer: &mut GlobalTimer) -> Result<()> {
|
||||||
write(i2c, 3, (read(3)? & 0xdf) | (1 << 5))?; // DHOLD=1
|
let val = read(i2c, 3)?;
|
||||||
|
write(i2c, 3, (val & 0xdf) | (1 << 5))?; // DHOLD=1
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::siphaser::switch_clocks_write(if rc { 1 } else { 0 });
|
csr::siphaser::switch_clocks_write(if rc { 1 } else { 0 });
|
||||||
}
|
}
|
||||||
write(i2c, 3, (read(3)? & 0xdf) | (0 << 5))?; // DHOLD=0
|
let val = read(i2c, 3)?;
|
||||||
monitor_lock(timer)?;
|
write(i2c, 3, (val & 0xdf) | (0 << 5))?; // DHOLD=0
|
||||||
|
monitor_lock(i2c, timer)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn phase_shift(direction: u8, timer: GlobalTimer) {
|
fn phase_shift(direction: u8, timer: &mut GlobalTimer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::siphaser::phase_shift_write(direction);
|
csr::siphaser::phase_shift_write(direction);
|
||||||
while csr::siphaser::phase_shift_done_read() == 0 {}
|
while csr::siphaser::phase_shift_done_read() == 0 {}
|
||||||
@ -297,7 +299,7 @@ pub mod siphaser {
|
|||||||
timer.delay_us(500);
|
timer.delay_us(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_error(timer: GlobalTimer) -> bool {
|
fn has_error(timer: &mut GlobalTimer) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::siphaser::error_write(1);
|
csr::siphaser::error_write(1);
|
||||||
}
|
}
|
||||||
|
@ -485,6 +485,11 @@ pub extern fn main_core0() -> i32 {
|
|||||||
|
|
||||||
let mut hardware_tick_ts = 0;
|
let mut hardware_tick_ts = 0;
|
||||||
|
|
||||||
|
print!("all set");
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
info!("rx_disable_read: {}, rx_up_read: {}", csr::drtiosat::rx_disable_read(), csr::drtiosat::rx_up_read());
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
while !drtiosat_link_rx_up() {
|
while !drtiosat_link_rx_up() {
|
||||||
drtiosat_process_errors();
|
drtiosat_process_errors();
|
||||||
@ -493,13 +498,17 @@ pub extern fn main_core0() -> i32 {
|
|||||||
rep.service(&routing_table, rank, &mut timer);
|
rep.service(&routing_table, rank, &mut timer);
|
||||||
}
|
}
|
||||||
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
||||||
|
unsafe {
|
||||||
|
info!("rx_disable_read: {}, rx_up_read: {}", csr::drtiosat::rx_disable_read(), csr::drtiosat::rx_up_read());
|
||||||
|
}
|
||||||
|
timer.delay_us(1000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("uplink is up, switching to recovered clock");
|
info!("uplink is up, switching to recovered clock");
|
||||||
#[cfg(has_siphaser)]
|
#[cfg(has_siphaser)]
|
||||||
{
|
{
|
||||||
si5324::siphaser::select_recovered_clock(true).expect("failed to switch clocks");
|
si5324::siphaser::select_recovered_clock(&mut i2c, true, &mut timer).expect("failed to switch clocks");
|
||||||
si5324::siphaser::calibrate_skew().expect("failed to calibrate skew");
|
si5324::siphaser::calibrate_skew(&mut timer).expect("failed to calibrate skew");
|
||||||
}
|
}
|
||||||
|
|
||||||
drtioaux::reset(0);
|
drtioaux::reset(0);
|
||||||
@ -532,7 +541,7 @@ pub extern fn main_core0() -> i32 {
|
|||||||
drtiosat_tsc_loaded();
|
drtiosat_tsc_loaded();
|
||||||
info!("uplink is down, switching to local oscillator clock");
|
info!("uplink is down, switching to local oscillator clock");
|
||||||
#[cfg(has_siphaser)]
|
#[cfg(has_siphaser)]
|
||||||
si5324::siphaser::select_recovered_clock(false).expect("failed to switch clocks");
|
si5324::siphaser::select_recovered_clock(&mut i2c, false, &mut timer).expect("failed to switch clocks");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user