From nobody Tue Dec 16 07:30:42 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 BA3A9223DE1; Thu, 8 May 2025 12:32:23 +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=1746707545; cv=none; b=rlFBHdKEbfk2JWKsiuA09sKhJGLqJqnAYGNG0S+PaM3tAZs5xUp32Z6NBTDOalZxof1AgGH4g0vk9IwGYcaTbX5l+r5gyIECGMpKGcww+Fb6YUcyRnmKNBUWSEnMXePhihkFtwhQYHVwIamIByl0Qfrlph1fpmePiXlcea1Ml7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746707545; c=relaxed/simple; bh=E4oEosSyCiPNDkT22KvKs41/Oniec7K9eXj1nBEHYXY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XMq4DdKleVR9fV7BqV7rqcH6HBHEweqoUDcCz7unKUusD9c+2lKmS0a4upH7QjNFaZXFblY5+Sx+9bo9c7IAhsc+JVVofPWoFdu+Ifg3jJscbKheA9VbAHgGeJ2qU8CemWKSDY9YlHsId98sOU38YEpPq2FryahkBlADm0+3Ze0= 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=BqcYmesB; 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="BqcYmesB" 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 5489D7e8013396; Thu, 8 May 2025 08:31:49 -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=luQpb VFooXCJXBeCKn2OxAfDeV2OTc2lqpPMukD7Zgo=; b=BqcYmesBZr2TwJBWw0CsW 6mN4HTp9XSl/oVuMx8cLJ51OySwa1XZYRbPtCzrng4mh4fIMObnKp17g+2aSukGo SoVPTTNFLs0RSY/sZ65ShJJ0O6E1Y1Ijk6tVZaFTyy70JauqB8Sn3gT8tSr7DsMj TOVGPfOG4QNrcLgFPvJwc35a4i2SP2SmTmrDdTfT3cyMeB9SkpYdVjZ2kCL62RJo my7ZnX6wYruiyHPB24q0qoDf5yLZ3E8lSDoYipNtSKlYM8teOvcSbB4GoULWaxj+ VeFLAArKR2E4TBsKtoJrYJxWtlXFceorYMi2WYuVyo205wiloNW/fzF7Kgu/7Cg7 A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46gpct1uj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 May 2025 08:31:49 -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 548CVmI9019187 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 May 2025 08:31:48 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 8 May 2025 08:31:47 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 8 May 2025 08:31:47 -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 548CVFtd002317; Thu, 8 May 2025 08:31:40 -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 , Pop Ioan Daniel , Ramona Alexandra Nechita , , , Subject: [PATCH v2 1/4] iio: backend: update iio_backend_oversampling_ratio_set Date: Thu, 8 May 2025 15:30:54 +0300 Message-ID: <20250508123107.3797042-2-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250508123107.3797042-1-pop.ioan-daniel@analog.com> References: <20250508123107.3797042-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-Authority-Analysis: v=2.4 cv=J/eq7BnS c=1 sm=1 tr=0 ts=681ca435 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=fL5q2TxrE0MATQOmR6AA:9 X-Proofpoint-GUID: koe-7oWa1sQGWmPwVKEKvxKeRElGbmu1 X-Proofpoint-ORIG-GUID: koe-7oWa1sQGWmPwVKEKvxKeRElGbmu1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTA4MDEwMyBTYWx0ZWRfX9QPTZDp8ssJG lYABLio9pFUTHLDqRp06dFJ8O4SKAUQOAb9zn3PAlf+vdFPqgVWGzcDob+Yg78NaFYGG8TQDawR 3jQ1p6ZiPPsGcdEAgYLue4QgBmQiFMm+gorO2yVxahqN1Udfc/F2TuL/2DihApugCmWz+eu0lJ4 claPHMVUjfXSisZ3XX3tDr/6Ia2i09KmfvXt0bKdLjc2821srrlQqP6ex1GwMG/y465TQGLBe2a Us+R5Z1DLT/qADuPhyXyc61Ae2OYZznO9hw7vPgtW2pEW/zaqbAs35iUB68OFQ7k1dz1fv1B9K1 VAk9s5QZBP443ljSMXABPio0zziswFvKi7DxuNMOgibX/Rq8CbtbNZpnoY+gBbY1QwNLhmqnqRH eA7AwBZL0uJBE+RH2n3p5wSl3feSdGtPFJaUrvNslIHaNpRm19Fa0akQKTB9T7Q3/9S49HiU 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-08_04,2025-05-07_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 clxscore=1011 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505080103 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 v2: - remove iio_backend_set_dec_rate function and use=20 iio_backend_oversampling_ratio_set function drivers/iio/adc/ad4851.c | 2 +- drivers/iio/adc/adi-axi-adc.c | 3 ++- drivers/iio/industrialio-backend.c | 3 ++- include/linux/iio/backend.h | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c index 98ebc853db79..a943d5aac9e5 100644 --- a/drivers/iio/adc/ad4851.c +++ b/drivers/iio/adc/ad4851.c @@ -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 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 Tue Dec 16 07:30:42 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 6B22C223DDA; Thu, 8 May 2025 12:32:23 +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=1746707544; cv=none; b=dZ776NEqoITzKtW5dcRqD8Jaz4fMi8dRe0vVRgCCtrCguTHXf7pwn2DFyTbWTC5H/DpIwFuRn6FZrlqLEBcSHI4i1t/YO4X6whbePWmOssRD2Zb3Nq9LkK5+W4/Pn5OFQTbSPLwauOSbESkII73iPpRAUULlhHCfmKOtSdUNj9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746707544; c=relaxed/simple; bh=40ebb2cwjTLIp3Z7qvZGDycv+JCJe/VeSQoUx+s43Ik=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aS15D3GGrB/BzoxgTz7zqR/S4zayTmLN9bMisiO0O5q2u6kP6QzaDtC5zQDVw/A0Y/TROu7lEl70W/+fqzuw5zyem1OHY8joisL2GuXh1pVfgwJ5xntZ7ZI1bUc6PWkKC+wDDuekwUZx4xwuW8teJYLlFdbYQijjMvJefgLehW0= 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=vee09aI4; 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="vee09aI4" 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 5489Dt1S013492; Thu, 8 May 2025 08:32:01 -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=+vGCE Mfc5ckM0R57MNBPDhXEB/R+W3cwClciV1LPL98=; b=vee09aI41vAWwMPyaPNEH Q3wMH9cPxwO/4Qd6sPZF6cLGou8y8E6TvPxHmZ+8XjjkJjg2+6pYaO7A0aYm9D06 L/QVx5VnOELFTnqLYLvI182WYqwPTcBSg3IIkLEOPv1gnRV0FTD9Vaq5v1++ruI5 W2gn3J02K9M5Zfch69x+O0A24nzYoiJdj/6UxQrgOUmUE6QB17Su3Zky/Q0bUUN4 ml3T//5HflzEDc/1Fvp2utw8A75LlM8XOGqbGDghu9IKyw3osckvnincyeTrPjtm lS5tlikL1WvNlMYiS1f43jNSj1dCEME6ohkiQ1AH8rZu4GMhRn2ATES3iAn+1Q+z w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46gpct1uk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 May 2025 08:32:00 -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 548CVxxm006292 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 May 2025 08:31:59 -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; Thu, 8 May 2025 08:31:59 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 8 May 2025 08:31:59 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 8 May 2025 08:31:59 -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 548CVFte002317; Thu, 8 May 2025 08:31:50 -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 v2 2/4] iio: adc: adi-axi-adc: add set decimation rate Date: Thu, 8 May 2025 15:30:55 +0300 Message-ID: <20250508123107.3797042-3-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250508123107.3797042-1-pop.ioan-daniel@analog.com> References: <20250508123107.3797042-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-Authority-Analysis: v=2.4 cv=J/eq7BnS c=1 sm=1 tr=0 ts=681ca440 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=YaUefwTmmUCeskgydjwA:9 X-Proofpoint-GUID: MzianQqEkvlnyWGtlXxWFvD7Vx-Lb3F9 X-Proofpoint-ORIG-GUID: MzianQqEkvlnyWGtlXxWFvD7Vx-Lb3F9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTA4MDEwMyBTYWx0ZWRfX7gQQeh/Akjzw U0BWlv+dyAz+HBFg7SHX5Uz6jdfL2hIPz7I1lG4/Np30KDE72kjjz2LZGtsO/QIdVVvMnOUeV87 nSvW6UEm2tnrZU/ZMRDL8A6M+ZquMOocv0H0Shujutlmwoog+XTzmVTowipUVlcwAXv1Bqjy9Be mSz+cAYDyUyspgGks2SnEIbl9c6ftNSEBThEpjK3PdTcF0WdAOrxdlU7qMTEhP+CGsnK6WouDzv EikxF3MWz00bhYJS7BBrbTngouBRuCXg+myZULebg6UJbvPHrF6d+pZgANtyz0LU9phB7JDhE2L lZqHlD3SYDAFy9iIkD3d+BW8SozIrKpBi0sZ6dbrhZ2ucl2i469ceDy5VFe/YnR2TWwUgqjCakl lBg6Et/SJdg8uDO+iCLUnSyUuHkhD71pnHDaCvSXxRTTfLQ4/M8ufZhUgpPfR7Eokrp6cZO3 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-08_04,2025-05-07_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 clxscore=1011 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505080103 Content-Type: text/plain; charset="utf-8" Add support for setting decimation rate. Signed-off-by: Pop Ioan Daniel --- changes in v2: - update ADI_AXI_ADC_REG_CHAN_USR_CTRL_2 register in a per-channel register - rename ADI_AXI_ADC_DEC_RATE_MASK in ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK - add channel index parameter to keep axi_adc_set_dec_rate generic - remove ad7405 chip-specific struct drivers/iio/adc/adi-axi-adc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 9e8c30230791..33eb8f337e0b 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,17 @@ static int axi_adc_test_pattern_set(struct iio_backend= *back, } } =20 +static int axi_adc_set_dec_rate(struct iio_backend *back, unsigned int cha= n, + 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 +564,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_set_dec_rate, .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 Tue Dec 16 07:30:42 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 EEF8B223DE1; Thu, 8 May 2025 12:32:29 +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=1746707551; cv=none; b=L7FRV+CwoEJCSChxVNJefOGe9/N+YFzeSWXbKATlLTYT2qwuSVWpVq9gioRo74s/7Vje3K2x/514HPluiIuT+AMM3FzVGyQfar09+4Dq103NZ4uDo3O2Ewc3m/TNdZP4h7ZZgPCQwwp6GDZ1ueHR7C+B0fwJc8yT+a7JuB7V8G0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746707551; c=relaxed/simple; bh=Tqq+ds2T097BlhJu6VZKIFexesFc/Se4hllVNLOjWSk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pOjj77MCpHk1jGoytVIEx0rwkwDxuKKGLs1jzRDEIoNW7TGINer/pcnXYS+ov/FaL/o6t2or5Bevv7IpwlgxiXqehJ3ybDtb4gXJhjt2G/Slphtd+z9AAlPPCUs1c4U7XtkDOMjHAyEsKd/+DPAQ3e/YS8I7lbxWJDZSKJ0f3+E= 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=zZm/md/x; 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="zZm/md/x" 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 54894rKa013536; Thu, 8 May 2025 08:32:08 -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=jXBRW aRx8lJDpRJefpKv/9YZiNvgPTrjqpVF9x2liDY=; b=zZm/md/xwTikIqzGwsji5 q+9tPvb+OlBz8Qe9mSIrPIU0xMBG8El4HT04SecVmkmawAfjB83h9q7hkbTt57su Shnvng20m7sAaWvzLXzOsNnI7n4/P754sNZY0MAKQgQRtpccn6OmhX7Qw3wFAEU2 DsKNhL/YV+kirpkcLio+2nzQldvG0tHESSG4QR6whxRXsf4pHzYreAfm/fDMSyww OcQFJQMTzM3LnYdoXF8iJd97C9YQwD3zKtZEEFcowy+Iv3Lt0qhPR4wz3VVdxUPn vvNSBioNuBijee8tnBZlBPhVHi0+aSq/47NK39NuDS0OddD1NxyJK2XSjS9RtJyO Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46gpct1um7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 May 2025 08:32:08 -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 548CW7Pn006295 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 May 2025 08:32:07 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 8 May 2025 08:32:07 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 8 May 2025 08:32:07 -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 548CVFtf002317; Thu, 8 May 2025 08:31: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 , Pop Ioan Daniel , AngeloGioacchino Del Regno , Ramona Alexandra Nechita , , , Subject: [PATCH v2 3/4] dt-bindings: iio: adc: add ad7405 Date: Thu, 8 May 2025 15:30:56 +0300 Message-ID: <20250508123107.3797042-4-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250508123107.3797042-1-pop.ioan-daniel@analog.com> References: <20250508123107.3797042-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-Authority-Analysis: v=2.4 cv=J/eq7BnS c=1 sm=1 tr=0 ts=681ca448 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==: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-GUID: GUpfBeC2G7GbxXaue-ZSVK48bHfbil6i X-Proofpoint-ORIG-GUID: GUpfBeC2G7GbxXaue-ZSVK48bHfbil6i X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTA4MDEwMyBTYWx0ZWRfX5UcqVyOoAhXL qJRwvCa8rhBYnJ6lgdb5ADkbdM2eNKqnebg/KlygbKOLRyv/CgfSA5pU7rQpscKZUMk+F3O5Oki 89/2CQNEcBnkFb0i4FfA2V7IPzjUFCmAdTVXJPXgswTQirZToYySP0nC2UDRJsAldRh8+d+9v7X q4oC7F14Q7cmaJENsbYTGe0Q4HQv0LCyhQtxY85Nzkoct5Z/7EObQpmiJpD30yuCMiGPtLjTTza UQu5otw8/xI2QoKYrLXfyIOrkdK/UGSZ+gj6MXGTzyCXMD9OfjNjtmqVAfQojgpD53Ds1e3XxZH Om2R5CC6SLRan7TskncKNX3hep2Wt7LdWssYK9ay9fnKC55Fd4Lz9C6Wx4qGdWGQyy5O2i45Apt /IhoHbA8T7LmJ512h313Rk4MGpiaQj9qAhxNHTE5wXLFmmXSKUqSoI+KftYI3DB4ZcgRMKTM 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-08_04,2025-05-07_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 adultscore=0 lowpriorityscore=1 mlxlogscore=999 priorityscore=1501 bulkscore=1 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505080103 Add devicetree bindings for ad7405/adum770x family. Signed-off-by: Pop Ioan Daniel --- changes in v2: - remove #address-cells and #size-cells - add additionalProperties: false instead of unevaluatedProperties: false - remove #include because it's not used - add new line at the end of the file - add mantainer .../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..8c30a712968d --- /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 + + vdd1-supply: true + + vdd2-supply: true + + clocks: + maxitems: 1 + + io-backends: + maxItems: 1 + +required: + - compatible + - vdd1-supply + - vdd2-supply + - clocks + - 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 Tue Dec 16 07:30:42 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 D2B1422577C; Thu, 8 May 2025 12:32:41 +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=1746707564; cv=none; b=o3LrtnyaZfzDMethSLJqq/teLsekH6SmONoe+ClI/mR1aeGX+PRJKfZxj1kY6bynGmr0QzPbFtEz7f3kEadKB1G/Z1D8Fj0J8OJMY/gJ06jjAd/PTNtyvvNqvytFYhzsNZvgaEvxm6wFm8tCZIvZiY9eQ9whETg21/ZTYHuVByI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746707564; c=relaxed/simple; bh=Jwpu6YdHH3kNDY9JO80FOOQiXWmBMRZum5SYHEwWhVY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DA5tVrUTES/uH4kPfUzqKMbQVtXlrnRt00mwlDwLtMYpnTX3QU0wSD4Cw+QhL8VCb04m4d2tZRee7nmdNSEVhcss/mC355lKs+9/jXUrLZZykUg0Px81DKYb42J640hVrc/3U21zEV3uy9Ml7pyWk4f43DFizU72x1itoCocS88= 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=qWLNNLQL; 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="qWLNNLQL" 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 548BDZAP010473; Thu, 8 May 2025 08:32:20 -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=7dkvz t5EByozw81MJjeobuPYPumFgB5VvJsZNm22UaE=; b=qWLNNLQL+FLIpqSn1VBtX tbGLl+3U/4wbHwuuRtZTDjlU0s4dKCSMRk+f/bBxHwgHTiFXJ08MJ5nG1/2+U68P ATXur7DEnjTkriSPRdGNo5Tgv4NHBU11+/EJAkcDv4GqGafGe9rfX3HGAVc2Ys0d GIRszSpTVwAYkS5ea6BWfZFXnTFGHLDKlgFx1uwXD1tOvJR/1/86O84mMI/5ku0c ldfQsGS+yX1TcDayM7D9TUQ1CN5naUPgZfA0XFqNWBUuNQ7oQJHnnGFxB94lfgGT wk9Rlns5//CoD14/wy2E3h4Kdp2gx42ri12Myk6166bg8WHzj26Hr0S8iOJ8nO/c Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46gr04scxq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 May 2025 08:32:19 -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 548CWIEi006307 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 May 2025 08:32:18 -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; Thu, 8 May 2025 08:32:18 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 8 May 2025 08:32:18 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 8 May 2025 08:32:18 -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 548CVFtg002317; Thu, 8 May 2025 08:32:09 -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 , Ioan Daniel , , , Subject: [PATCH v2 4/4] iio: adc: ad7405: add ad7405 driver Date: Thu, 8 May 2025 15:30:57 +0300 Message-ID: <20250508123107.3797042-5-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250508123107.3797042-1-pop.ioan-daniel@analog.com> References: <20250508123107.3797042-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-Spam-Details-Enc: AW1haW4tMjUwNTA4MDEwMiBTYWx0ZWRfX+KzPkRwzC7e9 Eb2pGr5YsoZ3yT2pxbOMdkcx+qY2aTz2DGh9YHrjHn/eT/+K0JWfFWPAC3P6QBSlFHoN7ssbqLP W2G2U9luF+5YaliiVqrtZxGeQKAwL67EsQ7diEXN9vvK8j4MA7CMFORjytG8bk7P3e1ZQP9+ESo ucA3XNCy7A6WbMY1uvstY7hri9ZhLc04iy8jtRnL7K919+3g3QLLDzjU/Ihl+Y2MMsu3tAwD9Vl r5XoR/pPcRnR0u3EiGzHttAbr4r5+Z2q0LPRdB5MLdjXFqDH2F2J41NhiCE87DpDXaidIIAzHWk B4ws+JrMUKGmh1hm4qTXYcWRL3E/YZqxHX1DvbQlD9VTAO4y9BHaDxolDM+NtmyVsPDMWvdTsGC jiNNwC2hcg6m7yHChyCmPmgUYJSz/NTtUfKC5O2WBGE4gSBvyEIXC9O4rJ29nS3Wrmoy6U+O X-Authority-Analysis: v=2.4 cv=cfnSrmDM c=1 sm=1 tr=0 ts=681ca453 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-GUID: W-AngUH9k6PGkA-w2rdmeVWsuLwtmvVP X-Proofpoint-ORIG-GUID: W-AngUH9k6PGkA-w2rdmeVWsuLwtmvVP 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-08_04,2025-05-07_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1011 malwarescore=0 mlxscore=0 impostorscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505080102 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 v2: - sort the includes in alphabetical order - delete headers that aren't used - remove min_rate member - remove ad7405_update_scan_mode because there is only one channel - rename axi_clk_gen to clk - remove unuseful members from ad7405 state struct - return -EINVAL on ad7405_write_raw - fix indentation - remove blank lines - remove chan, bits, sign parameters from AD7405_IIO_CHANNEL - remove shift =3D 0 - add info_mask_shared_by_type with IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_OFFSET flags - add scan_index, differential, channel2 in AD7405_IIO_CHANNEL - remove ad7405_channel_masks[] - remove unuseful members from ad7405_chip_info struct - remove platform_get_drvdata() from probe - use device_get_match_data to be able to use different chip info - use devm_clk_get_enabled() for efficiency - add devm_add_action_or_reset to disable_unprepare the clock when the dri= ver is removed - replace the devm_regulator_bulk_get_enable before applying any other sig= nals - check for return value of 0 for st->ref_frequency - remove indio_dev->modes =3D INDIO_DIRECT_MODE - remove iio_backend_disable/enable that is done implicitly by devm_iio_backend_enable() drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7405.c | 264 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 275 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..5fe36ce61819 --- /dev/null +++ b/drivers/iio/adc/ad7405.c @@ -0,0 +1,264 @@ +// 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 + +const unsigned int ad7405_dec_rates[] =3D { + 4096, 2048, 1024, 512, 256, 128, 64, 32, +}; + +struct ad7405_chip_info { + const char *name; + unsigned int max_rate; + struct iio_chan_spec channel[]; +}; + +struct ad7405_state { + struct iio_backend *back; + /* lock to protect multiple accesses to the device registers */ + struct mutex lock; + const struct ad7405_chip_info *info; + unsigned int sample_frequency_tbl[ARRAY_SIZE(ad7405_dec_rates)]; + unsigned int sample_frequency; + unsigned int ref_frequency; +}; + +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_sampling_rate(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int samp_rate) +{ + struct ad7405_state *st =3D iio_priv(indio_dev); + unsigned int dec_rate, idx; + int ret; + + dec_rate =3D DIV_ROUND_CLOSEST_ULL(st->ref_frequency, samp_rate); + + idx =3D find_closest_descending(dec_rate, ad7405_dec_rates, + ARRAY_SIZE(ad7405_dec_rates)); + + dec_rate =3D ad7405_dec_rates[idx]; + + ret =3D iio_backend_oversampling_ratio_set(st->back, 0, dec_rate); + if (ret) + return ret; + + st->sample_frequency =3D DIV_ROUND_CLOSEST_ULL(st->ref_frequency, dec_rat= e); + + return 0; +} + +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_SAMP_FREQ: + *val =3D st->sample_frequency; + 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_SAMP_FREQ: + if (val < 1) + return -EINVAL; + return ad7405_set_sampling_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) +{ + struct ad7405_state *st =3D iio_priv(indio_dev); + + switch (info) { + case IIO_CHAN_INFO_SAMP_FREQ: + *vals =3D st->sample_frequency_tbl; + *length =3D ARRAY_SIZE(st->sample_frequency_tbl); + *type =3D IIO_VAL_INT; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static void ad7405_clk_disable_unprepare(void *clk) +{ + clk_disable_unprepare(clk); +} + +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_all =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .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", + .channel =3D { + AD7405_IIO_CHANNEL, + }, +}; + +static const struct ad7405_chip_info adum7701_chip_info =3D { + .name =3D "ADUM7701", + .channel =3D { + AD7405_IIO_CHANNEL, + }, +}; + +static const char * const ad7405_power_supplies[] =3D { + "vdd1", "vdd2", +}; + +static int ad7405_probe(struct platform_device *pdev) +{ + const struct ad7405_chip_info *chip_info; + 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); + + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; + + chip_info =3D device_get_match_data(dev); + if (!chip_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); + + ret =3D devm_add_action_or_reset(dev, ad7405_clk_disable_unprepare, clk); + if (ret) + return ret; + + 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 chip_info->name; + indio_dev->channels =3D chip_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_sampling_rate(indio_dev, &indio_dev->channels[0], + chip_info->max_rate); + 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 &adum7701_chip_info, }, + { .compatible =3D "adi,adum7703", .data =3D &adum7701_chip_info, }, + { /* end of list */ }, +}; +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