From nobody Sat Oct 4 05:01:31 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 78A34183CC3; Wed, 20 Aug 2025 12:03:42 +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=1755691423; cv=none; b=AQ1sQFrLcSf8gpz6btBcJ1R6LwJc1GAABw/TKPre43wp/qZN9zoaVOU9+20RsSvuKWuqRcryWBm/njhTlA6JEm2MFm/9ePk4yD74AaRiL7gW74rZD+ByUY+I3KUdPlHHEUBrqb5rMX1B9dyqilCkfyuclTjYwA9gurvzQq0glUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755691423; c=relaxed/simple; bh=z8bLqHwpvngK6gcUYWs7qMVeXee4Vtw/v6LaTDPqbxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bdAmFD98NqkYQJxZ3xRGmi58YRSCZwtBPO3PSCPAINiL8WB4UsdwfV3I/+zLpFyoqrX1iIGRQr0CjgUWUMWPzMNKHP43ITjTmMxzK+1PPoggWQfIg2zpQwdUs1L9x1o7+VEaneM5U6Qb6BRm3EYLVVrEbB72MVh2VAQ1xWeu110= 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=tVXjdnlR; 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="tVXjdnlR" 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 57KAeT62009192; Wed, 20 Aug 2025 08:03:21 -0400 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=VlroM pKcXDPuoJj+59G58B7SlPdih7G8ELsAp5BUcS8=; b=tVXjdnlRlk+uV18twGtpC prlyi+/Ja6DcpK8HpDxRedD+K9irLDG6cMI/rdYauFn9hS4h/cofbGVQsnb9G5BK fZc4hjAlN7h8TfXFNI9e9uiMogfQfh9glzlYoLmxgB3Azo1KTpw6iqUqRK/kTkTG sSMyIGZ2uTu+PBV61BqYkpuPkF2IWlyTg/DPVzaYMcqCWaJNzbhU/c0bCI15YAdi M1Z2yg9lMYl/DgLh3Btz96D+hPpQgSypSS6EYe3pHJTYDDc+A/dVcor561fSjivc BinXLW4S3g5twYiliKYfyqQHqGk7oGxsTuskkQAikVSa7oF68AkgEM7K3EbgSfh1 Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 48n0tdufg2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Aug 2025 08:03:21 -0400 (EDT) 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 57KC3KX9037336 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Aug 2025 08:03:20 -0400 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.10; Wed, 20 Aug 2025 08:03:20 -0400 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.1748.10; Wed, 20 Aug 2025 08:03:20 -0400 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.1748.10 via Frontend Transport; Wed, 20 Aug 2025 08:03:20 -0400 Received: from IRISTEIU-L01.ad.analog.com (IRISTEIU-L01.ad.analog.com [10.48.65.173]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 57KC31n1020092; Wed, 20 Aug 2025 08:03:13 -0400 From: Ioana Risteiu 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 , Ramona Nechita , , , CC: Ioana Risteiu Subject: [PATCH v4 1/4] iio: adc: adi-axi-adc: add axi_adc_num_lanes_set Date: Wed, 20 Aug 2025 15:02:42 +0300 Message-ID: <20250820120247.3012-2-Ioana.Risteiu@analog.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250820120247.3012-1-Ioana.Risteiu@analog.com> References: <20250820120247.3012-1-Ioana.Risteiu@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-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NSBTYWx0ZWRfX2J1p6Omh5b1d Ly+xmKXL4WSxbM+jjA3/8OVHCwVJadfG5WIKutGrC1NDdbuvD6mZdOs7tM9OT+FQfd766udY2Ya mlfg4rb4AZwPflmV3U+hzpRdaqHK0sDjsXq11JSxbU/VlWkMEO3JxBSmINnPv4YWxDzpEercaXx jkOlAEfCvJqqwM8GU0auZN2UOk3z45ynZHss3AQvUwr2CtGGeMpfDWVrIVbZE/rpWvJsfYQYh71 hLU6qTOrRtcYSeQOmf7LXx4zRLEfHeHTSecC3JARXH+bMPoyQ5ZuJe3sTM68C5/ibqi/ZmRBEqK AR+egvW5MDSMvHBQ/5J6m63SelIDXLHuoc+6M9JMIJH7Em6KkqbQXYQz2qW97nnRBQ9vJ/pg4P5 m8eEQ1Yg2sX3bOGGJqpyYdUy5Ay1tQ== X-Proofpoint-ORIG-GUID: ouMI4jWoYZs6O73CNBe3TyHeECUAGTaB X-Authority-Analysis: v=2.4 cv=BoHEAYX5 c=1 sm=1 tr=0 ts=68a5b989 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=2OwXVqhp2XgA:10 a=gAnH3GRIAAAA:8 a=Jw71EcAk_mQ5ulMM_6cA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: ouMI4jWoYZs6O73CNBe3TyHeECUAGTaB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-20_03,2025-08-20_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2508110000 definitions=main-2508190195 Content-Type: text/plain; charset="utf-8" Add axi_adc_num_lanes_set in the adi_axi_adc_ops structure to support setting number of lanes used by AXI ADC. This operation is included in the generic structure because the number of lanes is a configurable parameter of the generic AXI ADC IP core, not specific to a device. Signed-off-by: Ioana Risteiu --- changes in v4: - improved patch description drivers/iio/adc/adi-axi-adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 2d86bb0e08a7..20bb59c24acf 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -617,6 +617,7 @@ static const struct iio_backend_ops adi_axi_adc_ops =3D= { .chan_status =3D axi_adc_chan_status, .interface_type_get =3D axi_adc_interface_type_get, .oversampling_ratio_set =3D axi_adc_oversampling_ratio_set, + .num_lanes_set =3D axi_adc_num_lanes_set, .debugfs_reg_access =3D iio_backend_debugfs_ptr(axi_adc_reg_access), .debugfs_print_chan_status =3D iio_backend_debugfs_ptr(axi_adc_debugfs_pr= int_chan_status), }; --=20 2.47.2 From nobody Sat Oct 4 05:01:31 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 A8C7C27605C; Wed, 20 Aug 2025 12:03:42 +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=1755691424; cv=none; b=BYpS4mBiy33HGsScAKIaFzxYJ6E6kpRmPxywyBUBMigJ4abMeZt8uWHiAXMzfH94APLtBwYiSL+d4DUNlVms3Oc1mYb9LVGzN+cC238YhY4Gi6C9Z5VCyP9uHeNUsakMqdDmo8ZWO7B59Vmdn08K5r8q6xPphs2gyNs/bswnoHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755691424; c=relaxed/simple; bh=6DVSW1b86Rsazl1faHqxTsS4ZQHj7kU+V64WxGV6UMQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VyvDTuC/xV5MyGDLdXv0ifhtTVa2hV0wvOxZrn9CvowIe0N8E2Xr0kAQera+/+qIQl3j7L7DquXsAgp907pBYkCagJGUxAa5X/36pRaWI6OGq7delAoYw5cHmN6DzFeNU7YEQE65Wdt/GoBCT40jWhD/40QHSW6TMrjwiwyV5Bk= 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=pneLz1ag; 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="pneLz1ag" 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 57KA3cOh004349; Wed, 20 Aug 2025 08:03:26 -0400 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=uuvof AA3L0xu8ZK2d7GUgFtboylj1xqQu0EZxfODhx8=; b=pneLz1agtpZ1ruyUNZ/wX z9t9w9unRGPnkZlBaGL/ieXKmq70SSBBxG0X6s5qYNX/DQULAq/ibP7A8shhqZgC HM/CjKhLfpuElTHFL0DD+QDdtYw6Rn44sYPkMHNf8eTs2atrdbV1k/9siHkJOwzV BCoEbJeVhDox3ohEVTRIADju9bvHgJUEyvShrLMA/f1PyRsPAOf3ndYY2WgK8LjB CcqIbZRtGYewFOqhv6quBt3iv+5vo7EsOw9/YHEDeWVkcptTURcec+eh3bqm4VlD hOOWI19EuHw/8KHFD3xK3NAic7gD26Ae6gMb0/ouO5EPOcbXwFHuDPHFa58vUILr w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 48n0td3gtp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Aug 2025 08:03:25 -0400 (EDT) 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 57KC3OWD037342 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Aug 2025 08:03:24 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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.10; Wed, 20 Aug 2025 08:03:24 -0400 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.1748.10 via Frontend Transport; Wed, 20 Aug 2025 08:03:24 -0400 Received: from IRISTEIU-L01.ad.analog.com (IRISTEIU-L01.ad.analog.com [10.48.65.173]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 57KC31n2020092; Wed, 20 Aug 2025 08:03:18 -0400 From: Ioana Risteiu 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 , Ramona Nechita , , , CC: Ioana Risteiu , Krzysztof Kozlowski Subject: [PATCH v4 2/4] dt-bindings: iio: adc: add IIO backend support Date: Wed, 20 Aug 2025 15:02:43 +0300 Message-ID: <20250820120247.3012-3-Ioana.Risteiu@analog.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250820120247.3012-1-Ioana.Risteiu@analog.com> References: <20250820120247.3012-1-Ioana.Risteiu@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-Authority-Analysis: v=2.4 cv=bvAVxEai c=1 sm=1 tr=0 ts=68a5b98e cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=2OwXVqhp2XgA:10 a=VwQbUJbxAAAA:8 a=KKAkSRfTAAAA:8 a=gAnH3GRIAAAA:8 a=k_RRbiLaOECQDL48JDUA:9 a=cvBusfyB2V15izCimMoJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: W7zzJ9gwtKXgyJVcIdOhymImS1YndAMM X-Proofpoint-ORIG-GUID: W7zzJ9gwtKXgyJVcIdOhymImS1YndAMM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NSBTYWx0ZWRfX7qzns3J4Wd4F oFRBzC+Dg0OQ1Hy9dGuCEhXBd9A8+msyHvpm6/o4MWeb/6yCpKTqgnlropY8M0q7faeKcCj/5Eu iM4KB+mrthMrUyHqOcgPF9EHECYDNbD5bhmaGbj90rGg3jfunb0erGlqwevBeS8uqewsA0isEQ+ AyXuRerI40+Hvx/yGvBjwzkrIx5kY0nWASPBWqwUuQw9/FxCa8AKe2L4UW4LdBnZfQKC08sgNzS EpqlTEBCzCTKcKGGvhg4bm1Qn+CE1+keuxxPl88Bm9muKykt1h59HafKmtkF1AEd+vQllekWAVP 3y0DLPIXEf+8XyDOquHZ/ipIf7K+Ir6v+Al12YeuL+ObHsKxpJh9TcXqbsTc23L6u5AM9rsnHKx raL8UEREB5IrlL3mJyiSaarbrJ7YNQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-20_03,2025-08-20_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 clxscore=1011 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2508110000 definitions=main-2508190195 Content-Type: text/plain; charset="utf-8" Add the generic io-backends property to the AD7779 binding to enable support for the IIO backend framework. Also add the adi,num-lanes property to set the number of lanes used by AD7779. Reviewed-by: Rob Herring (Arm) Reviewed-by: Krzysztof Kozlowski Signed-off-by: Ioana Risteiu --- changes in v4: - included previously omitted reviewers from earlier patches - modified the logic for handling adi,num-lanes in devicetree .../bindings/iio/adc/adi,ad7779.yaml | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7779.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad7779.yaml index 044f92f39cfa..ba3f7b2bd6cf 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7779.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7779.yaml @@ -80,11 +80,36 @@ properties: reset-gpios: maxItems: 1 =20 + io-backends: + maxItems: 1 + + adi,num-lanes: + description: + Number of lanes on which the data is sent on the output when the data + output interface is used. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4] + default: 4 + required: - compatible - reg - clocks - - interrupts + +allOf: + - if: + not: + required: + - io-backends + then: + properties: + adi,num-lanes: false + +oneOf: + - required: + - interrupts + - required: + - io-backends =20 unevaluatedProperties: false =20 @@ -107,4 +132,21 @@ examples: clocks =3D <&adc_clk>; }; }; + + - | + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@0 { + compatible =3D "adi,ad7779"; + reg =3D <0>; + start-gpios =3D <&gpio0 87 GPIO_ACTIVE_LOW>; + reset-gpios =3D <&gpio0 93 GPIO_ACTIVE_LOW>; + clocks =3D <&adc_clk>; + io-backends =3D <&iio_backend>; + adi,num-lanes =3D <4>; + }; + }; ... --=20 2.47.2 From nobody Sat Oct 4 05:01:31 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 DF3092F3C2A; Wed, 20 Aug 2025 12:03: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=1755691428; cv=none; b=CRBq/b/rKjP14XQf+hTC4cX7g3QvrWnLsp8v5zU3W7QoFgih1j5U/ieqfyG4qxjgffucv4N++1+oE0A/EU2dgHPRc8JTjQUjfT0fNkB0ZsFTi3faUx+3TX5wRYhxB3l1Oz1lCB5hWT0gQePahLH+IfvqKTkrjPFdh/Prvyyfck8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755691428; c=relaxed/simple; bh=1OJFpcp4YYqG2GVDaeP2XJuGBpnCCCGj/RAEZS/bfOc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iwOZMsvAIOkCBMaVfb3hgk081lTmsbw3h0LmEkoNFBCNXP/iGqvlbdqVOigXvhmluAqgR6QjCAWAQuWYNmqlZMAIX/NsZBPRsyfUnEMsdJ/Qm+1huABq7u9ugGfSyXbLTjUGq1qRoCvx7b2UwxE6Hw8cqy+FuhVyAtHPdnqeYw4= 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=ZWIrXcpb; 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="ZWIrXcpb" 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 57KAcs9o004346; Wed, 20 Aug 2025 08:03:33 -0400 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=7fOTP 1CEnTzzN3ibLisR9ekC7LLlotBk71PqCaUFRVo=; b=ZWIrXcpb7C9CJeAMk9JvD BEYHP/3jxfSkZt7tlSl4674KZ7jzePFwoWsWLwbnFCIGkvCw+J8UXp5EY4p5OTJt UYpNiaF8qXqgG5va+ikGllTCvruuRQVApQkeHDTaergTXfc/2HSYNTHm66n9tqDr xaR0P4QCv6xmEsh+IGWwRaV88RkegxVYSq8uco8dsLB4rb5VlZnrZgjOk740jE6S xdkdz0dpTHSbeekOEe7DxaWTGi5pWbFBkfwL8oXb3EA8WiRINODh84z6Pz0QSgx/ /Ptz2RTwZFpBB4F7dXg7h09id4CNUbpRgJ0SS0l/5XY8zDZDrBnlVPhXvNOpeqvh A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 48n0td3guj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Aug 2025 08:03:32 -0400 (EDT) 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 57KC3VSv004706 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Aug 2025 08:03:31 -0400 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.10; Wed, 20 Aug 2025 08:03:31 -0400 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.1748.10; Wed, 20 Aug 2025 08:03:31 -0400 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.1748.10 via Frontend Transport; Wed, 20 Aug 2025 08:03:31 -0400 Received: from IRISTEIU-L01.ad.analog.com (IRISTEIU-L01.ad.analog.com [10.48.65.173]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 57KC31n3020092; Wed, 20 Aug 2025 08:03:24 -0400 From: Ioana Risteiu 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 , Ramona Nechita , , , CC: Ioana Risteiu Subject: [PATCH v4 3/4] iio: adc: extract setup function without backend Date: Wed, 20 Aug 2025 15:02:44 +0300 Message-ID: <20250820120247.3012-4-Ioana.Risteiu@analog.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250820120247.3012-1-Ioana.Risteiu@analog.com> References: <20250820120247.3012-1-Ioana.Risteiu@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-Authority-Analysis: v=2.4 cv=bvAVxEai c=1 sm=1 tr=0 ts=68a5b994 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=2OwXVqhp2XgA:10 a=gAnH3GRIAAAA:8 a=e6B03PNIoHuVPIBsO9AA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: WQwN1nrInSMs8PEmrVZjifBKCsbxCgda X-Proofpoint-ORIG-GUID: WQwN1nrInSMs8PEmrVZjifBKCsbxCgda X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NSBTYWx0ZWRfX/AtsBmOsquDt SxFmX+1SaTgfsa8bCJFCavZLb2mR/4ARV3Ce7Gp4JxUA4Twf1R18aTRxLNIgKoGEoT0eesj4+x4 o7NUjfyGkxnNJVOzbgTlb+39vrWfXmLt8HPDCzZt0sUH2SmtaJVwDut6zwe8t+erWA+oo9We2H2 xBc/TQiTy1Kfc6aYd6E6FdSneYYK2nWBSJmvcQCRekVUMX1dAS6S6Ovu48TirFoAPvpJuxS6Xyi 7t4wkWEEgki0lorybAnlVaAJpP3gXXHLrPra86bMyJKfFMGPlcmMGN4uxP1l/4n/ohk95xunBnZ 1vgs/CkO7dWAuA3TcVDopFP78ezbvwPX3kj8OAXmAdv3V4rdNF0vBGyk4+01/8DwacxMWpblhI6 va9ZVBNDkGqHI1y+UUT7pgRbuP7rPg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-20_03,2025-08-20_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2508110000 definitions=main-2508190195 Content-Type: text/plain; charset="utf-8" Refactor probe function by moving the initialization specific to communication without iio-backend into a separate setup function. The purpose of this modification is better code organization. No functional changes intended. Signed-off-by: Ioana Risteiu --- no changes in v4. drivers/iio/adc/ad7779.c | 83 ++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c index 845adc510239..f7e681c0e8c0 100644 --- a/drivers/iio/adc/ad7779.c +++ b/drivers/iio/adc/ad7779.c @@ -752,6 +752,50 @@ static int ad7779_conf(struct ad7779_state *st, struct= gpio_desc *start_gpio) return 0; } =20 +static int ad7779_setup_without_backend(struct ad7779_state *st, struct ii= o_dev *indio_dev) +{ + int ret; + struct device *dev =3D &st->spi->dev; + + indio_dev->info =3D &ad7779_info; + indio_dev->channels =3D st->chip_info->channels; + + st->trig =3D devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, + iio_device_id(indio_dev)); + if (!st->trig) + return -ENOMEM; + + st->trig->ops =3D &ad7779_trigger_ops; + + iio_trigger_set_drvdata(st->trig, st); + + ret =3D devm_request_irq(dev, st->spi->irq, iio_trigger_generic_data_rdy_= poll, + IRQF_ONESHOT | IRQF_NO_AUTOEN, indio_dev->name, + st->trig); + if (ret) + return dev_err_probe(dev, ret, "request IRQ %d failed\n", + st->spi->irq); + + ret =3D devm_iio_trigger_register(dev, st->trig); + if (ret) + return ret; + + indio_dev->trig =3D iio_trigger_get(st->trig); + + init_completion(&st->completion); + + ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, + &iio_pollfunc_store_time, + &ad7779_trigger_handler, + &ad7779_buffer_setup_ops); + if (ret) + return ret; + + return ad7779_spi_write_mask(st, AD7779_REG_DOUT_FORMAT, + AD7779_DCLK_CLK_DIV_MSK, + FIELD_PREP(AD7779_DCLK_CLK_DIV_MSK, 7)); +} + static int ad7779_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -760,9 +804,6 @@ static int ad7779_probe(struct spi_device *spi) struct device *dev =3D &spi->dev; int ret =3D -EINVAL; =20 - if (!spi->irq) - return dev_err_probe(dev, ret, "DRDY irq not present\n"); - indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; @@ -804,45 +845,11 @@ static int ad7779_probe(struct spi_device *spi) return ret; =20 indio_dev->name =3D st->chip_info->name; - indio_dev->info =3D &ad7779_info; indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels =3D st->chip_info->channels; indio_dev->num_channels =3D ARRAY_SIZE(ad7779_channels); =20 - st->trig =3D devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, - iio_device_id(indio_dev)); - if (!st->trig) - return -ENOMEM; - - st->trig->ops =3D &ad7779_trigger_ops; - - iio_trigger_set_drvdata(st->trig, st); - - ret =3D devm_request_irq(dev, spi->irq, iio_trigger_generic_data_rdy_poll, - IRQF_ONESHOT | IRQF_NO_AUTOEN, indio_dev->name, - st->trig); - if (ret) - return dev_err_probe(dev, ret, "request IRQ %d failed\n", - st->spi->irq); - - ret =3D devm_iio_trigger_register(dev, st->trig); - if (ret) - return ret; - - indio_dev->trig =3D iio_trigger_get(st->trig); - - init_completion(&st->completion); - - ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, - &iio_pollfunc_store_time, - &ad7779_trigger_handler, - &ad7779_buffer_setup_ops); - if (ret) - return ret; + ret =3D ad7779_setup_without_backend(st, indio_dev); =20 - ret =3D ad7779_spi_write_mask(st, AD7779_REG_DOUT_FORMAT, - AD7779_DCLK_CLK_DIV_MSK, - FIELD_PREP(AD7779_DCLK_CLK_DIV_MSK, 7)); if (ret) return ret; =20 --=20 2.47.2 From nobody Sat Oct 4 05:01:31 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 DF8482E8889; Wed, 20 Aug 2025 12:03: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=1755691434; cv=none; b=gQ9xFbMu7pVb3uawF8Aw/ydxWjQeMAD3n/quuyF/8ditUAwAQkbb6hzm1Hlp0k44WDRQjJfJVsUf7K6W1XMR9UdS+17hEC0kQ9sI00goaFpFcfzAz104+BBdFl8NdkuyLmMvAtm/fRTrmLSaajJrnVoxgw7R5MVEsE/N/iItZg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755691434; c=relaxed/simple; bh=Ksl/P0FewlvtlAM4h8GRfzNWfnApy8twRnod3sBzruo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WJekBwBZ6UhZmCcs2MqPWoztQU+0ZRyQMhSXu731xBm6JXrzYZqGx346fxbAgBqOYKR7UBQWg1JY5FR/vK6bryGhClJi8lgKJpv2tG1sfHfoDU0QWrMLBnm5u8C5z/dZz5OkYWMUgRRqtUzu9kCp8vcSo0VXEB5mnwh9TFy+yWI= 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=sA9hxJPx; 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="sA9hxJPx" 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 57KAeT6E009192; Wed, 20 Aug 2025 08:03:38 -0400 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=szKwJ DHvtugDHsPzhtNq0i+ZtQ0tz1Z1J3+jkQRTVn0=; b=sA9hxJPx3OTi6QXz/RiAt 4wBhjxWlgmGEzbLNzprFuFVc2nUSpW3FB/IoBnQPoPW5/zHgM62j0rQ1ANLOQ0vn MSC5QCz6D5Eh7k1zEdacXYlp5hjrPA8uTn6M4YFbZ+Vh6FlDBnVnY7NK+aKaKH/F /64KadhfJpiejZKYPmZPC1cULSuChMIh7THFpR3oBVUwZ+7LEyFJpVkm9HSOGPyY VH3TXZ+8p+df1wCJ3lSioMaQ+hlvO9kvlkIR/NTvYZBDW5rMovTwQEOh+Gncv+EL uWEhNF04RnWxQs+BX3C2qLCPLWMBlTNj700G0IcQhlTuSHdy663zfIcrgKfGku44 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 48n0tdufhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Aug 2025 08:03:37 -0400 (EDT) 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 57KC3aqH037366 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Aug 2025 08:03:36 -0400 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.1748.10; Wed, 20 Aug 2025 08:03:36 -0400 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.1748.10; Wed, 20 Aug 2025 08:03:36 -0400 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.1748.10 via Frontend Transport; Wed, 20 Aug 2025 08:03:36 -0400 Received: from IRISTEIU-L01.ad.analog.com (IRISTEIU-L01.ad.analog.com [10.48.65.173]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 57KC31n4020092; Wed, 20 Aug 2025 08:03:29 -0400 From: Ioana Risteiu 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 , Ramona Nechita , , , CC: Ioana Risteiu Subject: [PATCH v4 4/4] iio: adc: update ad7779 to use IIO backend Date: Wed, 20 Aug 2025 15:02:45 +0300 Message-ID: <20250820120247.3012-5-Ioana.Risteiu@analog.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250820120247.3012-1-Ioana.Risteiu@analog.com> References: <20250820120247.3012-1-Ioana.Risteiu@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-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NSBTYWx0ZWRfX0B6s+v+BXogx u4PCRGjlJMqip62mE7N/4AUl3x9rqeoqeVjhZHMrGKVdj/mZBto2vFnFz0auUJOqzYkpffuqZjf Ire7Py9W9FH/0BtRnNTGHSjGsVMhySNADIAdT+xSe7NSJ+iMnq0GeZLjgRTPmNEUTfbvrIxTeyA j/XbYPC/jXbZ7wTeC5tWNkRQwnAfHttMLlST8yV3lzjIIPMKu6YVOWVi4gwW/MRaSA16mLI04v2 IuH9uX7AsrNMWbkoDIuw4ChovZ7T5bLGDIIg2o8FA5ArYHWKdIABirDRZbbNxuO5IwYhXq9MTZu gNwvNc/+RASmRs5aaHUcg86v90EVA3jr6gK9gF1H2Zg9yPV0sFvIv19HnhrbCSvpDms6ajlIfuu 3iz4SOspI9OiItlAt0s0274dFe1d2g== X-Proofpoint-ORIG-GUID: hiXJFulbev_dI0BC2Put3c1GCiTAzDcB X-Authority-Analysis: v=2.4 cv=BoHEAYX5 c=1 sm=1 tr=0 ts=68a5b999 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=2OwXVqhp2XgA:10 a=gAnH3GRIAAAA:8 a=VjRcvFoKhyOr0kwuT1sA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: hiXJFulbev_dI0BC2Put3c1GCiTAzDcB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-20_03,2025-08-20_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2508110000 definitions=main-2508190195 Content-Type: text/plain; charset="utf-8" Add a new functionality to ad7779 driver that streams data through data output interface using IIO backend interface. Signed-off-by: Ioana Risteiu --- changes in v4: - grouped includes in alphabetical order - reordered fields in struct ad7779_state - modified logic of setting the number of lanes=20 - validating devicetree value drivers/iio/adc/ad7779.c | 116 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c index f7e681c0e8c0..adca490061c9 100644 --- a/drivers/iio/adc/ad7779.c +++ b/drivers/iio/adc/ad7779.c @@ -25,6 +25,7 @@ #include =20 #include +#include #include #include #include @@ -116,6 +117,12 @@ #define AD7779_CRC8_POLY 0x07 DECLARE_CRC8_TABLE(ad7779_crc8_table); =20 +enum ad7779_data_lines { + AD7779_1LINE =3D 1, + AD7779_2LINES =3D 2, + AD7779_4LINES =3D 4, +}; + enum ad7779_filter { AD7779_SINC3, AD7779_SINC5, @@ -145,6 +152,7 @@ struct ad7779_state { struct completion completion; unsigned int sampling_freq; enum ad7779_filter filter_enabled; + struct iio_backend *back; /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -630,12 +638,38 @@ static int ad7779_reset(struct iio_dev *indio_dev, st= ruct gpio_desc *reset_gpio) return ret; } =20 +static int ad7779_update_scan_mode(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct ad7779_state *st =3D iio_priv(indio_dev); + unsigned int c; + int ret; + + for (c =3D 0; c < AD7779_NUM_CHANNELS; c++) { + if (test_bit(c, scan_mask)) + ret =3D iio_backend_chan_enable(st->back, c); + else + ret =3D iio_backend_chan_disable(st->back, c); + if (ret) + return ret; + } + + return 0; +} + static const struct iio_info ad7779_info =3D { .read_raw =3D ad7779_read_raw, .write_raw =3D ad7779_write_raw, .debugfs_reg_access =3D &ad7779_reg_access, }; =20 +static const struct iio_info ad7779_info_data =3D { + .read_raw =3D ad7779_read_raw, + .write_raw =3D ad7779_write_raw, + .debugfs_reg_access =3D &ad7779_reg_access, + .update_scan_mode =3D &ad7779_update_scan_mode, +}; + static const struct iio_enum ad7779_filter_enum =3D { .items =3D ad7779_filter_type, .num_items =3D ARRAY_SIZE(ad7779_filter_type), @@ -752,6 +786,49 @@ static int ad7779_conf(struct ad7779_state *st, struct= gpio_desc *start_gpio) return 0; } =20 +static int ad7779_set_data_lines(struct iio_dev *indio_dev, + unsigned int num_lanes) +{ + struct ad7779_state *st =3D iio_priv(indio_dev); + int ret =3D -EINVAL; + + if (num_lanes !=3D AD7779_1LINE && + num_lanes !=3D AD7779_2LINES && + num_lanes !=3D AD7779_4LINES) + return ret; + + ret =3D ad7779_set_sampling_frequency(st, num_lanes * AD7779_DEFAULT_SAMP= LING_1LINE); + if (ret) + return ret; + + ret =3D iio_backend_num_lanes_set(st->back, num_lanes); + if (ret) + return ret; + + return ad7779_spi_write_mask(st, AD7779_REG_DOUT_FORMAT, + AD7779_DOUT_FORMAT_MSK, + FIELD_PREP(AD7779_DOUT_FORMAT_MSK, 2 - ilog2(num_lanes))); +} + +static int ad7779_setup_channels(struct iio_dev *indio_dev, const struct a= d7779_state *st) +{ + struct iio_chan_spec *channels; + struct device *dev =3D &st->spi->dev; + + channels =3D devm_kmemdup_array(dev, st->chip_info->channels, + ARRAY_SIZE(ad7779_channels), + sizeof(*channels), GFP_KERNEL); + if (!channels) + return -ENOMEM; + + for (int i =3D 0; i < ARRAY_SIZE(ad7779_channels); i++) + channels[i].scan_type.endianness =3D IIO_CPU; + + indio_dev->channels =3D channels; + + return 0; +} + static int ad7779_setup_without_backend(struct ad7779_state *st, struct ii= o_dev *indio_dev) { int ret; @@ -796,6 +873,39 @@ static int ad7779_setup_without_backend(struct ad7779_= state *st, struct iio_dev FIELD_PREP(AD7779_DCLK_CLK_DIV_MSK, 7)); } =20 +static int ad7779_setup_backend(struct ad7779_state *st, struct iio_dev *i= ndio_dev) +{ + struct device *dev =3D &st->spi->dev; + int ret =3D -EINVAL; + int num_lanes; + + indio_dev->info =3D &ad7779_info_data; + + ret =3D ad7779_setup_channels(indio_dev, st); + if (ret) + return ret; + + st->back =3D devm_iio_backend_get(dev, NULL); + if (IS_ERR(st->back)) + return dev_err_probe(dev, PTR_ERR(st->back), + "failed to get iio backend"); + + ret =3D devm_iio_backend_request_buffer(dev, st->back, indio_dev); + if (ret) + return ret; + + ret =3D devm_iio_backend_enable(dev, st->back); + if (ret) + return ret; + + num_lanes =3D 4; + ret =3D device_property_read_u32(dev, "adi,num-lanes", &num_lanes); + if (ret && ret !=3D -EINVAL) + return ret; + + return ad7779_set_data_lines(indio_dev, num_lanes); +} + static int ad7779_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -848,7 +958,10 @@ static int ad7779_probe(struct spi_device *spi) indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->num_channels =3D ARRAY_SIZE(ad7779_channels); =20 - ret =3D ad7779_setup_without_backend(st, indio_dev); + if (device_property_present(dev, "io-backends")) + ret =3D ad7779_setup_backend(st, indio_dev); + else + ret =3D ad7779_setup_without_backend(st, indio_dev); =20 if (ret) return ret; @@ -943,3 +1056,4 @@ module_spi_driver(ad7779_driver); MODULE_AUTHOR("Ramona Alexandra Nechita "); MODULE_DESCRIPTION("Analog Devices AD7779 ADC"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_BACKEND"); --=20 2.47.2