From nobody Fri Dec 19 20:37:41 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 999AC236431; Fri, 16 May 2025 10:59:25 +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=1747393167; cv=none; b=kVjpMWxBpP89B0IaR8eKTSCt6BmPEBl5M6XRJ3VWQi1gI8QD0zm8qLG++9m644Erxgkqt1UGYfqxxVYz0w0qLADNkbQSTirNiZDylREfW39XDTifMalywcZRdoIr/D3Ud8ofh7Dqj2U+J+2IJCKUZEiV9qpz5oJDy4rtYC7WRqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747393167; c=relaxed/simple; bh=8n5vfw2mNTOuq2EktnNj1CALxl3b0x26IBLkYOudw2U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZHb87m2pFu/6B0Tfvp3IJp/fjVppnzWB2sB9Y+RnL8Ka6iX+z4TqhOAI20/CMJWaPEmWRKaaVRvdwG7jolOBndyha/yYympl5202SA8uAlwZz/XtQGL3B7fAIuPIJkzq/qWH477p6SzGVt7XkqdFiJlaI7/zVYhLOk42pvdRQdU= 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=fX4Qcerz; 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="fX4Qcerz" 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 54G8fjBq016350; Fri, 16 May 2025 06:58:59 -0400 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=qf2gi ndpfEn5Dnk29cqTyVX1Ov9nbZCV1G3+utnQJyw=; b=fX4QcerzzWkdb6x/RAzWb c+nxnekmM1jyRqIS333kgWW/ql6VWiVrAQBG1+1tGPo/CZrYcen/eO/V9V12IhvH /lYb8Bv0nPBgpz58yWu+IIYnqLkcfTpxPC0RHAN4bVZ6r3dGRmKNuCkGObeLjA9G b4oB0g5ms5TH4W/5eM15IjZowuD/BbPPZ7WsdYkp3e0HDv9azz8PmgCPqrFMKRfR egjAZC75jCNKnYjgvkuhzd26UccOyAMM2D2b5UqUe2VGtaf5rgbk4s2J9rx8o91h cGyg6BLyRUWDDWYvFDol/0tUGu5yYuQtUszwtXniJ0fElRg+kxoRpIquU2w5sFox g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46mn655jtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 May 2025 06:58:59 -0400 (EDT) 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 54GAwwte050052 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 May 2025 06:58:58 -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.986.14; Fri, 16 May 2025 06:58:58 -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.986.14; Fri, 16 May 2025 06:58:58 -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.986.14 via Frontend Transport; Fri, 16 May 2025 06:58:58 -0400 Received: from romlx5.adlk.analog.com ([10.48.65.73]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 54GAwRHv006196; Fri, 16 May 2025 06:58:48 -0400 From: Pop Ioan Daniel 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 , Sergiu Cuciurean , "Dragos Bogdan" , Antoniu Miclaus , Olivier Moysan , Javier Carrasco , Matti Vaittinen , Tobias Sperling , Marcelo Schmitt , Alisa-Dariana Roman , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Gon=C3=A7alves?= , Herve Codina , "Ioan Daniel" , , , Subject: [PATCH v3 1/4] iio: backend: update iio_backend_oversampling_ratio_set Date: Fri, 16 May 2025 13:58:01 +0300 Message-ID: <20250516105810.3028541-2-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> References: <20250516105810.3028541-1-pop.ioan-daniel@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: jGpNSYt9TeuP3nSrjJ88BF_LLReK7_XI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE2MDEwNCBTYWx0ZWRfXyxydKLcLgRIS SAm1IK1sBPxXjaEPDA+gfJfDY0YO9WssMzC8W/tZLfnrvLzNOcjdwyMulNIM/SYgy/2gmkpcdeK BpFUT7Y8OZ3MvZsljHDREnWG3RsRcrALcQ2eWeRLSc/GqwwCywgy3xZ+ksUUN6bYHqQ78mfPedj ySIv8IRpn6VnWc/CNtNmmm3eL42hxoNoCMozTjLxOJazwBVoqBxWIvf/sLioLVFQASsz3icZu0y pgytZE/+2U80RELjPt0rL1eAxxOi+dxbErWKpIiwth31R4atz0N5lRklINYpooVpG2zT+5FR3sY hVx/NdUQ/igHM0NQ1oYR/5sDONNJq6s5qOr2baS3Fo32PGzGO4R0HRu6gQPlgLJiHFHBrAJutWC TcvarNsZZRt67ETJKioy0Q1I6VJ/c0tFwhLwGBll82bJajVv77gYGk7tFXn3U6GbsWPc9NuW X-Authority-Analysis: v=2.4 cv=SZL3duRu c=1 sm=1 tr=0 ts=68271a73 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=fL5q2TxrE0MATQOmR6AA:9 X-Proofpoint-ORIG-GUID: jGpNSYt9TeuP3nSrjJ88BF_LLReK7_XI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-16_04,2025-05-16_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 clxscore=1011 phishscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505160104 Content-Type: text/plain; charset="utf-8" In the function iio_backend_oversampling_ratio_set the chan parameter was added. The function can be used in contexts where the channel must be specified. All affected files have been modified. Signed-off-by: Pop Ioan Daniel --- changes in v3: - fix ad4851_set_oversampling_ratio function channel error drivers/iio/adc/ad4851.c | 6 +++--- drivers/iio/adc/adi-axi-adc.c | 3 ++- drivers/iio/industrialio-backend.c | 3 ++- include/linux/iio/backend.h | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c index 98ebc853db79..fccfca256670 100644 --- a/drivers/iio/adc/ad4851.c +++ b/drivers/iio/adc/ad4851.c @@ -294,7 +294,7 @@ static int ad4851_scale_fill(struct iio_dev *indio_dev) } =20 static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, + unsigned int chan, unsigned int osr) { struct ad4851_state *st =3D iio_priv(indio_dev); @@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev= *indio_dev, return ret; } =20 - ret =3D iio_backend_oversampling_ratio_set(st->back, osr); + ret =3D iio_backend_oversampling_ratio_set(st->back, chan, osr); if (ret) return ret; =20 @@ -831,7 +831,7 @@ static int ad4851_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_CALIBBIAS: return ad4851_set_calibbias(st, chan->channel, val); case IIO_CHAN_INFO_OVERSAMPLING_RATIO: - return ad4851_set_oversampling_ratio(indio_dev, chan, val); + return ad4851_set_oversampling_ratio(indio_dev, chan->channel, val); default: return -EINVAL; } diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 4116c44197b8..9e8c30230791 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -381,7 +381,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_back= end *back, } =20 static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back, - unsigned int ratio) + unsigned int chan, + unsigned int ratio) { struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); =20 diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index c1eb9ef9db08..a4e3e54fecb1 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -720,9 +720,10 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_data_size_set, "IIO_B= ACKEND"); * 0 on success, negative error number on failure. */ int iio_backend_oversampling_ratio_set(struct iio_backend *back, + unsigned int chan, unsigned int ratio) { - return iio_backend_op_call(back, oversampling_ratio_set, ratio); + return iio_backend_op_call(back, oversampling_ratio_set, chan, ratio); } EXPORT_SYMBOL_NS_GPL(iio_backend_oversampling_ratio_set, "IIO_BACKEND"); =20 diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index e59d909cb659..dbf4e4a5f4b1 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -144,7 +144,7 @@ struct iio_backend_ops { enum iio_backend_interface_type *type); int (*data_size_set)(struct iio_backend *back, unsigned int size); int (*oversampling_ratio_set)(struct iio_backend *back, - unsigned int ratio); + unsigned int chan, unsigned int ratio); int (*read_raw)(struct iio_backend *back, struct iio_chan_spec const *chan, int *val, int *val2, long mask); @@ -209,6 +209,7 @@ int iio_backend_interface_type_get(struct iio_backend *= back, enum iio_backend_interface_type *type); int iio_backend_data_size_set(struct iio_backend *back, unsigned int size); int iio_backend_oversampling_ratio_set(struct iio_backend *back, + unsigned int chan, unsigned int ratio); int iio_backend_read_raw(struct iio_backend *back, struct iio_chan_spec const *chan, int *val, int *val2, --=20 2.34.1 From nobody Fri Dec 19 20:37:41 2025 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 E64DE236457; Fri, 16 May 2025 10:59:35 +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=1747393177; cv=none; b=pxOGaxJb6C39lwJp6Ume/bmmpsLl8Hs7sW7vn+qbfDEiQDgoQrfgDBtKMH1OlIiwoltZ2egOpqY6Gd6mVv58Ec2Dqosz2V3/Pmsq07/NCARz5DiuQI6OES3iwRqF1IvhxZFUGhBRlss24zd5KZsOiEhWASlUs0ZudITRMvepwkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747393177; c=relaxed/simple; bh=3RlenhZGYIHgiDVKL+qnZWSFUVuEfrCQ5ijfKTjQA0U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XxqWvza/Q7aFVuWups5/UbQc1Il4tf6NT4vdjCp5ELceFXxHkAV6Zmr8BiYS3Y9/k/5jp/CMxWkhBp7nBchavTxugoMOSQqHrtsTtjTYSUUynhUo8i/xT/X2/O/HpVL+0k+Apdmd8hGsrz7LzToOcB8P7GprIKzmoB3f0jRF+/8= 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=ggxS6rYe; 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="ggxS6rYe" 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 54GAATML010053; Fri, 16 May 2025 06:59:10 -0400 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=ACLF9 1C2Y72Z54/yLRk+5FNXWZ+Y82MsyQoA6tXtCZ4=; b=ggxS6rYelA5MaTmLqFnYX AjKTcTOv+dQcRPOBG1kQ2WHVIPuH4BFRg/ljXfTP5WpRmfTIOl6jwulr2V7kzwtS p4Bm+FEvDIFHzZT2y+y3lv0AZHkAsRVhSj6jZURSZsKHGncuP8QAEjHOhsfLvayj 29baJcx2L7mwYlXiezXCF7388lHdmCFI1K70RC1UrxBUaEQ8z6lLxP1V8N7qJxE+ Na5RXOZPQhjQiZAceWMRJaSZqpFTfJoRhqCIeyIFHOrnFy6qh+C4MiH7GEHwiL7n WecSI+cyfOrfSc9OwXlWTOM254I2sTIzIo3JMfpWJkdzXvO55uzbfevgmzcRzym3 g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46p070s4r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 May 2025 06:59:10 -0400 (EDT) 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 54GAx9If050070 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 May 2025 06:59:09 -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.986.14; Fri, 16 May 2025 06:59:08 -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.986.14 via Frontend Transport; Fri, 16 May 2025 06:59:08 -0400 Received: from romlx5.adlk.analog.com ([10.48.65.73]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 54GAwRHw006196; Fri, 16 May 2025 06:58:59 -0400 From: Pop Ioan Daniel 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 , Sergiu Cuciurean , Dragos Bogdan , Antoniu Miclaus , Olivier Moysan , Javier Carrasco , Matti Vaittinen , Tobias Sperling , Alisa-Dariana Roman , Marcelo Schmitt , Matteo Martelli , Ramona Alexandra Nechita , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Gon=C3=A7alves?= , Ioan Daniel , , , Subject: [PATCH v3 2/4] iio: adc: adi-axi-adc: add axi_adc_oversampling_ratio_set Date: Fri, 16 May 2025 13:58:02 +0300 Message-ID: <20250516105810.3028541-3-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> References: <20250516105810.3028541-1-pop.ioan-daniel@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: L8UXBkSJjOOhak6Mxu0yPnUtu6Iyj2QL X-Proofpoint-GUID: L8UXBkSJjOOhak6Mxu0yPnUtu6Iyj2QL X-Authority-Analysis: v=2.4 cv=A/9sP7WG c=1 sm=1 tr=0 ts=68271a7e cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=hj20C08OGkFrgq5-ZMUA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE2MDEwNCBTYWx0ZWRfXxZf06yojoHdO Y8LbqY2VCor7h22mekxrrH958L5vJpEBETS39ti2NQ+obAtwNhUMbkSSkXz5VrdRpmSf2fqt1Nx wqhH86SED41fYoS3TKTuoV64D0sHBXEGLABr6ruhAyYLd6Y7b1ibJxEjIsHAmmFGj3lKrxSLtKr t2KGMEHr7WjVYe1UEP50icjiu0UVyIaMBeFodr3gVtgjHvthqFvrPwjXxbVRBY0lz813lPKAeBp 8pP/tTqCF6IomyDokOwoUuDTFeOhHLn0ECn5SlkW33hDVsSYXWi9Jb7hSYKPZ0exOIrD9f6dLsB YYqwHA37SZAPkvgF81uux/M8tKnqv0YAw8Qdmk1UnMcTCVlns3smRfb1K1wm5HVpwl35yiDT8IY Ql/Zl2K2oxvpAqdrvJF1zGnyAOokDBm5x9D3ssOaAMdryPrzI2/goWlznFkdY7jigjDmueq1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-16_04,2025-05-16_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 impostorscore=0 clxscore=1015 adultscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505160104 Content-Type: text/plain; charset="utf-8" Add support for setting decimation rate. Signed-off-by: Pop Ioan Daniel Reviewed-by: David Lechner --- drivers/iio/adc/adi-axi-adc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 9e8c30230791..0b8673668745 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -80,6 +80,9 @@ #define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40) #define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16) =20 +#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40) +#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15, 0) + /* IO Delays */ #define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4) #define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0) @@ -242,6 +245,19 @@ static int axi_adc_test_pattern_set(struct iio_backend= *back, } } =20 +static int axi_adc_oversampling_ratio_set(struct iio_backend *back, + unsigned int chan, + unsigned int rate) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + + return regmap_update_bits(st->regmap, + ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan), + ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, + FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK, + rate)); +} + static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned= int chan, unsigned int *status) { @@ -550,6 +566,7 @@ static const struct iio_backend_ops adi_axi_adc_ops =3D= { .test_pattern_set =3D axi_adc_test_pattern_set, .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, .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.34.1 From nobody Fri Dec 19 20:37:41 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 95683236445; Fri, 16 May 2025 10:59: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=1747393191; cv=none; b=TGUZA9vRPfrRSNMMeR0TCdqeJzN3nfQmc3a4kytREnEvzUDRiNNrzh3lbLy0xGYFCW/QoI1hXVNOlxl/oTuhxeeQJAsAMfXtFPx9oiKlhlnOYfnsDrk3wnCzYbhzGKVGvAhEFJqZUvy8vYxAJZhGW4JiY9GhCzSzQCwvyp/5vuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747393191; c=relaxed/simple; bh=PUGb250iZt0noGJToKSIbpZHT4mePC5MCiRR382sU6E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RGziKlKxHDwJmJiRbmq8mcsIsWDX+WSSoxNwtcFjragJOXT8KTLVCmsZln6bgJvXsybcKoL277/5ra74fvPvyA8Yt38U/KZsCr5UcAq7gYczcGjKrab6pXIH2CnUBERczD3VVP/jjeuviAvTqpyd27UJulAbOhIVLKSXUFAtDWU= 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=Z7zhu4Rr; 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="Z7zhu4Rr" 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 54G90ow5016384; Fri, 16 May 2025 06:59:17 -0400 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=KrJyf nXo9p+iNk+fhlsORQVNIFZgpomkbj8qttbkWlQ=; b=Z7zhu4Rrr2iUpx/SO62pC hfna0YiTqPHKxny5O1j+lu6RfUu4LdLnQvNWPQWhQRfyOvRK9Ji37kfJcczpL9kR eDTocy5NURA6jE9UTJT71NGTzsKmlLTbXkaSgM9WqSpdMUbjKzapz/N5SrMwQ/Ug 0NbhRLxhcPGiQzgCxFt/EOhzPh2aahuFbHb8wgRysqDHRhF+K2Y5CCDAcBtbn8Eq 6MP9TXij1AVOWEoUPtKdwfnzRuu230j453Zdl/mxRPWb+eiJW5bHnj1oHHUV/Q1E wpd5zNZzTn808oGEbgQiCUSSv2qvRrq6160QAwGSySEovbqkOj+GguoVRBbkyt5b Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46mn655ju7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 May 2025 06:59:17 -0400 (EDT) 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 54GAxGNr050082 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 May 2025 06:59:16 -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.986.14; Fri, 16 May 2025 06:59:16 -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.986.14 via Frontend Transport; Fri, 16 May 2025 06:59:16 -0400 Received: from romlx5.adlk.analog.com ([10.48.65.73]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 54GAwRHx006196; Fri, 16 May 2025 06:59:08 -0400 From: Pop Ioan Daniel 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 , Sergiu Cuciurean , Dragos Bogdan , Antoniu Miclaus , Olivier Moysan , Javier Carrasco , Matti Vaittinen , Tobias Sperling , Alisa-Dariana Roman , Marcelo Schmitt , Trevor Gamblin , Matteo Martelli , Ioan Daniel , , , Subject: [PATCH v3 3/4] dt-bindings: iio: adc: add ad7405 Date: Fri, 16 May 2025 13:58:03 +0300 Message-ID: <20250516105810.3028541-4-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> References: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: EtsiGCavoRD7woJCeVyXC5VL-MgIViZ2 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE2MDEwNCBTYWx0ZWRfXxzN1fEM1/UxT 4VO1Z7DJo8Az9Z4anEiReDB0HTScgnxvL0IG1qVCG/J3Xzwib4nXY62RStHeYF6bNDIrysgqoey Pz6Ho6uoLS+VZ2RrbhHlcBe06W24f/XSudsPLodWHo/JRJQC6z/l0kBkolFP/34REVrBHO8Bucg Ns3MNsqLcSRmehDzHjFulJ/iww3xBKO48HeOfDBaBEs8ahHVay5D6SRu89nrZMVbSHqkIUX00a9 JcrWAeWMPtegYy941QKBS+Uxh3IBHTiU0V+4zPmnji6525Dt/+LyiWFhzRO3s4AMcAEjoQRpKwo WUMfdcrE00xcfzJNUiCDJiEssQywfhmBIqmBbLymZAEUMg9+h6U0RW7KikT/RtJdGua+SJl4VMY BTIKl1hTpWiu2CvB+AJzPn6ucUyRaBlSaYWv0gA0A5sxoRBtJzarWCORbLuT6nd38qXVQhkV X-Authority-Analysis: v=2.4 cv=SZL3duRu c=1 sm=1 tr=0 ts=68271a85 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=BlUfrHhC_0NcX1HyLxIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=sptkURWiP4Gy88Gu7hUp:22 X-Proofpoint-ORIG-GUID: EtsiGCavoRD7woJCeVyXC5VL-MgIViZ2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-16_04,2025-05-16_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505160104 Add devicetree bindings for ad7405/adum770x family. Signed-off-by: Pop Ioan Daniel Reviewed-by: Krzysztof Kozlowski --- changes in v2: - fix properties: clocks issue .../bindings/iio/adc/adi,ad7405.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7405.ya= ml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad7405.yaml new file mode 100644 index 000000000000..939de3bd6f26 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7405.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2025 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7405.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7405 family + +maintainers: + - Dragos Bogdan + - Pop Ioan Daniel + +description: | + Analog Devices AD7405 is a high performance isolated ADC, 1-channel, + 16-bit with a second-order =CE=A3-=CE=94 modulator that converts an anal= og input signal + into a high speed, single-bit data stream. + + https://www.analog.com/media/en/technical-documentation/data-sheets/ad74= 05.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/adum= 7701.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/adum= 7702.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ADuM= 7703.pdf + +properties: + compatible: + enum: + - adi,ad7405 + - adi,adum7701 + - adi,adum7702 + - adi,adum7703 + + clocks: + maxItems: 1 + + vdd1-supply: true + + vdd2-supply: true + + io-backends: + maxItems: 1 + +required: + - compatible + - clocks + - vdd1-supply + - vdd2-supply + - io-backends + +additionalProperties: false + +examples: + - | + adc { + compatible =3D "adi,ad7405"; + clocks =3D <&axi_clk_gen 0>; + vdd1-supply =3D <&vdd1>; + vdd2-supply =3D <&vdd2>; + io-backends =3D <&iio_backend>; + }; +... --=20 2.34.1 From nobody Fri Dec 19 20:37:41 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 2A895236457; Fri, 16 May 2025 10:59: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=1747393193; cv=none; b=ez+rwcvLxdhv9chphosf3p4h+9ujW+r5MOqCZ14UXKh1EaF8DOBbTb8skzptSUbtljcuHc+rCHN+28fAkowBjCs42zMFtr8iLZReGmBesEgkntIaEHao/QV9ie9WYB7eZWklmbgbvWIyrq7/dz8UyIMqua1Ea/5k67yrBq9pZFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747393193; c=relaxed/simple; bh=1qqkUNiewa4GiC+u/mKThZ1heYMWFWHXrqn9DFjD5C0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XEqvVXaePckVFSMNV6XfcA4vL48u42VGQFEqlUcNo5npcJIcKtlEmv9gCQpGJrYr86/p6fH2PM/Av+S38GHNFMD2Kcd70nCsHsPYmKCIkncanIQlFRdu6UQZZSF3ePRz6tX76bo2hdknpVjvt7e0p9p1btko4/o/4csq2Zu1N1Y= 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=JNcnSS6+; 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="JNcnSS6+" 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 54GACOsV016361; Fri, 16 May 2025 06:59:29 -0400 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=5DiVW 76qgYRvwGSguiZRcF9OACH1zYoGV6Mvpa3hWlU=; b=JNcnSS6+RWN/wSpB/S/f3 rDVqNFvXwHDXljR5F7lQlywRS2Cmu6d9DWhGstoIbovtpC/W1gjSsiE9RQlBq7r7 ID6h8kbl+M0S/NQhbHvnaqbVMUZP5DiOOvedBiD3wJBpoOH04yiSFRykH3m+QWhy SfH5c7pA6qFd9MnFQpiG3a8ePU/26keqT0jdafD51sf3tCwMSGK1m9FudrjQPcti w4VuAqN8/AgDB1xxcu8j5nf2WOLaUXY+vAbBS4DmCk5kfxkrxQdLz/iVy5NHYlFq dXrl8/T1EnmR8aFOMTPg9uM/06ALFCbB5mAnxyxYWG5GgCYj24LutliSSlhYrzlu w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46mn655jun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 May 2025 06:59:29 -0400 (EDT) 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 54GAxSLS018850 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 May 2025 06:59:28 -0400 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, 16 May 2025 06:59:27 -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.986.14; Fri, 16 May 2025 06:59:27 -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.986.14 via Frontend Transport; Fri, 16 May 2025 06:59:27 -0400 Received: from romlx5.adlk.analog.com ([10.48.65.73]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 54GAwRI0006196; Fri, 16 May 2025 06:59:18 -0400 From: Pop Ioan Daniel 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 , Sergiu Cuciurean , "Dragos Bogdan" , Antoniu Miclaus , Olivier Moysan , Javier Carrasco , Matti Vaittinen , Tobias Sperling , Marcelo Schmitt , Alisa-Dariana Roman , Esteban Blanc , Ioan Daniel , , , Subject: [PATCH v3 4/4] iio: adc: ad7405: add ad7405 driver Date: Fri, 16 May 2025 13:58:04 +0300 Message-ID: <20250516105810.3028541-5-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> References: <20250516105810.3028541-1-pop.ioan-daniel@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: uY3jR7RQjdIQQBCVwXJB5HA9IXhA45d1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE2MDEwNCBTYWx0ZWRfX8o5WEDVgajNT WL8E7B/Mdm0dCY3G+K+LM+OnbTtVbsWkvSiBlycSh/GyJpxH9QkCXAyh+OdEie+im/YPxtzYVkQ nnHzvBCGTs5SKdQC1f7C1gBspw6zKBnHMBh/YcHZ/y1WIZ3imD37qK84xuxOkhaqoLJBdmjR/+7 wmcxzViGDVUFa8xIdJD29+cWIjhRZRq3NPhh3Nr7RFZcDKGBr7toqnt0D/3TXUu50XNKUb/vqih 6nMBj8GRVTw95ZNJibqFA9pF48XES8XeTllQuLssbfKaroQRdmQxmd/B0BCND5ayczaTa70JAn8 bWZS710EmuHP2aiE7tDS6Vmhq7YORlXhT9lQecFkZkCX4hOoEMtF132whs4RpV8z+mFJHguOT54 LpQlLwku3yi5TTwCkDmFkwEtl4nM8lN2ocJqMtz00Y/zevcdy1PV1IKILkP0B+9/Z/lH5hja X-Authority-Analysis: v=2.4 cv=SZL3duRu c=1 sm=1 tr=0 ts=68271a91 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=iGn3AVPVnOFhGmbdwOgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: uY3jR7RQjdIQQBCVwXJB5HA9IXhA45d1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-16_04,2025-05-16_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505160104 Add support for the AD7405/ADUM770x, a high performance isolated ADC, 1-channel, 16-bit with a second-order =CE=A3-=CE=94 modulator that converts= an analog input signal into a high speed, single-bit data stream. Signed-off-by: Pop Ioan Daniel --- changes in v3: - edit ad7405_chip_info struct instances - remove lock - add implementation for IIO_CHAN_INFO_SCALE - use IIO_CHAN_INFO_OVERSAMPLING_RATIO for controlling the decimation rate - use IIO_CHAN_INFO_SAMP_FREQ for read-only - remove dem_clk_get_enabled() function - remove chip_info variable from probe function - fix indentation - remove max_rate - rename ad7405_set_sampling_rate in ad7405_det_dec_rate add adum7702 and adum7703 chip_info drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7405.c | 276 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 drivers/iio/adc/ad7405.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index ad06cf556785..6ed1042636d9 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -251,6 +251,16 @@ config AD7380 To compile this driver as a module, choose M here: the module will be called ad7380. =20 +config AD7405 + tristate "Analog Device AD7405 ADC Driver" + select IIO_BACKEND + help + Say yes here to build support for Analog Devices AD7405, ADUM7701, + ADUM7702, ADUM7703 analog to digital converters (ADC). + + To compile this driver as a module, choose M here: the module will be + called ad7405. + config AD7476 tristate "Analog Devices AD7476 1-channel ADCs driver and other similar d= evices from AD and TI" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 07d4b832c42e..8115f30b7862 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_AD7291) +=3D ad7291.o obj-$(CONFIG_AD7292) +=3D ad7292.o obj-$(CONFIG_AD7298) +=3D ad7298.o obj-$(CONFIG_AD7380) +=3D ad7380.o +obj-$(CONFIG_AD7405) +=3D ad7405.o obj-$(CONFIG_AD7476) +=3D ad7476.o obj-$(CONFIG_AD7606_IFACE_PARALLEL) +=3D ad7606_par.o obj-$(CONFIG_AD7606_IFACE_SPI) +=3D ad7606_spi.o diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c new file mode 100644 index 000000000000..1a96a283ab01 --- /dev/null +++ b/drivers/iio/adc/ad7405.c @@ -0,0 +1,276 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Analog Devices AD7405 driver + * + * Copyright 2025 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static const unsigned int ad7405_scale_table[][2] =3D { + {640, 0}, +}; + +static const unsigned int adum7702_scale_table[][2] =3D { + {128, 0}, +}; + +static const unsigned int ad7405_dec_rates[] =3D { + 4096, 2048, 1024, 512, 256, 128, 64, 32, +}; + +struct ad7405_chip_info { + const char *name; + struct iio_chan_spec channel; + const unsigned int (*scale_table)[2]; +}; + +struct ad7405_state { + struct iio_backend *back; + const struct ad7405_chip_info *info; + unsigned int sample_frequency_tbl[ARRAY_SIZE(ad7405_dec_rates)]; + unsigned int sample_frequency; + unsigned int ref_frequency; + unsigned int dec_rate; +}; + +static void ad7405_fill_samp_freq_table(struct ad7405_state *st) +{ + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(ad7405_dec_rates); i++) + st->sample_frequency_tbl[i] =3D + DIV_ROUND_CLOSEST_ULL(st->ref_frequency, ad7405_dec_rates[i]); +} + +static int ad7405_set_dec_rate(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int dec_rate) +{ + struct ad7405_state *st =3D iio_priv(indio_dev); + int ret; + + ret =3D iio_backend_oversampling_ratio_set(st->back, 0, dec_rate); + if (ret) + return ret; + + st->dec_rate =3D dec_rate; + + return 0; +} + +static int ad7405_get_scale(struct ad7405_state *st, int *val, int *val2) +{ + unsigned int tmp; + + tmp =3D (st->info->scale_table[0][0] * 1000000ULL) >> + st->info->channel.scan_type.realbits; + *val =3D tmp / 1000000; + *val2 =3D tmp % 1000000; + + return IIO_VAL_INT_PLUS_NANO; +} + +static int ad7405_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, int *val, + int *val2, long info) +{ + struct ad7405_state *st =3D iio_priv(indio_dev); + + switch (info) { + case IIO_CHAN_INFO_SCALE: + return ad7405_get_scale(st, val, val2); + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *val =3D st->dec_rate; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val =3D DIV_ROUND_CLOSEST_ULL(st->ref_frequency, st->dec_rate); + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int ad7405_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, + int val2, long info) +{ + switch (info) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + return ad7405_set_dec_rate(indio_dev, chan, val); + case IIO_CHAN_INFO_SAMP_FREQ: + if (val < 1) + return -EINVAL; + return ad7405_set_dec_rate(indio_dev, chan, val); + default: + return -EINVAL; + } +} + +static int ad7405_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long info) +{ + switch (info) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *vals =3D ad7405_dec_rates; + *length =3D ARRAY_SIZE(ad7405_dec_rates); + *type =3D IIO_VAL_INT; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static const struct iio_info ad7405_iio_info =3D { + .read_raw =3D &ad7405_read_raw, + .write_raw =3D &ad7405_write_raw, + .read_avail =3D &ad7405_read_avail, +}; + +#define AD7405_IIO_CHANNEL { \ + .type =3D IIO_VOLTAGE, \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all =3D IIO_CHAN_INFO_SAMP_FREQ | \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .info_mask_shared_by_all_available =3D \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .indexed =3D 1, \ + .channel =3D 0, \ + .channel2 =3D 1, \ + .differential =3D 1, \ + .scan_index =3D 0, \ + .scan_type =3D { \ + .sign =3D 'u', \ + .realbits =3D 16, \ + .storagebits =3D 16, \ + }, \ +} + +static const struct ad7405_chip_info ad7405_chip_info =3D { + .name =3D "AD7405", + .scale_table =3D ad7405_scale_table, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7701_chip_info =3D { + .name =3D "ADUM7701", + .scale_table =3D ad7405_scale_table, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7702_chip_info =3D { + .name =3D "ADUM7702", + .scale_table =3D adum7702_scale_table, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7703_chip_info =3D { + .name =3D "ADUM7703", + .scale_table =3D ad7405_scale_table, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const char * const ad7405_power_supplies[] =3D { + "vdd1", "vdd2", +}; + +static int ad7405_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct iio_dev *indio_dev; + struct ad7405_state *st; + struct clk *clk; + int ret; + + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st =3D iio_priv(indio_dev); + + st->info =3D device_get_match_data(dev); + if (!st->info) + return dev_err_probe(dev, -EINVAL, "no chip info\n"); + + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad7405_power_suppl= ies), + ad7405_power_supplies); + + if (ret) + return dev_err_probe(dev, ret, "failed to get and enable supplies"); + + clk =3D devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + st->ref_frequency =3D clk_get_rate(clk); + if (!st->ref_frequency) + return -EINVAL; + + ad7405_fill_samp_freq_table(st); + + indio_dev->dev.parent =3D dev; + indio_dev->name =3D st->info->name; + indio_dev->channels =3D &st->info->channel; + indio_dev->num_channels =3D 1; + indio_dev->info =3D &ad7405_iio_info; + + 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 iio_backend_chan_enable(st->back, 0); + if (ret) + return ret; + + 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; + + ret =3D ad7405_set_dec_rate(indio_dev, &indio_dev->channels[0], 256); + if (ret) + return ret; + + return devm_iio_device_register(dev, indio_dev); +} + +/* Match table for of_platform binding */ +static const struct of_device_id ad7405_of_match[] =3D { + { .compatible =3D "adi,ad7405", .data =3D &ad7405_chip_info, }, + { .compatible =3D "adi,adum7701", .data =3D &adum7701_chip_info, }, + { .compatible =3D "adi,adum7702", .data =3D &adum7702_chip_info, }, + { .compatible =3D "adi,adum7703", .data =3D &adum7703_chip_info, }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad7405_of_match); + +static struct platform_driver ad7405_driver =3D { + .driver =3D { + .name =3D "ad7405", + .owner =3D THIS_MODULE, + .of_match_table =3D ad7405_of_match, + }, + .probe =3D ad7405_probe, +}; +module_platform_driver(ad7405_driver); + +MODULE_AUTHOR("Dragos Bogdan "); +MODULE_AUTHOR("Pop Ioan Daniel "); +MODULE_DESCRIPTION("Analog Devices AD7405 driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_BACKEND"); --=20 2.34.1