From patchwork Tue Jul 9 11:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727682 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 B516D155389 for ; Tue, 9 Jul 2024 11:11:33 +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=1720523495; cv=none; b=JZcRWl2tTAOqxZ/vWky1CLCMq7iNC+Mceug72bTN8kxmcnGzpPwL5tOrfGB2bHeUAMcR/5zlNkGFjEe1YU94UjCp9lDPbAOYN9xZmfuzcrsCAA+SZY4WQndBIh3OZ5aJuvGYX6OCAZwuauH9IhEXPz6OcEcsUDsxmSVCazn7XW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523495; c=relaxed/simple; bh=Al29ZryMOt7mW3zbmyPn+19GEwlMRD9iEs9gUbVZai4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=o36f1JAt9QhIVl/Rsws9w66Pb7ZdI/1HsPDAo0PYmEWpRJdYUSpF5NFzxFrDtLHSqpaKCKm05V42ibv0/boAEYRH+bDb7nm+vLrem5IGSsV3qg51zekzKTswD/jZcOxJvJ/7bWWpfOPOD/he1YJsQehOWm85CtmSgk8NYu/V1nw= 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=re6j4p8c; 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="re6j4p8c" 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 4695eVX5004270; Tue, 9 Jul 2024 07:11:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=Nw5dO PGLvqy7uzeU9rXeimsxvHwod7kP3TtA7PWy1fM=; b=re6j4p8cqth2PbVeJCkgG 2w0sW3fjrPXtAibcSptRcN4pTLomgvith1dn90cYnq/M6wjLxBVfMpu7EWq87t/n A8RAYmzj74dsPpyao15FnnCSgmv1fhnkptFeyb7iexCEsfSORGISqQFKxJOHMRfh v3WrJsbYPTgQRaWk5Xj7Bo1tPjY8LVfaWX53hibGXSRM4Tb9vbT1eZOhQJpfkf8L s6tqt6NaL+CIlV1RKvQEyLWFcY74/LnyzoaOtk/H8aPGZVAY1/3UsFaTZjdANYhK va8XVhAMhFctrqg9Ug96Rg5wZ/I5E/vrs0hY+qR5PC0mrZTnomXAO5TCynDKoNYi Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 408y9291nf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:04 -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 469BB3Ia055135 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:03 -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; Tue, 9 Jul 2024 07:11:02 -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; Tue, 9 Jul 2024 07:11:02 -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; Tue, 9 Jul 2024 07:11:02 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgk032387; Tue, 9 Jul 2024 07:10:55 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:28 +0200 Subject: [PATCH 1/9] iio: backend: remove unused parameter Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-1-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Olivier Moysan" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=2431; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=Al29ZryMOt7mW3zbmyPn+19GEwlMRD9iEs9gUbVZai4=; b=oiswgVQEXtlCPM/5ZG8SWTtwVdW9QvhzNRt/BguBAZY7bUeuR51MLepT7xtNIlao3QfOxkgWS Jovf5tWZNczCf/kGfGDy8Uf+F5FQQSLZMwGWiBLI9LcRyEdx6T7+U4+ X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 2xR6hp4_D9Tj6XD3FKMGIno8YsEf162y X-Proofpoint-ORIG-GUID: 2xR6hp4_D9Tj6XD3FKMGIno8YsEf162y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=982 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 Indio_dev was not being used in iio_backend_extend_chan_spec() so remove it. Signed-off-by: Nuno Sa --- drivers/iio/dac/ad9739a.c | 3 +-- drivers/iio/industrialio-backend.c | 4 +--- include/linux/iio/backend.h | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/dac/ad9739a.c b/drivers/iio/dac/ad9739a.c index f56eabe53723..9b1570e788b6 100644 --- a/drivers/iio/dac/ad9739a.c +++ b/drivers/iio/dac/ad9739a.c @@ -413,8 +413,7 @@ static int ad9739a_probe(struct spi_device *spi) if (ret) return ret; - ret = iio_backend_extend_chan_spec(indio_dev, st->back, - &ad9739a_channels[0]); + ret = iio_backend_extend_chan_spec(st->back, &ad9739a_channels[0]); if (ret) return ret; diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c index efe05be284b6..65a42944d090 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -451,7 +451,6 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_ext_info_set, IIO_BACKEND); /** * iio_backend_extend_chan_spec - Extend an IIO channel - * @indio_dev: IIO device * @back: Backend device * @chan: IIO channel * @@ -461,8 +460,7 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_ext_info_set, IIO_BACKEND); * RETURNS: * 0 on success, negative error number on failure. */ -int iio_backend_extend_chan_spec(struct iio_dev *indio_dev, - struct iio_backend *back, +int iio_backend_extend_chan_spec(struct iio_backend *back, struct iio_chan_spec *chan) { const struct iio_chan_spec_ext_info *frontend_ext_info = chan->ext_info; diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index 8099759d7242..4e81931703ab 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -142,8 +142,7 @@ ssize_t iio_backend_ext_info_set(struct iio_dev *indio_dev, uintptr_t private, ssize_t iio_backend_ext_info_get(struct iio_dev *indio_dev, uintptr_t private, const struct iio_chan_spec *chan, char *buf); -int iio_backend_extend_chan_spec(struct iio_dev *indio_dev, - struct iio_backend *back, +int iio_backend_extend_chan_spec(struct iio_backend *back, struct iio_chan_spec *chan); void *iio_backend_get_priv(const struct iio_backend *conv); struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name); From patchwork Tue Jul 9 11:14:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727689 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 576B5155389 for ; Tue, 9 Jul 2024 11:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523506; cv=none; b=ZLSZeFNuE0BDOeZhrRJEAWo9g2jFixLvyL0dSeS2cuHgmSbF+bG4WAAzZF+XjhhWanbHTo0xMoFS8Cw8WyhKLSBv3wl2WlPRUumDSvUcF11ZyfoWhXWC9DcBLCUZ2hSdl5szK60aOi+aHDnG/fa+dvckSoKrs4e67OBn9Cysx+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523506; c=relaxed/simple; bh=o50v2cJuiKP8YniWONn9l3GpdiNckMIc1Fnj6RUCT+E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=lxqS/l5q58VlK0UGo8qQoiQ7ysP8HmLLBo+ABwsrsLTDRsUdnEJbWd1oZOrUwZifXT809/K+P8MUiUzcFsg1l1V6fUvGGLG3w4+S07WB7giYdVC2TmcxnIecAu6yELXxoUJ10Jnx7jWikidN6I5CHvsiWKMJ15GmCO4+4ew4AaI= 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=mhrRiAY9; 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="mhrRiAY9" 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 4697grl0029841; Tue, 9 Jul 2024 07:11:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=fkgBB ukgMdl0yPC3xMRBr0VWsgGPAhcytTqKtBKhtNQ=; b=mhrRiAY90urWGvByqWIS9 sHMnOmnJQmXwl3Bna+NKdHfgWiy6HktVgE1kZGJ95EvYRR9byojt9KEIshepst+9 apVKlwIiMURCG5U5+poKD6xkrdoH5fZTS+AsECcryTqJCdrVkCUCznCnv/BWUSaj SlRG/Vx9nE9dhPbSpRAeXxywvtYkhPr9FZ3yvU0Nmvsj0x3UXVx6VMTGT76YZTNB J9y4/ny9xhyepVOa84kliWHhRqGiDe7RZRTban3TPFlPkOzALB0WOKRap/AzGVi9 h+zxY7JfnzPaMAi8qL4g0SEnHmZ/S+rOzgOMwPni6jNIBP73fFJ2h/ntIN3Et7xE A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 408fy44100-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:06 -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 469BB5J2046284 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:05 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:04 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 9 Jul 2024 07:11:04 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgl032387; Tue, 9 Jul 2024 07:10:56 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:29 +0200 Subject: [PATCH 2/9] iio: backend: print message in case op is not implemented Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-2-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Olivier Moysan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=1120; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=o50v2cJuiKP8YniWONn9l3GpdiNckMIc1Fnj6RUCT+E=; b=dAaUv2pd6eStfOClkw5zDO5pjW5G8rYl7z9mHQjgZgFOvf9zS2X1CU2uZnln5nhhIDPh40ahI uNh2rs4qAA2D+R4R+3uAn5/kTok9ouBZIMLVD9MbSi9A3jC68CLL/fH X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: iQGcJ-NfH-QNeOhESClkDHlukmUy23nW X-Proofpoint-ORIG-GUID: iQGcJ-NfH-QNeOhESClkDHlukmUy23nW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=633 clxscore=1015 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 For APIs that have a return value, -EOPNOTSUPP is returned in case the backend does not support the functionality. However, for APIs that do not have a return value we are left in silence. Hence, at least print a debug message in case the callback is not implemented by the backend. Signed-off-by: Nuno Sa --- drivers/iio/industrialio-backend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c index 65a42944d090..f9da635cdfea 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -111,6 +112,9 @@ static DEFINE_MUTEX(iio_back_lock); __ret = iio_backend_check_op(__back, op); \ if (!__ret) \ __back->ops->op(__back, ##args); \ + else \ + dev_dbg(__back->dev, "Op(%s) not implemented\n",\ + __stringify(op)); \ } /** From patchwork Tue Jul 9 11:14:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727681 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 7A066156F45 for ; Tue, 9 Jul 2024 11:11:33 +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=1720523495; cv=none; b=pgYWf9AnNfGV30dAEQSFpdZG9o9jxlfzcYKyaRRtlplgGTeSK09qiCbonXm7fSImu/kAukJ5kdwLCP8c0k8ZOho+fSDRAUmBTYfkhbH0MfHI7occs7Ei8AHa4GRinDaF8fgpOxiCuj+bS0d+GJu8Ah6mkmdrQ+Te6UId9WFi9DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523495; c=relaxed/simple; bh=AxoDbIsUCwSnpCKE90xWkm5dUWtjVswyE9WNQfobjbo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=iqndigOLq0WLELo8I4iT++4KbUYmsqp8YUBICxqzvyQ2W5LjpJZTKTX3U+nzR2VMP+eg7pQy9hz189cEWCnQ8+GkdFp7PconkplrrIv3FrtLnCbmc2J1HnEevvXYgk6KUCRnhMq0+TAB0p4zU7JfWeumV1YGEOt4tK8xW3ZUkUo= 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=CtSnOtca; 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="CtSnOtca" 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 4697pnEK011000; Tue, 9 Jul 2024 07:11:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=jm2q/ HuubdAJiDA5Sc1XDDuVl8Nt039rEqc8IbcH0Wc=; b=CtSnOtcaamaqJuhlB1Je8 cgu1OngaMAu4ggjQlcWf6qu8Np6nTswoWc6eWY9+aVDELX/FX30I4ACjnG443da2 i/0hqYLO53KOYN1qJDOPAvJRIs7TEkU2wwAq0vPrKiNilDHcGOnyi8kwWYSidviE CuMMnsPqGRyV+y/bPZNPeU9gscVC3yzn8gjnPQXIgRGe2OxIqOKZYWgrHFeoMWRp kNFcxKa09ey2FvpsFLiY1XRsnpGy6NjsJYDwJdbGsUoMkHD/JQy79jFkxZd1jqqo cXapDBXJ99LUgZQpPYYGNnlb924qCNCK5s5k8CnzCVEuO5roYBmE8S9oxzTvgS2H w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 408fy4m1qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:04 -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 469BB3kx046278 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:03 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:02 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 9 Jul 2024 07:11:02 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgm032387; Tue, 9 Jul 2024 07:10:56 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:30 +0200 Subject: [PATCH 3/9] iio: backend: add debugFs interface Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-3-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Olivier Moysan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=6823; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=AxoDbIsUCwSnpCKE90xWkm5dUWtjVswyE9WNQfobjbo=; b=l7SfHM9ilv+L+F9MrnpY7EO+ZqCUo/WkW/mWH1/C37a4bGrGVJTpbN389lo3huV2S2oMs3Wjt 8jpjbxSxLerCo7J/mlbA7FL3XwZz2V7O7dmo324EgDlmL4PM6YFvDtj X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: zd7t_c0Nn4AGemms1rC6D6kAfkhI_YWD X-Proofpoint-ORIG-GUID: zd7t_c0Nn4AGemms1rC6D6kAfkhI_YWD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 adultscore=0 priorityscore=1501 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090076 This adds a basic debugfs interface for backends. Two new ops are being added: * debugfs_reg_access: Analogous to the core IIO one but for backend devices. * debugfs_print_chan_status: One useful usecase for this one is for testing test tones in a digital interface and "ask" the backend to dump more details on why a test tone might have errors. Signed-off-by: Nuno Sa --- drivers/iio/industrialio-backend.c | 115 +++++++++++++++++++++++++++++++++++++ include/linux/iio/backend.h | 16 +++++- 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c index f9da635cdfea..52cbde0d5885 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -32,6 +32,7 @@ #define dev_fmt(fmt) "iio-backend: " fmt #include +#include #include #include #include @@ -46,6 +47,8 @@ #include #include +#define IIO_BACKEND_DEFAULT_NAME "backend" + struct iio_backend { struct list_head entry; const struct iio_backend_ops *ops; @@ -53,6 +56,8 @@ struct iio_backend { struct device *dev; struct module *owner; void *priv; + const char *name; + unsigned int cached_reg_addr; }; /* @@ -117,6 +122,111 @@ static DEFINE_MUTEX(iio_back_lock); __stringify(op)); \ } +static ssize_t iio_backend_debugfs_read_reg(struct file *file, + char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct iio_backend *back = file->private_data; + char read_buf[20]; + unsigned int val; + int ret, len; + + ret = iio_backend_op_call(back, debugfs_reg_access, + back->cached_reg_addr, 0, &val); + if (ret) + return ret; + + len = scnprintf(read_buf, sizeof(read_buf), "0x%X\n", val); + + return simple_read_from_buffer(userbuf, count, ppos, read_buf, len); +} + +static ssize_t iio_backend_debugfs_write_reg(struct file *file, + const char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct iio_backend *back = file->private_data; + unsigned int val; + char buf[80]; + ssize_t rc; + int ret; + + rc = simple_write_to_buffer(buf, sizeof(buf), ppos, userbuf, count); + if (rc < 0) + return rc; + + ret = sscanf(buf, "%i %i", &back->cached_reg_addr, &val); + + switch (ret) { + case 1: + return count; + case 2: + ret = iio_backend_op_call(back, debugfs_reg_access, + back->cached_reg_addr, val, NULL); + if (ret) + return ret; + return count; + default: + return -EINVAL; + } +} + +static const struct file_operations iio_backend_debugfs_reg_fops = { + .open = simple_open, + .read = iio_backend_debugfs_read_reg, + .write = iio_backend_debugfs_write_reg, +}; + +/** + * iio_backend_debugfs_add - Add debugfs interfaces for Backends + * @back: Backend device + * @indio_dev: IIO device + */ +void iio_backend_debugfs_add(struct iio_backend *back, + struct iio_dev *indio_dev) +{ + struct dentry *d = iio_get_debugfs_dentry(indio_dev); + char attr_name[128]; + + if (!IS_ENABLED(CONFIG_DEBUG_FS)) + return; + if (!back->ops->debugfs_reg_access || !d) + return; + + snprintf(attr_name, sizeof(attr_name), "%s_direct_reg_access", + back->name); + + debugfs_create_file(attr_name, 0644, d, back, + &iio_backend_debugfs_reg_fops); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_debugfs_add, IIO_BACKEND); + +/** + * iio_backend_debugfs_print_chan_status - Print channel status + * @back: Backend device + * @chan: Channel number + * @buf: Buffer where to print the status + * @len: Available space + * + * One usecase where this is useful is for testing test tones in a digital + * interface and "ask" the backend to dump more details on why a test tone might + * have errors. + * + * RETURNS: + * Number of copied bytes on success, negative error code on failure. + */ +ssize_t iio_backend_debugfs_print_chan_status(struct iio_backend *back, + unsigned int chan, char *buf, + size_t len) +{ + if (!IS_ENABLED(CONFIG_DEBUG_FS)) + return -ENODEV; + + return iio_backend_op_call(back, debugfs_print_chan_status, chan, buf, + len); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_debugfs_print_chan_status, IIO_BACKEND); + /** * iio_backend_chan_enable - Enable a backend channel * @back: Backend device @@ -577,6 +687,11 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) if (ret) return ERR_PTR(ret); + if (name) + back->name = name; + else + back->name = IIO_BACKEND_DEFAULT_NAME; + return back; } diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index 4e81931703ab..a643d86c7487 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -9,6 +9,7 @@ struct fwnode_handle; struct iio_backend; struct device; struct iio_dev; +struct dentry *d; enum iio_backend_data_type { IIO_BACKEND_TWOS_COMPLEMENT, @@ -22,6 +23,8 @@ enum iio_backend_data_source { IIO_BACKEND_DATA_SOURCE_MAX }; +#define iio_backend_debugfs_ptr(ptr) PTR_IF(IS_ENABLED(CONFIG_DEBUG_FS), ptr) + /** * IIO_BACKEND_EX_INFO - Helper for an IIO extended channel attribute * @_name: Attribute name @@ -81,6 +84,8 @@ enum iio_backend_sample_trigger { * @extend_chan_spec: Extend an IIO channel. * @ext_info_set: Extended info setter. * @ext_info_get: Extended info getter. + * @debugfs_print_chan_status: Print channel status into a buffer. + * @debugfs_reg_access: Read or write register value of backend. **/ struct iio_backend_ops { int (*enable)(struct iio_backend *back); @@ -113,6 +118,11 @@ struct iio_backend_ops { const char *buf, size_t len); int (*ext_info_get)(struct iio_backend *back, uintptr_t private, const struct iio_chan_spec *chan, char *buf); + int (*debugfs_print_chan_status)(struct iio_backend *back, + unsigned int chan, char *buf, + size_t len); + int (*debugfs_reg_access)(struct iio_backend *back, unsigned int reg, + unsigned int writeval, unsigned int *readval); }; int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan); @@ -152,5 +162,9 @@ __devm_iio_backend_get_from_fwnode_lookup(struct device *dev, int devm_iio_backend_register(struct device *dev, const struct iio_backend_ops *ops, void *priv); - +ssize_t iio_backend_debugfs_print_chan_status(struct iio_backend *back, + unsigned int chan, char *buf, + size_t len); +void iio_backend_debugfs_add(struct iio_backend *back, + struct iio_dev *indio_dev); #endif From patchwork Tue Jul 9 11:14:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727680 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 7A0B2157A72 for ; Tue, 9 Jul 2024 11:11:33 +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=1720523494; cv=none; b=g65PQw7MZgjCstvsAAJmbw+ymXdNlUR8asl1JrpE3rv6ZUUUX9sh6YLX7vW6tg9gMxH+dGzDpQfVL00OMIkei8MnJlNNudmPsu6h3mU40yjkrjXtiCgq5wGH4UAjbvtc9fgcB2Sg2HvW74jibOnCXZgVJFuc53bQyhifaoko8Ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523494; c=relaxed/simple; bh=JmEnLymVEakXYCG8Gu6w27A4qKIHmUWngZwraQwLMbM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=CEvVAzH+67bD/KoMyFymYedm7udhPF0wMlPnq6S/xkS/pD789Moowkn+9mny9e9aVgf1c4vMTqIFe4YFOqVpVaeg/AlOXj9kVvoepoWJTXP9dmE6o6VJBbR3dUHV3ybpFitUEZ8f9QgucuOZs8MJRi800mgIETsWNhDW4vSmjVI= 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=pWXyu4Af; 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="pWXyu4Af" 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 4696xnpm029771; Tue, 9 Jul 2024 07:11:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=tFIuN vtrfGIkOVFgIf2UnJhYV/kpeSig03oC4Onw/rI=; b=pWXyu4Af/l2Z9ODo2l+03 zUISM0NMTD1lQBAr1B90WoSzlmcnuNqxguVpfIKcXCCqsSB8sWFkznsm4y4acZQw XNwP/8YWx+XpsnlF0Pee9ZpcO/+hP0tk5ZPR+uYAKKlrHPW7QXmWmIVWLs18xFni Gu1RdGQ6I1FnH71lHdHrmkCE4GgihAdGfHa21ZDfCRRaP2x+40NuhwlHGDHKWz0j sP1IZlXdaq+mvjkadUSqoPBLqizV1azAW6VnnjoXnqHYwVuYL1UF0Ve9DZNvRpNU 278QVPWg6GWlG4k2K7IUqaXvzB7O2UzLQEJdJWPvXN+pQFzrY/HdDGfOZEsmFhQk A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 408fy440yx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:04 -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 469BB3WL046281 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:03 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:02 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:02 -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; Tue, 9 Jul 2024 07:11:02 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgn032387; Tue, 9 Jul 2024 07:10:57 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:31 +0200 Subject: [PATCH 4/9] iio: backend: add a modified prbs23 support Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-4-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Olivier Moysan" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=666; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=JmEnLymVEakXYCG8Gu6w27A4qKIHmUWngZwraQwLMbM=; b=tFCIN1dUJOoDnP/jpU6e7rP0EEIV3LkHdb/I+yQ4hw4sj9dNbhLImvxsr9gYDoRM2LOsWX6Wx gePism3w9jkDibJehPmWJb9mRc/PQNSzRfumL+dHr58AuMn0vA0vZpS X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: peAsANirFbniL4836hT326w9WHdqFn1j X-Proofpoint-ORIG-GUID: peAsANirFbniL4836hT326w9WHdqFn1j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=567 clxscore=1015 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 Support ADI specific prb23 sequence that can be used both for calibrating or debugging digital interfaces. Signed-off-by: Nuno Sa --- include/linux/iio/backend.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index a643d86c7487..7cdcab6ded66 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -57,6 +57,8 @@ enum iio_backend_test_pattern { IIO_BACKEND_NO_TEST_PATTERN, /* modified prbs9 */ IIO_BACKEND_ADI_PRBS_9A = 32, + /* modified prbs23 */ + IIO_BACKEND_ADI_PRBS_23A, IIO_BACKEND_TEST_PATTERN_MAX }; From patchwork Tue Jul 9 11:14:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727687 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 733B41586C0 for ; Tue, 9 Jul 2024 11:11:37 +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=1720523498; cv=none; b=rcfs3mJyz7kHngXCzqfkc54WCG8h7Y+COUsnUfaqrHvVixWXPNipiOkp3zLV7+FBsjCllM9xn/8Qo0/UVKEbqgpC5jJHkfkpHAorUJ+uV82JAm0AdfrHhxgz/EuAcQhbzoOPGf5HNcomBi4CWKY5US/jSlPqzMYpIFY7QGc4uKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523498; c=relaxed/simple; bh=tK8Yviq+3nXdKD/hKLYBM5KYfUTuZS8wuUq/gPw1kRU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=qeOuO5MVkXeAaNKIWTJQLRaaHdMythrTtGegKT0TxqrYKZf4HfoQ6zld5+BfgKZQb4c8sJ+NJv159qOd0SGUJ4VER4capqasheM8+1sIa3jiFAje+29ETiTm+/EpfslpLv5s2mvBw5MCYVNwc4eJsQVoyMllquckn+b+zXjxdnY= 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=rGbTCWBD; 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="rGbTCWBD" 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 4697Z95M011314; Tue, 9 Jul 2024 07:11:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=FjlLS WZUvn24siIHzIoCLohnbPXGknueBcfRclZplSE=; b=rGbTCWBDQAeYGLxy0Ox7U LzNwGJWcvM85NZBfgTfg4pOwdYipHuktoOykrEm1Otiiof/3JTsJNjgqk3GBhTZ4 bWhBE3Qquy8bcIfMYeY7FYgqJb8CoMbKQpIVvDSnbKqgw43Bkt6FAIgn8Dg8+jWH iSHXDvrNQj5oOzSu3SoQEYWEPJwxgidMVvXHtbFtZH+yuTwUglPPYTBMMELtCQPt td+BrfTJg3EvCUGChWpn8NpMImwoPOUhgio3N0fkzHfPT29bKO9ofTeEGDioTzUX 7XtdW2lkhd+Ffc6BKFF7H5M2cYe4Nkq/SnopBzcu0YH9BJ3zOwQmSza7eDQrbbli A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 408fy4m1qt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:06 -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 469BB55C046287 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:05 -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.986.14; Tue, 9 Jul 2024 07:11:04 -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; Tue, 9 Jul 2024 07:11:04 -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; Tue, 9 Jul 2024 07:11:04 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgo032387; Tue, 9 Jul 2024 07:10:58 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:32 +0200 Subject: [PATCH 5/9] iio: adc: adi-axi-adc: support modified prbs23 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-5-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Olivier Moysan" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=882; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=tK8Yviq+3nXdKD/hKLYBM5KYfUTuZS8wuUq/gPw1kRU=; b=07n4Lm7aHsKPzRbiZbQ73Pv75WZ1tkTtpXKf0a1izppQQ+yqLfkW3GYb1cY1mMEQi337rZlsD Y3IFxX88T3/DppSGs43m0N3edsK/fsaZ5VcrJsWJRplrEsLXIhpnEN+ X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: zE6JifwVPdZlbkc-5PeTUk6Ow3l17xzB X-Proofpoint-ORIG-GUID: zE6JifwVPdZlbkc-5PeTUk6Ow3l17xzB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxlogscore=757 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 adultscore=0 priorityscore=1501 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090076 Add support for configuring the prbs23 sequence. Signed-off-by: Nuno Sa --- drivers/iio/adc/adi-axi-adc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 21ce7564e83d..54499653d888 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -199,6 +199,10 @@ static int axi_adc_test_pattern_set(struct iio_backend *back, return regmap_update_bits(st->regmap, ADI_AXI_ADC_REG_CHAN_CTRL_3(chan), ADI_AXI_ADC_CHAN_PN_SEL_MASK, FIELD_PREP(ADI_AXI_ADC_CHAN_PN_SEL_MASK, 0)); + case IIO_BACKEND_ADI_PRBS_23A: + return regmap_update_bits(st->regmap, ADI_AXI_ADC_REG_CHAN_CTRL_3(chan), + ADI_AXI_ADC_CHAN_PN_SEL_MASK, + FIELD_PREP(ADI_AXI_ADC_CHAN_PN_SEL_MASK, 1)); default: return -EINVAL; } From patchwork Tue Jul 9 11:14:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727685 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 916D815747F for ; Tue, 9 Jul 2024 11:11:36 +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=1720523497; cv=none; b=iKP5YuOdC5XaG0+xZ45VlfXiwQrhj3N6OAekAi8fARTojUOJzNYmPTNuHgwA3O8TtQsKMuFw8DljAPirLhYLs6rjRbRwQZGyzRYiW5/7G36Hc2tqKHZj6lsppdkLbqGgOvOJ6gbsRTHG/wKjK0LQ+6pGMzJjW49szrFURG2zJXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523497; c=relaxed/simple; bh=NoqNQ9VgQrHbv9NQVFmgb43v3d4fB2Ho/WZ9p6zySP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=c05H1Nkv5OVeRG+SPzID5MCokqOS28oqhjOfsXzMHlqtLVHPKLs7xL5ntsqqPNSFAaNmbKBfCberA+8akhoaBr+/66JKD8wXBSdM59pTrwToz/y4EU3HfVtATMog1YKIHFLqrK8MqrROCuq9xXQ68/bVqtbkEW+mENUbj592u5E= 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=iL0FbmcR; 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="iL0FbmcR" 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 469B6395004305; Tue, 9 Jul 2024 07:11:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=7n/i7 fMcq4vQdDlnhdr8Ww84yQs70bRCY9EAgw8RqyE=; b=iL0FbmcR9fRusDRDvJ7FC ZjUVivmTA5YXmAQSL5zgH7Xil2xx64rBw4FUOMvOfvYMERvZo+Be88lKp1iTQXsp 5ZyUbDsqXraYV8Q6t2RGDoYoCCOZjZtsS4zBRKAxH/iS6lgE5U5b0TPBcUJ1/7UA Ijxgm789H4bVQrgUXA/rF3v/rNFMmoN/Fm11indaMxGg+caQALPSWjOOFXkr2247 nCmqUQ8wgd/hLyNmYNUIGxLW/+P+9zX8X25PaDYgy37vI7SKoihwqpXlOL+BBfej 320brM/dWnTmE4AGbI7L0gwwURbIUHVBRVEn4xLvaDmu6/9L6IOSBb5wSayvS32b g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 408y9291nu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11: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 469BB8a0046293 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:08 -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; Tue, 9 Jul 2024 07:11: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; Tue, 9 Jul 2024 07:11:07 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgp032387; Tue, 9 Jul 2024 07:10:59 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:33 +0200 Subject: [PATCH 6/9] iio: adc: adi-axi-adc: split axi_adc_chan_status() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-6-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Olivier Moysan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=1692; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=NoqNQ9VgQrHbv9NQVFmgb43v3d4fB2Ho/WZ9p6zySP4=; b=y9KOZnyLP4ZLR1/AeWSzUCLb5M5937hT1KgA+6wUfHDInRe21yo1LVaDlzeCJiX6/6/mdUVc9 Ft+yroRh+DHAf4ZW+dP0Fz4aOqh45ZYUsvl3avZqL6C3Zg4zKMycGjS X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 2gxGTZa-AR8TCGCI6s5ZfaYdqjIJ_p8q X-Proofpoint-ORIG-GUID: 2gxGTZa-AR8TCGCI6s5ZfaYdqjIJ_p8q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=907 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 Add a new axi_adc_read_chan_status() helper so we get the raw register value out of it. This is in preparation of a future change where we really want to look into dedicated bits of the register. Signed-off-by: Nuno Sa --- drivers/iio/adc/adi-axi-adc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 54499653d888..12e0e6350a38 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -208,12 +208,10 @@ static int axi_adc_test_pattern_set(struct iio_backend *back, } } -static int axi_adc_chan_status(struct iio_backend *back, unsigned int chan, - bool *error) +static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned int chan, + unsigned int *status) { - struct adi_axi_adc_state *st = iio_backend_get_priv(back); int ret; - u32 val; guard(mutex)(&st->lock); /* reset test bits by setting them */ @@ -225,7 +223,18 @@ static int axi_adc_chan_status(struct iio_backend *back, unsigned int chan, /* let's give enough time to validate or erroring the incoming pattern */ fsleep(1000); - ret = regmap_read(st->regmap, ADI_AXI_ADC_REG_CHAN_STATUS(chan), &val); + return regmap_read(st->regmap, ADI_AXI_ADC_REG_CHAN_STATUS(chan), + status); +} + +static int axi_adc_chan_status(struct iio_backend *back, unsigned int chan, + bool *error) +{ + struct adi_axi_adc_state *st = iio_backend_get_priv(back); + u32 val; + int ret; + + ret = axi_adc_read_chan_status(st, chan, &val); if (ret) return ret; From patchwork Tue Jul 9 11:14:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727686 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 7BB45158203 for ; Tue, 9 Jul 2024 11:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523498; cv=none; b=RVWeXYAK6L6oxkNf/LJrreol99eFOBCyCDNqwS7UvPLMmCDlgWMFTgrcV6UCrSYvt6nPNCAF8JfHyZYQxNzVd8EgsL5kRCmis4S3sN/Caa564ZChH2xnpZTHYCPZdSnpmt+kGsnY+NHa4QFcN73JAtCgeK8kpPQxTsvRwfMKHMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523498; c=relaxed/simple; bh=UOKb5xsRk8GE+oZEu4a3bggb6Yvr5WNWj548FnXuzOY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Vye5apgQ08fYQhUyUTZSxLW1ODPSzVPT/kM5OOXztu4qLQbGYUg8bEeiXFia0Chy7jhGi0gMT3ojtuxqu30gtERDAV8vnNEfvZX208RbtaNOKo4mGZYUYVZY6vvqF/Lpu0fk3beddP4WrdRDxo1spwgRJt+SFiDpFKoEZiOUDdk= 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=1y2Ox4Np; 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="1y2Ox4Np" 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 4697DaI9029871; Tue, 9 Jul 2024 07:11:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=ZSskR zocRRzOQrCPVXJMpeyC/vEfaGAZrNh3InMNjZk=; b=1y2Ox4NprcBUjH24N8fJK T6guLR8wRLiU3EY5PMd7pXsO3QMeDPEZ9URtTTwD4W95TGFKlAHuIPxNNl9W9bB6 4h+JEzNtRR0paxt7yGnbFySjeQhIipmYJIspTkPrpUm3xPtNikUc/pGsxiNfRAoU ve25mEFDpWr1/T8axZuk6nPHiQHbxa4EyORYlmqfqHI/1r6dr2EcSXKpRE6/JX2s mbW/At3kS//PrHTJT0HZVqenPoLn9i+vShoYU0q6KbC+dIScfUBOANIah+8nJks7 ImH4nEFBSK+S9eAU0I93g3qUpvMFxrfHCr+57KCUfnxG2/fb0HBrV6JrCx1K4leP w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 408fy44107-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:07 -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 469BB60I055143 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:06 -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; Tue, 9 Jul 2024 07:11:05 -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; Tue, 9 Jul 2024 07:11:05 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgq032387; Tue, 9 Jul 2024 07:11:00 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:34 +0200 Subject: [PATCH 7/9] iio: adc: adi-axi-adc: implement backend debugfs interface Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-7-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Olivier Moysan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523682; l=2893; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=UOKb5xsRk8GE+oZEu4a3bggb6Yvr5WNWj548FnXuzOY=; b=As+SZJIv2jTZcEh22RSobgvSEjVbhA6EhkJCjrTmPoltXIDSkLBm7Z+PPJb7Fx/JIeRd76Pbp C0/fkI6FI5tAIMZAgpA2bI/nDhstUeHontGSPfhjH4ubGv4BvuDJFDs X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: QChZsbagO_3YA-P96kTAIJoW7ER-Nd62 X-Proofpoint-ORIG-GUID: QChZsbagO_3YA-P96kTAIJoW7ER-Nd62 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 Implement debugfs options to read/write registers and print the channel status into a buffer (so we may know better the cause for errors) . Signed-off-by: Nuno Sa --- drivers/iio/adc/adi-axi-adc.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 12e0e6350a38..7cba347cf8eb 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -61,6 +61,10 @@ #define ADI_AXI_ADC_REG_CHAN_STATUS(c) (0x0404 + (c) * 0x40) #define ADI_AXI_ADC_CHAN_STAT_PN_MASK GENMASK(2, 1) +/* out of sync */ +#define ADI_AXI_ADC_CHAN_STAT_PN_OOS BIT(1) +/* spurious out of sync */ +#define ADI_AXI_ADC_CHAN_STAT_PN_ERR BIT(2) #define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40) #define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16) @@ -246,6 +250,30 @@ static int axi_adc_chan_status(struct iio_backend *back, unsigned int chan, return 0; } +static int axi_adc_debugfs_print_chan_status(struct iio_backend *back, + unsigned int chan, char *buf, + size_t len) +{ + struct adi_axi_adc_state *st = iio_backend_get_priv(back); + u32 val; + int ret; + + ret = axi_adc_read_chan_status(st, chan, &val); + if (ret) + return ret; + + /* + * PN_ERR is cleared in case out of sync is set. Hence, no point in + * checking both bits. + */ + if (val & ADI_AXI_ADC_CHAN_STAT_PN_OOS) + return scnprintf(buf, len, "CH%u: Out of Sync.\n", chan); + if (val & ADI_AXI_ADC_CHAN_STAT_PN_ERR) + return scnprintf(buf, len, "CH%u: Spurious Out of Sync.\n", chan); + + return scnprintf(buf, len, "CH%u: OK.\n", chan); +} + static int axi_adc_chan_enable(struct iio_backend *back, unsigned int chan) { struct adi_axi_adc_state *st = iio_backend_get_priv(back); @@ -280,6 +308,17 @@ static void axi_adc_free_buffer(struct iio_backend *back, iio_dmaengine_buffer_free(buffer); } +static int axi_adc_reg_access(struct iio_backend *back, unsigned int reg, + unsigned int writeval, unsigned int *readval) +{ + struct adi_axi_adc_state *st = iio_backend_get_priv(back); + + if (readval) + return regmap_read(st->regmap, reg, readval); + + return regmap_write(st->regmap, reg, writeval); +} + static const struct regmap_config axi_adc_regmap_config = { .val_bits = 32, .reg_bits = 32, @@ -298,6 +337,8 @@ static const struct iio_backend_ops adi_axi_adc_generic = { .iodelay_set = axi_adc_iodelays_set, .test_pattern_set = axi_adc_test_pattern_set, .chan_status = axi_adc_chan_status, + .debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access), + .debugfs_print_chan_status = iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status), }; static int adi_axi_adc_probe(struct platform_device *pdev) From patchwork Tue Jul 9 11:14:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727684 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 88AEC158205 for ; Tue, 9 Jul 2024 11:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523496; cv=none; b=GzXB0mICTRq7CFl9e9A1bCaodIaERhxCJW3ctPgnOnTY88tsZVjgBVE7OR/9kOqnDVqz1hZfyoXZ6aHCHRnhXUvdq1elXFX7d8CUMkHwVe5Fi9jO/WHVAZCQDi818WzJF7qR3BLvbCx5hrcRfRN4yaNNl9SH6du0mB7Lg6iKZ04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523496; c=relaxed/simple; bh=ORQVhXl18L7QpqOhlMxALCTW9W1adG0MCwa3NMU5bf8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=lUntcsmuQZ6BbCCoRhObyBVvNb4rTiGlcAQ5re6VHMlBDMjIOHE+HlOwFonfPTi2XDqTer3d2Wdctx8kaEayFZcgUqYo+sfrJMqXamK4QcL4qew8ejUq6lIUs3B2kfvfQqrwM21Zw2B3jKjlhhnEpTX+jOj8kEnkCcA5MvnmDIA= 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=mVxH0ARf; 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="mVxH0ARf" 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 469B5ab9004256; Tue, 9 Jul 2024 07:11:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=adlDQ ZJma+BSIfS1p4KIv2RQDb0Bz2C7Cf3eGvlL+hg=; b=mVxH0ARfwj2XGqQhzKwVf 1fiC6GfTZ/Ouu2C6Lyfat6TsSfF0vNTZGnpGU3708KfdmE+aVZ4xxKpgKvQ3n//O l5+Tx6rGfb8r0T5kEJRObXE7As4AaNtD6liqb3eVmUeFPtYlzb8MLPyDrkZwbezI Fax+NYUkK93uocvq5vSh+Wp9z/FjLYIs45aDlKoqoSIkBuWANPnPGDhFlO3PRbRq TX3WHOiVxUTxJzcO1m9N/lvSQ5vCSQAHcMvtCxHdby7pl9+6nJjaZincHLuXTIl0 btXDRscXnwrzo77QMLoMSrFehN0MwsQdykoDF/F5WGS4Uo3Jn24Kh3jrFFr2eH8W g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 408y9291nt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:08 -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 469BB7UC055150 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:07 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:06 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:06 -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; Tue, 9 Jul 2024 07:11:06 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgr032387; Tue, 9 Jul 2024 07:11:01 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:35 +0200 Subject: [PATCH 8/9] iio: adc: ad9467: add backend test mode helpers Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-8-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Olivier Moysan" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523683; l=3095; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=ORQVhXl18L7QpqOhlMxALCTW9W1adG0MCwa3NMU5bf8=; b=j6dtuRPPRnYdBTUSwUutagNGyYthRSdzUBwdB0YyS242wmfVPG/lWlRE82wFrh2R9S+TF1u56 c5yFQc40cKNC72yguZRz+mAVOtMMWQWkjlI5x0MFedM7KVpA6yLAvCX X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: QFq2LFsQHPpXzkmndIOx-tLvzitS2bpr X-Proofpoint-ORIG-GUID: QFq2LFsQHPpXzkmndIOx-tLvzitS2bpr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=725 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 Group the backend configurations to be done in preparing and stopping calibration in two new helpers analogous to ad9467_testmode_set(). This is in preparation for adding support for debugFS test_mode where we need similar configurations as in the calibration process. Signed-off-by: Nuno Sa --- drivers/iio/adc/ad9467.c | 67 ++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c index 557d98ca2f25..2f4bbbd5611c 100644 --- a/drivers/iio/adc/ad9467.c +++ b/drivers/iio/adc/ad9467.c @@ -494,11 +494,49 @@ static int ad9467_testmode_set(struct ad9467_state *st, unsigned int chan, AN877_ADC_TRANSFER_SYNC); } -static int ad9647_calibrate_prepare(struct ad9467_state *st) +static int ad9467_backend_testmode_on(struct ad9467_state *st, + unsigned int chan, + enum iio_backend_test_pattern pattern) { struct iio_backend_data_fmt data = { .enable = false, }; + int ret; + + ret = iio_backend_data_format_set(st->back, chan, &data); + if (ret) + return ret; + + ret = iio_backend_test_pattern_set(st->back, chan, pattern); + if (ret) + return ret; + + return iio_backend_chan_enable(st->back, chan); +} + +static int ad9467_backend_testmode_off(struct ad9467_state *st, + unsigned int chan) +{ + struct iio_backend_data_fmt data = { + .enable = true, + .sign_extend = true, + }; + int ret; + + ret = iio_backend_chan_disable(st->back, chan); + if (ret) + return ret; + + ret = iio_backend_test_pattern_set(st->back, chan, + IIO_BACKEND_NO_TEST_PATTERN); + if (ret) + return ret; + + return iio_backend_data_format_set(st->back, chan, &data); +} + +static int ad9647_calibrate_prepare(struct ad9467_state *st) +{ unsigned int c; int ret; @@ -511,16 +549,8 @@ static int ad9647_calibrate_prepare(struct ad9467_state *st) if (ret) return ret; - ret = iio_backend_data_format_set(st->back, c, &data); - if (ret) - return ret; - - ret = iio_backend_test_pattern_set(st->back, c, - IIO_BACKEND_ADI_PRBS_9A); - if (ret) - return ret; - - ret = iio_backend_chan_enable(st->back, c); + ret = ad9467_backend_testmode_on(st, c, + IIO_BACKEND_ADI_PRBS_9A); if (ret) return ret; } @@ -601,24 +631,11 @@ static int ad9467_calibrate_apply(struct ad9467_state *st, unsigned int val) static int ad9647_calibrate_stop(struct ad9467_state *st) { - struct iio_backend_data_fmt data = { - .sign_extend = true, - .enable = true, - }; unsigned int c, mode; int ret; for (c = 0; c < st->info->num_channels; c++) { - ret = iio_backend_chan_disable(st->back, c); - if (ret) - return ret; - - ret = iio_backend_test_pattern_set(st->back, c, - IIO_BACKEND_NO_TEST_PATTERN); - if (ret) - return ret; - - ret = iio_backend_data_format_set(st->back, c, &data); + ret = ad9467_backend_testmode_off(st, c); if (ret) return ret; From patchwork Tue Jul 9 11:14:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Nuno_S=C3=A1?= X-Patchwork-Id: 13727688 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 49CB3158858 for ; Tue, 9 Jul 2024 11:11:38 +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=1720523501; cv=none; b=LKnCUJO+lFytOfejb9o1zzSlxhl9eOmFa/QvhOTk0VbuOdvS5JhQCEEBkfWyhsFUdIJH0jsUYnNw0uiM4yMYvDhCTcfnq7euTHcLF7TnD3uLVaGFKt4w27FhPUVYcdYo8hgHbo9+FeewAz/O7H+XoHdybVU6xSF20E/rjUQDCt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523501; c=relaxed/simple; bh=mIc8cdfVRPXmxVLFiNbyxGXSotI9LgS9R1xB3cY+/mw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=pkzDZwVSXhFBZqB7+dcCf1f2rpXczVsxn2IFie8DB5uwmQWJeWq3txi+9qnqO8Co8HUasYDih5K8ubsKb28ilMwaAB6t/v6CFFd2S5bJTqR7Xk+FQaeciqHhu1ErL01Sc9/BtdMgfSLjRGYgiFNWL9+y/h6/8v/uXVQ99+oRcNE= 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=lgVPDxg9; 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="lgVPDxg9" 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 469B6396004305; Tue, 9 Jul 2024 07:11:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=a4mDY 0r955OSY6grK89Xi6KkFWQA3o0QoT0LGnChgqs=; b=lgVPDxg96DuBOdKWQ0KQ4 iIqmEvjpydf7b+3Yeml+BShM1QzH4US/Uf/WaufwAeerFOhSu9pDMJF3NzjWhYXh 7CKDZo7CvEzoJILc/IzplUR6ZvCFRpo+6pMvchr0ujMGQPbw9Ov/DJ3lrbZ093mY 8VvlAUZcWiZGQbfpcJcxdOW0nhu07EflAM5DcqsigLT0H7aTp1qnr9q6j1m+Rw8H pb1Ief9BAnK0CI0iFZyNJ4qBw1Mr7CiHZrTJswm8nYd00iEfEElibOpI0x9H9M5C onUsG0oP9NS4JsiHqe6Xty+10futcfbDRAiupK9X6CbPXaqgtvnMDc296TyqCbgw Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 408y9291p0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 07:11:10 -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 469BB9FC046296 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jul 2024 07:11:09 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 9 Jul 2024 07:11:08 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 9 Jul 2024 07:11:08 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 469BAlgs032387; Tue, 9 Jul 2024 07:11:01 -0400 From: Nuno Sa Date: Tue, 9 Jul 2024 13:14:36 +0200 Subject: [PATCH 9/9] iio: adc: ad9467: add digital interface test to debugfs Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240709-dev-iio-backend-add-debugfs-v1-9-fb4b8f2373c7@analog.com> References: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> In-Reply-To: <20240709-dev-iio-backend-add-debugfs-v1-0-fb4b8f2373c7@analog.com> To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Olivier Moysan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720523683; l=10407; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=mIc8cdfVRPXmxVLFiNbyxGXSotI9LgS9R1xB3cY+/mw=; b=oiO70dp1cEUAMEb/JaTQNELJcoJ5AyjUk9zgAI1XSvSFASZXcwBGeBRzPDp6CSU0Wi/ivGmUB IhQ04l0oYlpCHcQOJtk2+03t4TU5w6VQVM6ITsjmtyYej4ywyHdBiWc X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 1CLNC3h0A1-nFvP8PcqVStzA6Z2Blhbs X-Proofpoint-ORIG-GUID: 1CLNC3h0A1-nFvP8PcqVStzA6Z2Blhbs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-09_02,2024-07-08_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407090077 One useful thing to do (in case of problems) in this high speed devices with digital interfaces is to try different test patterns to see if the interface is working properly (and properly calibrated). Hence add this to debugfs. On top of this, for some test patterns, the backend may have a matching validator block which can be helpful in identifying possible issues. For the other patterns some test equipment must be used so one can look into the signal and see how it looks like. Hence, we also add the backend debugfs interface with iio_backend_debugfs_add(). Signed-off-by: Nuno Sa --- drivers/iio/adc/ad9467.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c index 2f4bbbd5611c..ce0bae94aa3a 100644 --- a/drivers/iio/adc/ad9467.c +++ b/drivers/iio/adc/ad9467.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,8 @@ struct ad9467_chip_info { unsigned int num_channels; const unsigned int (*scale_table)[2]; int num_scales; + unsigned long test_mask; + unsigned int test_mask_len; unsigned long max_rate; unsigned int default_output_mode; unsigned int vref_mask; @@ -147,11 +150,19 @@ struct ad9467_chip_info { bool has_dco_invert; }; +struct ad9467_chan_test_mode { + struct ad9467_state *st; + unsigned int idx; + u8 mode; +}; + struct ad9467_state { const struct ad9467_chip_info *info; struct iio_backend *back; struct spi_device *spi; struct clk *clk; + /* used for debugfs */ + struct ad9467_chan_test_mode *chan_test; unsigned int output_mode; unsigned int (*scales)[2]; /* @@ -308,6 +319,23 @@ static const struct iio_chan_spec ad9652_channels[] = { AD9467_CHAN(1, BIT(IIO_CHAN_INFO_SCALE), 1, 16, 's'), }; +static const char * const ad9467_test_modes[] = { + [AN877_ADC_TESTMODE_OFF] = "off", + [AN877_ADC_TESTMODE_MIDSCALE_SHORT] = "midscale_short", + [AN877_ADC_TESTMODE_POS_FULLSCALE] = "pos_fullscale", + [AN877_ADC_TESTMODE_NEG_FULLSCALE] = "neg_fullscale", + [AN877_ADC_TESTMODE_ALT_CHECKERBOARD] = "checkerboard", + [AN877_ADC_TESTMODE_PN23_SEQ] = "prbs23", + [AN877_ADC_TESTMODE_PN9_SEQ] = "prbs9", + [AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE] = "one_zero_toggle", + [AN877_ADC_TESTMODE_USER] = "user", + [AN877_ADC_TESTMODE_BIT_TOGGLE] = "bit_toggle", + [AN877_ADC_TESTMODE_SYNC] = "sync", + [AN877_ADC_TESTMODE_ONE_BIT_HIGH] = "one_bit_high", + [AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY] = "mixed_bit_frequency", + [AN877_ADC_TESTMODE_RAMP] = "ramp", +}; + static const struct ad9467_chip_info ad9467_chip_tbl = { .name = "ad9467", .id = CHIPID_AD9467, @@ -317,6 +345,9 @@ static const struct ad9467_chip_info ad9467_chip_tbl = { .channels = ad9467_channels, .num_channels = ARRAY_SIZE(ad9467_channels), .test_points = AD9647_MAX_TEST_POINTS, + .test_mask = GENMASK(AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE, + AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE + 1, .default_output_mode = AD9467_DEF_OUTPUT_MODE, .vref_mask = AD9467_REG_VREF_MASK, .num_lanes = 8, @@ -331,6 +362,8 @@ static const struct ad9467_chip_info ad9434_chip_tbl = { .channels = ad9434_channels, .num_channels = ARRAY_SIZE(ad9434_channels), .test_points = AD9647_MAX_TEST_POINTS, + .test_mask = GENMASK(AN877_ADC_TESTMODE_USER, AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_USER + 1, .default_output_mode = AD9434_DEF_OUTPUT_MODE, .vref_mask = AD9434_REG_VREF_MASK, .num_lanes = 6, @@ -345,6 +378,9 @@ static const struct ad9467_chip_info ad9265_chip_tbl = { .channels = ad9467_channels, .num_channels = ARRAY_SIZE(ad9467_channels), .test_points = AD9647_MAX_TEST_POINTS, + .test_mask = GENMASK(AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE, + AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE + 1, .default_output_mode = AD9265_DEF_OUTPUT_MODE, .vref_mask = AD9265_REG_VREF_MASK, .has_dco = true, @@ -360,6 +396,9 @@ static const struct ad9467_chip_info ad9643_chip_tbl = { .channels = ad9643_channels, .num_channels = ARRAY_SIZE(ad9643_channels), .test_points = AD9647_MAX_TEST_POINTS, + .test_mask = BIT(AN877_ADC_TESTMODE_RAMP) | + GENMASK(AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY, AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_RAMP + 1, .vref_mask = AD9643_REG_VREF_MASK, .has_dco = true, .has_dco_invert = true, @@ -375,6 +414,9 @@ static const struct ad9467_chip_info ad9649_chip_tbl = { .channels = ad9649_channels, .num_channels = ARRAY_SIZE(ad9649_channels), .test_points = AD9649_TEST_POINTS, + .test_mask = GENMASK(AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY, + AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY + 1, .has_dco = true, .has_dco_invert = true, .dco_en = AN877_ADC_DCO_DELAY_ENABLE, @@ -389,6 +431,9 @@ static const struct ad9467_chip_info ad9652_chip_tbl = { .channels = ad9652_channels, .num_channels = ARRAY_SIZE(ad9652_channels), .test_points = AD9647_MAX_TEST_POINTS, + .test_mask = GENMASK(AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE, + AN877_ADC_TESTMODE_OFF), + .test_mask_len = AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE + 1, .vref_mask = AD9652_REG_VREF_MASK, .has_dco = true, }; @@ -933,6 +978,128 @@ static int ad9467_iio_backend_get(struct ad9467_state *st) return -ENODEV; } +static int ad9467_test_mode_available_show(struct seq_file *s, void *ignored) +{ + struct ad9467_state *st = s->private; + unsigned int bit; + + for_each_set_bit(bit, &st->info->test_mask, st->info->test_mask_len) + seq_printf(s, "%s\n", ad9467_test_modes[bit]); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(ad9467_test_mode_available); + +static ssize_t ad9467_chan_test_mode_read(struct file *file, + char __user *userbuf, size_t count, + loff_t *ppos) +{ + struct ad9467_chan_test_mode *chan = file->private_data; + struct ad9467_state *st = chan->st; + char buf[128] = {0}; + size_t len; + int ret; + + if (chan->mode == AN877_ADC_TESTMODE_PN9_SEQ || + chan->mode == AN877_ADC_TESTMODE_PN23_SEQ) { + len = scnprintf(buf, sizeof(buf), "Running \"%s\" Test:\n\t", + ad9467_test_modes[chan->mode]); + + ret = iio_backend_debugfs_print_chan_status(st->back, chan->idx, + buf + len, + sizeof(buf) - len); + if (ret < 0) + return ret; + len += ret; + } else if (chan->mode == AN877_ADC_TESTMODE_OFF) { + len = scnprintf(buf, sizeof(buf), "No test Running...\n"); + } else { + len = scnprintf(buf, sizeof(buf), "Running \"%s\" Test on CH:%u\n", + ad9467_test_modes[chan->mode], chan->idx); + } + + return simple_read_from_buffer(userbuf, count, ppos, buf, len); +} + +static ssize_t ad9467_chan_test_mode_write(struct file *file, + const char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct ad9467_chan_test_mode *chan = file->private_data; + struct ad9467_state *st = chan->st; + char test_mode[32] = {0}; + unsigned int mode; + int ret; + + ret = simple_write_to_buffer(test_mode, sizeof(test_mode) - 1, ppos, + userbuf, count); + if (ret < 0) + return ret; + + for_each_set_bit(mode, &st->info->test_mask, st->info->test_mask_len) { + if (sysfs_streq(test_mode, ad9467_test_modes[mode])) + break; + } + + if (mode == st->info->test_mask_len) + return -EINVAL; + + guard(mutex)(&st->lock); + + if (mode == AN877_ADC_TESTMODE_OFF) { + unsigned int out_mode; + + if (chan->mode == AN877_ADC_TESTMODE_PN9_SEQ || + chan->mode == AN877_ADC_TESTMODE_PN23_SEQ) { + ret = ad9467_backend_testmode_off(st, chan->idx); + if (ret) + return ret; + } + + ret = ad9467_testmode_set(st, chan->idx, mode); + if (ret) + return ret; + + out_mode = st->info->default_output_mode | AN877_ADC_OUTPUT_MODE_TWOS_COMPLEMENT; + ret = ad9467_outputmode_set(st, out_mode); + if (ret) + return ret; + } else { + ret = ad9467_outputmode_set(st, st->info->default_output_mode); + if (ret) + return ret; + + ret = ad9467_testmode_set(st, chan->idx, mode); + if (ret) + return ret; + + /* some patterns have a backend matching monitoring block */ + if (mode == AN877_ADC_TESTMODE_PN9_SEQ) { + ret = ad9467_backend_testmode_on(st, chan->idx, + IIO_BACKEND_ADI_PRBS_9A); + if (ret) + return ret; + } else if (mode == AN877_ADC_TESTMODE_PN23_SEQ) { + ret = ad9467_backend_testmode_on(st, chan->idx, + IIO_BACKEND_ADI_PRBS_23A); + if (ret) + return ret; + } + } + + chan->mode = mode; + + return count; +} + +static const struct file_operations ad9467_chan_test_mode_fops = { + .open = simple_open, + .read = ad9467_chan_test_mode_read, + .write = ad9467_chan_test_mode_write, + .llseek = default_llseek, + .owner = THIS_MODULE, +}; + static ssize_t ad9467_dump_calib_table(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) @@ -971,12 +1138,33 @@ static void ad9467_debugfs_init(struct iio_dev *indio_dev) { struct dentry *d = iio_get_debugfs_dentry(indio_dev); struct ad9467_state *st = iio_priv(indio_dev); + char attr_name[32]; + unsigned int chan; if (!IS_ENABLED(CONFIG_DEBUG_FS)) return; + st->chan_test = devm_kcalloc(&st->spi->dev, st->info->num_channels, + sizeof(*st->chan_test), GFP_KERNEL); + if (!st->chan_test) + return; + debugfs_create_file("calibration_table_dump", 0400, d, st, &ad9467_calib_table_fops); + + for (chan = 0; chan < st->info->num_channels; chan++) { + snprintf(attr_name, sizeof(attr_name), "in_voltage%u_test_mode", + chan); + st->chan_test[chan].idx = chan; + st->chan_test[chan].st = st; + debugfs_create_file(attr_name, 0600, d, &st->chan_test[chan], + &ad9467_chan_test_mode_fops); + } + + debugfs_create_file("in_voltage_test_mode_available", 0400, d, st, + &ad9467_test_mode_available_fops); + + iio_backend_debugfs_add(st->back, indio_dev); } static int ad9467_probe(struct spi_device *spi)