From 0775ae1c191d796c5ea9d177be3723d4c528a897 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 4 Dec 2022 02:23:38 +0000 Subject: [PATCH] firmware: Fix Kasli v2 runtime rtio_clock selection SI5324_EXT_REF now only controls the (deprecated) fallbacks for when the rtio_clock option is not set. --- artiq/firmware/libboard_artiq/si5324.rs | 5 ++++- artiq/firmware/runtime/rtio_clocking.rs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/artiq/firmware/libboard_artiq/si5324.rs b/artiq/firmware/libboard_artiq/si5324.rs index 3b1103d99..bc4930c96 100644 --- a/artiq/firmware/libboard_artiq/si5324.rs +++ b/artiq/firmware/libboard_artiq/si5324.rs @@ -214,8 +214,11 @@ pub fn bypass(input: Input) -> Result<()> { Ok(()) } -pub fn setup(settings: &FrequencySettings, input: Input) -> Result<()> { +pub fn setup(settings: &FrequencySettings, ext_input: Input) -> Result<()> { let s = map_frequency_settings(settings)?; + + // FREE_RUN=1 routes XA/XB to CKIN2. + let input = if settings.crystal_ref { Input::Ckin2 } else { ext_input }; let cksel_reg = match input { Input::Ckin1 => 0b00, Input::Ckin2 => 0b01, diff --git a/artiq/firmware/runtime/rtio_clocking.rs b/artiq/firmware/runtime/rtio_clocking.rs index a7259bc66..bb2c6b88d 100644 --- a/artiq/firmware/runtime/rtio_clocking.rs +++ b/artiq/firmware/runtime/rtio_clocking.rs @@ -212,9 +212,8 @@ fn setup_si5324_as_synthesizer(cfg: RtioClock) { } } }; - #[cfg(all(soc_platform = "kasli", hw_rev = "v2.0", not(si5324_ext_ref)))] - let si5324_ref_input = si5324::Input::Ckin2; - #[cfg(all(soc_platform = "kasli", hw_rev = "v2.0", si5324_ext_ref))] + + #[cfg(all(soc_platform = "kasli", hw_rev = "v2.0"))] let si5324_ref_input = si5324::Input::Ckin1; #[cfg(all(soc_platform = "kasli", not(hw_rev = "v2.0")))] let si5324_ref_input = si5324::Input::Ckin2; @@ -222,6 +221,7 @@ fn setup_si5324_as_synthesizer(cfg: RtioClock) { let si5324_ref_input = si5324::Input::Ckin2; #[cfg(soc_platform = "kc705")] let si5324_ref_input = si5324::Input::Ckin2; + si5324::setup(&si5324_settings, si5324_ref_input).expect("cannot initialize Si5324"); }