aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-05-13 18:55:40 +0200
committerpennae <[email protected]>2023-05-17 18:35:58 +0200
commitd3494a4bdf513d5b61210180fa227a9bd99935ca (patch)
treeb229335ce29ba68c1f598ab1d9650a9a32084576
parent2f2860b09697845029b4827462fdf98b515e8898 (diff)
rp/clocks: reset all plls at once
we might not configure both, so we should put the others into reset state. leaving them fully as is might leave them running, which might not be the goal for runtime reconfig (when it comes around). this now mirrors how we reset all clock-using peripherals and only unreset those that are properly clocked.
-rw-r--r--embassy-rp/src/clocks.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs
index d34082716..bfca3f02e 100644
--- a/embassy-rp/src/clocks.rs
+++ b/embassy-rp/src/clocks.rs
@@ -203,6 +203,13 @@ pub(crate) unsafe fn init(config: ClockConfig) {
203 c.clk_ref_ctrl().modify(|w| w.set_src(ClkRefCtrlSrc::ROSC_CLKSRC_PH)); 203 c.clk_ref_ctrl().modify(|w| w.set_src(ClkRefCtrlSrc::ROSC_CLKSRC_PH));
204 while c.clk_ref_selected().read() != 1 {} 204 while c.clk_ref_selected().read() != 1 {}
205 205
206 // Reset the PLLs
207 let mut peris = reset::Peripherals(0);
208 peris.set_pll_sys(true);
209 peris.set_pll_usb(true);
210 reset::reset(peris);
211 reset::unreset_wait(peris);
212
206 if let Some(config) = config.rosc { 213 if let Some(config) = config.rosc {
207 configure_rosc(config); 214 configure_rosc(config);
208 } 215 }
@@ -587,16 +594,6 @@ unsafe fn configure_pll(p: pac::pll::Pll, input_freq: u32, config: PllConfig) {
587 assert!(config.post_div2 <= config.post_div1); 594 assert!(config.post_div2 <= config.post_div1);
588 assert!(ref_freq <= (config.vco_freq / 16)); 595 assert!(ref_freq <= (config.vco_freq / 16));
589 596
590 // Reset it
591 let mut peris = reset::Peripherals(0);
592 match p {
593 pac::PLL_SYS => peris.set_pll_sys(true),
594 pac::PLL_USB => peris.set_pll_usb(true),
595 _ => unreachable!(),
596 }
597 reset::reset(peris);
598 reset::unreset_wait(peris);
599
600 // Load VCO-related dividers before starting VCO 597 // Load VCO-related dividers before starting VCO
601 p.cs().write(|w| w.set_refdiv(config.refdiv as _)); 598 p.cs().write(|w| w.set_refdiv(config.refdiv as _));
602 p.fbdiv_int().write(|w| w.set_fbdiv_int(fbdiv as _)); 599 p.fbdiv_int().write(|w| w.set_fbdiv_int(fbdiv as _));