* [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode
2025-01-20 11:34 [PATCH v5 0/3] ADF4371 refin mode and doubler support Antoniu Miclaus
@ 2025-01-20 11:34 ` Antoniu Miclaus
2025-01-21 17:35 ` Conor Dooley
2025-01-20 11:34 ` [PATCH v5 2/3] iio: frequency: " Antoniu Miclaus
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Antoniu Miclaus @ 2025-01-20 11:34 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus
Add support for selecting between single-ended and differential
reference input.
Input frequency boundaries are change based on the mode selected
(single-ended/differential).
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v5:
- drop default description/option.
Documentation/devicetree/bindings/iio/frequency/adf4371.yaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
index 1cb2adaf66f9..53d607441612 100644
--- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
+++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
@@ -30,8 +30,9 @@ properties:
clock-names:
description:
- Must be "clkin"
- maxItems: 1
+ Must be "clkin" if the input reference is single ended or "clkin-diff"
+ if the input reference is differential.
+ enum: [clkin, clkin-diff]
adi,mute-till-lock-en:
type: boolean
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode
2025-01-20 11:34 ` [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode Antoniu Miclaus
@ 2025-01-21 17:35 ` Conor Dooley
0 siblings, 0 replies; 6+ messages in thread
From: Conor Dooley @ 2025-01-21 17:35 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
On Mon, Jan 20, 2025 at 01:34:02PM +0200, Antoniu Miclaus wrote:
> Add support for selecting between single-ended and differential
> reference input.
>
> Input frequency boundaries are change based on the mode selected
> (single-ended/differential).
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 2/3] iio: frequency: adf4371: add refin mode
2025-01-20 11:34 [PATCH v5 0/3] ADF4371 refin mode and doubler support Antoniu Miclaus
2025-01-20 11:34 ` [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode Antoniu Miclaus
@ 2025-01-20 11:34 ` Antoniu Miclaus
2025-01-20 11:34 ` [PATCH v5 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
2025-01-25 12:39 ` [PATCH v5 0/3] ADF4371 refin mode and doubler support Jonathan Cameron
3 siblings, 0 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2025-01-20 11:34 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus, Nuno Sa
Add support for single-ended/differential reference input mode.
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
no changes in v5.
drivers/iio/frequency/adf4371.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c
index b27088464826..50450e7b5464 100644
--- a/drivers/iio/frequency/adf4371.c
+++ b/drivers/iio/frequency/adf4371.c
@@ -41,6 +41,10 @@
#define ADF4371_MOD2WORD_MSK GENMASK(5, 0)
#define ADF4371_MOD2WORD(x) FIELD_PREP(ADF4371_MOD2WORD_MSK, x)
+/* ADF4371_REG22 */
+#define ADF4371_REFIN_MODE_MASK BIT(6)
+#define ADF4371_REFIN_MODE(x) FIELD_PREP(ADF4371_REFIN_MODE_MASK, x)
+
/* ADF4371_REG24 */
#define ADF4371_RF_DIV_SEL_MSK GENMASK(6, 4)
#define ADF4371_RF_DIV_SEL(x) FIELD_PREP(ADF4371_RF_DIV_SEL_MSK, x)
@@ -69,6 +73,7 @@
#define ADF4371_MAX_FREQ_PFD 250000000UL /* Hz */
#define ADF4371_MAX_FREQ_REFIN 600000000UL /* Hz */
+#define ADF4371_MAX_FREQ_REFIN_SE 500000000UL /* Hz */
/* MOD1 is a 24-bit primary modulus with fixed value of 2^25 */
#define ADF4371_MODULUS1 33554432ULL
@@ -175,6 +180,7 @@ struct adf4371_state {
unsigned int mod2;
unsigned int rf_div_sel;
unsigned int ref_div_factor;
+ bool ref_diff_en;
u8 buf[10] __aligned(IIO_DMA_MINALIGN);
};
@@ -503,6 +509,17 @@ static int adf4371_setup(struct adf4371_state *st)
ADF4371_ADDR_ASC(1) | ADF4371_ADDR_ASC_R(1));
if (ret < 0)
return ret;
+
+ if ((st->ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN) ||
+ (!st->ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN_SE))
+ return -EINVAL;
+
+ ret = regmap_update_bits(st->regmap, ADF4371_REG(0x22),
+ ADF4371_REFIN_MODE_MASK,
+ ADF4371_REFIN_MODE(st->ref_diff_en));
+ if (ret < 0)
+ return ret;
+
/*
* Calculate and maximize PFD frequency
* fPFD = REFIN × ((1 + D)/(R × (1 + T)))
@@ -572,9 +589,16 @@ static int adf4371_probe(struct spi_device *spi)
indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels;
+ st->ref_diff_en = false;
+
st->clkin = devm_clk_get_enabled(&spi->dev, "clkin");
- if (IS_ERR(st->clkin))
- return PTR_ERR(st->clkin);
+ if (IS_ERR(st->clkin)) {
+ st->clkin = devm_clk_get_enabled(&spi->dev, "clkin-diff");
+ if (IS_ERR(st->clkin))
+ return PTR_ERR(st->clkin);
+
+ st->ref_diff_en = true;
+ }
st->clkin_freq = clk_get_rate(st->clkin);
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v5 3/3] iio: frequency: adf4371: add ref doubler
2025-01-20 11:34 [PATCH v5 0/3] ADF4371 refin mode and doubler support Antoniu Miclaus
2025-01-20 11:34 ` [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode Antoniu Miclaus
2025-01-20 11:34 ` [PATCH v5 2/3] iio: frequency: " Antoniu Miclaus
@ 2025-01-20 11:34 ` Antoniu Miclaus
2025-01-25 12:39 ` [PATCH v5 0/3] ADF4371 refin mode and doubler support Jonathan Cameron
3 siblings, 0 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2025-01-20 11:34 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus, Nuno Sa
Add support for the reference doubler.
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
no changes in v5.
drivers/iio/frequency/adf4371.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c
index 50450e7b5464..a57fc24a6799 100644
--- a/drivers/iio/frequency/adf4371.c
+++ b/drivers/iio/frequency/adf4371.c
@@ -44,6 +44,8 @@
/* ADF4371_REG22 */
#define ADF4371_REFIN_MODE_MASK BIT(6)
#define ADF4371_REFIN_MODE(x) FIELD_PREP(ADF4371_REFIN_MODE_MASK, x)
+#define ADF4371_REF_DOUB_MASK BIT(5)
+#define ADF4371_REF_DOUB(x) FIELD_PREP(ADF4371_REF_DOUB_MASK, x)\
/* ADF4371_REG24 */
#define ADF4371_RF_DIV_SEL_MSK GENMASK(6, 4)
@@ -75,6 +77,9 @@
#define ADF4371_MAX_FREQ_REFIN 600000000UL /* Hz */
#define ADF4371_MAX_FREQ_REFIN_SE 500000000UL /* Hz */
+#define ADF4371_MIN_CLKIN_DOUB_FREQ 10000000ULL /* Hz */
+#define ADF4371_MAX_CLKIN_DOUB_FREQ 125000000ULL /* Hz */
+
/* MOD1 is a 24-bit primary modulus with fixed value of 2^25 */
#define ADF4371_MODULUS1 33554432ULL
/* MOD2 is the programmable, 14-bit auxiliary fractional modulus */
@@ -481,7 +486,7 @@ static const struct iio_info adf4371_info = {
static int adf4371_setup(struct adf4371_state *st)
{
unsigned int synth_timeout = 2, timeout = 1, vco_alc_timeout = 1;
- unsigned int vco_band_div, tmp;
+ unsigned int vco_band_div, tmp, ref_doubler_en = 0;
int ret;
/* Perform a software reset */
@@ -514,8 +519,14 @@ static int adf4371_setup(struct adf4371_state *st)
(!st->ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN_SE))
return -EINVAL;
+ if (st->clkin_freq < ADF4371_MAX_CLKIN_DOUB_FREQ &&
+ st->clkin_freq > ADF4371_MIN_CLKIN_DOUB_FREQ)
+ ref_doubler_en = 1;
+
ret = regmap_update_bits(st->regmap, ADF4371_REG(0x22),
+ ADF4371_REF_DOUB_MASK |
ADF4371_REFIN_MODE_MASK,
+ ADF4371_REF_DOUB(ref_doubler_en) |
ADF4371_REFIN_MODE(st->ref_diff_en));
if (ret < 0)
return ret;
@@ -529,7 +540,8 @@ static int adf4371_setup(struct adf4371_state *st)
*/
do {
st->ref_div_factor++;
- st->fpfd = st->clkin_freq / st->ref_div_factor;
+ st->fpfd = st->clkin_freq * (1 + ref_doubler_en) /
+ st->ref_div_factor;
} while (st->fpfd > ADF4371_MAX_FREQ_PFD);
/* Calculate Timeouts */
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v5 0/3] ADF4371 refin mode and doubler support
2025-01-20 11:34 [PATCH v5 0/3] ADF4371 refin mode and doubler support Antoniu Miclaus
` (2 preceding siblings ...)
2025-01-20 11:34 ` [PATCH v5 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
@ 2025-01-25 12:39 ` Jonathan Cameron
3 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-01-25 12:39 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: robh, conor+dt, linux-iio, devicetree, linux-kernel, linux-pwm
On Mon, 20 Jan 2025 13:34:01 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> Add support for selecting between single-ended and differential
> reference input. By default the single-ended input is enabled.
>
> Input frequency boundaries are change based on the mode selected
> (single-ended/differential).
>
> Add support for the reference doubler. This feature is enabled
> automatically to improve noise performance if the input frequency
> is within the accepted range.
>
> Antoniu Miclaus (3):
> dt-bindings: iio: adf4371: add refin mode
> iio: frequency: adf4371: add refin mode
> iio: frequency: adf4371: add ref doubler
Hi Antoniu
This needs a rebase as there was some recent cleanup from Nuno of
the driver so your set doesn't apply.
Thanks,
Jonathan
>
> .../bindings/iio/frequency/adf4371.yaml | 5 ++-
> drivers/iio/frequency/adf4371.c | 44 +++++++++++++++++--
> 2 files changed, 43 insertions(+), 6 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread