From patchwork Mon Jan 20 11:34:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miclaus, Antoniu" X-Patchwork-Id: 13945024 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51874191F95; Mon, 20 Jan 2025 11:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372885; cv=none; b=aiIT7d0aDP5fRYuExPz+3QUVTHaFFQ1/XeQya8LAXS0QyGt55p/5Pd51iHNKgpbW/hU/9OE8d7JVRl+OwGNK5fOkyUnndzZj4vE6xJN5mcCZtMe4pVAh129+V9DqBoOc5vTy40FUKigJT8Sm6nShdWcKhi/hDKOxlFBWI0+HnVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372885; c=relaxed/simple; bh=KY0d6LnwQGgOSB29A5j2A6iKjLfm0RFz2SChSuT45Rw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fpNO+iyJ3Yd45MpM5B41xroBTkBKEgxX21OnbnFU/09wkuxoMmzNvaK5toJdvyybJEw8bUf92SHdkxQQWx5yHOmvAW3+1wrvgSnYSyNOgzgoq4+cWHJC/7BubjKnEg4GEmh4gCUAjC3JXJPaziyOFe7gZlGCGAX4QzWpaTJEReQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=U+sVPyKs; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="U+sVPyKs" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50KAZKaN010170; Mon, 20 Jan 2025 06:34:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=OZngX Z24kqHgNuE62DAGuHxHbr8eaj10nYiXfAc+yng=; b=U+sVPyKssjM4zYOBReWmt rKq/feEaOoXVumnfyRj7kYupZTj4pS38q1l5+puprH1wgOD4hDXIYJlL22Yfkipo vEiNsGpleUgCSy6QfeMywCxwSSwXi8oBoYpUgOvUj/4QJI7hTqDSkeaJozbK8Eel BybPs4WpGQG2WSzn6I7j/+igP1GubeTlS88NNJdeCsujJBaGH62pQuWNN+2300hS 8Z8IsLSKgh8vVVgj4r58r55H8iHybEFjCt4V93gdRMwkb1xZBqKQ8BtguwzXB2oY 3H9MzjK5YMxjNwhQp1h0MHLZAjZgoBcfQ1wj0K4kPgQm8vNQusBSyAjHYzIHymhm w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 449mv9g6e6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jan 2025 06:34:29 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 50KBYRE7001542 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Jan 2025 06:34:27 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:27 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:27 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 20 Jan 2025 06:34:27 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.159]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 50KBYEp0007657; Mon, 20 Jan 2025 06:34:23 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v5 1/3] dt-bindings: iio: adf4371: add refin mode Date: Mon, 20 Jan 2025 13:34:02 +0200 Message-ID: <20250120113408.24395-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120113408.24395-1-antoniu.miclaus@analog.com> References: <20250120113408.24395-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: CTOGXvyH3Y6QJT8GBUVVVbh8myuYGHWZ X-Proofpoint-GUID: CTOGXvyH3Y6QJT8GBUVVVbh8myuYGHWZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-20_02,2025-01-20_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 spamscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501200096 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 --- 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 From patchwork Mon Jan 20 11:34:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Miclaus, Antoniu" X-Patchwork-Id: 13945025 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C33551DF256; Mon, 20 Jan 2025 11:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372886; cv=none; b=TwN4nrVa5Z2+hv+FAZvpik4IJOwnLKOImyHYxwYUtvH9xBwmv3TyrnCA/eJr+rubAnpX3dDFwtxLZupdZBCCk9fN9st1mO9nfJy61jFmqgrC/H/zDkWwRB8wtGEWcyo47oo1sgsrrl9aE8/fGeiYWWhGXnSZA69kuyWFqfwbdVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372886; c=relaxed/simple; bh=P5c80eGx5/5MCgfCdSGcqhRe7K09vr50zQvxwJVTvPI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BSUYbo+fpyDf15loWcM2cwebXdhVknMMHzTHt39J8DONjCz7dSzatlaRO7isesm8KuvJKeJUjv8APw021OE31ejZp2kafu3L4QVbtxQ7zL8FWsUG8sHpERtV80XZ8K6T9HpDTxh1qkrhfnJ8hJbJ0YRCjQX184ZB/HMJViZMdvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=Nxdhj50k; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="Nxdhj50k" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50K9ldRU009358; Mon, 20 Jan 2025 06:34:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=1M6Ks A6CmeokaaBTsJpORh2J42WqBydGxWSFtG9261I=; b=Nxdhj50kLuiTxvTjHYCC8 9kmNU603cY3tZmLHIFib2TaGs9j8cWcQpaH9Xy0SaIIpIInME4cesaLFsfPMBNNx RGeFyO3TZQBeBWPARL6eOr6/9cCabl7hwB9pttl8HxanQ6k+daHclm9zBAJXG/L0 f9T083B+kO0eM8UgNz12ZvhLDr9TO6Xq5qHGOX+SEwE6yjuKswZN54Bqmq9iBECi dJwNsjw+XrM6Bp0b1DorkXcNSOfXSDFMKZ2BanaZBlazp1jZ857X+PLNlrcC/gr2 EfDl1dYpVveGt+zoZ9Z8kE/U1L1AeAiLf8C54VrkW1BKvCNyZVXxOSlqwZKad8lV Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 449g3ehfcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jan 2025 06:34:30 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 50KBYSTv001545 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Jan 2025 06:34:28 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:28 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:28 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 20 Jan 2025 06:34:28 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.159]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 50KBYEp1007657; Mon, 20 Jan 2025 06:34:25 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus , Nuno Sa Subject: [PATCH v5 2/3] iio: frequency: adf4371: add refin mode Date: Mon, 20 Jan 2025 13:34:03 +0200 Message-ID: <20250120113408.24395-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120113408.24395-1-antoniu.miclaus@analog.com> References: <20250120113408.24395-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: qD9lpI4OQArFYRsdTZKs0bPsT1ibLRVi X-Proofpoint-GUID: qD9lpI4OQArFYRsdTZKs0bPsT1ibLRVi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-20_02,2025-01-20_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501200096 Add support for single-ended/differential reference input mode. Reviewed-by: Nuno Sa Signed-off-by: Antoniu Miclaus --- 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); From patchwork Mon Jan 20 11:34:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miclaus, Antoniu" X-Patchwork-Id: 13945026 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A075F1DFD80; Mon, 20 Jan 2025 11:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372888; cv=none; b=PX746BwsI0cPPAAaKcHMi0XZaK59xAbBgjypVcY26jMaZxEpuAnmI2DfV0oZVsorCnYZOh9hTHRDDvbV3n/S1xrigpOIB4lL08j9YGwu5Oofg4rr7lHw6xFZrDkKfBcQNw/gzknahBEFNowDjMZkETTPxOuVwdfX8XPtTXxDCLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737372888; c=relaxed/simple; bh=aO+WC3B3j0oUxEYPFawrqm6fg9Ck0oLDA2Q9yrwPUn8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p11knflj4ais3YQuaRWA1dMoBWPiNnp90wfI4W1a+/fLlWiaXgqxG/2jVAEadoE6dhXYvsp6FksJ6CEFZoE2IOBPyHinuoxSC8jmzEqxry3baCusHPwan2meeIZ0cMjPQJC0gQHmwdeXqRP4rWTZwGCEPRialGr+RPuPawXbXug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=Vw0bU7Jd; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="Vw0bU7Jd" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50K9kOrt009331; Mon, 20 Jan 2025 06:34:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=SK7z8 Bb7mqOPFwks4seyfmxXc5JiJvQcd3gEDXGi0gg=; b=Vw0bU7JdNfcrJ4oB+fec0 gLWmaQCSf54B1ZgQ60r+HZ6uYTMeYoW9jyhkuGuL6dJPd6DRoczhmaV30XUJEyP9 ruMP76wunVHibCsU8TAyPgsO7golR4mXJLmzWG5ia/gtownOtqLWNeOadBOwXGRe hhC2oCNAgya1iLX10K2fi68+1ct2d1J7WtDNED4e5Tpz3c6miFUgPy8yZYsDn0Uo JxCXxpet1U/LIvA8vpIQxopvdS0W/7+1UsD0xJkj0epDh8zt8xngAw/ZpTZXbqJS MheIwcF2bkL0GFAmuKV5eeiLbOUAWSw3KSc59T2IatFcBuSKBywMh0oAZ2Doum+s A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 449g3ehfcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jan 2025 06:34:31 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 50KBYUkX001550 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Jan 2025 06:34:30 -0500 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:30 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 20 Jan 2025 06:34:30 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 20 Jan 2025 06:34:30 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.159]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 50KBYEp2007657; Mon, 20 Jan 2025 06:34:26 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus , Nuno Sa Subject: [PATCH v5 3/3] iio: frequency: adf4371: add ref doubler Date: Mon, 20 Jan 2025 13:34:04 +0200 Message-ID: <20250120113408.24395-4-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120113408.24395-1-antoniu.miclaus@analog.com> References: <20250120113408.24395-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: Q6eu2DzPs265X1bGXx1bgXns0-Ia66Bv X-Proofpoint-GUID: Q6eu2DzPs265X1bGXx1bgXns0-Ia66Bv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-20_02,2025-01-20_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501200096 Add support for the reference doubler. Reviewed-by: Nuno Sa Signed-off-by: Antoniu Miclaus --- 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 */