Skip to content

Commit 60cd83e

Browse files
sylvioalvesdanieldegrasse
authored andcommitted
clock: esp32c6: enable and calibrate digital regulators
Enable the RTC-domain and main digital regulators early in clock init, then load and program the factory/runtime calibrated bias values for high-power and low-power regulators into the PMU. This ensures the correct voltage/current settings for stable, low-noise clock operation in active, modem and sleep modes. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 061036f commit 60cd83e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/clock_control/clock_control_esp32.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,19 @@ static int esp32_cpu_clock_configure(const struct esp32_cpu_clock_config *cpu_cf
646646
REG_SET_FIELD(LP_CLKRST_FOSC_CNTL_REG, LP_CLKRST_FOSC_DFREQ, rtc_clk_cfg.clk_8m_dfreq);
647647
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_SCK_DCAP, rtc_clk_cfg.slow_clk_dcap);
648648
REG_SET_FIELD(LP_CLKRST_RC32K_CNTL_REG, LP_CLKRST_RC32K_DFREQ, rtc_clk_cfg.rc32k_dfreq);
649+
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_ENIF_RTC_DREG, 1);
650+
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_ENIF_DIG_DREG, 1);
651+
652+
uint32_t hp_cali_dbias = get_act_hp_dbias();
653+
uint32_t lp_cali_dbias = get_act_lp_dbias();
654+
655+
SET_PERI_REG_BITS(PMU_HP_ACTIVE_HP_REGULATOR0_REG, PMU_HP_ACTIVE_HP_REGULATOR_DBIAS,
656+
hp_cali_dbias, PMU_HP_ACTIVE_HP_REGULATOR_DBIAS_S);
657+
SET_PERI_REG_BITS(PMU_HP_MODEM_HP_REGULATOR0_REG, PMU_HP_MODEM_HP_REGULATOR_DBIAS,
658+
hp_cali_dbias, PMU_HP_MODEM_HP_REGULATOR_DBIAS_S);
659+
SET_PERI_REG_BITS(PMU_HP_SLEEP_LP_REGULATOR0_REG, PMU_HP_SLEEP_LP_REGULATOR_DBIAS,
660+
lp_cali_dbias, PMU_HP_SLEEP_LP_REGULATOR_DBIAS_S);
661+
649662
#else
650663
REG_SET_FIELD(RTC_CNTL_REG, RTC_CNTL_SCK_DCAP, rtc_clk_cfg.slow_clk_dcap);
651664
REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_CK8M_DFREQ, rtc_clk_cfg.clk_8m_dfreq);
@@ -655,6 +668,9 @@ static int esp32_cpu_clock_configure(const struct esp32_cpu_clock_config *cpu_cf
655668
REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_CK8M_DIV_SEL, rtc_clk_cfg.clk_8m_div - 1);
656669
#elif defined(CONFIG_SOC_SERIES_ESP32C6)
657670
clk_ll_rc_fast_tick_conf();
671+
672+
esp_rom_uart_tx_wait_idle(0);
673+
rtc_clk_xtal_freq_update(rtc_clk_cfg.xtal_freq);
658674
#else
659675
/* Configure 150k clock division */
660676
rtc_clk_divider_set(rtc_clk_cfg.clk_rtc_clk_div);

0 commit comments

Comments
 (0)