* [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref
@ 2024-12-09 10:41 Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 2/3] iio: frequency: " Antoniu Miclaus
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2024-12-09 10:41 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus
Add support for enabling differential input reference.
By default the single-ended input is enabled.
Input frequency boundaries are change based on the mode selected
(single-ended/differential).
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v2:
- improve commit body.
Documentation/devicetree/bindings/iio/frequency/adf4371.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
index 1cb2adaf66f9..dd9a592d0026 100644
--- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
+++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
@@ -40,6 +40,11 @@ properties:
output stage will shut down until the ADF4371/ADF4372 achieves lock as
measured by the digital lock detect circuitry.
+ adi,ref-differential-enable:
+ type: boolean
+ description:
+ If this property is present, differential input reference is enabled.
+
required:
- compatible
- reg
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] iio: frequency: adf4371: add differential ref
2024-12-09 10:41 [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Antoniu Miclaus
@ 2024-12-09 10:41 ` Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
2024-12-15 12:35 ` [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2024-12-09 10:41 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus
Add support for differential input reference clock.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
no changes in v2.
drivers/iio/frequency/adf4371.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c
index b27088464826..55bee06fb42d 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
@@ -476,6 +481,7 @@ 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;
+ bool ref_diff_en;
int ret;
/* Perform a software reset */
@@ -497,12 +503,25 @@ static int adf4371_setup(struct adf4371_state *st)
return ret;
}
+ ref_diff_en = device_property_read_bool(&st->spi->dev, "adi,ref-differential-enable");
+
/* Set address in ascending order, so the bulk_write() will work */
ret = regmap_update_bits(st->regmap, ADF4371_REG(0x0),
ADF4371_ADDR_ASC_MSK | ADF4371_ADDR_ASC_R_MSK,
ADF4371_ADDR_ASC(1) | ADF4371_ADDR_ASC_R(1));
if (ret < 0)
return ret;
+
+ if ((ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN) ||
+ (!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(ref_diff_en));
+ if (ret < 0)
+ return ret;
+
/*
* Calculate and maximize PFD frequency
* fPFD = REFIN × ((1 + D)/(R × (1 + T)))
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler
2024-12-09 10:41 [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 2/3] iio: frequency: " Antoniu Miclaus
@ 2024-12-09 10:41 ` Antoniu Miclaus
2024-12-19 11:28 ` Dan Carpenter
2024-12-15 12:35 ` [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Jonathan Cameron
2 siblings, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2024-12-09 10:41 UTC (permalink / raw)
To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel,
linux-pwm
Cc: Antoniu Miclaus
Add support for the reference doubler.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v2:
- drop redundant brackets.
drivers/iio/frequency/adf4371.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c
index 55bee06fb42d..fd33a6f1cd9a 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 */
@@ -480,7 +485,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;
bool ref_diff_en;
int ret;
@@ -516,6 +521,10 @@ static int adf4371_setup(struct adf4371_state *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_REFIN_MODE_MASK,
ADF4371_REFIN_MODE(ref_diff_en));
@@ -531,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.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref
2024-12-09 10:41 [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 2/3] iio: frequency: " Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
@ 2024-12-15 12:35 ` Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-12-15 12:35 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: robh, conor+dt, linux-iio, devicetree, linux-kernel, linux-pwm
On Mon, 9 Dec 2024 12:41:31 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> Add support for enabling differential input reference.
>
> By default the single-ended input is enabled.
>
> Input frequency boundaries are change based on the mode selected
> (single-ended/differential).
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
> changes in v2:
> - improve commit body.
It still has the same question I raised on v1. Why is this not
selecting between what I think is two different clocks given they
are wired to either one pin or two.
refin, refin-diff
Please add a cover letter to all series of more than 1 patch as it
gives a place for general explanations and discussion.
Thanks,
Jonathan
> Documentation/devicetree/bindings/iio/frequency/adf4371.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
> index 1cb2adaf66f9..dd9a592d0026 100644
> --- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
> +++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml
> @@ -40,6 +40,11 @@ properties:
> output stage will shut down until the ADF4371/ADF4372 achieves lock as
> measured by the digital lock detect circuitry.
>
> + adi,ref-differential-enable:
> + type: boolean
> + description:
> + If this property is present, differential input reference is enabled.
> +
> required:
> - compatible
> - reg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler
2024-12-09 10:41 ` [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
@ 2024-12-19 11:28 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2024-12-19 11:28 UTC (permalink / raw)
To: oe-kbuild, Antoniu Miclaus, jic23, robh, conor+dt, linux-iio,
devicetree, linux-kernel, linux-pwm
Cc: lkp, oe-kbuild-all, Antoniu Miclaus
Hi Antoniu,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Antoniu-Miclaus/iio-frequency-adf4371-add-differential-ref/20241209-184437
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20241209104201.25205-3-antoniu.miclaus%40analog.com
patch subject: [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler
config: parisc-randconfig-r073-20241219 (https://download.01.org/0day-ci/archive/20241219/202412191811.lAia02sc-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202412191811.lAia02sc-lkp@intel.com/
smatch warnings:
drivers/iio/frequency/adf4371.c:545 adf4371_setup() error: uninitialized symbol 'ref_doubler_en'.
vim +/ref_doubler_en +545 drivers/iio/frequency/adf4371.c
7f699bd14913423 Stefan Popa 2019-06-04 487 static int adf4371_setup(struct adf4371_state *st)
7f699bd14913423 Stefan Popa 2019-06-04 488 {
7f699bd14913423 Stefan Popa 2019-06-04 489 unsigned int synth_timeout = 2, timeout = 1, vco_alc_timeout = 1;
347e385fdd6ecda Antoniu Miclaus 2024-12-09 490 unsigned int vco_band_div, tmp, ref_doubler_en;
011032df594999f Antoniu Miclaus 2024-12-09 491 bool ref_diff_en;
7f699bd14913423 Stefan Popa 2019-06-04 492 int ret;
7f699bd14913423 Stefan Popa 2019-06-04 493
7f699bd14913423 Stefan Popa 2019-06-04 494 /* Perform a software reset */
7f699bd14913423 Stefan Popa 2019-06-04 495 ret = regmap_write(st->regmap, ADF4371_REG(0x0), ADF4371_RESET_CMD);
7f699bd14913423 Stefan Popa 2019-06-04 496 if (ret < 0)
7f699bd14913423 Stefan Popa 2019-06-04 497 return ret;
7f699bd14913423 Stefan Popa 2019-06-04 498
7f699bd14913423 Stefan Popa 2019-06-04 499 ret = regmap_multi_reg_write(st->regmap, adf4371_reg_defaults,
7f699bd14913423 Stefan Popa 2019-06-04 500 ARRAY_SIZE(adf4371_reg_defaults));
7f699bd14913423 Stefan Popa 2019-06-04 501 if (ret < 0)
7f699bd14913423 Stefan Popa 2019-06-04 502 return ret;
7f699bd14913423 Stefan Popa 2019-06-04 503
def914a4c3899b6 Stefan Popa 2019-06-24 504 /* Mute to Lock Detect */
def914a4c3899b6 Stefan Popa 2019-06-24 505 if (device_property_read_bool(&st->spi->dev, "adi,mute-till-lock-en")) {
def914a4c3899b6 Stefan Popa 2019-06-24 506 ret = regmap_update_bits(st->regmap, ADF4371_REG(0x25),
def914a4c3899b6 Stefan Popa 2019-06-24 507 ADF4371_MUTE_LD_MSK,
def914a4c3899b6 Stefan Popa 2019-06-24 508 ADF4371_MUTE_LD(1));
def914a4c3899b6 Stefan Popa 2019-06-24 509 if (ret < 0)
def914a4c3899b6 Stefan Popa 2019-06-24 510 return ret;
def914a4c3899b6 Stefan Popa 2019-06-24 511 }
def914a4c3899b6 Stefan Popa 2019-06-24 512
011032df594999f Antoniu Miclaus 2024-12-09 513 ref_diff_en = device_property_read_bool(&st->spi->dev, "adi,ref-differential-enable");
011032df594999f Antoniu Miclaus 2024-12-09 514
7f699bd14913423 Stefan Popa 2019-06-04 515 /* Set address in ascending order, so the bulk_write() will work */
7f699bd14913423 Stefan Popa 2019-06-04 516 ret = regmap_update_bits(st->regmap, ADF4371_REG(0x0),
7f699bd14913423 Stefan Popa 2019-06-04 517 ADF4371_ADDR_ASC_MSK | ADF4371_ADDR_ASC_R_MSK,
7f699bd14913423 Stefan Popa 2019-06-04 518 ADF4371_ADDR_ASC(1) | ADF4371_ADDR_ASC_R(1));
7f699bd14913423 Stefan Popa 2019-06-04 519 if (ret < 0)
7f699bd14913423 Stefan Popa 2019-06-04 520 return ret;
011032df594999f Antoniu Miclaus 2024-12-09 521
011032df594999f Antoniu Miclaus 2024-12-09 522 if ((ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN) ||
011032df594999f Antoniu Miclaus 2024-12-09 523 (!ref_diff_en && st->clkin_freq > ADF4371_MAX_FREQ_REFIN_SE))
011032df594999f Antoniu Miclaus 2024-12-09 524 return -EINVAL;
011032df594999f Antoniu Miclaus 2024-12-09 525
347e385fdd6ecda Antoniu Miclaus 2024-12-09 526 if (st->clkin_freq < ADF4371_MAX_CLKIN_DOUB_FREQ &&
347e385fdd6ecda Antoniu Miclaus 2024-12-09 527 st->clkin_freq > ADF4371_MIN_CLKIN_DOUB_FREQ)
347e385fdd6ecda Antoniu Miclaus 2024-12-09 528 ref_doubler_en = 1;
Uninitialized on else path.
347e385fdd6ecda Antoniu Miclaus 2024-12-09 529
011032df594999f Antoniu Miclaus 2024-12-09 530 ret = regmap_update_bits(st->regmap, ADF4371_REG(0x22),
011032df594999f Antoniu Miclaus 2024-12-09 531 ADF4371_REFIN_MODE_MASK,
011032df594999f Antoniu Miclaus 2024-12-09 532 ADF4371_REFIN_MODE(ref_diff_en));
011032df594999f Antoniu Miclaus 2024-12-09 533 if (ret < 0)
011032df594999f Antoniu Miclaus 2024-12-09 534 return ret;
011032df594999f Antoniu Miclaus 2024-12-09 535
7f699bd14913423 Stefan Popa 2019-06-04 536 /*
7f699bd14913423 Stefan Popa 2019-06-04 537 * Calculate and maximize PFD frequency
7f699bd14913423 Stefan Popa 2019-06-04 538 * fPFD = REFIN × ((1 + D)/(R × (1 + T)))
7f699bd14913423 Stefan Popa 2019-06-04 539 * Where D is the REFIN doubler bit, T is the reference divide by 2,
7f699bd14913423 Stefan Popa 2019-06-04 540 * R is the reference division factor
7f699bd14913423 Stefan Popa 2019-06-04 541 * TODO: it is assumed D and T equal 0.
7f699bd14913423 Stefan Popa 2019-06-04 542 */
7f699bd14913423 Stefan Popa 2019-06-04 543 do {
7f699bd14913423 Stefan Popa 2019-06-04 544 st->ref_div_factor++;
347e385fdd6ecda Antoniu Miclaus 2024-12-09 @545 st->fpfd = st->clkin_freq * (1 + ref_doubler_en) /
347e385fdd6ecda Antoniu Miclaus 2024-12-09 546 st->ref_div_factor;
7f699bd14913423 Stefan Popa 2019-06-04 547 } while (st->fpfd > ADF4371_MAX_FREQ_PFD);
7f699bd14913423 Stefan Popa 2019-06-04 548
7f699bd14913423 Stefan Popa 2019-06-04 549 /* Calculate Timeouts */
7f699bd14913423 Stefan Popa 2019-06-04 550 vco_band_div = DIV_ROUND_UP(st->fpfd, 2400000U);
7f699bd14913423 Stefan Popa 2019-06-04 551
7f699bd14913423 Stefan Popa 2019-06-04 552 tmp = DIV_ROUND_CLOSEST(st->fpfd, 1000000U);
7f699bd14913423 Stefan Popa 2019-06-04 553 do {
7f699bd14913423 Stefan Popa 2019-06-04 554 timeout++;
7f699bd14913423 Stefan Popa 2019-06-04 555 if (timeout > 1023) {
7f699bd14913423 Stefan Popa 2019-06-04 556 timeout = 2;
7f699bd14913423 Stefan Popa 2019-06-04 557 synth_timeout++;
7f699bd14913423 Stefan Popa 2019-06-04 558 }
7f699bd14913423 Stefan Popa 2019-06-04 559 } while (synth_timeout * 1024 + timeout <= 20 * tmp);
7f699bd14913423 Stefan Popa 2019-06-04 560
7f699bd14913423 Stefan Popa 2019-06-04 561 do {
7f699bd14913423 Stefan Popa 2019-06-04 562 vco_alc_timeout++;
7f699bd14913423 Stefan Popa 2019-06-04 563 } while (vco_alc_timeout * 1024 - timeout <= 50 * tmp);
7f699bd14913423 Stefan Popa 2019-06-04 564
7f699bd14913423 Stefan Popa 2019-06-04 565 st->buf[0] = vco_band_div;
7f699bd14913423 Stefan Popa 2019-06-04 566 st->buf[1] = timeout & 0xFF;
7f699bd14913423 Stefan Popa 2019-06-04 567 st->buf[2] = ADF4371_TIMEOUT(timeout >> 8) | 0x04;
7f699bd14913423 Stefan Popa 2019-06-04 568 st->buf[3] = synth_timeout;
7f699bd14913423 Stefan Popa 2019-06-04 569 st->buf[4] = ADF4371_VCO_ALC_TOUT(vco_alc_timeout);
7f699bd14913423 Stefan Popa 2019-06-04 570
7f699bd14913423 Stefan Popa 2019-06-04 571 return regmap_bulk_write(st->regmap, ADF4371_REG(0x30), st->buf, 5);
7f699bd14913423 Stefan Popa 2019-06-04 572 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-19 11:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 10:41 [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 2/3] iio: frequency: " Antoniu Miclaus
2024-12-09 10:41 ` [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler Antoniu Miclaus
2024-12-19 11:28 ` Dan Carpenter
2024-12-15 12:35 ` [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox