From eb0ce933c59292628196d865f0fbef77cae6397f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 20 Jan 2020 12:05:56 +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 691cff75b..154e151f3 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 { @@ -80,7 +85,11 @@ pub mod jdac { fn init_one(dacno: u8) -> Result<(), &'static str> { 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");