From patchwork Mon Dec 9 10:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13899278 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 F377412D758; Mon, 9 Dec 2024 10:42:52 +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=1733740974; cv=none; b=A92BfYWyV9zTXU29K1uJBP1C1+RoFzEuIC9xvjfS/zSZ+Zg+xuM2p/Eojbjupe/Ww4O2MSacW+7Zqo8tbrRoHjurRJWK6wwY9/6hVHf/e97ZdhneOm8kzHxDCMfa+wM9WgaQRYblZE+uLbrMBmuBP6YhSaP+vKOkeBPCbsbHzbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733740974; c=relaxed/simple; bh=h17uuSw7iE4TfKcHSMiLy0W7uz798S2F5mihSRo09h8=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KuS3ir7SGWoZ0FcNPSim85ygpHnM82BtFFZr+aVhxJ8NStG0tmg677yQOC3jgFQkNS9IhhxMrO23hMnyknUPwe0rGYhpSnN32G6a8ilpKzw90JICq4yqZaqCLVRakr6mo/ioJxg95zKlyHrcabfR+Closg1E4XJbddNah9y13Uw= 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=C+Zsfh5c; 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="C+Zsfh5c" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B98tLD2025159; Mon, 9 Dec 2024 05:42:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=DKIM; bh=V/1IBlK9w9X6N6BhBfAtefgRIm0 4sNLsBXYhaxnlzzY=; b=C+Zsfh5c5SWGSJBROPLRkVV28OKU0+oRRtBaflHt07S BXWjq0fLuGFInTJM0yMfmKYWfgF4RRRUiOvzA+/UW2dpTw7brGotZ1YTJ1/ClBEv wEE2RCO/n/XwUaCt/w6MzLm8O9nNUNV/hKmVK3E0P35T96UtS+bLjkCfttVBrCfa YT/sziQS4NYRZ3mbcrnmKof/VAmWtjRetFOrR+C7R5BQ6eH5ZIEnHo+JJXpSvHIe hDhZXoI+EXtigt+l6HyBRBOHagzEJ8emnAuBt1VaegyT9bxvjz+123TP5IGYEj3A AiXNyZ6usH1QX3Vwvq9ZSTjUXmCZrBQDWnx0AhUuRWg== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43cm557q76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 05:42:37 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 4B9Aga9F037884 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Dec 2024 05:42:36 -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, 9 Dec 2024 05:42:36 -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, 9 Dec 2024 05:42:36 -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, 9 Dec 2024 05:42:36 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.187]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4B9AgQVR004359; Mon, 9 Dec 2024 05:42:28 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v2 1/3] dt-bindings: iio: adf4371: add differential ref Date: Mon, 9 Dec 2024 12:41:31 +0200 Message-ID: <20241209104201.25205-1-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 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: 8nAbxi4qj8lWbVUbOjc-qFE6DGRRQO0Q X-Proofpoint-GUID: 8nAbxi4qj8lWbVUbOjc-qFE6DGRRQO0Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090084 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 --- 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 From patchwork Mon Dec 9 10:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13899280 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 D265D216E0A; Mon, 9 Dec 2024 10:42:53 +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=1733740975; cv=none; b=cvYi3h0xRxlfvgZVic9vjYTTWSGjk686tT3Mk1zAKnmoBIEGoYLLDyhvcJ5yt7A4zrF5K+JxpXwF5C5BmKw0WxMbAQfy77Rc7xMR2tJcHxHKjwb+JLMBXlJ1hFQDhlUyDTeOZniN7MlZTC6YRWRVLYif4j8WFEmbpmnZ/hK+dwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733740975; c=relaxed/simple; bh=37qxXKc6ebAjv3/kOXkCtwOhD0HhCCJVcwYeG3dmjK0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B7IWU9OrBy7ioGeFP7rcHremV8Rf3lJPA1NH5QdGybn99LAv+77JjiVxOJhM+YqEDL1Bzhx3L2CZxAyN0zP41ehXD2M4MHWjA8qO9qiZB2j+bXhtyXoaksBWvDaYaBVCjm6dQjNr587A0gIXTawCOOlyxCC5A9jk/RQIbWPUHLI= 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=Jo5iOMOO; 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="Jo5iOMOO" 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 4B9843Zd030180; Mon, 9 Dec 2024 05:42:39 -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=S5+/Z jdcwNvL4q5mh5oX4eYXQWlLWxUQX6chh5Zdg8U=; b=Jo5iOMOO47YkkTykF4GDE kQ6pULMBy3hjvxJknJubcoTwCWPgZbK6S8J2Z5V/c5KOUAKKlvWNWz0HghB8CuDR Csz9DD3mTTzILenWZ4ApXSy7X9BGdhc8DJQH08oqgF2sEvw9QAXugJl5wNaFj7j1 o5PKm5YcF6x3zNWtfRuH5oi9EVyqlrr4fTFo35oBFkjFQV5zFm6HngCaQMB9d3LC 5lkXtZ19+cXu1jVPg8eHkWlfeFBdSJsSOOgf8a6fF5YCfF2485id1GyTl8HofiUP ohf9WXtOeVoti2t035pxYRJkXOcDBMbwWRhhwgOQoH14m0+j6C8YZiQfkHTBXJTn A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43ch37g9jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 05:42:39 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 4B9Agcjq037887 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Dec 2024 05:42:38 -0500 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) 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, 9 Dec 2024 05:42:37 -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, 9 Dec 2024 05:42:37 -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, 9 Dec 2024 05:42:37 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.187]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4B9AgQVS004359; Mon, 9 Dec 2024 05:42:32 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v2 2/3] iio: frequency: adf4371: add differential ref Date: Mon, 9 Dec 2024 12:41:32 +0200 Message-ID: <20241209104201.25205-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209104201.25205-1-antoniu.miclaus@analog.com> References: <20241209104201.25205-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-GUID: NqsxksU89RCRGf7wq4gMvJzL7yfbaeLD X-Proofpoint-ORIG-GUID: NqsxksU89RCRGf7wq4gMvJzL7yfbaeLD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 mlxscore=0 impostorscore=0 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090083 Add support for differential input reference clock. Signed-off-by: Antoniu Miclaus --- 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))) From patchwork Mon Dec 9 10:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13899279 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 097E52165FD; Mon, 9 Dec 2024 10:42:52 +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=1733740975; cv=none; b=Q0ar0ty6FBE7PjfkYlxy7QPZd5jGpDDvKrpttW7PjSYsg4kmUHjP3kO3Uru/11bDP5QFS9gEhbSK1/BoHW5z1JNYqJZeR+pyuspd4dkOeBtuWwA9C93fNTcNi5OgWKz//1bAaM2PpR9OMx2X3V5b8evXVLMecVI65Aao5ST80ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733740975; c=relaxed/simple; bh=SM6swpyt8jyb0ikai78MJrCg7kSAZsAaAumPcFkP1i0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UE8tmaoSEKp8dZDucLP68CvEljGktNP3S9bFa/PAbKlRRCkVLD2IZrocRfFlj+7E8HUVgqwoLARtmH+9xlbTOUrFY0fcoQaW07RyBbOESDcvf3nwDWzaFk3yQKNP5Lr3HAGOqNYYEwlctBEWJdhtnrAMCXl1aiW6Eqf8XN1Z+xY= 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=mOKT+Y6X; 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="mOKT+Y6X" 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 4B97E6Nr024881; Mon, 9 Dec 2024 05:42:38 -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=tYhmV 12hRFOk2EbO6khmI3eie7oSghHEWzk+IUbPKBY=; b=mOKT+Y6XvIL/Xv1X23BrK tpSqA5N0HYW9G+1pfTmma4NisKRJmEWYhl0xBQsaqfeP3HrH3PUa9J1YHVHzH3+6 W0kEYCHGk0hxCjSYVjRtt77GM4OA9GeONthrbBdcRlYxBJZX6aRaatCDyEhoCLUI fKPEF4KdDsG/5OWgiJKWIz14DGJCW0O8O6tE/NsNTHK3YcarLa2O24jS9YKcY3A5 vpcv4NqOFEDvlPTZ/5gFVxvUN8a8o4Q7S+hEu6REBTYO++wgMyRECzfI1OhFta8O OjBL2tRO2pleNtZ9sL+aIvQ5oUP1eS6CfKufZBZaUsEFlFp2S70rsc6YKUnEqZrg w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 43duyw8vuf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 05:42:37 -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 4B9AgaP7010907 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Dec 2024 05:42:36 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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, 9 Dec 2024 05:42:36 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 9 Dec 2024 05:42:36 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.187]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4B9AgQVT004359; Mon, 9 Dec 2024 05:42:33 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v2 3/3] iio: frequency: adf4371: add ref doubler Date: Mon, 9 Dec 2024 12:41:33 +0200 Message-ID: <20241209104201.25205-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209104201.25205-1-antoniu.miclaus@analog.com> References: <20241209104201.25205-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: 4HeFODJ2jYYahXkO8ttp9jO48FsUlMom X-Proofpoint-GUID: 4HeFODJ2jYYahXkO8ttp9jO48FsUlMom X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090084 Add support for the reference doubler. Signed-off-by: Antoniu Miclaus --- 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 */