From nobody Sun Dec 14 06:37:04 2025 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 E792C31ED9C; Fri, 12 Dec 2025 15:42:45 +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=1765554168; cv=none; b=m5vYpGN0Z7OYPhkXRVqfsgvJDaC4C1jerGW+nd0mnvlM1fIdia9EkRE4pWynAzJYtPm+FKquQv2mR9sGICB/iCR8Jr9lkcUhozZM4gPklYOsmjORBAYMy9E168Wn1hl2nHm2usqBHEk/YviiuW+xAk/4RzwCbcgocThSHGSeESc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765554168; c=relaxed/simple; bh=b8AJHovfXvxmy6pHa2NrUD6n3G4cYRcEBVsG/J9gs8I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lmjzHRXpupY/H2RvoYmgLF+xUIN+WPqt1qIBbZxflR3N5Z1asApFe2gE6rMc60RUFon7ZfsJXq3F8MDus64ogwTkTSpUXEO4kX9RFtztgm39DwLGEgDo1eV8CH/jkvXJqm/GR1rtzymSvwOKEjlEM/fyunXyIRUq4OO5LvsvYXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=zM05Sq9o; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="zM05Sq9o" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BCDETYn3817140; Fri, 12 Dec 2025 10:42:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=Sv+jj b3Guc4stnz+E3ro+DHtywiEGxzZ+pjXeY7hCdA=; b=zM05Sq9oBf9xvTs1KW6C2 1C8H2RA9mmKUhWkNP0Le6+7s9eGVJbbNtydDsV9APqySRZ3CL6DWXwSQFv9rFKKs vEwfu83uVYf+hsb6knQ1OvlbsKo1InHM0xyuQBCLfmRg6/Q9A3cgAoIlA4enK79s E/NRwUEN60xnS219Vu8nRauG4hAWfE6Fur9cR6w0oe6pnSCmUJk9j7NXZiOAyqZc NMD2vY74zGhuuM+ygXZyMhA27+TM4/zazt6ACJEfSTZ8MbnNb7D1WYtrVOsZlRli cAD51Uxz+6vm41mSVfmX7sjOPkxRwZPwf1r1NEXqethT3qKMo9F9/wJF8S3W0A5i w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4b07r23r4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Dec 2025 10:42:30 -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 5BCFgTFg049190 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Dec 2025 10:42:29 -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.1748.37; Fri, 12 Dec 2025 10:42:29 -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.1748.37; Fri, 12 Dec 2025 10:42:29 -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.1748.37 via Frontend Transport; Fri, 12 Dec 2025 10:42:29 -0500 Received: from HYB-b1tGeUj4GP1.ad.analog.com ([10.32.13.98]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 5BCFg2oT020112; Fri, 12 Dec 2025 10:42:22 -0500 From: Antoniu Miclaus To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "David Lechner" , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , , , Subject: [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113 Date: Fri, 12 Dec 2025 17:38:25 +0200 Message-ID: <20251212153908.138422-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251212153908.138422-1-antoniu.miclaus@analog.com> References: <20251212153908.138422-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: tLZ11hpEIKjgHbC7jO5TAL49s6MPIPf0 X-Authority-Analysis: v=2.4 cv=GpRPO01C c=1 sm=1 tr=0 ts=693c37e7 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=VwQbUJbxAAAA:8 a=1yNy12B5puk2P9Y3jxYA:9 a=4Crt4hL0rqkA:10 a=shvgCOL7IKUA:10 a=sptkURWiP4Gy88Gu7hUp:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjEyMDEyNCBTYWx0ZWRfX3RFmh2tAQb30 fzyr5srMWdgMoeMjfGlKDz1yFRQFUHJU7qR5Mf3DNtnW17SM82Ztk5RqjKRJ+legvWsarGekM2u JPkDHET1wcW7Deyv+4xP6uLcMIzyN5q017bs0Bujbm9BandQ2otJOh2ZkVf1y7nyrVNjBpE++CI KbZW+T9djSRhFH+kwTFWsgkh1i6Rv9EqFzbnFduo7nhztqK24jMF+6owUePp9pjxFv4081JrtW1 dLLhuGVV4LFwdLnFTUsuidte+3/Levx5RQaPH8sw2KNUvW3JdTX3KrI20Kfoj+OMK2SX9cYAEbm WOaDW00Zw4ogfOmeM/LF9goomoLyubhVzSkoUGugTz0fNXWnp/vSIOu9xRjWJQEkgoPbjRE/XN5 KcMuys4Dwiu7rToOoi5YSCN7hpQ40w== X-Proofpoint-GUID: tLZ11hpEIKjgHbC7jO5TAL49s6MPIPf0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-12_04,2025-12-11_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 clxscore=1015 phishscore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512120124 Content-Type: text/plain; charset="utf-8" Add devicetree bindings for the ADL8113 Low Noise Amplifier. The bindings include support for specifying gain values of external amplifiers connected to the two external bypass paths (A and B). These optional properties allow the gain values to be selectable via the hardwaregain attribute, enabling complete devicetree description of the signal chain including external components. Reviewed-by: Rob Herring (Arm) Signed-off-by: Antoniu Miclaus --- changes in v7: - Enhanced commit message to describe the external bypass gains feature .../bindings/iio/amplifiers/adi,adl8113.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/amplifiers/adi,ad= l8113.yaml diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.y= aml b/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml new file mode 100644 index 000000000000..6b8491d18139 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/amplifiers/adi,adl8113.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADL8113 Low Noise Amplifier with integrated bypass s= witches + +maintainers: + - Antoniu Miclaus + +description: | + The ADL8113 is a 10MHz to 12GHz Low Noise Amplifier with integrated bypa= ss + switches controlled by two GPIO pins (VA and VB). The device supports fo= ur + operation modes: + - Internal Amplifier: VA=3D0, VB=3D0 - Signal passes through the inter= nal LNA + - Internal Bypass: VA=3D1, VB=3D1 - Signal bypasses through internal p= ath + - External Bypass A: VA=3D0, VB=3D1 - Signal routes from RFIN to OUT_A= and from IN_A to RFOUT + - External Bypass B: VA=3D1, VB=3D0 - Signal routes from RFIN to OUT_B= and from IN_B to RFOUT + + https://www.analog.com/en/products/adl8113.html + +properties: + compatible: + const: adi,adl8113 + + vdd1-supply: true + + vdd2-supply: true + + vss2-supply: true + + ctrl-gpios: + items: + - description: VA control pin + - description: VB control pin + + adi,external-bypass-a-gain-db: + description: + Gain in dB of external amplifier connected to bypass path A (OUT_A/I= N_A). + When specified, this gain value becomes selectable via the hardwareg= ain + attribute and automatically routes through the external A path. + + adi,external-bypass-b-gain-db: + description: + Gain in dB of external amplifier connected to bypass path B (OUT_B/I= N_B). + When specified, this gain value becomes selectable via the hardwareg= ain + attribute and automatically routes through the external B path. + +required: + - compatible + - ctrl-gpios + - vdd1-supply + - vdd2-supply + - vss2-supply + +additionalProperties: false + +examples: + - | + #include + + /* Basic configuration with only internal paths */ + amplifier { + compatible =3D "adi,adl8113"; + ctrl-gpios =3D <&gpio 22 GPIO_ACTIVE_HIGH>, + <&gpio 23 GPIO_ACTIVE_HIGH>; + vdd1-supply =3D <&vdd1_5v>; + vdd2-supply =3D <&vdd2_3v3>; + vss2-supply =3D <&vss2_neg>; + }; + + - | + #include + + /* Configuration with external bypass amplifiers */ + amplifier { + compatible =3D "adi,adl8113"; + ctrl-gpios =3D <&gpio 24 GPIO_ACTIVE_HIGH>, + <&gpio 25 GPIO_ACTIVE_HIGH>; + vdd1-supply =3D <&vdd1_5v>; + vdd2-supply =3D <&vdd2_3v3>; + vss2-supply =3D <&vss2_neg>; + adi,external-bypass-a-gain-db =3D <20>; /* 20dB external amp on p= ath A */ + adi,external-bypass-b-gain-db =3D <6>; /* 6dB external amp on pa= th B */ + }; +... --=20 2.43.0 From nobody Sun Dec 14 06:37:04 2025 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 CE14728F50F; Fri, 12 Dec 2025 15:42: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=1765554179; cv=none; b=PVALAw8z8SPcVWp56ZWMO7uUkBPXNkmoABSCEM5qA56lRCCO4Y0WiUfdoTmULRpavKXdEPzPfyyOYmYmkBQj23Vnh+Rwk9lNMuLVpxJrJDS59e4S9hrrbqJyvNadVs83ORb/QXdeEqJL6HIu2agBOKwraKXQBoFzZ38tCuQmdGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765554179; c=relaxed/simple; bh=jc+W3UqWU9UBPFcBx8tauk1jlgy5DbGJSjEYi76MhuA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s1W4V6QV2tV3uL1aF02mvNLC4M2NQC2zV7KPaYGvbPR2NibkaoNtxXb4i6WtC6IGdaUBnSwXv21tCmrSGdYEe1Dbtqa+UHlwiw+gUlA/Dok466ivHppTx8Jom+8ZFddwwaerSk1O0GhogN8rA3EvrEyCl0pwFIbWdPxgsAWaIVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=TBGx5NXX; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="TBGx5NXX" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BCBsFjx3366469; Fri, 12 Dec 2025 10:42:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=fYpih qc4W2N9KRgWuRJ1Vsd8mbafzRTAER9w9OyXTys=; b=TBGx5NXXXKfNjVu6yPP9o Ud1k25kYmDldzozCOVBCfqqyK5denU/PgDLODMgLL5FuH/2PCvIOXvQpANciuEvZ jN+y/ztmC+CK4zoL3nCAGkH+cWSDzV3wE6zXNFVYyGYlGZmwX+VboPLlLU6V93EH N0lFgsGNgpIFM1Dkxz7Zm+re/7+1knAtFgiNXvYhW/lOvpgZaM9asHm9O4s2ug7t v3QzBukIfPfaWN3ctTwrAKY21kE63YcucyNRZ1d1kfMAF2mhjh+mzzBfcCfmKu6T sl4Qttl1Wcj7ZGT3aeYlLD4YmYf2IVOktK4RbZ9EceQuClZknKp4ogUyWV+Q247u w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4b05uhm8r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Dec 2025 10:42:43 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 5BCFgg8D049210 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Dec 2025 10:42:42 -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.1748.37; Fri, 12 Dec 2025 10:42:42 -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.1748.37; Fri, 12 Dec 2025 10:42:42 -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.1748.37 via Frontend Transport; Fri, 12 Dec 2025 10:42:42 -0500 Received: from HYB-b1tGeUj4GP1.ad.analog.com ([10.32.13.98]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 5BCFg2oU020112; Fri, 12 Dec 2025 10:42:34 -0500 From: Antoniu Miclaus To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "David Lechner" , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , , , Subject: [PATCH v7 2/2] iio: amplifiers: adl8113: add driver support Date: Fri, 12 Dec 2025 17:38:26 +0200 Message-ID: <20251212153908.138422-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251212153908.138422-1-antoniu.miclaus@analog.com> References: <20251212153908.138422-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: cWL6Q_HHrSJDqB4_TyNEF3Suxi6OPV6r X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjEyMDEyNCBTYWx0ZWRfXwrgYKiDsUKQ0 h/qgV52+8dz1+qnrcgAPp3QxgN62ZIIJ1qALzwpNOEEHieHg1qUTq1xsm63Vau4XLe99LhBS3xy tAMN8jg1VkukVWnY99g2YrWcodGU3NCkfR/Aj0mFq2znO1vRRmwkw/GFWsVmBDPemU0VPAH/IAg hDOM8X7fFSZ1jLGNM3YliNHuwsUK0AGnEH9yzXv59dH0wSPWCKrlFlreBxH47UMhogHelh0JXJD VL4V7p3qbaBYDkZqj3ck/NckeF4uVn+P//9UhZXH4uB7bKgs3hrC4sNQ9wiEHU/NeRJLyqHfRjS BClqcSugout6+1b6cn3jvWrFzFvmUari8B3X58h3juvdbC6gAmSqDhQfpbaGNIdx+SFYgFWDAAJ jQIjR/H5305YuMMlijohS748ALlYUg== X-Proofpoint-ORIG-GUID: cWL6Q_HHrSJDqB4_TyNEF3Suxi6OPV6r X-Authority-Analysis: v=2.4 cv=DeMaa/tW c=1 sm=1 tr=0 ts=693c37f3 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=gAnH3GRIAAAA:8 a=hAzo1ZWYCqDvnDRTSZMA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-12_04,2025-12-11_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512120124 Content-Type: text/plain; charset="utf-8" Add support for adl8113 10MHz to 12GHz Low Noise Amplifier with 10MHz to 14GHz bypass switches. Signed-off-by: Antoniu Miclaus --- changes in v7: - Removed includes: limits.h, device.h, slab.h, sysfs.h - Added includes: bitmap.h, types.h, dev_printk.h, device/driver.h - Removed unused va and vb struct fields - Added trailing comma to supply names array - Changed num_gain_configs to unsigned int - Replaced bitmap operations with bitmap_write() - Enhanced comment showing bit mapping - Changed loop counters to unsigned int - Used compound literals for struct initialization - Fixed devm_kcalloc() line wrapping - Removed INT_MIN testing code - Removed duplicate gain validation - Fixed format specifier to %u for ndescs - Removed redundant blank line drivers/iio/amplifiers/Kconfig | 12 ++ drivers/iio/amplifiers/Makefile | 1 + drivers/iio/amplifiers/adl8113.c | 269 +++++++++++++++++++++++++++++++ 3 files changed, 282 insertions(+) create mode 100644 drivers/iio/amplifiers/adl8113.c diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index 55eb16b32f6c..a8a604863eed 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -36,6 +36,18 @@ config ADA4250 To compile this driver as a module, choose M here: the module will be called ada4250. =20 +config ADL8113 + tristate "Analog Devices ADL8113 Low Noise Amplifier" + depends on GPIOLIB + help + Say yes here to build support for Analog Devices ADL8113 Low Noise + Amplifier with integrated bypass switches. The device supports four + operation modes controlled by GPIO pins: internal amplifier, + internal bypass, and two external bypass modes. + + To compile this driver as a module, choose M here: the + module will be called adl8113. + config HMC425 tristate "Analog Devices HMC425A and similar GPIO Gain Amplifiers" depends on GPIOLIB diff --git a/drivers/iio/amplifiers/Makefile b/drivers/iio/amplifiers/Makef= ile index 2126331129cf..0a76443be1aa 100644 --- a/drivers/iio/amplifiers/Makefile +++ b/drivers/iio/amplifiers/Makefile @@ -6,4 +6,5 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD8366) +=3D ad8366.o obj-$(CONFIG_ADA4250) +=3D ada4250.o +obj-$(CONFIG_ADL8113) +=3D adl8113.o obj-$(CONFIG_HMC425) +=3D hmc425a.o diff --git a/drivers/iio/amplifiers/adl8113.c b/drivers/iio/amplifiers/adl8= 113.c new file mode 100644 index 000000000000..b8a431b6616b --- /dev/null +++ b/drivers/iio/amplifiers/adl8113.c @@ -0,0 +1,269 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ADL8113 Low Noise Amplifier with integrated bypass switches + * + * Copyright 2025 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum adl8113_signal_path { + ADL8113_INTERNAL_AMP, + ADL8113_INTERNAL_BYPASS, + ADL8113_EXTERNAL_A, + ADL8113_EXTERNAL_B, +}; + +struct adl8113_gain_config { + enum adl8113_signal_path path; + int gain_db; +}; + +struct adl8113_state { + struct gpio_descs *gpios; + struct adl8113_gain_config *gain_configs; + unsigned int num_gain_configs; + enum adl8113_signal_path current_path; +}; + +static const char * const adl8113_supply_names[] =3D { + "vdd1", + "vss2", + "vdd2", +}; + +static int adl8113_set_path(struct adl8113_state *st, + enum adl8113_signal_path path) +{ + DECLARE_BITMAP(values, 2); + int ret; + + /* + * Determine GPIO values based on signal path. + * Va: bit 0, Vb: bit 1. + */ + switch (path) { + case ADL8113_INTERNAL_AMP: + bitmap_write(values, 0x00, 0, 2); + break; + case ADL8113_INTERNAL_BYPASS: + bitmap_write(values, 0x03, 0, 2); + break; + case ADL8113_EXTERNAL_A: + bitmap_write(values, 0x02, 0, 2); + break; + case ADL8113_EXTERNAL_B: + bitmap_write(values, 0x01, 0, 2); + break; + default: + return -EINVAL; + } + + ret =3D gpiod_set_array_value_cansleep(st->gpios->ndescs, st->gpios->desc, + st->gpios->info, values); + if (ret) + return ret; + + st->current_path =3D path; + return 0; +} + +static int adl8113_find_gain_config(struct adl8113_state *st, int gain_db) +{ + unsigned int i; + + for (i =3D 0; i < st->num_gain_configs; i++) { + if (st->gain_configs[i].gain_db =3D=3D gain_db) + return i; + } + return -EINVAL; +} + +static const struct iio_chan_spec adl8113_channels[] =3D { + { + .type =3D IIO_VOLTAGE, + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_HARDWAREGAIN), + }, +}; + +static int adl8113_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct adl8113_state *st =3D iio_priv(indio_dev); + unsigned int i; + + switch (mask) { + case IIO_CHAN_INFO_HARDWAREGAIN: + /* Find current gain configuration */ + for (i =3D 0; i < st->num_gain_configs; i++) { + if (st->gain_configs[i].path =3D=3D st->current_path) { + *val =3D st->gain_configs[i].gain_db; + *val2 =3D 0; + return IIO_VAL_INT_PLUS_MICRO_DB; + } + } + return -EINVAL; + default: + return -EINVAL; + } +} + +static int adl8113_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct adl8113_state *st =3D iio_priv(indio_dev); + int config_idx; + + switch (mask) { + case IIO_CHAN_INFO_HARDWAREGAIN: + if (val2 !=3D 0) + return -EINVAL; + + config_idx =3D adl8113_find_gain_config(st, val); + if (config_idx < 0) + return config_idx; + + return adl8113_set_path(st, st->gain_configs[config_idx].path); + default: + return -EINVAL; + } +} + +static const struct iio_info adl8113_info =3D { + .read_raw =3D adl8113_read_raw, + .write_raw =3D adl8113_write_raw, +}; + +static int adl8113_init_gain_configs(struct device *dev, struct adl8113_st= ate *st) +{ + int external_a_gain, external_b_gain; + unsigned int i; + + /* + * Allocate for all 4 possible paths: + * - Internal amp and bypass (always present) + * - External bypass A and B (optional if configured) + */ + st->gain_configs =3D devm_kcalloc(dev, 4, sizeof(*st->gain_configs), + GFP_KERNEL); + if (!st->gain_configs) + return -ENOMEM; + + /* Start filling the gain configurations with data */ + i =3D 0; + + /* Always include internal amplifier (14dB) */ + st->gain_configs[i++] =3D (struct adl8113_gain_config) { + .path =3D ADL8113_INTERNAL_AMP, + .gain_db =3D 14, + }; + + /* Always include internal bypass (-2dB insertion loss) */ + st->gain_configs[i++] =3D (struct adl8113_gain_config) { + .path =3D ADL8113_INTERNAL_BYPASS, + .gain_db =3D -2, + }; + + /* Add external bypass A if configured */ + if (!device_property_read_u32(dev, "adi,external-bypass-a-gain-db", + &external_a_gain)) { + st->gain_configs[i++] =3D (struct adl8113_gain_config) { + .path =3D ADL8113_EXTERNAL_A, + .gain_db =3D external_a_gain, + }; + } + + /* Add external bypass B if configured */ + if (!device_property_read_u32(dev, "adi,external-bypass-b-gain-db", + &external_b_gain)) { + st->gain_configs[i++] =3D (struct adl8113_gain_config) { + .path =3D ADL8113_EXTERNAL_B, + .gain_db =3D external_b_gain, + }; + } + + st->num_gain_configs =3D i; + + return 0; +} + +static int adl8113_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct adl8113_state *st; + struct iio_dev *indio_dev; + int ret; + + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st =3D iio_priv(indio_dev); + + st->gpios =3D devm_gpiod_get_array(dev, "ctrl", GPIOD_OUT_LOW); + if (IS_ERR(st->gpios)) + return dev_err_probe(dev, PTR_ERR(st->gpios), + "failed to get control GPIOs\n"); + + if (st->gpios->ndescs !=3D 2) + return dev_err_probe(dev, -EINVAL, + "expected 2 control GPIOs, got %u\n", + st->gpios->ndescs); + + ret =3D devm_regulator_bulk_get_enable(dev, + ARRAY_SIZE(adl8113_supply_names), + adl8113_supply_names); + if (ret) + return dev_err_probe(dev, ret, + "failed to get and enable supplies\n"); + + /* Initialize gain configurations from devicetree */ + ret =3D adl8113_init_gain_configs(dev, st); + if (ret) + return ret; + + /* Initialize to internal amplifier path (14dB) */ + ret =3D adl8113_set_path(st, ADL8113_INTERNAL_AMP); + if (ret) + return ret; + + indio_dev->info =3D &adl8113_info; + indio_dev->name =3D "adl8113"; + indio_dev->channels =3D adl8113_channels; + indio_dev->num_channels =3D ARRAY_SIZE(adl8113_channels); + + return devm_iio_device_register(dev, indio_dev); +} + +static const struct of_device_id adl8113_of_match[] =3D { + { .compatible =3D "adi,adl8113" }, + { } +}; +MODULE_DEVICE_TABLE(of, adl8113_of_match); + +static struct platform_driver adl8113_driver =3D { + .driver =3D { + .name =3D "adl8113", + .of_match_table =3D adl8113_of_match, + }, + .probe =3D adl8113_probe, +}; +module_platform_driver(adl8113_driver); + +MODULE_AUTHOR("Antoniu Miclaus "); +MODULE_DESCRIPTION("Analog Devices ADL8113 Low Noise Amplifier"); +MODULE_LICENSE("GPL"); --=20 2.43.0