Skip to content

Commit 0d419e6

Browse files
mhennerichnunojsa
authored andcommitted
iio: hmc7044: Add debug options to bypass VCO limits and force R2 = 1
This patch introduces two new device tree properties for debugging and special synchronization scenarios: - adi,ignore-vco-limits: Allows bypassing the PLL2 frequency range check. This is intended for debug purposes only and may lead to instability across process, voltage, and temperature variations. - adi,sync-through-pll2-force-r2-eq-1: Forces R2 divider to 1 during PLL2 calculations. This can be useful in specific sync tree configurations requiring deterministic behavior. Both options are guarded and default to disabled to ensure safe operation in production environments. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
1 parent 26f5457 commit 0d419e6

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

drivers/iio/frequency/hmc7044.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ struct hmc7044 {
338338
bool is_sysref_provider;
339339
bool hmc_two_level_tree_sync_en;
340340
bool read_write_confirmed;
341+
bool ignore_vco_limits; /* Debug only, is at own risk! */
342+
bool sync_through_pll2_force_r2_eq_1;
341343
};
342344

343345
static const char * const hmc7044_input_clk_names[] = {
@@ -1010,8 +1012,20 @@ static int hmc7044_setup(struct iio_dev *indio_dev)
10101012
hmc->pll1_pfd = pfd1_freq;
10111013

10121014
if (pll2_freq < HMC7044_LOW_VCO_MIN ||
1013-
pll2_freq > HMC7044_HIGH_VCO_MAX)
1014-
return -EINVAL;
1015+
pll2_freq > HMC7044_HIGH_VCO_MAX) {
1016+
if (hmc->ignore_vco_limits) {
1017+
/* Debug only, is at own risk! May fail across process, voltage and temperature */
1018+
dev_warn(&hmc->spi->dev,
1019+
"PLL2 frequency %lu kHz is out of range, "
1020+
"ignoring limits\n", pll2_freq);
1021+
} else {
1022+
dev_err(&hmc->spi->dev,
1023+
"PLL2 frequency %lu kHz is out of range (%u - %u)\n",
1024+
pll2_freq, HMC7044_LOW_VCO_MIN / 1000,
1025+
HMC7044_HIGH_VCO_MAX / 1000);
1026+
return -EINVAL;
1027+
}
1028+
}
10151029

10161030
vco_limit = (HMC7044_LOW_VCO_MAX + HMC7044_HIGH_VCO_MIN) / 2;
10171031
if (pll2_freq >= vco_limit)
@@ -1022,12 +1036,14 @@ static int hmc7044_setup(struct iio_dev *indio_dev)
10221036
/* fVCO / N2 = fVCXO * doubler / R2 */
10231037
pll2_freq_doubler_en = true;
10241038
rational_best_approximation(pll2_freq, vcxo_freq * 2,
1025-
HMC7044_N2_MAX, HMC7044_R2_MAX,
1039+
HMC7044_N2_MAX,
1040+
hmc->sync_through_pll2_force_r2_eq_1 ? 1 : HMC7044_R2_MAX,
10261041
&n2[0], &r2[0]);
10271042

10281043
if (pll2_freq != vcxo_freq * n2[0] / r2[0]) {
10291044
rational_best_approximation(pll2_freq, vcxo_freq,
1030-
HMC7044_N2_MAX, HMC7044_R2_MAX,
1045+
HMC7044_N2_MAX,
1046+
hmc->sync_through_pll2_force_r2_eq_1 ? 1 : HMC7044_R2_MAX,
10311047
&n2[1], &r2[1]);
10321048

10331049
if (abs((int)pll2_freq - (int)(vcxo_freq * 2 * n2[0] / r2[0])) >
@@ -1677,6 +1693,10 @@ static int hmc7044_parse_dt(struct device *dev,
16771693

16781694
hmc->clkin1_vcoin_en =
16791695
of_property_read_bool(np, "adi,clkin1-vco-in-enable");
1696+
1697+
hmc->ignore_vco_limits = of_property_read_bool(np, "adi,ignore-vco-limits");
1698+
hmc->sync_through_pll2_force_r2_eq_1 =
1699+
of_property_read_bool(np, "adi,sync-through-pll2-force-r2-eq-1");
16801700
} else {
16811701
ret = of_property_read_u32_array(np, "adi,gpi-controls",
16821702
hmc->gpi_ctrl, 1);

0 commit comments

Comments
 (0)