From 45efee724ef3bf20e386d45d8004b9c5faebf48d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 20 Jan 2020 12:47:31 +0800 Subject: [PATCH] sayma: add JESD204 PHY done diagnostics --- artiq/firmware/satman/jdcg.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/satman/jdcg.rs b/artiq/firmware/satman/jdcg.rs index 38e5bf866..929c6a121 100644 --- a/artiq/firmware/satman/jdcg.rs +++ b/artiq/firmware/satman/jdcg.rs @@ -11,7 +11,12 @@ pub mod jesd { unsafe { (csr::JDCG[dacno as usize].jesd_control_enable_write)(if en {1} else {0}) } - clock::spin_us(5000); + } + + pub fn phy_done(dacno: u8) -> bool { + unsafe { + (csr::JDCG[dacno as usize].jesd_control_phy_done_read)() != 0 + } } pub fn ready(dacno: u8) -> bool { @@ -84,7 +89,11 @@ pub mod jdac { info!("DAC-{} initializing...", dacno); jesd::enable(dacno, true); - clock::spin_us(10); + clock::spin_us(10_000); + if !jesd::phy_done(dacno) { + error!("JESD core PHY not done"); + return Err("JESD core PHY not done"); + } if !jesd::ready(dacno) { error!("JESD core reported not ready"); return Err("JESD core reported not ready");