@@ -50,20 +50,20 @@ use periph_helpers::{PreEnableParts, SPConfHelper};
5050use crate :: chips:: { ClockLimits , clock_limits} ;
5151use crate :: pac;
5252use crate :: pac:: cmc:: vals:: CkctrlCkmode ;
53- #[ cfg( feature = "mcxa2xx" ) ]
5453use crate :: pac:: scg:: vals:: {
55- Erefs , Fircacc , FircaccIe , FirccsrLk , Fircerr , FircerrIe , Fircsten , Fircvld , FreqSel , Range , SosccsrLk , Soscerr ,
56- Source , SpllLock , SpllcsrLk , Spllerr , Spllsten , TrimUnlock ,
54+ Erefs , Range , Scs , SirccsrLk , Sircerr , Sircvld , SosccsrLk , Soscerr , Source , SpllLock , SpllcsrLk , Spllerr , Spllsten ,
55+ TrimUnlock ,
5756} ;
58- use crate :: pac:: scg:: vals:: { Scs , SirccsrLk , Sircerr , Sircvld } ;
57+ #[ cfg( feature = "mcxa2xx" ) ]
58+ use crate :: pac:: scg:: vals:: { Fircacc , FircaccIe , FirccsrLk , Fircerr , FircerrIe , Fircsten , Fircvld , FreqSel } ;
5959use crate :: pac:: spc:: vals:: {
6060 ActiveCfgBgmode , ActiveCfgCoreldoVddDs , ActiveCfgCoreldoVddLvl , LpCfgBgmode , LpCfgCoreldoVddLvl , Vsm ,
6161} ;
62- use crate :: pac:: syscon:: vals:: { AhbclkdivUnstab , FrolfdivHalt , FrolfdivReset , FrolfdivUnstab } ;
63- #[ cfg( feature = "mcxa2xx" ) ]
6462use crate :: pac:: syscon:: vals:: {
65- FrohfdivHalt , FrohfdivReset , FrohfdivUnstab , Pll1clkdivHalt , Pll1clkdivReset , Pll1clkdivUnstab ,
63+ AhbclkdivUnstab , FrolfdivHalt , FrolfdivReset , FrolfdivUnstab , Pll1clkdivHalt , Pll1clkdivReset , Pll1clkdivUnstab ,
6664} ;
65+ #[ cfg( feature = "mcxa2xx" ) ]
66+ use crate :: pac:: syscon:: vals:: { FrohfdivHalt , FrohfdivReset , FrohfdivUnstab } ;
6767pub mod config;
6868pub mod periph_helpers;
6969
@@ -132,10 +132,8 @@ pub fn init(settings: ClocksConfig) -> Result<(), ClockError> {
132132 #[ cfg( all( feature = "mcxa5xx" , not( feature = "rosc-32k-as-gpio" ) ) ) ]
133133 operator. configure_osc32k_clocks ( ) ?;
134134
135- #[ cfg( feature = "mcxa2xx" ) ]
136135 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
137136 operator. configure_sosc ( ) ?;
138- #[ cfg( feature = "mcxa2xx" ) ]
139137 operator. configure_spll ( ) ?;
140138
141139 // Finally, setup main clock
@@ -307,7 +305,6 @@ unsafe fn restart_active_only_clocks(_cs: &CriticalSection) {
307305 }
308306
309307 // Ensure SOSC is up and running
310- #[ cfg( feature = "mcxa2xx" ) ]
311308 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
312309 if let Some ( clk_in) = clocks. clk_in . as_ref ( )
313310 && !matches ! ( clk_in. power, PoweredClock :: AlwaysEnabled )
@@ -316,7 +313,6 @@ unsafe fn restart_active_only_clocks(_cs: &CriticalSection) {
316313 }
317314
318315 // Ensure SPLL is up and running
319- #[ cfg( feature = "mcxa2xx" ) ]
320316 if let Some ( spll) = clocks. pll1_clk . as_ref ( )
321317 && !matches ! ( spll. power, PoweredClock :: AlwaysEnabled )
322318 {
@@ -401,7 +397,6 @@ pub struct Clocks {
401397
402398 /// The `clk_in` is a clock provided by an external oscillator
403399 /// AKA SOSC
404- #[ cfg( feature = "mcxa2xx" ) ]
405400 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
406401 pub clk_in : Option < Clock > ,
407402
@@ -493,11 +488,9 @@ pub struct Clocks {
493488 pub cpu_system_clk : Option < Clock > ,
494489
495490 /// `pll1_clk` is the output of the main system PLL, `pll1`.
496- #[ cfg( feature = "mcxa2xx" ) ]
497491 pub pll1_clk : Option < Clock > ,
498492
499493 /// `pll1_clk_div` is a configurable frequency clock, sourced from `pll1_clk`
500- #[ cfg( feature = "mcxa2xx" ) ]
501494 pub pll1_clk_div : Option < Clock > ,
502495}
503496
@@ -800,7 +793,6 @@ impl Clocks {
800793 }
801794
802795 /// Ensure the `clk_in` clock is active and valid at the given power state.
803- #[ cfg( feature = "mcxa2xx" ) ]
804796 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
805797 #[ inline]
806798 pub fn ensure_clk_in_active ( & self , at_level : & PoweredClock ) -> Result < u32 , ClockError > {
@@ -875,14 +867,12 @@ impl Clocks {
875867 }
876868
877869 /// Ensure the `pll1_clk` clock is active and valid at the given power state.
878- #[ cfg( feature = "mcxa2xx" ) ]
879870 #[ inline]
880871 pub fn ensure_pll1_clk_active ( & self , at_level : & PoweredClock ) -> Result < u32 , ClockError > {
881872 self . ensure_clock_active ( & self . pll1_clk , "pll1_clk" , at_level)
882873 }
883874
884875 /// Ensure the `pll1_clk_div` clock is active and valid at the given power state.
885- #[ cfg( feature = "mcxa2xx" ) ]
886876 #[ inline]
887877 pub fn ensure_pll1_clk_div_active ( & self , at_level : & PoweredClock ) -> Result < u32 , ClockError > {
888878 self . ensure_clock_active ( & self . pll1_clk_div , "pll1_clk_div" , at_level)
@@ -1576,7 +1566,6 @@ impl ClockOperator<'_> {
15761566 Ok ( ( ) )
15771567 }
15781568
1579- #[ cfg( feature = "mcxa2xx" ) ]
15801569 fn ensure_ldo_active ( & mut self , for_clock : & ' static str , for_power : & PoweredClock ) -> Result < ( ) , ClockError > {
15811570 let bg_good = match for_power {
15821571 PoweredClock :: NormalEnabledDeepSleepDisabled => self . clocks . bandgap_active ,
@@ -1607,7 +1596,6 @@ impl ClockOperator<'_> {
16071596 }
16081597
16091598 /// Configure the SOSC/clk_in oscillator
1610- #[ cfg( feature = "mcxa2xx" ) ]
16111599 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
16121600 fn configure_sosc ( & mut self ) -> Result < ( ) , ClockError > {
16131601 let Some ( parts) = self . config . sosc . as_ref ( ) else {
@@ -1712,7 +1700,6 @@ impl ClockOperator<'_> {
17121700 Ok ( ( ) )
17131701 }
17141702
1715- #[ cfg( feature = "mcxa2xx" ) ]
17161703 fn configure_spll ( & mut self ) -> Result < ( ) , ClockError > {
17171704 // # Vocab
17181705 //
@@ -1746,6 +1733,7 @@ impl ClockOperator<'_> {
17461733 . as_ref ( )
17471734 . map ( |c| ( c, Source :: SOSC ) )
17481735 . ok_or ( "sosc not active" ) ,
1736+ #[ cfg( feature = "mcxa2xx" ) ]
17491737 config:: SpllSource :: Firc => self
17501738 . clocks
17511739 . clk_45m
@@ -2091,7 +2079,6 @@ impl ClockOperator<'_> {
20912079
20922080 fn configure_main_clk ( & mut self ) -> Result < ( ) , ClockError > {
20932081 let ( var, name, clk) = match self . config . main_clock . source {
2094- #[ cfg( feature = "mcxa2xx" ) ]
20952082 #[ cfg( not( feature = "sosc-as-gpio" ) ) ]
20962083 MainClockSource :: SoscClkIn => ( Scs :: SOSC , "clk_in" , self . clocks . clk_in . as_ref ( ) ) ,
20972084 MainClockSource :: SircFro12M => ( Scs :: SIRC , "fro_12m" , self . clocks . fro_12m . as_ref ( ) ) ,
@@ -2101,7 +2088,6 @@ impl ClockOperator<'_> {
21012088 MainClockSource :: RoscFro16K => ( Scs :: ROSC , "fro16k" , self . clocks . clk_16k_vdd_core . as_ref ( ) ) ,
21022089 #[ cfg( all( feature = "mcxa5xx" , not( feature = "rosc-32k-as-gpio" ) ) ) ]
21032090 MainClockSource :: RoscOsc32K => ( Scs :: ROSC , "osc32k" , self . clocks . clk_32k_vdd_core . as_ref ( ) ) ,
2104- #[ cfg( feature = "mcxa2xx" ) ]
21052091 MainClockSource :: SPll1 => ( Scs :: SPLL , "pll1_clk" , self . clocks . pll1_clk . as_ref ( ) ) ,
21062092 } ;
21072093 let Some ( main_clk_src) = clk else {
0 commit comments