From patchwork Fri Dec 20 09:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13916435 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 9D6201AA1F4; Fri, 20 Dec 2024 09:56:56 +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=1734688618; cv=none; b=QBwK5Q8OKaGuINq3SYWqYULl4IV6eJoZhVNo9QQKhQnRwPBQm/IKerEysqMv0QUqWsS1cYfkYKtTvuFLiqoseCOKWmpsgAaqRuY02qghyye5zy03PUb5ns3gczvTvYAujBV8CgKmLwplu4fDmnaG3CKqNjnWAkmaCivxO7qxvHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734688618; c=relaxed/simple; bh=WFCAty3T5OlZTVXtz3EXQOL8iEJyNRBY4SckHO4UzTE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=frRD+sVXVb2y5yrtg1dlmXm/Zu73PKJYBOmxzuOsVwxNf+ae0mWBHNR8xAy4CuqmIxlyiEHKXlP7Xk5mzT3Z36ZRO6VJJ5EcxeuRFlmfRy/6RtSexhMyYNPO6nZYOCZYPwJ42AEyzejVaDOqtu21BuU2WDvNHUFs3IF68CZ74jA= 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=ctDEvyWx; 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="ctDEvyWx" 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 4BK9Ugmm001674; Fri, 20 Dec 2024 04:56:54 -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=nGNo+ y7yEdnfOVIlU7Lnm+js2gsKnUSiFTcoyykDQY0=; b=ctDEvyWxTyzf1T98LLfLC 8qcBcypm5U15zIEHXyheKTpRsdQ5R9nK197rsotADf9Av8wC3R6z87yyINsESeSp NBz8s0dYXwkyg3ooE131cRzIxlT8nrhj5Ll0je5RtPAGs9RFUFMsfRTwI3tYsI34 pKtVMPMc5VU+kIAQJXP570Zyjm5z/3q84Lq6WyD57988BEIlnrV3bAJH3tlxIdAW fTiznXB9BkshbSQ47jkvYE9iFOk3WO5Sdo5vL6rmrtv6CxksjZjM5CBLE0ZEtAL9 oVSEjkrDBJsdLyGj30WSS1S7fFAnnY1F0ocqC1G0zgSYgCVWGIvZ2x+OLODB9u/6 Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 43n60ug3v2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 04:56:53 -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 4BK9ucvc002458 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Dec 2024 04:56:38 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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, 20 Dec 2024 04:56:38 -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, 20 Dec 2024 04:56:38 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.133]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4BK9uROV023622; Fri, 20 Dec 2024 04:56:32 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 1/3] dt-bindings: iio: adf4371: add refin mode Date: Fri, 20 Dec 2024 11:56:13 +0200 Message-ID: <20241220095620.4918-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220095620.4918-1-antoniu.miclaus@analog.com> References: <20241220095620.4918-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: Iph49NjI6xGHxJJJ3C_wLgAUUTCfwol_ X-Proofpoint-ORIG-GUID: Iph49NjI6xGHxJJJ3C_wLgAUUTCfwol_ 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 mlxscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412200082 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). Signed-off-by: Antoniu Miclaus --- changes in v3: - add option to select between refin-se and refin-diff .../devicetree/bindings/iio/frequency/adf4371.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml index 1cb2adaf66f9..f927d3af9f43 100644 --- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml +++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml @@ -40,6 +40,13 @@ properties: output stage will shut down until the ADF4371/ADF4372 achieves lock as measured by the digital lock detect circuitry. + adi,refin-mode: + description: + Choose between single-ended or differential reference input. + refin-se - Single-Ended Reference Input + refin-diff - Differential Reference Input + enum: [refin-se, refin-diff] + required: - compatible - reg From patchwork Fri Dec 20 09:56:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13916436 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 C32BB1B4237; Fri, 20 Dec 2024 09:56:56 +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=1734688618; cv=none; b=YAMWJd2SPIWMF0cMmPO8Wx9YC1LJ8gRjIKEX09prYHzfIGRS85KblM046zW+XJdIvwgRVgu0b4r5ctvCavtqF+eAWK7qQbDQQxJRnnkW0EiRfNK710DWDzJRetYZ0RRpuNd8kKIqY3xYhOXNFx0347Ru3UkFggp1R4IOSGZekiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734688618; c=relaxed/simple; bh=j1Z97RR9ZGRu0VecUNl8FAARVXyajzps9es1P5etqCQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X6RA2kob9CPhD//rNOHJsyDP8Fehq8YuZDPLI46vXRsqT4J9XYqbtBqQqP3cfXkxZmWLOy0nIEsu3HqsudEFwXZyTzLDJRy82/drHLRXvjxqiX7mjAO9/D0Yq8OrseWbqDoDOiwwT+qoIVKz4fB5W2XMOc5PGdM4hhbmrEM/t5o= 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=OT2y5n3O; 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="OT2y5n3O" 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 4BK6tvTv026657; Fri, 20 Dec 2024 04:56:54 -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=LczxP /ItOE6qabCIGfsaeZQmoiD2ClJiKZFUxFP8gO0=; b=OT2y5n3OoDrGzlEkitg52 3h5QnOYZacugYf7VYDw5+RHzkKwB3EH0rqE6FLE3BCiJ1QLv2IRPAcQ6RRO1VfRx iRI3U8t+jABrn/Kb/dJwEjpfkX7VYIe/OfDJXjUrUCIQ1y1zjz6oN5+V0Ck6Ruh2 n5/sqyJqAwgtL//BZkmybZ3ZAdqt/vl+CGaOjk4Mc9X2YiGDZNvDlswBS1Z34+t2 6HwvjN++8nE3aRUwigw24Aj00/Z2uS9ef0A45xq87iW+eeZUWg5Y1PgNFhkegvCy NxnOPLTgC5XM1SJgvsWbRy/0uK7IqHpY7j1+KaphPDDHrfGYGOY5uODi8vkZhH/V Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43mxv09x2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 04:56:54 -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 4BK9ubbB002455 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Dec 2024 04:56:37 -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; Fri, 20 Dec 2024 04:56:37 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Fri, 20 Dec 2024 04:56:37 -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, 20 Dec 2024 04:56:37 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.133]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4BK9uROW023622; Fri, 20 Dec 2024 04:56:34 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 2/3] iio: frequency: adf4371: add refin mode Date: Fri, 20 Dec 2024 11:56:14 +0200 Message-ID: <20241220095620.4918-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220095620.4918-1-antoniu.miclaus@analog.com> References: <20241220095620.4918-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: PSRi3Dqb5LesPlPT0QW2ezoggyjRyrNb X-Proofpoint-ORIG-GUID: PSRi3Dqb5LesPlPT0QW2ezoggyjRyrNb 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 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412200082 Add support for single-ended/differential reference input mode. Signed-off-by: Antoniu Miclaus --- changes in v3: - parse refin-mode options. drivers/iio/frequency/adf4371.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index b27088464826..34fb75c379b0 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 = false; int ret; /* Perform a software reset */ @@ -497,12 +503,30 @@ static int adf4371_setup(struct adf4371_state *st) return ret; } + if (!device_property_match_string(&st->spi->dev, "adi,refin-mode", + "refin-diff")) + ref_diff_en = true; + else if (!device_property_match_string(&st->spi->dev, "adi,refin-mode", + "refin-se")) + ref_diff_en = false; + /* 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 20 09:56:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13916437 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 6B4981BC077; Fri, 20 Dec 2024 09:56:57 +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=1734688619; cv=none; b=Vz1iWvdhJobjn8ShNbn8Xw4wdghPRUbTw52Zt2j8SpC5oDLvAmly1vF8Aio69MVuXDjxEoGOT4aLTWEep1RrxiCtiF/5k3ugIV4CgYqIeFdMnLAY+R/TF21jWIxR4jNvMChbDa1AIaBd9zgs6IQmeL17pjaiB8O1ywto9RcVdeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734688619; c=relaxed/simple; bh=VoOyaY0QWxPey2QVd7s1JiZJ9f+uDDzmBlhY87ItAYI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kTkDT7tOVCrbuKXuAnlnvX7r2x+3SnLGyxR7j0wnA2zZ7aRYa0RF6i9j5Jo8VmJG0TSsTsIT0j+7dJRVxrSZrG5gxanVo13eEuhGy8KIzA6I00pLVM9Ae9vp6czaHEUXmzNLb2UvipEi2s1yJ+9V+PJLojOCArirbMocS5h2BOI= 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=DoGceU9x; 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="DoGceU9x" 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 4BK8i9x6014129; Fri, 20 Dec 2024 04:56:55 -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=OiAl4 QX88Q39bwrOiLDGxQZP9++AIGG098upwcBsr1k=; b=DoGceU9xXLh/T1jvfxVLP o/4IamvnYAK3KsuCon5QTzadQ4SrghFX7IY3FNO4F2txBIgC5gqdSmIMTWBBHm0e 5txhOZ+SUP/FNeGV5c9ScqhiB7rsYllWGMAMJoOohxcaXFAq/fmgNmeimBkwsZp2 SYFIGMVn4KgGSBKdS8bny2ETLi2Ux25NEsCaMB/RbjZkbYkj6YET6e+4nP4p5vVZ 57LzVTdYdwm/wf3z6NY1SQnMyxkNGIe6unyrjXe3+zHpRP56lcg5hkuR91Ih6DfX qcu+Bjl8NC8W6I+cCe5ytwo5lFSVY0rpIcPhxVts9MXqdQfpRyPGzC13XPszy4nb w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43n5b589c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 04:56:54 -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 4BK9ucrL050103 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Dec 2024 04:56:38 -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; Fri, 20 Dec 2024 04:56:38 -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; Fri, 20 Dec 2024 04:56:38 -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, 20 Dec 2024 04:56:38 -0500 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.133]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4BK9uROX023622; Fri, 20 Dec 2024 04:56:35 -0500 From: Antoniu Miclaus To: , , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 3/3] iio: frequency: adf4371: add ref doubler Date: Fri, 20 Dec 2024 11:56:15 +0200 Message-ID: <20241220095620.4918-4-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220095620.4918-1-antoniu.miclaus@analog.com> References: <20241220095620.4918-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: -j_NKXuJOjr-mF0D7OROxVF-aqH0KW-I X-Proofpoint-ORIG-GUID: -j_NKXuJOjr-mF0D7OROxVF-aqH0KW-I 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 suspectscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412200082 Add support for the reference doubler. Signed-off-by: Antoniu Miclaus --- changes in v3: - fix uninitialized variable. 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 34fb75c379b0..f889da110efa 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 = false; int ret; @@ -521,6 +526,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)); @@ -536,7 +545,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 */