From 7db80ef42bb487ec9c4e3aeeda7fd294b5c8fe33 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Fri, 22 Oct 2021 17:43:36 +0800 Subject: [PATCH 01/12] runtime: extract rtio_clocking, new config support --- src/runtime/src/main.rs | 84 +-------------------- src/runtime/src/rtio_clocking.rs | 123 +++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 81 deletions(-) create mode 100644 src/runtime/src/rtio_clocking.rs diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index 973afbe..da93f3f 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -18,12 +18,9 @@ use libasync::{task, block_async}; use libsupport_zynq::ram; use nb; use void::Void; -use embedded_hal::blocking::delay::DelayMs; use libconfig::Config; use libcortex_a9::l2c::enable_l2_cache; use libboard_artiq::{logger, identifier_read, init_gateware, pl}; -#[cfg(has_si5324)] -use libboard_artiq::si5324; mod proto_async; mod comms; @@ -35,6 +32,7 @@ mod rtio; #[path = "rtio_acp.rs"] mod rtio; mod rtio_mgt; +mod rtio_clocking; mod kernel; mod moninj; mod eh_artiq; @@ -44,65 +42,6 @@ mod analyzer; mod irq; mod i2c; -fn init_rtio(timer: &mut GlobalTimer, _cfg: &Config) { - #[cfg(has_rtio_crg_clock_sel)] - let clock_sel = - if let Ok(rtioclk) = _cfg.read_str("rtioclk") { - match rtioclk.as_ref() { - "internal" => { - info!("using internal RTIO clock"); - 0 - }, - "external" => { - info!("using external RTIO clock"); - 1 - }, - other => { - warn!("RTIO clock specification '{}' not recognized", other); - info!("using internal RTIO clock"); - 0 - }, - } - } else { - info!("using internal RTIO clock (default)"); - 0 - }; - - loop { - unsafe { - pl::csr::rtio_crg::pll_reset_write(1); - #[cfg(has_rtio_crg_clock_sel)] - pl::csr::rtio_crg::clock_sel_write(clock_sel); - pl::csr::rtio_crg::pll_reset_write(0); - } - timer.delay_ms(1); - let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 }; - if locked { - info!("RTIO PLL locked"); - break; - } else { - warn!("RTIO PLL failed to lock, retrying..."); - timer.delay_ms(500); - } - } - - unsafe { - pl::csr::rtio_core::reset_phy_write(1); - } -} - -#[cfg(has_drtio)] -fn init_drtio(timer: &mut GlobalTimer) -{ - unsafe { - pl::csr::drtio_transceiver::stable_clkin_write(1); - } - timer.delay_ms(2); // wait for CPLL/QPLL lock - unsafe { - pl::csr::drtio_transceiver::txenable_write(0xffffffffu32 as _); - } -} - fn wait_for_async_rtio_error() -> nb::Result<(), Void> { unsafe { @@ -136,19 +75,7 @@ async fn report_async_rtio_errors() { } } -#[cfg(has_si5324)] -// 125MHz output, from crystal, 7 Hz -const SI5324_SETTINGS: si5324::FrequencySettings - = si5324::FrequencySettings { - n1_hs : 10, - nc1_ls : 4, - n2_hs : 10, - n2_ls : 19972, - n31 : 4565, - n32 : 4565, - bwsel : 4, - crystal_ref: true -}; + static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17]; @@ -173,9 +100,6 @@ pub fn main_core0() { info!("detected gateware: {}", identifier_read(&mut [0; 64])); i2c::init(); - #[cfg(has_si5324)] - si5324::setup(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, - &SI5324_SETTINGS, si5324::Input::Ckin2, &mut timer).expect("cannot initialize Si5324"); let cfg = match Config::new() { Ok(cfg) => cfg, @@ -185,10 +109,8 @@ pub fn main_core0() { } }; - #[cfg(has_drtio)] - init_drtio(&mut timer); + rtio_clocking::init(&mut timer, &cfg); - init_rtio(&mut timer, &cfg); task::spawn(report_async_rtio_errors()); comms::main(timer, cfg); diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs new file mode 100644 index 0000000..20e2c3d --- /dev/null +++ b/src/runtime/src/rtio_clocking.rs @@ -0,0 +1,123 @@ +use log::{info, warn}; +use libboard_zynq::{timer::GlobalTimer}; +use embedded_hal::blocking::delay::DelayMs; +use libconfig::Config; +use libboard_artiq::pl; +use crate::i2c; + +#[cfg(has_si5324)] +use libboard_artiq::si5324; + + +#[derive(Debug, PartialEq, Copy, Clone)] +#[allow(non_camel_case_types)] +pub enum RtioClock { + Int_125, + Int_100, + Int_150, + Ext0_Bypass, + Ext0_Synth0_10to125, + Ext0_Synth0_100to125, + Ext0_Synth0_125to125, +} + +fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { + if let Ok(clk) = cfg.read_str("rtio_clock") { + match clk.as_ref() { + "int_125" => RtioClock::Int_125, + "int_100" => RtioClock::Int_100, + "int_150" => RtioClock::Int_150, + "ext0_bypass" => RtioClock::Ext0_Bypass, + "ext0_synth0_10to125" => RtioClock::Ext0_Synth0_10to125, + "ext0_synth0_100to125" => RtioClock::Ext0_Synth0_100to125, + "ext0_synth0_125to125" => RtioClock::Ext0_Synth0_125to125, + _ => RtioClock::Int_125 + } + } + else { + RtioClock::Int_125 + } +} + + +fn init_rtio(timer: &mut GlobalTimer, _clk: RtioClock) { + #[cfg(has_rtio_crg_clock_sel)] + let clock_sel = match _clk { + RtioClock::Ext0_Bypass => { + info!("using bypassed external clock"); + 1 + }, + x => { + info!("using clock: {:?}", x); + 0 + } + }; + + loop { + unsafe { + pl::csr::rtio_crg::pll_reset_write(1); + #[cfg(has_rtio_crg_clock_sel)] + pl::csr::rtio_crg::clock_sel_write(clock_sel); + pl::csr::rtio_crg::pll_reset_write(0); + } + timer.delay_ms(1); + let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 }; + if locked { + info!("RTIO PLL locked"); + break; + } else { + warn!("RTIO PLL failed to lock, retrying..."); + timer.delay_ms(500); + } + } + + unsafe { + pl::csr::rtio_core::reset_phy_write(1); + } +} + +#[cfg(has_drtio)] +fn init_drtio(timer: &mut GlobalTimer) +{ + unsafe { + pl::csr::drtio_transceiver::stable_clkin_write(1); + } + timer.delay_ms(2); // wait for CPLL/QPLL lock + unsafe { + pl::csr::drtio_transceiver::txenable_write(0xffffffffu32 as _); + } +} + +#[cfg(has_si5324)] +fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { + let mut si5324_settings: Option = None; + // 125MHz output, from crystal, 7 Hz + if si5324_settings.is_none() || clk == RtioClock::Int_125 { + info!("using internal 125MHz RTIO clock"); + si5324_settings = Some(si5324::FrequencySettings { + n1_hs : 10, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 19972, + n31 : 4565, + n32 : 4565, + bwsel : 4, + crystal_ref: true + }); + } + si5324::setup(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, + &si5324_settings.unwrap(), si5324::Input::Ckin2, timer).expect("cannot initialize Si5324"); +} + +pub fn init(timer: &mut GlobalTimer, cfg: &Config) { + + let clk = get_rtio_clock_cfg(cfg); + #[cfg(has_si5324)] + setup_si5324(timer, clk); + + #[cfg(has_drtio)] + init_drtio(timer); + + init_rtio(timer, clk); + +} \ No newline at end of file -- 2.42.0 From 61442b3775a42bd0b1f165168a9f9cab35cc4967 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 25 Oct 2021 11:11:37 +0800 Subject: [PATCH 02/12] readme: update rtio_clock key info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fdae0d7..eb0f98f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The following configuration keys are available: - ``ip``: IPv4 address. - ``ip6``: IPv6 address. - ``startup``: startup kernel in ELF format (as produced by ``artiq_compile``). -- ``rtioclk``: source of RTIO clock; valid values are ``external`` and ``internal``. +- ``rtio_clock``: source of RTIO clock; valid values are ``ext0_bypass`` and ``int_125``. - ``boot``: SD card "boot.bin" file, for replacing the boot firmware/gateware. Write only. Configurations can be read/written/removed via ``artiq_coremgmt``. Config erase is -- 2.42.0 From c94582ccbe4478f4255a23833e2757779b4135f8 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 25 Oct 2021 14:16:32 +0800 Subject: [PATCH 03/12] rtio_clocking: added si5324 bypass --- src/runtime/src/rtio_clocking.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index 20e2c3d..db4c2e3 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -35,6 +35,7 @@ fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { } } else { + info!("error reading configuration. Using default internal 125MHz clock"); RtioClock::Int_125 } } @@ -105,16 +106,22 @@ fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { crystal_ref: true }); } + let si5324_ref_input = si5324::Input::Ckin2; si5324::setup(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, - &si5324_settings.unwrap(), si5324::Input::Ckin2, timer).expect("cannot initialize Si5324"); + &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); } pub fn init(timer: &mut GlobalTimer, cfg: &Config) { let clk = get_rtio_clock_cfg(cfg); #[cfg(has_si5324)] - setup_si5324(timer, clk); - + { + let si5324_ext_input = si5324::Input::Ckin2; + match clk { + RtioClock::Ext0_Bypass => si5324::bypass(si5324_ext_input).expect("cannot bypass Si5324"), + _ => setup_si5324(timer, clk), + } + } #[cfg(has_drtio)] init_drtio(timer); -- 2.42.0 From d772a9426504f1632531850a330605d527f3e080 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 25 Oct 2021 15:58:28 +0800 Subject: [PATCH 04/12] rtio_clocking: fix warnings and bypass --- src/runtime/src/rtio_clocking.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index db4c2e3..53f2192 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -1,14 +1,15 @@ use log::{info, warn}; -use libboard_zynq::{timer::GlobalTimer}; +use libboard_zynq::timer::GlobalTimer; use embedded_hal::blocking::delay::DelayMs; use libconfig::Config; use libboard_artiq::pl; +#[cfg(has_si5324)] +use libboard_zynq::i2c::I2c; +#[cfg(has_si5324)] use crate::i2c; - #[cfg(has_si5324)] use libboard_artiq::si5324; - #[derive(Debug, PartialEq, Copy, Clone)] #[allow(non_camel_case_types)] pub enum RtioClock { @@ -90,7 +91,7 @@ fn init_drtio(timer: &mut GlobalTimer) } #[cfg(has_si5324)] -fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { +fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { let mut si5324_settings: Option = None; // 125MHz output, from crystal, 7 Hz if si5324_settings.is_none() || clk == RtioClock::Int_125 { @@ -107,8 +108,7 @@ fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { }); } let si5324_ref_input = si5324::Input::Ckin2; - si5324::setup(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, - &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); + si5324::setup(i2c, &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); } pub fn init(timer: &mut GlobalTimer, cfg: &Config) { @@ -116,10 +116,11 @@ pub fn init(timer: &mut GlobalTimer, cfg: &Config) { let clk = get_rtio_clock_cfg(cfg); #[cfg(has_si5324)] { + let i2c = unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }; let si5324_ext_input = si5324::Input::Ckin2; match clk { - RtioClock::Ext0_Bypass => si5324::bypass(si5324_ext_input).expect("cannot bypass Si5324"), - _ => setup_si5324(timer, clk), + RtioClock::Ext0_Bypass => si5324::bypass(i2c, si5324_ext_input, timer).expect("cannot bypass Si5324"), + _ => setup_si5324(i2c, timer, clk), } } #[cfg(has_drtio)] -- 2.42.0 From 90b6dd3e8544ef4561879ee0e0e7f19fa1c77687 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 28 Oct 2021 12:33:43 +0800 Subject: [PATCH 05/12] rtio_clocking: brought on par with mainline ARTIQ --- src/runtime/src/rtio_clocking.rs | 46 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index 53f2192..9305fcd 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -13,6 +13,7 @@ use libboard_artiq::si5324; #[derive(Debug, PartialEq, Copy, Clone)] #[allow(non_camel_case_types)] pub enum RtioClock { + Default, Int_125, Int_100, Int_150, @@ -32,12 +33,15 @@ fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { "ext0_synth0_10to125" => RtioClock::Ext0_Synth0_10to125, "ext0_synth0_100to125" => RtioClock::Ext0_Synth0_100to125, "ext0_synth0_125to125" => RtioClock::Ext0_Synth0_125to125, - _ => RtioClock::Int_125 + _ => { + warn!("Unrecognised rtio_clock setting. Falling back to default."); + RtioClock::Int_125 + } } } else { - info!("error reading configuration. Using default internal 125MHz clock"); - RtioClock::Int_125 + info!("error reading configuration. Falling back to default."); + RtioClock::Default } } @@ -46,11 +50,11 @@ fn init_rtio(timer: &mut GlobalTimer, _clk: RtioClock) { #[cfg(has_rtio_crg_clock_sel)] let clock_sel = match _clk { RtioClock::Ext0_Bypass => { - info!("using bypassed external clock"); + info!("Using bypassed external clock"); 1 }, x => { - info!("using clock: {:?}", x); + info!("Using internal RTIO clock"); 0 } }; @@ -92,23 +96,23 @@ fn init_drtio(timer: &mut GlobalTimer) #[cfg(has_si5324)] fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { - let mut si5324_settings: Option = None; - // 125MHz output, from crystal, 7 Hz - if si5324_settings.is_none() || clk == RtioClock::Int_125 { - info!("using internal 125MHz RTIO clock"); - si5324_settings = Some(si5324::FrequencySettings { - n1_hs : 10, - nc1_ls : 4, - n2_hs : 10, - n2_ls : 19972, - n31 : 4565, - n32 : 4565, - bwsel : 4, - crystal_ref: true - }); - } + let si5324_settings = match clk { + _ => { // 125MHz output, from crystal, 7 Hz, default, also covers RtioClock::Int_125 + info!("using internal 125MHz RTIO clock"); + si5324::FrequencySettings { + n1_hs : 10, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 19972, + n31 : 4565, + n32 : 4565, + bwsel : 4, + crystal_ref: true + } + } + }; let si5324_ref_input = si5324::Input::Ckin2; - si5324::setup(i2c, &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); + si5324::setup(i2c, &si5324_settings, si5324_ref_input, timer).expect("cannot initialize Si5324"); } pub fn init(timer: &mut GlobalTimer, cfg: &Config) { -- 2.42.0 From 0de56e92bda4c1ab448581204365e232e2656351 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 28 Oct 2021 16:25:07 +0800 Subject: [PATCH 06/12] rtio_clocking: added explicit bypass aliases --- src/runtime/src/rtio_clocking.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index 9305fcd..fea273a 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -30,6 +30,8 @@ fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { "int_100" => RtioClock::Int_100, "int_150" => RtioClock::Int_150, "ext0_bypass" => RtioClock::Ext0_Bypass, + "ext0_bypass_125" => RtioClock::Ext0_Bypass, + "ext0_bypass_100" => RtioClock::Ext0_Bypass, "ext0_synth0_10to125" => RtioClock::Ext0_Synth0_10to125, "ext0_synth0_100to125" => RtioClock::Ext0_Synth0_100to125, "ext0_synth0_125to125" => RtioClock::Ext0_Synth0_125to125, -- 2.42.0 From 7ecee2b3ee7a1f58858142b61ffcf1d982288349 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 28 Oct 2021 16:25:29 +0800 Subject: [PATCH 07/12] rtio_clocking: warn on unsupported settings --- src/runtime/src/rtio_clocking.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index fea273a..ff4420c 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -99,7 +99,7 @@ fn init_drtio(timer: &mut GlobalTimer) #[cfg(has_si5324)] fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { let si5324_settings = match clk { - _ => { // 125MHz output, from crystal, 7 Hz, default, also covers RtioClock::Int_125 + RtioClock::Int_125 => { // 125MHz output, from crystal, 7 Hz info!("using internal 125MHz RTIO clock"); si5324::FrequencySettings { n1_hs : 10, @@ -112,6 +112,19 @@ fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { crystal_ref: true } } + _ => { // same setting as Int_125, but fallback to default + warn!("rtio_clock setting '{:x}' is unsupported. Falling back to default internal 125MHz RTIO clock."); + si5324::FrequencySettings { + n1_hs : 10, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 19972, + n31 : 4565, + n32 : 4565, + bwsel : 4, + crystal_ref: true + } + } }; let si5324_ref_input = si5324::Input::Ckin2; si5324::setup(i2c, &si5324_settings, si5324_ref_input, timer).expect("cannot initialize Si5324"); -- 2.42.0 From 8bc0266bbeef71f7ed35dce9c58143033cd1fb55 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 28 Oct 2021 16:44:39 +0800 Subject: [PATCH 08/12] rtio_clocking: additional warnings, fixes --- src/runtime/src/rtio_clocking.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index ff4420c..93869f4 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -55,9 +55,13 @@ fn init_rtio(timer: &mut GlobalTimer, _clk: RtioClock) { info!("Using bypassed external clock"); 1 }, - x => { + RtioClock::Int_125 => { info!("Using internal RTIO clock"); 0 + }, + _ => { + warn!("rtio_clock setting '{:?}' is not supported. Using default internal RTIO clock instead", _clk); + 0 } }; @@ -113,7 +117,7 @@ fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { } } _ => { // same setting as Int_125, but fallback to default - warn!("rtio_clock setting '{:x}' is unsupported. Falling back to default internal 125MHz RTIO clock."); + warn!("rtio_clock setting '{:?}' is unsupported. Falling back to default internal 125MHz RTIO clock.", clk); si5324::FrequencySettings { n1_hs : 10, nc1_ls : 4, -- 2.42.0 From fc7520bc63bdcd886dec3bb8f38eeeb051ecda7b Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 28 Oct 2021 16:54:53 +0800 Subject: [PATCH 09/12] rtio_clocking: added si5324 settings from mainline --- src/runtime/src/rtio_clocking.rs | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index 93869f4..566107f 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -103,6 +103,71 @@ fn init_drtio(timer: &mut GlobalTimer) #[cfg(has_si5324)] fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { let si5324_settings = match clk { + RtioClock::Ext0_Synth0_10to125 => { // 125 MHz output from 10 MHz CLKINx reference, 504 Hz BW + info!("using 10MHz reference to make 125MHz RTIO clock with PLL"); + si5324::FrequencySettings { + n1_hs : 10, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 300, + n31 : 6, + n32 : 6, + bwsel : 4, + crystal_ref: false + } + }, + RtioClock::Ext0_Synth0_100to125 => { // 125MHz output, from 100MHz CLKINx reference, 586 Hz loop bandwidth + info!("using 10MHz reference to make 125MHz RTIO clock with PLL"); + si5324::FrequencySettings { + n1_hs : 10, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 260, + n31 : 52, + n32 : 52, + bwsel : 4, + crystal_ref: false + } + }, + RtioClock::Ext0_Synth0_125to125 => { // 125MHz output, from 125MHz CLKINx reference, 606 Hz loop bandwidth + info!("using 10MHz reference to make 125MHz RTIO clock with PLL"); + si5324::FrequencySettings { + n1_hs : 5, + nc1_ls : 8, + n2_hs : 7, + n2_ls : 360, + n31 : 63, + n32 : 63, + bwsel : 4, + crystal_ref: false + } + }, + RtioClock::Int_150 => { // 150MHz output, from crystal + info!("using internal 150MHz RTIO clock"); + si5324::FrequencySettings { + n1_hs : 9, + nc1_ls : 4, + n2_hs : 10, + n2_ls : 33732, + n31 : 7139, + n32 : 7139, + bwsel : 3, + crystal_ref: true + } + }, + RtioClock::Int_100 => { // 100MHz output, from crystal. Also used as reference for Sayma HMC830. + info!("using internal 100MHz RTIO clock"); + si5324::FrequencySettings { + n1_hs : 9, + nc1_ls : 6, + n2_hs : 10, + n2_ls : 33732, + n31 : 7139, + n32 : 7139, + bwsel : 3, + crystal_ref: true + } + }, RtioClock::Int_125 => { // 125MHz output, from crystal, 7 Hz info!("using internal 125MHz RTIO clock"); si5324::FrequencySettings { -- 2.42.0 From a82e7a332bd1091b46f618f5ab438e2354e1d324 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Fri, 29 Oct 2021 09:56:44 +0800 Subject: [PATCH 10/12] gateware: kasli_soc: fix missing si5324 support --- src/gateware/kasli_soc.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gateware/kasli_soc.py b/src/gateware/kasli_soc.py index fa45fe8..da376ea 100755 --- a/src/gateware/kasli_soc.py +++ b/src/gateware/kasli_soc.py @@ -113,8 +113,8 @@ class GenericStandalone(SoCCore): platform.add_platform_command("create_clock -name clk_fpga_0 -period 8 [get_pins \"PS7/FCLKCLK[0]\"]") platform.add_platform_command("set_input_jitter clk_fpga_0 0.24") - self.rustc_cfg["HAS_SI5324"] = None - self.rustc_cfg["SI5324_SOFT_RESET"] = None + self.rustc_cfg["has_si5324"] = None + self.rustc_cfg["si5324_soft_reset"] = None self.crg = self.ps7 # HACK for eem_7series to find the clock self.submodules.rtio_crg = RTIOCRG(self.platform) @@ -393,6 +393,9 @@ class GenericSatellite(SoCCore): self.add_memory_group("drtioaux_mem", drtioaux_memory_group) self.add_csr_group("drtiorep", drtiorep_csr_group) + self.rustc_cfg["has_si5324"] = None + self.rustc_cfg["si5324_soft_reset"] = None + if self.acpki: self.rustc_cfg["ki_impl"] = "acp" self.submodules.rtio = acpki.KernelInitiator(self.rtio_tsc, -- 2.42.0 From 07410afe839ba5863df1cf0d5100fa83c316b8d9 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Fri, 29 Oct 2021 10:33:05 +0800 Subject: [PATCH 11/12] rtio_clocking: remove unrelated comment --- src/runtime/src/rtio_clocking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index 566107f..cd279da 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -155,7 +155,7 @@ fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { crystal_ref: true } }, - RtioClock::Int_100 => { // 100MHz output, from crystal. Also used as reference for Sayma HMC830. + RtioClock::Int_100 => { // 100MHz output, from crystal. info!("using internal 100MHz RTIO clock"); si5324::FrequencySettings { n1_hs : 9, -- 2.42.0 From ee3b1715cb169e89b88d6755263bf1ab84ebbda4 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Thu, 25 Nov 2021 16:38:56 +0800 Subject: [PATCH 12/12] rtio_clock: cfg uses default now, info->warn --- src/runtime/src/rtio_clocking.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index cd279da..a3e2f7b 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -24,8 +24,9 @@ pub enum RtioClock { } fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { + let mut res = RtioClock::Default; if let Ok(clk) = cfg.read_str("rtio_clock") { - match clk.as_ref() { + res = match clk.as_ref() { "int_125" => RtioClock::Int_125, "int_100" => RtioClock::Int_100, "int_150" => RtioClock::Int_150, @@ -37,14 +38,18 @@ fn get_rtio_clock_cfg(cfg: &Config) -> RtioClock { "ext0_synth0_125to125" => RtioClock::Ext0_Synth0_125to125, _ => { warn!("Unrecognised rtio_clock setting. Falling back to default."); - RtioClock::Int_125 + RtioClock::Default } - } + }; } else { - info!("error reading configuration. Falling back to default."); - RtioClock::Default + warn!("error reading configuration. Falling back to default."); } + if res == RtioClock::Default { + warn!("Using default configuration - internal 125MHz RTIO clock."); + return RtioClock::Int_125; + } + res } -- 2.42.0