From patchwork Fri Dec 6 15:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13897277 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 E033E148832; Fri, 6 Dec 2024 15:22:47 +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=1733498569; cv=none; b=jXtjkQ7nK2yr/TtLhzeJtsjJATiz1eb0vcsv1fRZLyEP79ha9a4sCRNRb0PiB+Yq+UahD1HgwB8DG8/ZtBONLkWLAKDnfjJqOSXzMkVv6NEG6esi5bnbJQl0sgfGRa+iqrJxhwrfEXp+JhXLj8lXTCVR4YVhIAfHpinohjpC+aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498569; c=relaxed/simple; bh=DhbQchCub9U5elTP6juJG/8cBmU+WUrbG7WOjeZ0sEg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Rn1QHlLMOS1lx8okCmyL/KD3t7KGsiimU5y51sbCjzib1DNAry+qGEMWJFDyhO4Tb6/yNFvpLIGtNe/naQU0Yzz3Sav5cTSgTXISyO/ZEQpfmLO5yEPfkRYECjIpNiXSHX23TKvWiLWMtNyq1S4JT0kxkukRVTduns2yM32TZ7k= 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=Ybjvw7ZQ; 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="Ybjvw7ZQ" 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 4B6CI5NC016048; Fri, 6 Dec 2024 10:22:33 -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=xxpIuAj3vCkmCNrV10X2ET//KfV tu4n49xBopSsZDXg=; b=Ybjvw7ZQW3xW/KjULS5G9DEIsMmPetQhcAVqnjumsrl fyXbkIgtOpw1rcTk1Y/y3qlcTINJ24yMbn6b2edqjLIAW7VvU+1gYVqWDUtf3Ecu SKMWqEXW740zbIeJr+psRw5nA/nzI2mU6babvoPtqwHw+8UVUruKBoaGtqtFwZ5K tkapRAnMyMwJ5XCl++NM7Lua+YD5a9mfHj34uXCPSn3Xr++MdGEVhvnuz9q5YI4f OMuoVgN1sc8A8BztOnQOl+Wt3glH8t1me2GxtkKjGtrPFoiJhN/uCCqlhJB2aSde 7RFJiSRV+4jl/gHk0uD3pEOt7ShBq/uWNS2wAWQv6zw== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 43c15c8qe0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Dec 2024 10:22:33 -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 4B6FMWTg020888 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Dec 2024 10:22:32 -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; Fri, 6 Dec 2024 10:22:32 -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; Fri, 6 Dec 2024 10:22:32 -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 4B6FMM1b025340; Fri, 6 Dec 2024 10:22:24 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH 1/3] dt-bindings: iio: adf4371: add differential ref Date: Fri, 6 Dec 2024 17:22:04 +0200 Message-ID: <20241206152207.37928-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: qtoTppQDTkhRj-VdQE3V7b-EW4i2m4Zw X-Proofpoint-GUID: qtoTppQDTkhRj-VdQE3V7b-EW4i2m4Zw 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 mlxscore=0 clxscore=1015 suspectscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 spamscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412060116 Add support for differential input reference clock. Signed-off-by: Antoniu Miclaus --- 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 Fri Dec 6 15:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13897278 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 9E8AF14F9F4; Fri, 6 Dec 2024 15:22:48 +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=1733498570; cv=none; b=bv64f+ewj+8KiiQmgwYUo1EWw/+IGVF+YJz05nQ12UzmjUtO49Ic5cOJcKg5R/syphDyg05qO2qXmIp/5Bb4pNgxpuA1VJsUcQCaBH7zcu8NXpgNASmeta/mDGbqpzqYSwlbvevt2JG7Bx+1PP+L2NL4+WZm5qcwOndLj2e3VX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498570; c=relaxed/simple; bh=9PbdXBS0v5c7RlaFuFZ3/F2tacxye402rSh31n5mVf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DdJTa2GwB+CecZY7sPjllxMtYGMXvMC8IsMnffjD9qSnnAtmY2ROAiZG03NxIfSjqxE0DX8DN0K+z6jzGq9rK2YZQVMaKJVJzkz+oa7wppFONkZFzd3V7ebw6Yn/S9+OD5lkhOlRhboSti8V4u0tCVizKnhAedyKAaQl3iMWrLw= 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=T+cD6eMt; 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="T+cD6eMt" 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 4B6E28Yf004484; Fri, 6 Dec 2024 10:22:33 -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=hUgMm 3Q6oPkxzpLnMmpM1AW/OzDa1/Z+iIiZpjK3tTw=; b=T+cD6eMtk6NC9YttaxilN +M/J7ZLj6HsqlSz4j7uMXMhacIHqDw/hMYJt0bEe1jKmvsZq5kSCfhFGHKY7uacD mfm4VkEYZZmh7J3buewLJNGg85TEjcMMMQ5ix88eIkQ1UcGciHuHn6CVr4JqcrIb /yvXJ1UI++GVdFbfxpOXi51LSjtyVpaDgEHv095NA1kRrWhsUD3eIqo+hU6XNDQ2 ShPdr80qz+EYI5A6EW4HgMv9lQWPl3GRm1LqxytNPAulf9MeViJ62AM03rAng9Wv dDczKBqs6EMLTgXBtCwBsInbuHjXNwBNxut14NUanJ+q1L4LtFV5uAUyrMiofBe6 Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43ak0edmtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Dec 2024 10:22:33 -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 4B6FMWx3020892 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Dec 2024 10:22:32 -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; Fri, 6 Dec 2024 10:22:32 -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; Fri, 6 Dec 2024 10:22:31 -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; Fri, 6 Dec 2024 10:22:31 -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 4B6FMM1c025340; Fri, 6 Dec 2024 10:22:27 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH 2/3] iio: frequency: adf4371: add differential ref Date: Fri, 6 Dec 2024 17:22:05 +0200 Message-ID: <20241206152207.37928-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206152207.37928-1-antoniu.miclaus@analog.com> References: <20241206152207.37928-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: W5aEM9VN0-vLWpF6qGpDOD9PVnSQwwnZ X-Proofpoint-ORIG-GUID: W5aEM9VN0-vLWpF6qGpDOD9PVnSQwwnZ 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 impostorscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412060116 Add support for differential input reference clock. Signed-off-by: Antoniu Miclaus --- 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 Fri Dec 6 15:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13897279 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 4F4C1207E1A; Fri, 6 Dec 2024 15:22:50 +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=1733498571; cv=none; b=nziH4xK4zKkOGpkWA6yoelZ1JzkNzubyp8YZEIz24DxaD9y2LrfHXKpUuHgeMxQ51dWxRWlLamcUkhoYkS6Ypkx6w27qMbUWJj1PghyGUd7MoOIpw0k5hnX/xc/rm1997nlJ+ChczR/AFATa28vexPT5p/wSSbU/bgvBIISGfWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498571; c=relaxed/simple; bh=ue0zjSDUKAz6ZdL96QI8A75tVCwRwgeQqRXoZImt3JY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PU/jpFQ9mjRnlYp0sR+qx9vxioYiDz1HazUIe33gKojtRxzI3BFL9V8bc7glKQuM+MpEqUc9aE1E0b/NFigUtqK4TWkV/lwv2AcIuzj1RHYfqsEpnjOqKL1zv1wLcScmruan3zv9DXMxnpxQhFqR12GDMRTVkw5h8yO7ebdbeSc= 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=ZNf4rL8k; 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="ZNf4rL8k" 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 4B6E3xAQ001605; Fri, 6 Dec 2024 10:22:48 -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=XgUbt M5YUPS4JP50Lpqpp/hIlUxc1ohCAAG3h35M6tw=; b=ZNf4rL8khlr8zJdrKwLKV KW+dMgw6GSUmznEmuzpPHShvcW2l06s/wdtteAcN96rDWalaHBjRK8jk7Y4FQDAT G3cj5LCdoMQGCk1a8UBOSELPmuEdWc6VBjlCLax7PoSw+pgEH1Lk6IjnKSIT9CbT jf5dL4WYvsAAkLuPFcL6n4icrHT0ckOFcRHCsrU7Nme4FwuynHKuN4HS/CJAz2LK hNL1IYjedV6vKc4ewJOm0rFkNg4jzoWh/bltyzy+2EKZ4x0+C4gAmqGI9PezCJai t0vIR5g/3AOL4hlNrs0iHKqAnkjtCKNeC5Lz4C+lZbitZXc+H8/AAnwCrlplEuur g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43bbcbxym1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Dec 2024 10:22:47 -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 4B6FMkL9020909 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Dec 2024 10:22:46 -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; Fri, 6 Dec 2024 10:22:46 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Fri, 6 Dec 2024 10:22:32 -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; Fri, 6 Dec 2024 10:22:32 -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 4B6FMM1d025340; Fri, 6 Dec 2024 10:22:29 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH 3/3] iio: frequency: adf4371: add ref doubler Date: Fri, 6 Dec 2024 17:22:06 +0200 Message-ID: <20241206152207.37928-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206152207.37928-1-antoniu.miclaus@analog.com> References: <20241206152207.37928-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: G6Vc7pkpStBiCNo0MxgSYbZ3wlgH8chi X-Proofpoint-ORIG-GUID: G6Vc7pkpStBiCNo0MxgSYbZ3wlgH8chi 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 adultscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412060115 Add support for the reference doubler. Signed-off-by: Antoniu Miclaus --- 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..dc01f2aafb9a 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 = 0; 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 */