diff --git a/drivers/clock_control/clock_control_silabs_siwx91x.c b/drivers/clock_control/clock_control_silabs_siwx91x.c index 477aaebf02c..f91d5b5fc72 100644 --- a/drivers/clock_control/clock_control_silabs_siwx91x.c +++ b/drivers/clock_control/clock_control_silabs_siwx91x.c @@ -14,6 +14,7 @@ #include "rsi_rom_clks.h" #include "rsi_sysrtc.h" #include "rsi_pll.h" +#include "rsi_adc.h" #include "clock_update.h" #include "sl_si91x_clock_manager.h" @@ -103,6 +104,9 @@ static int siwx91x_clock_on(const struct device *dev, clock_control_subsys_t sys ULPCLK->ULP_I2S_CLK_GEN_REG_b.ULP_I2S_MASTER_SLAVE_MODE_b = 1; RSI_ULPSS_PeripheralEnable(ULPCLK, ULP_I2S_CLK, ENABLE_STATIC_CLK); break; + case SIWX91X_ADC_CLK: + RSI_ADC_PowerControl(ADC_POWER_ON); + break; default: return -EINVAL; } @@ -138,6 +142,9 @@ static int siwx91x_clock_off(const struct device *dev, clock_control_subsys_t sy case SIWX91X_CLK_STATIC_ULP_I2S: RSI_ULPSS_PeripheralDisable(ULPCLK, ULP_I2S_CLK); break; + case SIWX91X_ADC_CLK: + RSI_ADC_PowerControl(ADC_POWER_OFF); + break; case SIWX91X_CLK_ULP_UART: case SIWX91X_CLK_I2C0: case SIWX91X_CLK_I2C1: @@ -185,6 +192,9 @@ static int siwx91x_clock_get_rate(const struct device *dev, clock_control_subsys static int siwx91x_clock_set_rate(const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate) { + ARG_UNUSED(dev); + int div_numerator = FIELD_GET(0xFFFF0000, *(uint32_t *)rate); + int div_denominator = FIELD_GET(0x0000FFFF, *(uint32_t *)rate); uintptr_t clockid = (uintptr_t)sys; ULP_I2S_CLK_SELECT_T ref_clk; uint32_t freq; @@ -203,6 +213,9 @@ static int siwx91x_clock_set_rate(const struct device *dev, clock_control_subsys return -EIO; } return 0; + case SIWX91X_ADC_CLK: + RSI_ADC_ClkDivfactor(AUX_ADC_DAC_COMP, div_numerator, div_denominator); + return 0; default: /* For now, no other driver need clock rate */ return -EINVAL; diff --git a/include/zephyr/dt-bindings/clock/silabs/siwx91x-clock.h b/include/zephyr/dt-bindings/clock/silabs/siwx91x-clock.h index b09eceb3c83..1bd454b53f5 100644 --- a/include/zephyr/dt-bindings/clock/silabs/siwx91x-clock.h +++ b/include/zephyr/dt-bindings/clock/silabs/siwx91x-clock.h @@ -21,5 +21,6 @@ #define SIWX91X_CLK_STATIC_I2S0 14 #define SIWX91X_CLK_ULP_I2S 15 #define SIWX91X_CLK_STATIC_ULP_I2S 16 +#define SIWX91X_ADC_CLK 17 #endif