Compare commits

...

2 Commits

2 changed files with 20 additions and 12 deletions

View File

@ -57,7 +57,7 @@ pub trait ClockSource {
/// 25.10.4 PLLs /// 25.10.4 PLLs
fn setup(target_freq: u32) { fn setup(target_freq: u32) {
let fdiv = (target_freq / PS_CLK).min(66) as u16; let fdiv = (target_freq / PS_CLK).min(66) as u16;
let (pll_res, pll_cp, lock_cnt) = PLL_FDIV_LOCK_PARAM.iter() let (pll_cp, pll_res, lock_cnt) = PLL_FDIV_LOCK_PARAM.iter()
.filter(|(fdiv_max, _)| fdiv <= *fdiv_max) .filter(|(fdiv_max, _)| fdiv <= *fdiv_max)
.nth(0) .nth(0)
.expect("PLL_FDIV_LOCK_PARAM") .expect("PLL_FDIV_LOCK_PARAM")

View File

@ -44,8 +44,7 @@ impl DdrRam {
Self::configure_iob(); Self::configure_iob();
let regs = regs::RegisterBlock::ddrc(); let regs = regs::RegisterBlock::ddrc();
let mut ddr = DdrRam { regs }; let mut ddr = DdrRam { regs };
ddr.configure(); ddr.reset_ddrc(|ddr| ddr.configure());
ddr.reset_ddrc();
ddr ddr
} }
} }
@ -319,15 +318,7 @@ impl DdrRam {
} }
/// Reset DDR controller /// Reset DDR controller
fn reset_ddrc(&mut self) { fn reset_ddrc<F: FnMut(&mut Self)>(&mut self, mut f: F) {
#[cfg(feature = "target_zc706")]
unsafe {
// row/column address bits
self.regs.dram_addr_map_bank.write(0x00000777);
self.regs.dram_addr_map_col.write(0xFFF00000);
self.regs.dram_addr_map_row.write(0x0F666666);
}
#[cfg(feature = "target_zc706")] #[cfg(feature = "target_zc706")]
let width = regs::DataBusWidth::Width32bit; let width = regs::DataBusWidth::Width32bit;
#[cfg(feature = "target_cora_z7_10")] #[cfg(feature = "target_cora_z7_10")]
@ -339,6 +330,23 @@ impl DdrRam {
.powerdown_en(false) .powerdown_en(false)
.data_bus_width(width) .data_bus_width(width)
); );
f(self);
#[cfg(feature = "target_zc706")]
unsafe {
// row/column address bits
self.regs.dram_addr_map_bank.write(0x00000777);
self.regs.dram_addr_map_col.write(0xFFF00000);
self.regs.dram_addr_map_row.write(0x0F666666);
}
#[cfg(feature = "target_cora_z7_10")]
unsafe {
// row/column address bits
self.regs.dram_addr_map_bank.write(0x00000666);
self.regs.dram_addr_map_col.write(0xFFFF0000);
self.regs.dram_addr_map_row.write(0x0F555555);
}
self.regs.ddrc_ctrl.modify(|_, w| w self.regs.ddrc_ctrl.modify(|_, w| w
.soft_rstb(true) .soft_rstb(true)
.powerdown_en(false) .powerdown_en(false)