modules: hal_silabs: Simplify HFRCO frequency selection

Recent versions of the HAL rely on interpreting the HFRCO frequency
selection as a plain integer in preprocessor comparisons. The
adaptation layer in Zephyr created a C expression that was not
possible to evaluate by the preprocessor. Simplify the logic to
directly passing the devicetree value to the driver.

This slightly changes the behavior of the code by no longer accepting
arbitrary frequencies and mapping them to the closest HFRCO band.
However, the binding documentation already states that the frequency
should match the band.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
This commit is contained in:
Aksel Skauge Mellbye
2025-11-05 10:42:38 +01:00
committed by Chris Friedt
parent e6cb52e8a5
commit 28edc26cc0

View File

@@ -29,22 +29,7 @@
(DT_ENUM_IDX(DT_NODELABEL(lfxo), timeout) << _LFXO_CFG_TIMEOUT_SHIFT)
/* HFRCODPLL */
#define SL_CLOCK_MANAGER_HFRCO_BAND \
(DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 1500000 ? 1000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 3000000 ? 2000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 5500000 ? 4000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 10000000 ? 7000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 14500000 ? 13000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 17500000 ? 16000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 23000000 ? 19000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 29000000 ? 26000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 35000000 ? 32000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 44000000 ? 38000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 52000000 ? 48000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 60000000 ? 56000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 72000000 ? 64000000U \
: DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency) < 90000000 ? 80000000U \
: 100000000U)
#define SL_CLOCK_MANAGER_HFRCO_BAND DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency)
#define SL_CLOCK_MANAGER_HFRCO_DPLL_EN DT_NUM_CLOCKS(DT_NODELABEL(hfrcodpll))
#define SL_CLOCK_MANAGER_DPLL_FREQ DT_PROP(DT_NODELABEL(hfrcodpll), clock_frequency)
#define SL_CLOCK_MANAGER_DPLL_N DT_PROP(DT_NODELABEL(hfrcodpll), dpll_n)