Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PLL7 (USB2 PLL) Support #170

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/chip/imxrt10xx/ccm/analog/pll7.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! The USB2 PLL.
//!
//! This PLL is associated with USB2, the secondary USB interface.

/// PLL7 frequency (Hz).
///
/// The reference manual notes that PLL7 should always run at 480MHz,
/// so this constant assumes that PLL7's DIV_SELECT field isn't
/// changed at runtime.
pub const FREQUENCY: u32 = 480_000_000;

/// The smallest PLL7_PFD divider.
pub const MIN_FRAC: u8 = 12;
/// The largest PLL7_PFD divider.
pub const MAX_FRAC: u8 = 35;

use crate::ral;

/// Restart the USB2 PLL.
pub fn restart(ccm_analog: &mut ral::ccm_analog::CCM_ANALOG) {
loop {
if ral::read_reg!(ral::ccm_analog, ccm_analog, PLL_USB2, ENABLE == 0) {
ral::write_reg!(ral::ccm_analog, ccm_analog, PLL_USB2_SET, ENABLE: 1);
continue;
}
if ral::read_reg!(ral::ccm_analog, ccm_analog, PLL_USB2, POWER == 0) {
ral::write_reg!(ral::ccm_analog, ccm_analog, PLL_USB2_SET, POWER: 1);
continue;
}
if ral::read_reg!(ral::ccm_analog, ccm_analog, PLL_USB2, LOCK == 0) {
continue;
}
if ral::read_reg!(ral::ccm_analog, ccm_analog, PLL_USB2, BYPASS == 1) {
ral::write_reg!(ral::ccm_analog, ccm_analog, PLL_USB2_CLR, BYPASS: 1);
continue;
}
if ral::read_reg!(ral::ccm_analog, ccm_analog, PLL_USB2, EN_USB_CLKS == 0) {
ral::write_reg!(ral::ccm_analog, ccm_analog, PLL_USB2_SET, EN_USB_CLKS: 1);
continue;
}
break;
}
}
1 change: 1 addition & 0 deletions src/chip/imxrt10xx/imxrt1060.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) mod ccm {

pub(crate) mod analog {
pub mod pll1;
pub mod pll7;
}

/// Re-exported by the common clock_gate module.
Expand Down