aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa/src/clocks/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mcxa/src/clocks/config.rs')
-rw-r--r--embassy-mcxa/src/clocks/config.rs88
1 files changed, 70 insertions, 18 deletions
diff --git a/embassy-mcxa/src/clocks/config.rs b/embassy-mcxa/src/clocks/config.rs
index 3f1729d00..4beca5f27 100644
--- a/embassy-mcxa/src/clocks/config.rs
+++ b/embassy-mcxa/src/clocks/config.rs
@@ -136,7 +136,7 @@ pub enum SoscMode {
136 ActiveClock, 136 ActiveClock,
137} 137}
138 138
139// SOSC/clk_in configuration 139/// SOSC/clk_in configuration
140#[derive(Copy, Clone)] 140#[derive(Copy, Clone)]
141pub struct SoscConfig { 141pub struct SoscConfig {
142 /// Mode of the external reference clock 142 /// Mode of the external reference clock
@@ -149,22 +149,23 @@ pub struct SoscConfig {
149 149
150// SPLL 150// SPLL
151 151
152// Fin: 32kHz to 150MHz 152/// PLL1/SPLL configuration
153// Fcco: 275MHz to 550MHz
154// Fout: 4.3MHz to 2x Max CPU Frequency
155
156pub struct SpllConfig { 153pub struct SpllConfig {
154 /// Input clock source for the PLL1/SPLL
157 pub source: SpllSource, 155 pub source: SpllSource,
156 /// Mode of operation for the PLL1/SPLL
158 pub mode: SpllMode, 157 pub mode: SpllMode,
158 /// Power state of the SPLL
159 pub power: PoweredClock, 159 pub power: PoweredClock,
160 /// Is the "pll1_clk_div" clock enabled? 160 /// Is the "pll1_clk_div" clock enabled?
161 pub pll1_clk_div: Option<Div8>, 161 pub pll1_clk_div: Option<Div8>,
162} 162}
163 163
164/// Input clock source for the PLL1/SPLL
164pub enum SpllSource { 165pub enum SpllSource {
165 /// External Oscillator (8-50M) 166 /// External Oscillator (8-50MHz)
166 Sosc, 167 Sosc,
167 /// Fast Internal Oscillator (45M) 168 /// Fast Internal Oscillator (45MHz)
168 // NOTE: Figure 69 says "firc_45mhz"/"clk_45m", not "fro_hf_gated", 169 // NOTE: Figure 69 says "firc_45mhz"/"clk_45m", not "fro_hf_gated",
169 // so this is is always 45MHz. 170 // so this is is always 45MHz.
170 Firc, 171 Firc,
@@ -173,32 +174,83 @@ pub enum SpllSource {
173 // TODO: the reference manual hints that ROSC is possible, 174 // TODO: the reference manual hints that ROSC is possible,
174 // however the minimum input frequency is 32K, but ROSC is 16K. 175 // however the minimum input frequency is 32K, but ROSC is 16K.
175 // Some diagrams show this option, and some diagrams omit it. 176 // Some diagrams show this option, and some diagrams omit it.
177 // SVD shows it as "reserved".
176 // 178 //
177 // /// Realtime Internal Oscillator (16K Osc) 179 // /// Realtime Internal Oscillator (16K Osc)
178 // Rosc, 180 // Rosc,
179} 181}
180 182
181/// N: 1..=255 183/// Mode of operation for the SPLL/PLL1
182/// M: 1..=65535 184///
183/// P: 1..=31 185/// NOTE: Currently, only "Mode 1" normal operational modes are implemented,
186/// as described in the Reference Manual.
187#[non_exhaustive]
184pub enum SpllMode { 188pub enum SpllMode {
185 /// Fout = M x Fin 189 /// Mode 1a does not use the Pre/Post dividers.
186 Mode1a { m_mult: u16 }, 190 ///
187 /// if !bypass_p2_div: Fout = (M / (2 x P)) x Fin 191 /// `Fout = m_mult x SpllSource`
188 /// if bypass_p2_div: Fout = (M / P ) x Fin 192 ///
193 /// Both of the following constraints must be met:
194 ///
195 /// * Fout: 275MHz to 550MHz
196 /// * Fout: 4.3MHz to 2x Max CPU Frequency
197 Mode1a {
198 /// PLL Multiplier. Must be in the range 1..=65535.
199 m_mult: u16,
200 },
201
202 /// Mode 1b does not use the Pre-divider.
203 ///
204 /// * `if !bypass_p2_div: Fout = (M / (2 x P)) x Fin`
205 /// * `if bypass_p2_div: Fout = (M / P ) x Fin`
206 ///
207 /// Both of the following constraints must be met:
208 ///
209 /// * Fcco: 275MHz to 550MHz
210 /// * `Fcco = m_mult x SpllSource`
211 /// * Fout: 4.3MHz to 2x Max CPU Frequency
189 Mode1b { 212 Mode1b {
213 /// PLL Multiplier. `m_mult` must be in the range 1..=65535.
190 m_mult: u16, 214 m_mult: u16,
215 /// Post Divider. `p_div` must be in the range 1..=31.
191 p_div: u8, 216 p_div: u8,
217 /// Bonus post divider
192 bypass_p2_div: bool, 218 bypass_p2_div: bool,
193 }, 219 },
194 /// Fout = (M / N) x Fin 220
195 Mode1c { m_mult: u16, n_div: u8 }, 221 /// Mode 1c does use the Pre-divider, but does not use the Post-divider
196 /// if !bypass_p2_div: Fout = (M / (N x 2 x P)) x Fin 222 ///
197 /// if bypass_p2_div: Fout = (M / ( N x P )) x Fin 223 /// `Fout = (M / N) x Fin`
224 ///
225 /// Both of the following constraints must be met:
226 ///
227 /// * Fout: 275MHz to 550MHz
228 /// * Fout: 4.3MHz to 2x Max CPU Frequency
229 Mode1c {
230 /// PLL Multiplier. `m_mult` must be in the range 1..=65535.
231 m_mult: u16,
232 /// Pre Divider. `n_div` must be in the range 1..=255.
233 n_div: u8,
234 },
235
236 /// Mode 1b uses both the Pre and Post dividers.
237 ///
238 /// * `if !bypass_p2_div: Fout = (M / (N x 2 x P)) x Fin`
239 /// * `if bypass_p2_div: Fout = (M / ( N x P )) x Fin`
240 ///
241 /// Both of the following constraints must be met:
242 ///
243 /// * Fcco: 275MHz to 550MHz
244 /// * `Fcco = (m_mult x SpllSource) / (n_div x p_div (x 2))`
245 /// * Fout: 4.3MHz to 2x Max CPU Frequency
198 Mode1d { 246 Mode1d {
247 /// PLL Multiplier. `m_mult` must be in the range 1..=65535.
199 m_mult: u16, 248 m_mult: u16,
249 /// Pre Divider. `n_div` must be in the range 1..=255.
200 n_div: u8, 250 n_div: u8,
251 /// Post Divider. `p_div` must be in the range 1..=31.
201 p_div: u8, 252 p_div: u8,
253 /// Bonus post divider
202 bypass_p2_div: bool, 254 bypass_p2_div: bool,
203 }, 255 },
204} 256}