@@ -45,6 +45,7 @@ pub(crate) enum CpuClock {
4545impl CpuClock {
4646 pub ( crate ) fn configure ( self ) {
4747 // Resolve presets
48+ // TODO: set some defaults to RTC clocks
4849 let mut config = match self {
4950 CpuClock :: _80MHz => ClockConfig {
5051 xtl_clk : None ,
@@ -102,12 +103,12 @@ fn detect_xtal_freq(clocks: &mut ClockTree) -> XtlClkConfig {
102103
103104 // Just an assumption for things to not panic.
104105 configure_xtl_clk ( clocks, XtlClkConfig :: _40) ;
106+ // TIMG0 counter is clocked from the APB clock, make sure APB_CLK == XTL_CLK
105107 configure_syscon_pre_div ( clocks, SysconPreDivConfig ( 0 ) ) ;
106108 configure_cpu_clk ( clocks, CpuClkConfig :: Xtal ) ;
107109
108- // Without the peripheral clock, we can't write peripheral registers.
109- configure_timg0_peripheral_clock ( clocks, Timg0PeripheralClockConfig :: ApbClk ) ;
110- request_timg0_peripheral_clock ( clocks) ;
110+ // By default the TIMG0 bus clock is running. Do not create a peripehral guard as dropping it
111+ // would reset the timer, and it would enable its WDT.
111112
112113 // Make sure the process doesn't time out due to some spooky configuration.
113114 #[ cfg( not( esp32) ) ]
@@ -146,7 +147,6 @@ fn detect_xtal_freq(clocks: &mut ClockTree) -> XtlClkConfig {
146147 . rtccalicfg ( )
147148 . modify ( |_, w| w. rtc_cali_start ( ) . clear_bit ( ) ) ;
148149 release_timg0_calibration_clock ( clocks) ;
149- release_timg0_peripheral_clock ( clocks) ;
150150
151151 let mhz = ( cali_value * ( calibration_clock_frequency / SLOW_CLOCK_CYCLES ) ) / 1_000_000 ;
152152 if mhz. abs_diff ( 40 ) < mhz. abs_diff ( 26 ) {
@@ -462,10 +462,10 @@ fn configure_cpu_clk_impl(
462462 ets_update_cpu_frequency_rom ( cpu_freq. as_mhz ( ) ) ;
463463
464464 let apb_freq = Rate :: from_hz ( apb_clk_frequency ( clocks) ) ;
465- update_cpu_frequency ( apb_freq) ;
465+ update_apb_frequency ( apb_freq) ;
466466}
467467
468- fn update_cpu_frequency ( freq : Rate ) {
468+ fn update_apb_frequency ( freq : Rate ) {
469469 let freq_shifted = ( freq. as_hz ( ) >> 12 ) & 0xFFFF ;
470470 let value = freq_shifted | ( freq_shifted << 16 ) ;
471471 LPWR :: regs ( )
@@ -567,19 +567,6 @@ fn configure_rtc_fast_clk_impl(
567567 } ) ;
568568}
569569
570- fn enable_timg0_peripheral_clock_impl ( _clocks : & mut ClockTree , _en : bool ) {
571- // TODO: currently managed by PeripheralClockControl. Perhaps these function impls should be
572- // generated?
573- }
574-
575- fn configure_timg0_peripheral_clock_impl (
576- _clocks : & mut ClockTree ,
577- _old_selector : Option < Timg0PeripheralClockConfig > ,
578- _new_selector : Timg0PeripheralClockConfig ,
579- ) {
580- // TIMG on ESP32 can only use a single clock source, it doesn't need to be configured.
581- }
582-
583570fn enable_timg0_calibration_clock_impl ( _clocks : & mut ClockTree , _en : bool ) {
584571 // Nothing to do, calibration clocks can only be selected. They are gated by the CALI_START bit,
585572 // which is managed by the calibration process.
@@ -605,19 +592,6 @@ fn configure_timg0_calibration_clock_impl(
605592 . modify ( |_, w| unsafe { w. rtc_cali_clk_sel ( ) . bits ( new_selector. cali_clk_sel_bits ( ) ) } ) ;
606593}
607594
608- fn enable_timg1_peripheral_clock_impl ( _clocks : & mut ClockTree , _en : bool ) {
609- // TODO: currently managed by PeripheralClockControl. Perhaps these function impls should be
610- // generated?
611- }
612-
613- fn configure_timg1_peripheral_clock_impl (
614- _clocks : & mut ClockTree ,
615- _old_selector : Option < Timg0PeripheralClockConfig > ,
616- _new_selector : Timg0PeripheralClockConfig ,
617- ) {
618- // TIMG on ESP32 can only use a single clock source, it doesn't need to be configured.
619- }
620-
621595fn enable_timg1_calibration_clock_impl ( _clocks : & mut ClockTree , _en : bool ) {
622596 // Nothing to do, calibration clocks can only be selected. They are gated by the CALI_START bit,
623597 // which is managed by the calibration process.
0 commit comments