From nobody Fri Dec 19 15:50:25 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 B30C72586CA; Mon, 19 May 2025 14:03:47 +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=1747663429; cv=none; b=oL9CuHysRVGz8TSt7EDgErl5mXA2YP+DP1B+KyQgSY0XMx5MFggjF+rnQnP/Gf2H1kLgJB3F7Is98ZIxwQf4FDylRYdl50ew+qhwyNv7XArEjsK0TGLoWrohDLJ921Ru2jWgrGzox381GE7eWLZKIINNSPLuqDcScf0oS9AB0vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663429; c=relaxed/simple; bh=dxKrONTUz7Yn3f+rST5oH5+Hj+KBcwuPb8DCRBEzaA0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qG2lqb7NzfyJ9p+whYZOsSEKBxXqJ9uqk4YBCL1ENARFxhXvjDhQRvtsY1vkppWj3CA8wW04he9HZhFrIDf3GcPKHW95o4ZTqfspEMGMpXmGtcEheDOOHMqq2zCUFaGjCtexJCgEPFWEITdOxontE2Hx8vx717hphXlmKFFRthw= 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=lhnOXz89; 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="lhnOXz89" 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 54JDVG2L012725; Mon, 19 May 2025 10:03: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=MElNI MeyW0gPszKkmcmqvag8Xk+RuOSaMKDhcdt0Hd8=; b=lhnOXz89bUxfoLGBLeXG/ aTxG7O6TvP0Wo3Jtf0haL+vjvq6qiK4hLOL+7A9sumRliROHQVqR+jlxgsDekpff gLvBE+oNYqTpNQasB+JGhX0Apj22RHhtQATzvrneZp4CVucyqdhCWUW0T2JWxqvN OU160fXfaNI57fHkrZJGN2XYr00jQZFebABhC1RxSHSnZ13bZk3v6j4CYGruD9uH G4oofNuyub243yB8JTYVc9766SqZr28+yaaeqe4h+6Gz4pKQ4X8UIIbzB5lrvcT8 MNTyPPIQHdYa4YfXFQzddX3K1lZAVGcfmaCxItQV9SvvMNlDzhu+GfDA+1ccOUPj w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46psveqt5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:09 -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 54JE38X7038210 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:08 -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; Mon, 19 May 2025 10:03:08 -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; Mon, 19 May 2025 10:03: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.1748.10 via Frontend Transport; Mon, 19 May 2025 10:03: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 54JE2bPD016713; Mon, 19 May 2025 10:03:00 -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 , Thomas Bonnefille , Pop Ioan Daniel , AngeloGioacchino Del Regno , , , Subject: [PATCH v4 1/6] iio: adc: ad4851: ad4851_set_oversampling_ratio parameters update Date: Mon, 19 May 2025 17:02:09 +0300 Message-ID: <20250519140220.81489-2-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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: ZnlxzQHkSlL7RRVq6jsTxbXvw35DZf2N X-Proofpoint-ORIG-GUID: ZnlxzQHkSlL7RRVq6jsTxbXvw35DZf2N X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfXweykrdhZJqnW 3un5UPBit5q2qw6q6ItNn2JrKNhxIngRjrTMJkYKSxy2z503W3vdFgaPLpSwMa0GoQzc326mbRj EptJ+qlnwNETvFVlI406jYHuM6bgDLl0gtNsdcFmM9WFwWDTeifjh3LfXVS9QMGepoGdMtCM1rP 4St9VC5X2KuWRj7L3Of1MXMKoArv6ABsEhkie4bTCC9Nd4IDuPi9PQPG2nEJY07CSC+TsznQovw hdwwbsLbv6MjubDJ2fab1FDX1i9Bayae//rTPAKpqnqNmOzSPJG8+PG/+Y1aTbAz29jB3p/qS9V +894QF89p6cN372BfS1COziUHx1CQQNAVXFRpadpxZ/Z7qnJC4AsgGnl+pX8z4ShDgjtKTKuxCv ZhxvKioUceoTL7zy8fmNVXwNze/htayU0PCeblGhTHpv01nZH4puNNwaU9isqs3Bh4syBcnO X-Authority-Analysis: v=2.4 cv=PqSTbxM3 c=1 sm=1 tr=0 ts=682b3a1d cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=r0u9AmH2YJ65VWHPuukA:9 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505190130 Content-Type: text/plain; charset="utf-8" Remove chan parameter from ad4851_set_oversampling_ratio parameters list. Signed-off-by: Pop Ioan Daniel Reviewed-by: David Lechner --- changes in v4: - remove chan parameter from parameters list drivers/iio/adc/ad4851.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c index 98ebc853db79..12f90aa3a156 100644 --- a/drivers/iio/adc/ad4851.c +++ b/drivers/iio/adc/ad4851.c @@ -294,7 +294,6 @@ 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 osr) { struct ad4851_state *st =3D iio_priv(indio_dev); @@ -831,7 +830,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, val); default: return -EINVAL; } --=20 2.34.1 From nobody Fri Dec 19 15:50:25 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 F2A63281366; Mon, 19 May 2025 14:03:48 +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=1747663430; cv=none; b=M/jGF7yl/lNVnL/h862mZqbLLfuIt+bj4DHPsnIhgoutj5IBHHZ28WrGFAmOCfhp1nrDtNnh3ZymDcoo2jrAtdWZIaXEzBmKTGCo5X9+TyLtZUzU0yawIzQpq0R/oVtSIq0jjJYXgyEo6wPYa5kCrDaLxHeGXYg9jEBPN5xVCwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663430; c=relaxed/simple; bh=1zDM1PgNvtQwT4WhfyLGPv1x/7cmDJLAjgJyUfe9lkc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QeNK3Cm46rsVnarIpj09u7poGkH/aAxSrs4XlUpM27bKFsNlJ/YzDkpCXj7pBCo7z3pFQLYsBc2A4Oogb0rf1AmGIzy6ySlCT5yeDrUOi/QqmgGCv9uY1UWysel5ax6W64AB0RmuxaiOW7Q0LwdjeQLFBObnwk44A7ZjVu17c4s= 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=sxhZILo8; 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="sxhZILo8" 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 54JCKmTO024220; Mon, 19 May 2025 10:03:18 -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=p4uO/ wSrNmyPZWU43/Bu9snkfrCLBZrGqVYFDKLMt7w=; b=sxhZILo88rx2mcz3nXuKi tNDrNCJ/dafOPv1QOscN0kugZrn4YyMH7/a83MyLz0R1vlUf19WfYX9tM6fK6Qet udU4tS/UEwYRPHRV2itoXsNQ/s5B5pkdeMr5rmRIQrZQNRjj4mmxHFvx/0V9pXSe ZLpGMRk1Fav7DadsI3NStMuWXXRVoL9FnTnYs81uBzJx1i+pEM7tCOHTbWfRCV6V bXjOKSwhiYmLXZeqnv1p/L9achqfopiEgiq/PtNLJlylSLzGLMLJGHOHX38lDu2d X9iPY0K7gxIiIlf1c/0jdhrkUSAOrs2xZuJDTzv4OI8nxb68ye/PFvSmMcEfVI99 g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46q8sfwjfr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:18 -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 54JE3HGX026729 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:17 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 19 May 2025 10:03:17 -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; Mon, 19 May 2025 10:03:17 -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 54JE2bPE016713; Mon, 19 May 2025 10:03: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 , Herve Codina , Trevor Gamblin , Thomas Bonnefille , Ioan Daniel , , , Subject: [PATCH v4 2/6] iio: backend: update iio_backend_oversampling_ratio_set Date: Mon, 19 May 2025 17:02:10 +0300 Message-ID: <20250519140220.81489-3-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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=FusF/3rq c=1 sm=1 tr=0 ts=682b3a26 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=lxCnnINleEiMd-tkFrgA:9 X-Proofpoint-GUID: 7eUZO-5NBB5H757vVwDwiIDHDTDfJhcy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfXw9hpGXkyqn1R QIWMA6nNRgZOc6OgUwRqkecfXc7BkgSds0Zsk9pN3b/l1Xxxt98A1zgHLs+r27PXufupTtUV5DF 2mc3Y+qn2D6fb64UkMoucbrV+9eXH73tV9MQ9mj+Ej4wFUnJcYr+l6ct3By6ba3r6TJwjfq97aI nmDEi+XaYM7hvgrq0ysZuZhdeM3s9cESNzhB82stKnjPptQAL75NhESDMC/E8HWDdTkSXxpMG70 h/0m83D08ERAW/BeXaHLTx08JQ05Mh70DXC5mUwCjw/M7LcqZB3Y3ZQ8gHX/A+82FioY0RjyHNv gvfkFdrQy+yI/6E9vZQDisThEXrajVOCqtXTDhgUoq7JVQiB9jN+OszSBsP5+3yfPu8x0O7qPXR PlNgh1PHYYCN33zSHgTKgCrgLgT5yXBIG14+rvoKOQLTRhxl/QeXs2dKUxr5+IhrfKTz4Jo3 X-Proofpoint-ORIG-GUID: 7eUZO-5NBB5H757vVwDwiIDHDTDfJhcy 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505190130 Content-Type: text/plain; charset="utf-8" Add chan parameter to iio_backed_oversampling_ration_set() to allow for contexts where the channel must be specified. Modify all existing users. Signed-off-by: Pop Ioan Daniel Reviewed-by: David Lechner Reviewed-by: Nuno S=C3=A1 --- changes in v4: - pass 0 in the list of parameters instead of chan drivers/iio/adc/ad4851.c | 4 ++-- drivers/iio/industrialio-backend.c | 3 ++- include/linux/iio/backend.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c index 12f90aa3a156..1f975858c496 100644 --- a/drivers/iio/adc/ad4851.c +++ b/drivers/iio/adc/ad4851.c @@ -319,8 +319,8 @@ static int ad4851_set_oversampling_ratio(struct iio_dev= *indio_dev, if (ret) return ret; } - - ret =3D iio_backend_oversampling_ratio_set(st->back, osr); + /* Channel is ignored by the backend being used here */ + ret =3D iio_backend_oversampling_ratio_set(st->back, 0, osr); if (ret) return ret; =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 15:50:25 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 C2935281528; Mon, 19 May 2025 14:03:54 +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=1747663436; cv=none; b=pVDi6OAxocKjme53TkIsReYg/oi2Od7y8p3G4p4slf/lswuT0vRWYkLm79Tu/c7us93mndCNAgg/K+vCMFikoAosn2RsHZGgTQaroD1S7INW1dsbfppm6qJq3lNYrkoWOXWrWukGqCFQYNCml5jCMiwuh+uRSHhKafnhQCbVlVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663436; c=relaxed/simple; bh=KqkzW6cqz8xSa8LPY0v6j3huAaayPsLu/UdoBTxeTck=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R8Oo0ODZS+WcFTqNh17ZVSYujUbfq6DJqe2wkiKhOXmpHU69hEqD7HJKSTatInXxhPMrg3G9KyhGsrh8QEqC4BVNEvmqlPfyDpQ5qneZYHdBUPnJ+yi7UA64TAi3aWbNASyh4Q7KEbZmAd/1vcViRWr01xcX29fHUIlCepZ5YD0= 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=H1ABcHz7; 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="H1ABcHz7" 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 54JCtsfx024158; Mon, 19 May 2025 10:03:27 -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=5ogTO glL2BFdN1jliJVncAuZvZAaBGr3wLkh3Tqhj38=; b=H1ABcHz7vpA6i5U2WoWQ1 33+8lVNLhI6DlQo33KtCxZpi6skJeHkEuabdsSH3YMRLXB6Vzj81JsKtldXM4Ag/ dV0I9Hfiq5w5U3Ah7YyAaph7ehn75o8V8PWIgN0UlRBwplBr1DoaeEHHqjf2Lq/R S37KZbgym+oy3OIZnsqQXWU2rfx+Hvx3IGHzV95+nBz85us9g5mamyNmY3u4Qz6Q Kcv3Zd7U/YpDDtZ2k9puu9YPz4KTjBwTMxqBS7AaIdG4emajzyt3D9TGml3JZuhQ TP7HStbNKhjO0F4Y7RWBzs835yJTcfVe1zkrcKEDM5IXwIr+VTukUH4YvQ4Ze2hu A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46q8sfwjgg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:27 -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 54JE3QQ5026740 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:26 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 19 May 2025 10:03:26 -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; Mon, 19 May 2025 10:03:26 -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 54JE2bPF016713; Mon, 19 May 2025 10:03: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 , Alisa-Dariana Roman , Marcelo Schmitt , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Gon=C3=A7alves?= , Thomas Bonnefille , Ioan Daniel , , , Subject: [PATCH v4 3/6] iio: adc: adi-axi-adc: add axi_adc_oversampling_ratio_set Date: Mon, 19 May 2025 17:02:11 +0300 Message-ID: <20250519140220.81489-4-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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=FusF/3rq c=1 sm=1 tr=0 ts=682b3a2f cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=YaUefwTmmUCeskgydjwA:9 X-Proofpoint-GUID: Qs9-DXtPanMXE-yryPnOOGMZu-xKFZdU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfX1wgQFuSHSFvS wjTdwnb6wl+Wm8SqOut8sZsexQGZN8YYrLLSho9Y4Pb++LsEEyQ7EkVoPztHPvA+Oj+buOB9ijk BufvGcHmBhnTwOywpfXIyXJUKGcJ1xh1OixQZka3poAvp77eizeG+UWtt0v6j9xDJ9ivUJWT0ek Lso0nBfizhs92aj5FKPrKEQMPXln54f/a86t+TqH82ftyrj1O754QZwkMKQS0jNlIIa8w+zRLc2 p97KHBmZoa97lzyiCkRJIDWC86/8ARGM5sculcWom9fmkpjd6zODpORWNgKTgcLUdDidH760h+0 g3+l9+p9Uni1zwnw0C8m3HWnIlVQquehWox2ZzyNJYzRrpwvgBBpWA4Hu2G915TBrP5s+qF0Z4S QcEK3khqnlGmnnUktWn2n9gs/3DTjudqya+8IYi1k1hZWLvdkgrsoZRMNut680bMbTtCfEDS X-Proofpoint-ORIG-GUID: Qs9-DXtPanMXE-yryPnOOGMZu-xKFZdU 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505190130 Content-Type: text/plain; charset="utf-8" Add support for setting decimation rate. Signed-off-by: Pop Ioan Daniel Reviewed-by: David Lechner Reviewed-by: Nuno S=C3=A1 --- no changes in v4. drivers/iio/adc/adi-axi-adc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 4116c44197b8..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) { @@ -381,7 +397,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 @@ -549,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 15:50:25 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 54DB0283152; Mon, 19 May 2025 14:04:02 +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=1747663443; cv=none; b=KxPtA9O9hBCxMO1Orl6FF7xn/JfgJnVwk5a4EAhe/GEpNfCn+ZeM0OVOzt00/GFucp658w5PPv4tprkVlmcOQY8lTZcIUdSOBWVYU2XusGWnlwmYUxD7VJ3ImMa5aqTos1TwZVvZew8j2C86NzxySBPXCDf0KHPStSFhoxoUMcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663443; c=relaxed/simple; bh=OKQLbxbISDh5KDh/idbjgz6tUjq9B2vCDTvCR12GsSo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lcb6TfIxlCspiiLQOOCsxI0ZrqVbXyirVcKYFNW5xT69FSK4G46NLa5oj2YH/ERLdrESPJdGkt3iobHc3b0Xc1jneL+igDNNry+BNJ44Wp/s0xA4yfZiX2Q/l1DsrpEogKyNxsifhTiU/I1uz7qBHojTv6PsmFUYbi5vm72dVVk= 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=DlLlz7ZP; 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="DlLlz7ZP" 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 54JCBbGA017336; Mon, 19 May 2025 10:03:39 -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=Riycv NRhRq8H5F+BahxTj1ImVkEP/f/mo9I5YT/Vn6M=; b=DlLlz7ZPQ7gwNMZxbQIJu iCN6nWGAhjN5z4iO/s+5xWHEjHPr+FcYk2DoKqDZjghBCUwPori4WuxYvEvGtzp9 OSMg7PDq0JA4kG9ck3YZJtLe161CVS6BuzFXwpY3C530Uq6ZcWUNMoUkjm2UTrNU etrJSUrf7oCjH1iiRABHjQFBfvfe5oYUaRx+Y2FHbURP6L4wvZkaJ+BrP3GgEA7Y amzAt6dj242HJ4FtVc5AFdV5xftEUMfAtDHwJNZz6avev8lRwHjpbEI3zGvnlgT1 mtpDmkgxlClgUUWEAVz3TtDXOdUH9hYQyhYJy+Bf6Oht51+kNr2w3KtBElGYFCXc g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46pqc586by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:39 -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 54JE3cgC026767 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:38 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 19 May 2025 10:03:37 -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; Mon, 19 May 2025 10:03:37 -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 54JE2bPG016713; Mon, 19 May 2025 10:03:28 -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 v4 4/6] dt-bindings: iio: adc: add ad7405 Date: Mon, 19 May 2025 17:02:12 +0300 Message-ID: <20250519140220.81489-5-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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=SKZCVPvH c=1 sm=1 tr=0 ts=682b3a3b 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-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfX41bnHkx/dyFg 3TL/edPjeG2jKHjVa7QK+DW5snnHOxMJXooCxHGMoY2CZPCTc2paXNpwuZGha56eP2WJtqdx0b6 Nn2groTwAhkxOSIo6utPql89l3kN4DiPt2larwZKwvDFYL+vVIXthB2x2X8Iz3oCbOd1rEm2esi 1T4tzJUD5IMdRQUCx/8w0QpqOab+xy7hS3onGpyLi/JaMesCYkiAE8T+ximRJDTZa9ZCmula+dk 2avoCFwe5LD9zxxLHjPU70LOEox+dLYW2u8ZSF0eIs1B9jVH0A84jUDqybENb4higl0sbH2pkNc N2e/xCejBAMCM3yMIP0hePqecgle31NB8rQ1r63P84n43C4l00xM/JrQ/+GtG9RHbC1CfrCKHET 12IBP5cEDbz1Vg7EtUZ+48kc+tbjL79gBtp6gp5w3tGDFtEA7AM+w36pqVokAZXLUZ5YBrWq X-Proofpoint-ORIG-GUID: cpwC3494UgSCRm71CUFecZvbWolzjEuv X-Proofpoint-GUID: cpwC3494UgSCRm71CUFecZvbWolzjEuv 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=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-2505190130 Add devicetree bindings for ad7405/adum770x family. Signed-off-by: Pop Ioan Daniel --- no changes in v4. .../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 15:50:25 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 8A384281528; Mon, 19 May 2025 14:04:14 +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=1747663456; cv=none; b=CumzQYEwnA33mbLl0qCyeOk+5rApKxqpK48OE4UsHVIAdhNHyvv/f6tilVXrAJuYgpoRwJ2nCkTK8QusL5YidUey7CLD63G9iCRrqHWq0Y77nkJ5ihBY+0Ux3V/RyLmymzkSCSJbFwCxyqH8Go3zWk+TBI5tt17aYyozIbPHhL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663456; c=relaxed/simple; bh=kqQMK/3KpDXgaWS/pYZ3VmfZtdfsfoeThCQJDd+NoKc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oXqUuj/uhsHTq6IXhR8HKLWZVJLBtwDrJf6oWPaw0jpBXk+EZR4+o8b1OJYs9LgoEU+mHvWjxuojlLjQzH4pIlsj4g6C75m5LARphfIOgDvsxrshqNfV/h6gtImNynUH4H5X49xmLTIuwz/Eaqco+0mzjZQKHqKSwKDrTj+Ui2M= 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=awFjoyA5; 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="awFjoyA5" 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 54JDVG2X012725; Mon, 19 May 2025 10:03:46 -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=ETSV9 DafWyOmWjJfwE5PR4gy7f9cEXluhSRXX982A1s=; b=awFjoyA5cjedykv8IZuqF GcQOzklSlrljPnOqyylAe6K9huYo7DwE0jDll7ifkscW/qXICJ8OJLvjsCF6aJs3 0H4JSdBv0zYT5AfkOeVxVgvpneviNEcms5pgdqgKmfw8LJBB2+e4jnHTM7T5wlCE abWJCC+IuoovuVRqtVH3Sivhsuw7Q1xahKX5ygeR+BWkldKFUi7IabVLw83aabIM fcDAAZlhb6lC1uEsg05p+NrvthoOxpNMd5vtfEaWP2l+nfq5TdeNqrD2SAKlo45q 5bWThFagO5wfXBRhHyUNVs/fWPo57o/soJfr50eJcGm+o6SbFXgj7vSOrN8qHa6Q g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46psveqt88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:46 -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 54JE3jTX026788 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:45 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 19 May 2025 10:03:44 -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; Mon, 19 May 2025 10:03:44 -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 54JE2bPH016713; Mon, 19 May 2025 10:03:37 -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 , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Gon=C3=A7alves?= , Pop Ioan Daniel , Esteban Blanc , , , Subject: [PATCH v4 5/6] dt-bindings: iio: adc: adi-axi-adc: add ad7405 example Date: Mon, 19 May 2025 17:02:13 +0300 Message-ID: <20250519140220.81489-6-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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: 6gn-iqYCo9IATDTAw8-2Z69BAg5OQPLP X-Proofpoint-ORIG-GUID: 6gn-iqYCo9IATDTAw8-2Z69BAg5OQPLP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfX0KeW8tnrmRXw Hqq/AHY/RWc6tWtuulg+/GF1Pa8X9jtTrRnQamEJEVCzW5Yj0juwtmuwStTFPx2ofj26IIvEN/a wvCOeDu6xgWW7dRB4+FKE95XLVy7DUSq4sNFwLqe+SEac0L5575bkxRe/05VDQBs617WA5sdaju D1mEZDddyuGSb/uaGQngZ0r+/6fFrFh9nOPyvWKD6YFJKcmvdcEycT/FNYLQTFoh02ThtwwSHbz ZTXQW06Lrm9AMCXuZ8exvKESIAYAFqsZEIjIxxy/ilIS8e5b1Ko4o/LP3G7Njl+wcMBect2KUzp MXQFNunkPhyf1hCsRH3Glytn2iGhMkNcPTZLDhmtw3Zqbg8oBq3eVOCtqAqOyAymk93sUkGhIND NXEJ3Z+bdwIhrMU1WPBxhq9fcbzHQnQl6Y+xX4WH5be0MK6t8oHQ+/zquiq/yNXTCEWEb06z X-Authority-Analysis: v=2.4 cv=PqSTbxM3 c=1 sm=1 tr=0 ts=682b3a42 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=1v7LO-Y7ZEEvXFWEQcsA:9 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=790 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505190130 Content-Type: text/plain; charset="utf-8" The ad7405 device is defined as a child of the AXI ADC. Signed-off-by: Pop Ioan Daniel --- changes in v4: - add ad7405 device that is defined as a child of the AXI ADC .../bindings/iio/adc/adi,axi-adc.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml b/D= ocumentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml index cf74f84d6103..a6bc8acd101f 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml @@ -135,4 +135,21 @@ examples: io-backends =3D <¶llel_bus_controller>; }; }; + - | + axi_adc@44a00000 { + compatible =3D "adi,axi-adc-10.0.a"; + reg =3D <0x44a00000 0x10000>; + dmas =3D <&rx_dma 0>; + dma-names =3D "rx"; + clocks =3D <&axi_clk>; + #io-backend-cells =3D <0>; + + adc@0 { + compatible =3D "adi,ad7405"; + clocks =3D <&axi_clk_gen 0>; + vdd1-supply =3D <&vdd1>; + vdd2-supply =3D <&vdd2>; + io-backends =3D <&axi_adc>; + }; + }; ... --=20 2.34.1 From nobody Fri Dec 19 15:50:25 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 062D5284682; Mon, 19 May 2025 14:04:18 +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=1747663460; cv=none; b=Xfzwjf3MunBfcy0Qq5u/o1ZiZg2on+sbGiSGezQfnXspj44jdtMX2QxJSTuX5X7nUuqn4RIjtCGQ3Igi8XoU+XdCZv2f37oDUDr7jMGrboMl2p7WKKo908/Vr3b97pxX5X4rDwoluJfHEonwCinZqeUYuLQXM3GTzC92W6ttUuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747663460; c=relaxed/simple; bh=IZtetJB/92NWxxvlLFSaouVDfN624TnDTljXTHTJAFU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V0+Z5wS0EwzRo5kthm9CctZe7R3l5JpgyqDqGC91pOVI35v1euf3EvN0KgNrouCkL+GmFg++Z1g5gvOwLc+DbpuejKDNFTVFIqRRx6H3u9pmGp7PFQV3vmChE8jqbu7ykVuBmK4g8QrexeC4e5M8wKLNzUFFbQ3l/gT08KRRS/0= 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=ObxpKFEr; 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="ObxpKFEr" 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 54JD7DK3012950; Mon, 19 May 2025 10:03:58 -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=LQ/95 ZYRq3Vd4upu32+zTsTHxCwfiiEz+RX9Qg85Cqc=; b=ObxpKFErIU9zV+tPiib15 mQSEgETV5K3lUKyx57Fa5wAPZokWV5T5iAod1tYNuK4T7AKgNxQi4D43loQ5fib8 Hc3G9hTiut6AsMKEgkzsO5V4xMaI7qynj7ngCaPJLsUNgI2G5mKkfLWZWC7kNd3k duES6+yBqVIBSzgAlzjHMWr1t2TXwZpaSqtCy34cm3sPQaWcQCJKXfnJRMT/xoWb wA6h5azo8QPZP4u7345ZF1C6zbnQRhxiIFxgRJdkAOVvKa3Ur3lkvqXxr+efQyjk RuA5vadv9AkRMkr/m2Lw16JJanzOvopPyLHNiYO3AA/DwErGhwDH01Ha2YlfLcJe w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 46psveqt93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 May 2025 10:03:57 -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 54JE3uTi038248 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 May 2025 10:03:56 -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; Mon, 19 May 2025 10:03:56 -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; Mon, 19 May 2025 10:03:55 -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; Mon, 19 May 2025 10:03:55 -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 54JE2bPI016713; Mon, 19 May 2025 10:03: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 , Alisa-Dariana Roman , Marcelo Schmitt , Pop Ioan Daniel , , , Subject: [PATCH v4 6/6] iio: adc: ad7405: add ad7405 driver Date: Mon, 19 May 2025 17:02:14 +0300 Message-ID: <20250519140220.81489-7-pop.ioan-daniel@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250519140220.81489-1-pop.ioan-daniel@analog.com> References: <20250519140220.81489-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: TEK-gKbzGyuFIdF2iVCea4BbAWyZxavu X-Proofpoint-ORIG-GUID: TEK-gKbzGyuFIdF2iVCea4BbAWyZxavu X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE5MDEzMCBTYWx0ZWRfXzPXPLGY+gMBz tqfF+VAz87O8g0uk49dTo1wXoXg0baAdgx+BOSeZHL+tPggAGfGnDCoBHsxrzV8YDWP+0rj7oZL ha4w0m35EgLpcOqXK7gyJpnENYGpoJBadEhFJ+YHUzTutY0W0pVf6qSzhSj35NPyxuZHpk0Uloh uOm8Z8QPDlACydNZg/GUO8gWE6Kq3Fp/3vT5NjV1d6ynky8oB0NpQ3feXw+4uaQYVS9vuoIzqvD ZGfJNbDdrXoj2RMvamzVjv7Gcdu0tL8Qs3r7b0a8kIHP/K6cjRBqCdaV+hETgsanTrybRTL0DTm qIaVVyAJQINOkoKnGBYYaGdgdBzcjLltDVIMdAIAwhSofz/hWWchuwtWe6sjiYlnPIVbwzaUDVZ i3tjnbGkX8nst52SqLrLIhSd5+QDbumzUUPvYFylJY/lEdfvnUXjPLXa5GvehZKEHsj0UyVT X-Authority-Analysis: v=2.4 cv=PqSTbxM3 c=1 sm=1 tr=0 ts=682b3a4d cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=gAnH3GRIAAAA:8 a=xMrnY01I1BIIJWUPG5oA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 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-19_06,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505070000 definitions=main-2505190130 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 v4: - changes in "depends on" instead of "select" for IIO_BACKEND in Kconfig - remove scale_tables variables - remove sample_frequency_tbl, sample_frequency - remove ad7405_fill_samp_freq_table function - rewrite ad7405_get_scale function as suggested - make sampling_frequency read-only - implement IIO_CHAN_INFO_OFFSET as suggested - fix code style drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7405.c | 250 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 drivers/iio/adc/ad7405.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index ad06cf556785..43af2070e27f 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" + depends on 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..fb249c83b87b --- /dev/null +++ b/drivers/iio/adc/ad7405.c @@ -0,0 +1,250 @@ +// 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_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 full_scale_mv; +}; + +struct ad7405_state { + struct iio_backend *back; + const struct ad7405_chip_info *info; + unsigned int ref_frequency; + unsigned int dec_rate; +}; + +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, chan->scan_index, de= c_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) +{ + *val =3D st->info->full_scale_mv; + *val2 =3D st->info->channel.scan_type.realbits - 1; + + return IIO_VAL_FRACTIONAL_LOG2; +} + +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; + case IIO_CHAN_INFO_OFFSET: + *val =3D 2 << (st->info->channel.scan_type.realbits - 1); + 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); + 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) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .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", + .full_scale_mv =3D 320, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7701_chip_info =3D { + .name =3D "ADUM7701", + .full_scale_mv =3D 320, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7702_chip_info =3D { + .name =3D "ADUM7702", + .full_scale_mv =3D 64, + .channel =3D AD7405_IIO_CHANNEL, +}; + +static const struct ad7405_chip_info adum7703_chip_info =3D { + .name =3D "ADUM7703", + .full_scale_mv =3D 320, + .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; + + 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