From nobody Sun Feb 8 23:42:00 2026 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 8CC39242D77; Fri, 25 Apr 2025 11:26:00 +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=1745580362; cv=none; b=eplGGQpfGk0zzok7qUrkNU7bNkmRD9EDXThPd3xZtrSOy3H29bDW2EigL/xxzgwaU4HjXHaxeDyZbsnry03NUekImq7SnQSosAODO4K4wTGsdTb2eFwoUTYeDOGZoG4NJy1cvEV2kxeoEOm5+mDr0OwscteEzU1KB3h6ly/LXRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580362; c=relaxed/simple; bh=jKD0Fvkhbkt/Nbn18+Y0DDmBYBcCCj9kOxH1VqdF2Ww=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hZzCS80W1qMnylHVaMYCni7BJk1G0PwceKc6jb3gY80ajN53sgMM4Z8M+fsm04S8o2c2qu7ARXj1vZZ3ZgjHW5o017R5Q1A2d+vweQltPF3FhwixmNX/wU/EdQeb+1M+8+uQEPlPXGohMaHRGzn5pIvN2QzYy+1uomyXUZ+RZcU= 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=z/hb23nH; 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="z/hb23nH" 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 53PBNnRZ014719; Fri, 25 Apr 2025 07:25:58 -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=DItPv E/G6RgDJjdJUkC+0TQLy6mncpdzKnHVih8ldUg=; b=z/hb23nHod6n97YW5ZVAb wqezTeXlUnyZ+s8wDQNR1S39i5W7CpdvcsSM+HUcYb3eWqMkENz2UXFG7beOK6kE s76bUAt0EBi+6GjK97uibpKxDgE5fkJ8rgHmsO2G2s5o+MgKsMWwj/TLKjupON2C HYSTevcbbEv+0B4Jd2N2U+K5Ck/DuJL1yZ5zvkpoIA/QRzcBLoqsupjIUZg+98mX 9agrqO/jpoRYgQG7V27ZIcSq+d/kbY76YZdfi3XD2MVc7c8UtHNnMVGJ8ghJnXlL XobA62riZ4elicczdw4mEf4HAQK09Ux/V9t+NC8OlsWaDkh63S9/5XcKb55V7LSE g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 466jjwf1g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:25: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 53PBPuL6049206 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:25:56 -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; Fri, 25 Apr 2025 07:25:56 -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; Fri, 25 Apr 2025 07:25:56 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbr003881; Fri, 25 Apr 2025 07:25:50 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 01/11] iio: backend: add support for filter config Date: Fri, 25 Apr 2025 14:25:28 +0300 Message-ID: <20250425112538.59792-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@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: bfYrKdjSxwR0puM1cr1KzAGLvYHiqRGj X-Authority-Analysis: v=2.4 cv=JMU7s9Kb c=1 sm=1 tr=0 ts=680b7145 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=UD3WkZFi8vOiteFn2FEA:9 X-Proofpoint-ORIG-GUID: bfYrKdjSxwR0puM1cr1KzAGLvYHiqRGj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX8JCgyO6przdI Go/8Uljs9R7E1cLT1uOS5/wdrbyWwnaXXrXTZaBWklXDleRDfArDPdq37oZ1VbQ9KrRZuvtPYUB csZCuP+DTdrGep9KPOaSjaOcO0PJg1QyKhO/ksJ7oSzQuGUoRO/TMkCrW+Ip2InumCdjy0jh0dw E4WOOD+OSBY5Z4505cz/yW3abFhlKpGgBQ9Wy0edMO0XDaSfdRQeMNDtC8veHlk4smk3JtRH94c /JdukB7IqgRzTGaZCA/MYozGB7pO4o7NyeSmmCPtlO+SVyaol1fOTD1RD3RxAOwPKzzSEszaSuV Azf3OpyY6HSrrbPRUSEMDRjFJz9Qo5kAGNuw0yXkddc0xfjJ/6koECneTsiwB+S8c5sVaM+r03+ JRBEGZeJzsfcCYNxANgNzlb4rTX7Q97gPFObdbAzqC0w3LHhqXuGwajc162RJn7HRkjh/1yW 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add backend support for digital filter type selection. This setting can be adjusted within the IP cores interfacing devices. The IP core can be configured based on the state of the actual digital filter configuration of the part. Signed-off-by: Antoniu Miclaus Reviewed-by: Nuno S=C3=A1 --- changes in v3: - update function to set the actual filter type instead of just enable/dis= able. drivers/iio/industrialio-backend.c | 15 +++++++++++++++ include/linux/iio/backend.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index d4ad36f54090..2d28eabb1607 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -778,6 +778,21 @@ static int __devm_iio_backend_get(struct device *dev, = struct iio_backend *back) return 0; } =20 +/** + * iio_backend_filter_type_set - Set filter type + * @back: Backend device + * @type: Filter type. + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_filter_type_set(struct iio_backend *back, + enum iio_backend_filter_type type) +{ + return iio_backend_op_call(back, filter_type_set, type); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_filter_type_set, "IIO_BACKEND"); + /** * iio_backend_ddr_enable - Enable interface DDR (Double Data Rate) mode * @back: Backend device diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index e45b7dfbec35..5526800f5d4a 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -76,6 +76,14 @@ enum iio_backend_interface_type { IIO_BACKEND_INTERFACE_MAX }; =20 +enum iio_backend_filter_type { + IIO_BACKEND_FILTER_TYPE_DISABLED, + IIO_BACKEND_FILTER_TYPE_SINC1, + IIO_BACKEND_FILTER_TYPE_SINC5, + IIO_BACKEND_FILTER_TYPE_SINC5_PLUS_COMP, + IIO_BACKEND_FILTER_TYPE_MAX +}; + /** * struct iio_backend_ops - operations structure for an iio_backend * @enable: Enable backend. @@ -100,6 +108,7 @@ enum iio_backend_interface_type { * @read_raw: Read a channel attribute from a backend device * @debugfs_print_chan_status: Print channel status into a buffer. * @debugfs_reg_access: Read or write register value of backend. + * @filter_type_set: Set filter type. * @ddr_enable: Enable interface DDR (Double Data Rate) mode. * @ddr_disable: Disable interface DDR (Double Data Rate) mode. * @data_stream_enable: Enable data stream. @@ -150,6 +159,8 @@ struct iio_backend_ops { size_t len); int (*debugfs_reg_access)(struct iio_backend *back, unsigned int reg, unsigned int writeval, unsigned int *readval); + int (*filter_type_set)(struct iio_backend *back, + enum iio_backend_filter_type type); int (*ddr_enable)(struct iio_backend *back); int (*ddr_disable)(struct iio_backend *back); int (*data_stream_enable)(struct iio_backend *back); @@ -190,6 +201,8 @@ int iio_backend_data_sample_trigger(struct iio_backend = *back, int devm_iio_backend_request_buffer(struct device *dev, struct iio_backend *back, struct iio_dev *indio_dev); +int iio_backend_filter_type_set(struct iio_backend *back, + enum iio_backend_filter_type type); int iio_backend_ddr_enable(struct iio_backend *back); int iio_backend_ddr_disable(struct iio_backend *back); int iio_backend_data_stream_enable(struct iio_backend *back); --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 BA3DE241CB7; Fri, 25 Apr 2025 11:25:59 +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=1745580361; cv=none; b=EY7e2niBWXu7JV0mqFQe6Qt9hH4tsjKLajVDMNv1xg04P0baxnebkj2HGV+xh9QwLBe3uzVvEc4+mzySFevcmRcJ1SY+NX9BOF4xECTlnCo2C5lu6ePh26ja78Wyh8AryDgR4rTei07muhJ2hldw/Dk1/M1yP79SZVMt1qStHc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580361; c=relaxed/simple; bh=Gm0S+KY5uY5IASM26sJYnBEQnvLbZkNSih5Hc8ek1HY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hWafNjzYrjvwAuq4HZoCORPK2LXDtALGKYo8j6i2EWkpnFeICm8Unu9SqoL2oU0BI96VZ3tsam3dcU9EtTWlwnHQZz0+4VCO87xkBgQM+QaUCG3FXoQ3a454Dp1/faAWRhAFRly7xa/ln49hOSwA4ovnWY2WGpnOfTkasCWXN0w= 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=wVl4u873; 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="wVl4u873" 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 53P9ocmL014720; Fri, 25 Apr 2025 07:25:56 -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=lEImt 4P6enOMzldO7z1W0hEuG/eFHH+4/RPwUMQ5tls=; b=wVl4u873HF5vTFCKELEcT XUJY1ZHLuvxHf1wqFhvFQEGhEbPkb+xQk18VfltgsLOVmfTPYI1uUV8kYPGYMaC2 Dp5UNujvz6MLLc5i9exe+ApwpM+X61dL4oRqwKAQq0WYvFjycM6l2Bu+sZKmVizw 1/vUaxapIGaao2gEo3lVe9bVZ8sxrOKih/F3VnP/Em8n7JG5QjP/9EQzZHqywq71 tLTvBWCS1c0V6uWWwY1FgYFfpgW0Cr4Gy/1LbctjVteg4LVPvtir/zrmOv54sOIq 7zth2t9JpDxnx5Q4rr9N2k7gJA2ONFr9RztF/D2I7OMvSdvRgPhi6sga1fRY4pJb A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 466jjwf1fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:25:56 -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 53PBPtOE049197 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:25:55 -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; Fri, 25 Apr 2025 07:25:55 -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; Fri, 25 Apr 2025 07:25:55 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbs003881; Fri, 25 Apr 2025 07:25:52 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 02/11] iio: backend: add support for data alignment Date: Fri, 25 Apr 2025 14:25:29 +0300 Message-ID: <20250425112538.59792-3-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@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: uXfURWZaERKBeyj9xsKYN6iGqot6ZFHx X-Authority-Analysis: v=2.4 cv=JMU7s9Kb c=1 sm=1 tr=0 ts=680b7144 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=AWommT912SskAef1OWUA:9 X-Proofpoint-ORIG-GUID: uXfURWZaERKBeyj9xsKYN6iGqot6ZFHx X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX/z7ag8jgtSLS +ItiPNcMqNebUK+yX9JWl2tg7T79UxtRWQerwDDQV01JlzNKCntxIZChACcESgsHD+8vnG6Hagz BnaQvcbqHEcqWgbjLiZGI5f7nb9cLJpTsRM5mdhllU00PAIWu2jceBshD367ZJUF0mucHy/T6T1 +Q6LvTxVD8RNRRcZmLsXhZZ/SbIq2ckPLmdp1MuDa+AmuKFZlbIzJvUakZAAIpatPsmg8gC1ptz bvHjWAFI5H9zoInmrrle4VJ44a8QS3OB58pYZdwx7IBvf+pMgo5P6pc+jLqAyKP2/Blcw51Mpe6 fDqJaA0JLzsfPuMZym/niZ6nJr7gTYBJePLQnPwa7UT2ei61ScdzHzG+gNIVRGAgvIjuzGdagby rsuX+XqBTLeolt5S1IUN+2WoULE4bY5cU/k3bC6hyr2dyuBLSPo2gmOTv+QRkUq+zlKJq40z 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add backend support for enabling/disabling the capture synchronization. When activated, it initates a proccess that aligns the sample's most significant bit (MSB) based solely on the captured data, without considering any other external signals. Signed-off-by: Antoniu Miclaus --- changes in v3: - update commit description and align with the new hdl changes. drivers/iio/industrialio-backend.c | 26 ++++++++++++++++++++++++++ include/linux/iio/backend.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index 2d28eabb1607..b77a31b16aa5 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -793,6 +793,32 @@ int iio_backend_filter_type_set(struct iio_backend *ba= ck, } EXPORT_SYMBOL_NS_GPL(iio_backend_filter_type_set, "IIO_BACKEND"); =20 +/** + * iio_backend_data_alignment_enable - Enable the sync process. + * @back: Backend device + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_data_alignment_enable(struct iio_backend *back) +{ + return iio_backend_op_call(back, data_alignment_enable); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_data_alignment_enable, "IIO_BACKEND"); + +/** + * iio_backend_data_alignment_disable - Disable the sync process. + * @back: Backend device + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_data_alignment_disable(struct iio_backend *back) +{ + return iio_backend_op_call(back, data_alignment_disable); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_data_alignment_disable, "IIO_BACKEND"); + /** * iio_backend_ddr_enable - Enable interface DDR (Double Data Rate) mode * @back: Backend device diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index 5526800f5d4a..bd973de8cad9 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -109,6 +109,8 @@ enum iio_backend_filter_type { * @debugfs_print_chan_status: Print channel status into a buffer. * @debugfs_reg_access: Read or write register value of backend. * @filter_type_set: Set filter type. + * @data_alignment_enable: Enable sync process. + * @data_alignment_disable: Disable sync process. * @ddr_enable: Enable interface DDR (Double Data Rate) mode. * @ddr_disable: Disable interface DDR (Double Data Rate) mode. * @data_stream_enable: Enable data stream. @@ -161,6 +163,8 @@ struct iio_backend_ops { unsigned int writeval, unsigned int *readval); int (*filter_type_set)(struct iio_backend *back, enum iio_backend_filter_type type); + int (*data_alignment_enable)(struct iio_backend *back); + int (*data_alignment_disable)(struct iio_backend *back); int (*ddr_enable)(struct iio_backend *back); int (*ddr_disable)(struct iio_backend *back); int (*data_stream_enable)(struct iio_backend *back); @@ -203,6 +207,8 @@ int devm_iio_backend_request_buffer(struct device *dev, struct iio_dev *indio_dev); int iio_backend_filter_type_set(struct iio_backend *back, enum iio_backend_filter_type type); +int iio_backend_data_alignment_enable(struct iio_backend *back); +int iio_backend_data_alignment_disable(struct iio_backend *back); int iio_backend_ddr_enable(struct iio_backend *back); int iio_backend_ddr_disable(struct iio_backend *back); int iio_backend_data_stream_enable(struct iio_backend *back); --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 76E692451D7; Fri, 25 Apr 2025 11:26:03 +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=1745580365; cv=none; b=uLx2UAMsLMLJ5BB0I+SZ6vQz4nWv5caGSnwCRpR50l+MULYgtwSMy+10pzNzXL37zPIDEPHsvcTELCsxhPQEHQw943ht4ICZPfMrI1y/1lERQ5cH+IgThzoEwWSlp0m7o5Xkhg6CSErHU7IydV8iX1hAwRnXWLmxm36OiSROyVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580365; c=relaxed/simple; bh=WhDNFGkTo2hyV//6S5wb+sluC9RI/UNt7SBlFjgTMzg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lcvxEsesIXJON3Q7in5XSKE1wwxm2T1U2hn/3QfKyteaOplie68CPxpQH47dQgo203F0CDp1lznZ8VFEEXwYITxLQMeq7VtyMCIxi17QOKfPtKb8thkPAuAWRfhePzKXL3kcZNFGmMbDT4xXid+faI9aYvQgYt+1CKXWUke/zkc= 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=Ak1e3QFh; 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="Ak1e3QFh" 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 53PAxBB0019343; Fri, 25 Apr 2025 07:26:00 -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=lDP6k CLEFE076BJOoAOJa4icE+7T0FgNjaJ0pdE2wEM=; b=Ak1e3QFhOkz/lz/7TDxqo qZ/WovoO4Un7flyM1jlVsSMYsJ/zqVyBb6htV3rOL6DlS1utcLpDC0RP5mGoycnE g6W6sT9iZQtLBUU9VuGEuU3+Yi6GduWXqEEMTTnprp/gH5C+WDaaefxKSEcgWyJx YUHq0+7qoOCJjZJL4kvoBRUDyPf4/gKJi3eekTjme507evWw3EQmRwN4umnKfDBI VdH07PN/EK4RvKI+etvNXRrsmYBsCXWtYjA7yoT+YxYfO3Or1CamDeJ65GclFmzN 9Z/r11fkzDljS5pHIxM9yjpYgKbYi8mI1YuGXEytNn/PJVcWjiQ0CazABdA0XRDo w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 466jjqxyjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:00 -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 53PBPxXR049227 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:25:59 -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; Fri, 25 Apr 2025 07:25:58 -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; Fri, 25 Apr 2025 07:25:58 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbt003881; Fri, 25 Apr 2025 07:25:53 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 03/11] iio: backend: add support for sync status Date: Fri, 25 Apr 2025 14:25:30 +0300 Message-ID: <20250425112538.59792-4-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: DPta38AQr57eSIHegsPyH9Eq2hLePTcJ X-Authority-Analysis: v=2.4 cv=DoJW+H/+ c=1 sm=1 tr=0 ts=680b7148 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=vaGy3gO87QTDluMa78cA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfXzM+EG+i/vrGt msj+XJ4fetH/gZRjbHKO+80wyCnnqC5eXpFrFpXM00eLyLHyQyfCT2rpbk+4ieymngsO//urNRQ MfQ1HAmKoH6pjvA3ObGU2Xmt3Qw9d+O/t9q/oVtBIwkH5vph7y0IdguKciBXdmGCTcDI1gmD5YI m6wjnzwpHCvJEfNkXI8LV4kv0iAELuhD7Ap9nKlCOiZn3D8+XHbnBxcmIVjYK7ITdIbC7V00tvY y5ASVocNjBuTiz1/z7y4QBmEHg27KLxJWwis/KF4tXsVwmIRUA7UVbgh9OisZy6bfwzIxnlwqIq vROzfuL1ZKamtmRutnQdJysjye1/8FO68vUCVdYrokVAnUAKycWjap7mNJUpeZPBLp15D9/kDFj 9NzZ/f/07PGb5gaaOKZAfGXHtO94TOrwGzf5SUVEWEzFJfJeNHdthD/Kn6eaLIuGD8I56V/i X-Proofpoint-GUID: DPta38AQr57eSIHegsPyH9Eq2hLePTcJ 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add iio backend support for synchronization status read. The return value is a boolean stating if the data alignment has been correctly performed and capture is synchronized. If successful, the return value will be true. Signed-off-by: Antoniu Miclaus --- changes in v3: - update commit description. drivers/iio/industrialio-backend.c | 14 ++++++++++++++ include/linux/iio/backend.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index b77a31b16aa5..f7c8167a248d 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -819,6 +819,20 @@ int iio_backend_data_alignment_disable(struct iio_back= end *back) } EXPORT_SYMBOL_NS_GPL(iio_backend_data_alignment_disable, "IIO_BACKEND"); =20 +/** + * iio_backend_sync_status_get - Read the syncronization status + * @back: Backend device + * @sync_en: Synchronization status returned (enabled or disabled) + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_sync_status_get(struct iio_backend *back, bool *sync_en) +{ + return iio_backend_op_call(back, sync_status_get, sync_en); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_sync_status_get, "IIO_BACKEND"); + /** * iio_backend_ddr_enable - Enable interface DDR (Double Data Rate) mode * @back: Backend device diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index bd973de8cad9..e93d1a98e066 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -111,6 +111,7 @@ enum iio_backend_filter_type { * @filter_type_set: Set filter type. * @data_alignment_enable: Enable sync process. * @data_alignment_disable: Disable sync process. + * @sync_status_get: Get the syncronization status (enabled/disabled). * @ddr_enable: Enable interface DDR (Double Data Rate) mode. * @ddr_disable: Disable interface DDR (Double Data Rate) mode. * @data_stream_enable: Enable data stream. @@ -165,6 +166,7 @@ struct iio_backend_ops { enum iio_backend_filter_type type); int (*data_alignment_enable)(struct iio_backend *back); int (*data_alignment_disable)(struct iio_backend *back); + int (*sync_status_get)(struct iio_backend *back, bool *sync_en); int (*ddr_enable)(struct iio_backend *back); int (*ddr_disable)(struct iio_backend *back); int (*data_stream_enable)(struct iio_backend *back); @@ -209,6 +211,7 @@ int iio_backend_filter_type_set(struct iio_backend *bac= k, enum iio_backend_filter_type type); int iio_backend_data_alignment_enable(struct iio_backend *back); int iio_backend_data_alignment_disable(struct iio_backend *back); +int iio_backend_sync_status_get(struct iio_backend *back, bool *sync_en); int iio_backend_ddr_enable(struct iio_backend *back); int iio_backend_ddr_disable(struct iio_backend *back); int iio_backend_data_stream_enable(struct iio_backend *back); --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 145D0244670; Fri, 25 Apr 2025 11:26:01 +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=1745580363; cv=none; b=nG2GDLfOLyGAuW5jw+7lmyAQaRxKJ8Ujmx9eQnEHZ6vHgXJqz/QU2dBxvGU6dmrzsk+RDCSJmQcnNTwzVKAA4Ch3/rAxSHRTbTrswN5LRlysxH7pziHfr3HjNPNHCv76QQ3kzcrPfqSqlXdoDRqJ2KhDv5ZeV+WYwn//LWYPX5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580363; c=relaxed/simple; bh=Xis74W/y46yl5FV3DUVOoe3qzLOou2I+XeCWpOdvZ5o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T2nSdhjYvVGmCGrfJQSkTmZxoCB+Te22az2C8SxOWXH4WwIcZBNdLcSfBUj7QwPyet+2Oay2xg6SDFULi0Z/z1yBcSw5cjNix5IbB7aTkNJFFIjXSsP7YVeRD+KYAg2s6aKXLLGDS0XGjdj8qlwNTqNNKhHm7NyklEd37odnKPY= 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=ps8Uyq0Z; 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="ps8Uyq0Z" 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 53P8nTrt016645; Fri, 25 Apr 2025 07:25:59 -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=81/Tj aNLvdT8nbcpDEyAHoglrZeW/WGIiJ4EPCsz5ek=; b=ps8Uyq0ZntWzCdssrvq/D iTrai0demK31Z9+2qemyonLpe7/Olbi8ul87wJLj64eBmdlsiHGbpX54dY772Vh+ ExLVvwcEl7woNq999ZgEObQafoKuVPGooDepRkQaXFBHYz8vObQ+1p1j0iBlsR3d qc8qKVbyyTFQAIQCOJO55UHHh/Jls504UvizejMsfFk628mDZ2onkBVprZZX/GZR aJBotmZww2mhuQsAnxkbwDcW2alNtWIk2OWKn19uq0iex814gzribKu6j/O4fPFk qoCGATQDLp4e5htbRhbB82AhfJ8R/a+KU7lPGQSmZXCAy3ay2UNxJD7CexYCHX0d w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qtr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:25:59 -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 53PBPwpv049218 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:25:58 -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; Fri, 25 Apr 2025 07:25:57 -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; Fri, 25 Apr 2025 07:25:57 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbu003881; Fri, 25 Apr 2025 07:25:54 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 04/11] iio: backend: add support for number of lanes Date: Fri, 25 Apr 2025 14:25:31 +0300 Message-ID: <20250425112538.59792-5-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: usRtVPNQMYev-BhaFXbB1K30H4ZPUp-R X-Proofpoint-GUID: usRtVPNQMYev-BhaFXbB1K30H4ZPUp-R X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX9ejcfEzQWtE3 BRNeoOJG+MYlYSPV4nE2BOgvvNBxxfQTbB9WA8OAf7iFXYiimFWsATXbKvgMDfesoAKkuERmssb 5qxir4FkLOWQck9mlmFlUJPzdiE5HsS+hqX05FgGAuVASAjlRSBGMnGNQHEdpWfxQlCUvNJvP08 LNU9d4cQTWXZmqUyHan0DbqoZYJtuU+phrYyBwKVffXjsU+RvLk20PbMzl6Kzp/K2pL3+sdCkmz V4b91NDzzTELfzQi4c/o8mK9yzbsgaWgeBoK8aD6HQTe307wVxEZqPeJGdgfebJt182BEmHwDdP 4J7tQrc50J9cXAboKqFPG300cRDVfDP1PO1vJM9XVhN7SBK+OMb79LhXAcMlYpLYJ1svp2qKFRc 1rsFqTVwvFyMvZCKSJivTd1tvfYxwqjfyrf8pSTES32X8zgGAGwQpVNLcMW+dcFZzCDOE87+ X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b7147 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=XGXJvG3QnRm3y18W1eIA: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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add iio backend support for number of lanes to be enabled. Signed-off-by: Antoniu Miclaus Reviewed-by: Nuno S=C3=A1 --- no changes in v3. drivers/iio/industrialio-backend.c | 17 +++++++++++++++++ include/linux/iio/backend.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index f7c8167a248d..1063935cd808 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -833,6 +833,23 @@ int iio_backend_sync_status_get(struct iio_backend *ba= ck, bool *sync_en) } EXPORT_SYMBOL_NS_GPL(iio_backend_sync_status_get, "IIO_BACKEND"); =20 +/** + * iio_backend_num_lanes_set - Number of lanes enabled. + * @back: Backend device + * @num_lanes: Number of lanes. + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_num_lanes_set(struct iio_backend *back, unsigned int num_l= anes) +{ + if (!num_lanes) + return -EINVAL; + + return iio_backend_op_call(back, num_lanes_set, num_lanes); +} +EXPORT_SYMBOL_NS_GPL(iio_backend_num_lanes_set, "IIO_BACKEND"); + /** * iio_backend_ddr_enable - Enable interface DDR (Double Data Rate) mode * @back: Backend device diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index e93d1a98e066..c8bcfe96c542 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -112,6 +112,7 @@ enum iio_backend_filter_type { * @data_alignment_enable: Enable sync process. * @data_alignment_disable: Disable sync process. * @sync_status_get: Get the syncronization status (enabled/disabled). + * @num_lanes_set: Set the number of lanes enabled. * @ddr_enable: Enable interface DDR (Double Data Rate) mode. * @ddr_disable: Disable interface DDR (Double Data Rate) mode. * @data_stream_enable: Enable data stream. @@ -167,6 +168,7 @@ struct iio_backend_ops { int (*data_alignment_enable)(struct iio_backend *back); int (*data_alignment_disable)(struct iio_backend *back); int (*sync_status_get)(struct iio_backend *back, bool *sync_en); + int (*num_lanes_set)(struct iio_backend *back, unsigned int num_lanes); int (*ddr_enable)(struct iio_backend *back); int (*ddr_disable)(struct iio_backend *back); int (*data_stream_enable)(struct iio_backend *back); @@ -212,6 +214,7 @@ int iio_backend_filter_type_set(struct iio_backend *bac= k, int iio_backend_data_alignment_enable(struct iio_backend *back); int iio_backend_data_alignment_disable(struct iio_backend *back); int iio_backend_sync_status_get(struct iio_backend *back, bool *sync_en); +int iio_backend_num_lanes_set(struct iio_backend *back, unsigned int num_l= anes); int iio_backend_ddr_enable(struct iio_backend *back); int iio_backend_ddr_disable(struct iio_backend *back); int iio_backend_data_stream_enable(struct iio_backend *back); --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 4EE68247293; Fri, 25 Apr 2025 11:26:04 +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=1745580366; cv=none; b=C9Eqf/cgeta0uH4obYnZvi+dnafNJ6USiestamgv4ERH00Qwx+Yq/xLhDbm42OmLXv1OiXV+tv2GQQ98ZoUHbty91H3/UEjEU71nyJnnD+j2bYbfKsQDUceYkctT+3uLLI73mf1fEyy/iuqVyHk2xrD3ty5LQlycw+50aHvUAYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580366; c=relaxed/simple; bh=luezTJpJz0RK2buP9pZzfZuqQ1R19pJY4CL1KohCf2I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DPeTDRzwMWuEWyXyGTPZHwLOR0ORaoypLo1lwHP1oADXprJGkLdqnWpScgnwoObTLWCKIgceRqRmsZ/VSe6VK20QeDJ+lX8S6ckU8abyNPGKL543zOx8ol9To3nBbwmkRPLL1sIFx8DICAvnk0FfRmBGde/24WwXYtCs6Iv9aXY= 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=qpi4jfdU; 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="qpi4jfdU" 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 53P8g6NL016641; Fri, 25 Apr 2025 07:26:02 -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=inrnn mBCMurOuxbxffwasYnpXiStrotr3slg59lcz4M=; b=qpi4jfdUdUqLpBr/JnA1X SqZipIL8fhMdJRbrPbPN6z9JuAd5JGRCHQTDTtG3hm7M8ioW2QLnmh6+9Oe7lQXk OownCUdUXur+2obWjADrp1ScV5HwXLgXcKL0cDNoH5lv+2iVhnqhzwOvGQyQiUKU 5hyng+0ud+q5PWjAB8Kef8oDmy5iDBcfKCKHtIZBoiRKxyXE5Y57yXKNnhrpOKVF Pbc8Vu5SSHdEH657rUzhvvEhBpA43CBouIopxxAxeyLIv9ldI5ib9s71icylG06t 7cAHA1xb3ooWlkX+Jcfk9ti7NkaQUwoBaK9FaJz3LZPtCbbzVcwBEsplEgfyuIk0 Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:02 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 53PBQ0pA049233 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:00 -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; Fri, 25 Apr 2025 07:26:00 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Fri, 25 Apr 2025 07:26:00 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Fri, 25 Apr 2025 07:26:00 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbv003881; Fri, 25 Apr 2025 07:25:55 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 05/11] dt-bindings: iio: adc: add ad408x axi variant Date: Fri, 25 Apr 2025 14:25:32 +0300 Message-ID: <20250425112538.59792-6-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: _czqMqDi4jEB3Sq-Tn7nQ682JqFr5jIu X-Proofpoint-GUID: _czqMqDi4jEB3Sq-Tn7nQ682JqFr5jIu X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX4pQDk9WRz3Vc mjiBwEiS0DSMf89yyjPqdkS4Y8zt4Inc1Q2Er0pjWIQlHHIfL9CJ4vHloxYFf6HZNZfxsVXMHbL u7oZVhr7oa8HmJ8m/Qe0m16zZgG0MskGIRBc1xDLQHLFLvSk1Csv+uIDYq7MPVHGQAqfgDgqgUQ 8V/39MnDTe9BFBRKKoNW7DE7O/Y//RB55H49rMyD2/lyOgYkZNRy3HfHnBKLD82vrhr5fjcx8KK gQ/ZGELazVAz4QP3yFv32yUhlqT8qG8FFtEHwTgiA4cLguMCVrI0gO19J1qFp8WfXzn9cjhJ22y GQM17NDRG5pk8BqjYZ6w//vbLuH7SKATdgsqCp30KGIscMz8rwor63zoqMpIIGeTCX5hdTdsfAx p4KFSdXHXeV1D0coqYfZ6HJpMXSKwCqulNuCwTRYkvcekOurA8h/F0eyhV9IgUlE/BS2aXAs X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b714a cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=wI1k2SEZAAAA:8 a=VwQbUJbxAAAA:8 a=q2Ulk47HLb923_f0sX4A:9 a=6HWbV-4b7c7AdzY24d_u:22 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add a new compatible and related bindings for the fpga-based AD408x AXI IP core, a variant of the generic AXI ADC IP. The AXI AD408x IP is a very similar HDL (fpga) variant of the generic AXI ADC IP, intended to control ad408x familiy. Although there are some particularities added for extended control of the ad408x devices such as the filter configuration. Wildcard naming is used to match the naming of the published firmware. Reviewed-by: Rob Herring (Arm) Signed-off-by: Antoniu Miclaus --- no changes in v3. Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml | 2 ++ 1 file changed, 2 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..e91e421a3d6b 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml @@ -27,6 +27,7 @@ description: | the ad7606 family. =20 https://wiki.analog.com/resources/fpga/docs/axi_adc_ip + https://analogdevicesinc.github.io/hdl/library/axi_ad408x/index.html https://analogdevicesinc.github.io/hdl/library/axi_ad485x/index.html http://analogdevicesinc.github.io/hdl/library/axi_ad7606x/index.html =20 @@ -34,6 +35,7 @@ properties: compatible: enum: - adi,axi-adc-10.0.a + - adi,axi-ad408x - adi,axi-ad7606x - adi,axi-ad485x =20 --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 75220242D89; Fri, 25 Apr 2025 11:26:04 +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=1745580366; cv=none; b=qPskldooQ1xLHyJBxBWcvqAT7YDxgDkoNEPtAxhSzHC7czoybGvgvY2aZDPpj4/7b+U1ghYv9/7Cv9u1ouLiARvUhMbAFwj85O63+S90yfDczBCYhBStF+WkZpoznvpnTtgnkTlf9xzHY4NaodHRW14mWWa4F6FmDkbHHDuXmwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580366; c=relaxed/simple; bh=gXzxQWyGZ6b0yLCCWpoFf0SG6RO6KNn0zLqSOnXFLgY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BTM3n0Dub1XYpMdIbDlzZ09il2q/qYBGt7pc1wTzaWAruKnFro0hG1pQroHoOEJ5boGD/SNRt+AQFI/QXxNTZB7mfEQwGbHzH6eSq+1hijcfPfgxuGApgAYNYXpAsa1S4E8IEqDkCPC82QHtWEwWTgy1Up36nKxt38TirBwiOlU= 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=WR84TC5c; 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="WR84TC5c" 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 53P8nTru016645; Fri, 25 Apr 2025 07:26:01 -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=iSvgE F9S7Tx5uJzr/Yh3Dv0JZMAbJQCAV0DbeVyswgk=; b=WR84TC5c1RRvFFhsuLOtA MJU70Vhj1k83C3YY65TjcLOve3dub8IxdfIygPDM9El51jhK1Med7rbDAcmchyEZ qAXM7P6ZXzoR8IQU7mBJ/3AaF79m+XjgRdOepKQyg/LofTQWQvK6kS3m3YkOFeut Z5djN1iVwGyK3g9e9P00zFyqu5YfFDMuK/kkAdj4G6evRsf5w1+HC/eGWHgAvlbp 118Th+4WoF85s8pY+KFiOafoG/cpkKLWOo8XUcJwVql5GunzKyRl4n97AS4SGAHx SKGAmc+tKw68gW+2u0WvoVJfwpcCsOwWF4duZbfGzjwjpLvR0gTXPAFL5eTmqumU A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:01 -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 53PBQ05g049230 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:00 -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; Fri, 25 Apr 2025 07:26:00 -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; Fri, 25 Apr 2025 07:26:00 -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; Fri, 25 Apr 2025 07:26:00 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbw003881; Fri, 25 Apr 2025 07:25:56 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 06/11] iio: adc: adi-axi-adc: add filter type config Date: Fri, 25 Apr 2025 14:25:33 +0300 Message-ID: <20250425112538.59792-7-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: RPPal2fQjoZURf6sLUi0M8f1h8P1oQvf X-Proofpoint-GUID: RPPal2fQjoZURf6sLUi0M8f1h8P1oQvf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX0FYfzkaqEiTx TE0mqy0de0826D5zb4YavOwV1MlpQx1CFo7H8M67rYZ3kR0cv9K76CUt/Xovbo5RFgkKA8yPXdL bXvgzm5h7DuBGJaNZYGZMU4NEPSID0E/LPNGtrD8+SFndY5lK5sVjx7vahjm+DhNky5GBX1nktn DoArNieSD2chl9RYrKz4IdtFUZB/M86KRZouDIWY8qvd+KZ/NiTYN+sc5TRA97o4VWSR5bwM8+n g/Ctztn9C9mEvgT0kbo1XmAdOQoDhPlh6mLve8Oqw3i9ZTM7T/ycps0GEUP8qyVDb3tw3MbkGaP mIAkhhnzOM3ZejDwl1cHqmU2pLPfDFe+2OkkhGY0Uh2CIVUk3GCl5QeNHHL9/9ssc0iiynWLwag KjpMJI4GrN/76F1RCRAJlq7ZWMuAlq6rjFly0Wl2PfxbZcIOjW+sK7LJrw46nh6WE5F7Vb5l X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b7149 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=tS2dMKavNNEhNzk4wysA: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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add support for enabling/disabling filter based on the filter type provided. Signed-off-by: Antoniu Miclaus Reviewed-by: Nuno S=C3=A1 --- changes in v3: - update the function to adapt to the backend interface. drivers/iio/adc/adi-axi-adc.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 61ab7dce43be..2a3a6c3f5e59 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -52,6 +52,7 @@ #define AXI_AD485X_PACKET_FORMAT_20BIT 0x0 #define AXI_AD485X_PACKET_FORMAT_24BIT 0x1 #define AXI_AD485X_PACKET_FORMAT_32BIT 0x2 +#define AXI_AD408X_CNTRL_3_FILTER_EN_MSK BIT(0) =20 #define ADI_AXI_ADC_REG_DRP_STATUS 0x0074 #define ADI_AXI_ADC_DRP_LOCKED BIT(17) @@ -402,6 +403,19 @@ static int axi_adc_ad485x_oversampling_ratio_set(struc= t iio_backend *back, } } =20 +static int axi_adc_ad408x_filter_type_set(struct iio_backend *back, + enum iio_backend_filter_type type) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + + if (type) + return regmap_set_bits(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, + AXI_AD408X_CNTRL_3_FILTER_EN_MSK); + + return regmap_clear_bits(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, + AXI_AD408X_CNTRL_3_FILTER_EN_MSK); +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -582,6 +596,24 @@ static const struct iio_backend_info axi_ad485x =3D { .ops =3D &adi_ad485x_ops, }; =20 +static const struct iio_backend_ops adi_ad408x_ops =3D { + .enable =3D axi_adc_enable, + .disable =3D axi_adc_disable, + .chan_enable =3D axi_adc_chan_enable, + .chan_disable =3D axi_adc_chan_disable, + .request_buffer =3D axi_adc_request_buffer, + .free_buffer =3D axi_adc_free_buffer, + .data_sample_trigger =3D axi_adc_data_sample_trigger, + .filter_type_set =3D axi_adc_ad408x_filter_type_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), +}; + +static const struct iio_backend_info axi_ad408x =3D { + .name =3D "axi-ad408x", + .ops =3D &adi_ad408x_ops, +}; + static int adi_axi_adc_probe(struct platform_device *pdev) { struct adi_axi_adc_state *st; @@ -697,9 +729,15 @@ static const struct axi_adc_info adc_ad7606 =3D { .has_child_nodes =3D true, }; =20 +static const struct axi_adc_info adi_axi_ad408x =3D { + .version =3D ADI_AXI_PCORE_VER(10, 0, 'a'), + .backend_info =3D &axi_ad408x, +}; + /* Match table for of_platform binding */ static const struct of_device_id adi_axi_adc_of_match[] =3D { { .compatible =3D "adi,axi-adc-10.0.a", .data =3D &adc_generic }, + { .compatible =3D "adi,axi-ad408x", .data =3D &adi_axi_ad408x }, { .compatible =3D "adi,axi-ad485x", .data =3D &adi_axi_ad485x }, { .compatible =3D "adi,axi-ad7606x", .data =3D &adc_ad7606 }, { /* end of list */ } --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 2EA29248889; Fri, 25 Apr 2025 11:26:06 +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=1745580368; cv=none; b=ACj4bslRE0teMJdc8u6a9yWknj2i1dqNRhmuH6h00iU21XTIPVap0q65cHdK9O5+7UzTOYLuJ+pBDr/x/QYILLfM3pTrLqOWymSMWsah/FoMK+mNj/p++x4l/E0HZ2aVf5SZFkwByVM1MNDZYR6CtPF/PPLkIgEKWLptpJTHP/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580368; c=relaxed/simple; bh=iGjdECwz05Q23TjbVzfJUEmfOx5w5Gtw9dhMLrMcSBQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pgH2qdjTRFFhxbhucMLMbuONDAh0FaOn+8h4BylSGKJvq72gPNRGTqrCX11gBR2ORZjOsi+7mIHNLcdQPKCXNfCMJHSivtD/LJGHeuo3qPBLlXnL4WB6nu2pJih53uH5dfFvih6Us7Cn8JQ8hAIeB+sBrj8ELqhxRDFZzaf20+g= 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=UAe3u3De; 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="UAe3u3De" 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 53P83ln8014684; Fri, 25 Apr 2025 07:26: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=lP+/q WeaBM22LT8OSzoG7B+UkNZ6KtprRXM/PBAyPJo=; b=UAe3u3DeHKi1IeYtzNlrE 2s7y2byupjwBmLIAUzvYw/sT+3LycgfpK07ESN3TxXq/TQhugvae4jvLGa2r3rE0 RamaUNgKDXmW/agCk5+i2suhdjt8oZUZlK/t2k8Qdy9LRZyKwqXU7iYIau1srqUR f9VcNAnCCFRLNZsFwyAP2IdUuMUuCPLR0YQqjORcugVtWDvqDJQG28XSO24yZyrG w1cyxyRjAeTNUYMZt1NDLCoTn6Gy3JGDctgt2aAwrvqAM6FFnuJTcmxZm09a40ug a7xr4oIat4SzTV+2M209YKjXYI0dst8P2+TKGguGmyQmFmmGO5IKBg4d3MBXUf1x w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 466jjwf1gr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:04 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 53PBQ3Vg049236 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:03 -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; Fri, 25 Apr 2025 07:26:03 -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; Fri, 25 Apr 2025 07:26:02 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjbx003881; Fri, 25 Apr 2025 07:25:57 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 07/11] iio: adc: adi-axi-adc: add sync enable/disable Date: Fri, 25 Apr 2025 14:25:34 +0300 Message-ID: <20250425112538.59792-8-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@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: 6fSa6DozUhHTvORUXs-MuD9MfQm4DiX4 X-Authority-Analysis: v=2.4 cv=JMU7s9Kb c=1 sm=1 tr=0 ts=680b714c cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=x1IIngsD5Fk5sZd3GpkA:9 X-Proofpoint-ORIG-GUID: 6fSa6DozUhHTvORUXs-MuD9MfQm4DiX4 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfXywQcnw0vhkvZ 6wSV0sI9fCN1FwRYCsO+XUw6Une5yPyjwhZAnWJLDeGpDb0Xz5iJAJW3FpKFGmxG1g79dUuaOIm G0Xtgajr0GtwCgNg5d/JTO6x5gt2rrgVHGW1gFI7AWme5bXhQmMKeCFUAjjgUFVrbWbJn4GmfoJ re8BKsNntjFHyDFjXNS8CBj2qtsjOaJ2F1KDEQOZnUoB2zOjl/fx3MYIwVCFw9lpa+cayp5WEBS GH4QWSfaacQMhkJnAj4Y1fpR99BW7GSmeeF0GCAU7mIBOjW0aITupho+ME5ab7Enok/1lM5nXEz 6LMdbDob3wkQk2yp4XuRW6cvO8kw2L47b5zpfk0z5cp3dL9Sduqxhci0is63KIU2RGT0G8gbD37 +g5FU4pVnQxwIqmuFwcwlDTnMadGW24w1TrMhJtqSfoaqNyfQ7RyOC5pVeYf6pKorI5XG6lV 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add support for enabling/disabling the sync process used for data capture alignment. Signed-off-by: Antoniu Miclaus --- changes in v3: - update the function to match the new backend interface. drivers/iio/adc/adi-axi-adc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 2a3a6c3f5e59..9947be059f98 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -44,6 +44,7 @@ #define ADI_AXI_ADC_REG_CONFIG_CMOS_OR_LVDS_N BIT(7) =20 #define ADI_AXI_ADC_REG_CTRL 0x0044 +#define AXI_AD408X_CTRL_SYNC_MSK BIT(3) #define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1) =20 #define ADI_AXI_ADC_REG_CNTRL_3 0x004c @@ -416,6 +417,22 @@ static int axi_adc_ad408x_filter_type_set(struct iio_b= ackend *back, AXI_AD408X_CNTRL_3_FILTER_EN_MSK); } =20 +static int axi_adc_sync_enable(struct iio_backend *back) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + + return regmap_set_bits(st->regmap, ADI_AXI_ADC_REG_CTRL, + AXI_AD408X_CTRL_SYNC_MSK); +} + +static int axi_adc_sync_disable(struct iio_backend *back) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + + return regmap_clear_bits(st->regmap, ADI_AXI_ADC_REG_CTRL, + AXI_AD408X_CTRL_SYNC_MSK); +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -559,6 +576,8 @@ static const struct iio_backend_ops adi_axi_adc_ops =3D= { .request_buffer =3D axi_adc_request_buffer, .free_buffer =3D axi_adc_free_buffer, .data_sample_trigger =3D axi_adc_data_sample_trigger, + .data_alignment_enable =3D axi_adc_sync_enable, + .data_alignment_disable =3D axi_adc_sync_disable, .iodelay_set =3D axi_adc_iodelays_set, .test_pattern_set =3D axi_adc_test_pattern_set, .chan_status =3D axi_adc_chan_status, @@ -605,6 +624,8 @@ static const struct iio_backend_ops adi_ad408x_ops =3D { .free_buffer =3D axi_adc_free_buffer, .data_sample_trigger =3D axi_adc_data_sample_trigger, .filter_type_set =3D axi_adc_ad408x_filter_type_set, + .data_alignment_enable =3D axi_adc_sync_enable, + .data_alignment_disable =3D axi_adc_sync_disable, .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.49.0 From nobody Sun Feb 8 23:42:00 2026 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 8B17224BC1D; Fri, 25 Apr 2025 11:26:08 +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=1745580370; cv=none; b=nj8vWTMLd6PactooX/q0ZNPmRlXQ7Oa/BaqKDfSyoKUO/XM5X36WNjYPmwJKiazxIjBv4cSVOUCW7Wy+d5qwrTNSNkgpuiHWBrsbmnyWtZzrDJyYEM0Jv6aYOPytAMc0bTD8botI9aw6xkEZPTS/c/NOeP02TNOasdAzznpHLsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580370; c=relaxed/simple; bh=iM/1+mjJkqBWEyhnMLBu2ypEJGJGAEfcebv0zZO/Gbo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HdGExODNr8Y9nomrulWY4gUprIjsKJXN8S4/Tsmoa1SYBbGjjYgYBNh26sXscJPDfHPeisa140Q8oG/ge05K3hyKNoUKaX1jYpvqVohyA5imNWWJC2ehhjx/erJyftm2xTy8PV59YCMYmtPAnPVo8Ry7Hv1Tr/g6YvpQSpRlcBw= 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=CdXnfpya; 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="CdXnfpya" 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 53P8g6NM016641; Fri, 25 Apr 2025 07:26: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=8jmzc BldPW65Itrqkf7TqCw7wyMvgIUB5AjWuoWuhQM=; b=CdXnfpyaiVWXdP2I1NQMU 5sp4ToOewRel5gGT2xW2xlmXJ+V872t57X3EqCniCtpFZRwZERE1pNJW3HvcUVvr wHLJcUJPOSwlvc/gktTtCbgX0rEfhfd/7E5slpfymVQ5iONGLfMiozOzwu7D10qP 7GdS+Xu1zvJxa4D7odsm3Yk2Fq8X9O8N8liynZSEd9PmIpDVJOrab8OV9ih5bWxK 4rOWwzv5AOys5M9CRKQzmUKFGM6TnQUKdBo7HBzBcn6jMe9Lu83sdZkS7Qx6CePO gUOQVkle2n54fpkIUn3XOwo2thcYhDyBeCqqKcWUYq7xGjf/8Wm4UsYLrgeyvVKk A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:05 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 53PBQ4AZ049242 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:04 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Fri, 25 Apr 2025 07:26: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; Fri, 25 Apr 2025 07:26: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; Fri, 25 Apr 2025 07:26:04 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjc0003881; Fri, 25 Apr 2025 07:25:58 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 08/11] iio: adc: adi-axi-adc: add sync status Date: Fri, 25 Apr 2025 14:25:35 +0300 Message-ID: <20250425112538.59792-9-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: mipgg8Rf1Mt4LBGT0chbJOI0WRE-h2mf X-Proofpoint-GUID: mipgg8Rf1Mt4LBGT0chbJOI0WRE-h2mf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX6/ldZ3VZ421/ zAr1cTCj1ZfVkl0QfDE3zOhkl2X14gWNp2Ved3L7+VeffWYCk8j22znNtphdozG0pZFIwMRj1qS ty30MOOaUHsSYXFq1lVg8yvUqVnjQBbM2a41/Rr/vL/RxDvH4JPwuDr5CCrvwdjv5wmzmA8yLiV feTPfxpxkgATNNwGJlWEj+1IM4baBQKbtiXYPsZALZ3Bt/AinALGNH7MxxIe/VbVaEdrSqAXNwl NAmtxJev6y9J7cP97f9Ap2Kod+OnAFJc5gQPFtUy6ZMD3TkYAsHYCtnC22cfkTQMpvEOwNG13r+ 8JwPJoZfiqVT/zHAfhy409Uui5AIU3VBNxEwv+TeiVO5sK1os+ElG5YchxixDwD1KK+FV3lI/Qu 4QoHUYjydUynICtC9r89wBn1YOdlJvjmQenqebrdA9A3I1onsx9Fb4lhvfwSWUnBe6mhaGIk X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b714d cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=kalMC6VxhFG8u9PshIUA: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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add support for checking the ADC sync status. A true value is obtained if the data capture is synchronized. Signed-off-by: Antoniu Miclaus --- no changes in v3. drivers/iio/adc/adi-axi-adc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index 9947be059f98..bf0155830d87 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -55,6 +55,9 @@ #define AXI_AD485X_PACKET_FORMAT_32BIT 0x2 #define AXI_AD408X_CNTRL_3_FILTER_EN_MSK BIT(0) =20 +#define ADI_AXI_ADC_REG_SYNC_STATUS 0x0068 +#define ADI_AXI_ADC_SYNC BIT(0) + #define ADI_AXI_ADC_REG_DRP_STATUS 0x0074 #define ADI_AXI_ADC_DRP_LOCKED BIT(17) =20 @@ -433,6 +436,21 @@ static int axi_adc_sync_disable(struct iio_backend *ba= ck) AXI_AD408X_CTRL_SYNC_MSK); } =20 +static int axi_adc_sync_status_get(struct iio_backend *back, bool *sync_en) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + int ret; + u32 val; + + ret =3D regmap_read(st->regmap, ADI_AXI_ADC_REG_SYNC_STATUS, &val); + if (ret) + return ret; + + *sync_en =3D FIELD_GET(ADI_AXI_ADC_SYNC, val); + + return 0; +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -582,6 +600,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, + .sync_status_get =3D axi_adc_sync_status_get, .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), }; @@ -626,6 +645,7 @@ static const struct iio_backend_ops adi_ad408x_ops =3D { .filter_type_set =3D axi_adc_ad408x_filter_type_set, .data_alignment_enable =3D axi_adc_sync_enable, .data_alignment_disable =3D axi_adc_sync_disable, + .sync_status_get =3D axi_adc_sync_status_get, .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.49.0 From nobody Sun Feb 8 23:42:00 2026 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 93DF22417C5; Fri, 25 Apr 2025 11:26:06 +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=1745580368; cv=none; b=l98acWK03OyeTSH0V1NAbzyqoLoj1dP/pZ578sOrzjDW7loPiPu0pvZ/l0zcy2Ss/4m5L2mEC7qVZwow3qbjfdmWeVQxwh2OjpbydlZ1+mnJAdjOGXlYAVB0Dxh6+i4xKuqz6IFuJtTMwf5EPrO2F0o97PF0MBuTkDfwfoSEsKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580368; c=relaxed/simple; bh=16U6K1ZaW9fJBAKa6h+jzo9hCrNCS2YDK4RdtwilTYE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fLUx0k5OoRUoDqlHt+dgRHFQy/WiJrtRO0KXtsuRonPhgmoAi6JCcJ0eyidZIFoIz2x4Hykn04dLRZWSkWZZRBXAZ/rmYsgjXv6UIA1DIes8zxi0E34P/vfn6gD1vpa/sNz1jqgQbZRv1GR0hv8hPJetpj3nAvEe0VBXjQs5IGA= 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=sG6rp7fo; 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="sG6rp7fo" 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 53P8aMOp016633; Fri, 25 Apr 2025 07:26: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=FxTA4 YN+qbGAZaVvp2OH98a+j0pSVAjr6TUg3qJra5Y=; b=sG6rp7foNTd6UFGEweMV3 bltG96gTewBYr5v6OBslZwkH28p1vJrdEpKN9UteZjYYFzRnFDcR81SQrtHc0TIy aRpPnNiKRE1IglGCWIbH6b/Fg/HOMJDcEJepykXDAeb7WCUebswcNtKEpHtQVuLY 30/fJh9CNB+1y0aHXnwUCxP01pIS+USldIKoad0vc85UuunncxLYukCUAcZrpSVv mcbA9KHOF5zNse1vP5/GmIiWuMbT+WD3J/C0NaNsJ/acY4nfzR2vagUFnfDge4o3 6ed+FEaPtx9kFHrNir41rAtpNFlenitLz6yGkdoTnc5I2vXsk9EGQzBeN2RFt5p6 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:04 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 53PBQ30G049239 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:03 -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; Fri, 25 Apr 2025 07:26:03 -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; Fri, 25 Apr 2025 07:26:03 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjc1003881; Fri, 25 Apr 2025 07:26:00 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 09/11] iio: adc: adi-axi-adc: add num lanes support Date: Fri, 25 Apr 2025 14:25:36 +0300 Message-ID: <20250425112538.59792-10-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: L7rksMhKkZS5CsKRDtCW_PcxQaxHa3P3 X-Proofpoint-GUID: L7rksMhKkZS5CsKRDtCW_PcxQaxHa3P3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX1MgfqAW4Iy/e 1Bg8alAl/BLzMLE05IrqexF5HfoKgR9OdEjtDz9bJJkOgS2mH3m4s7HdyDgSbigb95gJW51srse AjwZBhuU0DoT7IEY2yv72heNdIYOx5drwYlg0o+0mbZ5LRLSZ1iFmaDpVwKmNnAhQOXaPI9kUST LX02I+OaXzu099MM5xXSX/CsUomLCm2UI8/XLKiOXrGlMRgbMwJPSBwb+UN8LXsLhAPU3k2+a3p /xpFiQlnQjjYwbHCbwmImer1rWwcKvzLjBkIcXauK0fum1lpWL5FA5v4tBCnlAnT9UuAbSNQWsz AEeN2l0W8nEV/M19AhdFhSo5hPNBoUKnELW/W26unqdVF2KRyYokBnUin3XYFOq2seBCjhCCZpY XQkChpKa4ZSuLY/8qSJGwQydeJCbICbhL8GIqwZOkOIcsi4HB4eHcB3i77kKrrVDOBkfDPTX X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b714c cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=XZtg4_54fT2L5_ulfa8A: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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add support for setting the number of lanes enabled. Signed-off-by: Antoniu Miclaus Reviewed-by: Nuno S=C3=A1 --- no changes in v3. drivers/iio/adc/adi-axi-adc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index bf0155830d87..8ff781ab5ec3 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -44,6 +44,7 @@ #define ADI_AXI_ADC_REG_CONFIG_CMOS_OR_LVDS_N BIT(7) =20 #define ADI_AXI_ADC_REG_CTRL 0x0044 +#define AXI_AD408X_CTRL_NUM_LANES_MSK GENMASK(12, 8) #define AXI_AD408X_CTRL_SYNC_MSK BIT(3) #define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1) =20 @@ -451,6 +452,19 @@ static int axi_adc_sync_status_get(struct iio_backend = *back, bool *sync_en) return 0; } =20 +static int axi_adc_num_lanes_set(struct iio_backend *back, + unsigned int num_lanes) +{ + struct adi_axi_adc_state *st =3D iio_backend_get_priv(back); + + if (!num_lanes) + return -EINVAL; + + return regmap_update_bits(st->regmap, ADI_AXI_ADC_REG_CTRL, + AXI_AD408X_CTRL_NUM_LANES_MSK, + FIELD_PREP(AXI_AD408X_CTRL_NUM_LANES_MSK, num_lanes)); +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -601,6 +615,7 @@ static const struct iio_backend_ops adi_axi_adc_ops =3D= { .chan_status =3D axi_adc_chan_status, .interface_type_get =3D axi_adc_interface_type_get, .sync_status_get =3D axi_adc_sync_status_get, + .num_lanes_set =3D axi_adc_num_lanes_set, .debugfs_reg_access =3D iio_backend_debugfs_ptr(axi_adc_reg_access), .debugfs_print_chan_status =3D iio_backend_debugfs_ptr(axi_adc_debugfs_pr= int_chan_status), }; @@ -646,6 +661,7 @@ static const struct iio_backend_ops adi_ad408x_ops =3D { .data_alignment_enable =3D axi_adc_sync_enable, .data_alignment_disable =3D axi_adc_sync_disable, .sync_status_get =3D axi_adc_sync_status_get, + .num_lanes_set =3D axi_adc_num_lanes_set, .debugfs_reg_access =3D iio_backend_debugfs_ptr(axi_adc_reg_access), .debugfs_print_chan_status =3D iio_backend_debugfs_ptr(axi_adc_debugfs_pr= int_chan_status), }; --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 EE83E2512D2; Fri, 25 Apr 2025 11:26:10 +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=1745580372; cv=none; b=NlARuYijyaCWLbaJbtiOH7A1Lv5CMLcU2XyGB+Q+bZskHSK3NSSnntLwozhx6hlDvm35WrYuocj2SpiovEBHktknsAi2odHeyCq5WhUtz1gJo8mNuiIHpuHfSimGHo4QerdUtIODo+7es7TUHA124BAaBdg0rfDrn9/XwiQDy8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580372; c=relaxed/simple; bh=d5Ua307c1xd0Pkt4UIGYeadI1ECH0jl2nhydMIgjjwY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PwL96OLmsaw+RpWtj42iWQguw6D+5sXcCCeyCLol7jVp5VVHUwtijb3fLw7jXa9FJnHj4/W0iSFIqJVN0KBIaahhxpirE6Hq9/cgX7Efg028QO+OJI5HUJNFakXCN+LLj1+UbmLLVfEvgv/5pFdY93iJ1H718lryXdonJS0jhIY= 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=zdMUE7kI; 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="zdMUE7kI" 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 53P83lnA014684; Fri, 25 Apr 2025 07:26:08 -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=SsQjs BT/cNlJu23C8I/q8gXSOBy7VKLUQA+ihcrY6zI=; b=zdMUE7kIMmOFkM9FA+ClJ d5moF/yn0yWUFTUTqP6O7nkVCJ6qSDscqJHqYHVJU68o3vtfC30HH2i5v+GEseKZ FqSvsjVvqOLZrt5vC+lwlh95n0zbJu0n47ghVMQ0txmsrHt4//H3hll0N4itixuH YlGZndAA2X99icu5oovqWnxTFyyJ3nkvFTfNf+nC794BE2PteI9U37Eted3ItmPO 2sOynvl2CUoCIieTs6bXFTncqQf+hlhQXo0ifP03mEClkcaJyA/YpyHrbvwnqsRd nw7yIG2/T+xghShnruA+bMtDcd3ED7dAQZwK9q/ZUqJExCtnz2SxoXtZ/uUFn4Jq w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 466jjwf1h8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26:08 -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 53PBQ7Z0049251 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26:07 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Fri, 25 Apr 2025 07:26:06 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Fri, 25 Apr 2025 07:26:06 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjc2003881; Fri, 25 Apr 2025 07:26:01 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 10/11] dt-bindings: iio: adc: add ad4080 Date: Fri, 25 Apr 2025 14:25:37 +0300 Message-ID: <20250425112538.59792-11-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@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: RZ-5QacY3H1Sb3nDbJ4hmVEZ5lvvcL-e X-Authority-Analysis: v=2.4 cv=JMU7s9Kb c=1 sm=1 tr=0 ts=680b7150 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=VwQbUJbxAAAA:8 a=Hsn-j--P0uF4w0xjABcA:9 a=sptkURWiP4Gy88Gu7hUp:22 X-Proofpoint-ORIG-GUID: RZ-5QacY3H1Sb3nDbJ4hmVEZ5lvvcL-e X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX2Vn6to/BE2Rg zSK8Du5LrtkEjqDOuFlsRmriQOXb5gTOMVQ0NydDN1vhfbQTJG85oOTkRHw52l9vV9dK1DrCGeP GCRlNxfFqOEGzh537m3IYK7xqtOL0trBmuIdV+x/WHku6kDqrIgTdnCkfN6ojyXy6eXD48VKpei 1iWTRTQZBWYEnbPoUjh2bqa99Tr4xvvMqukxBVRBgg9W+yRmZy980x+Ayv1IA1v2/iGrbwcQa0E SSafRU9cL186FaHCgnYJD8g/bO62tyrvumPGbRb8HesHO5YQnBh6T26Agx89+w7ehVtL4CwgyV6 uLk/apJg7iRK3hpOdLLh+Dp+Y7FYAdcuDF3oIVpMn6TEIGiQ/1it5ogkHkr4bXUflNy+m2QkGWv 3gyb9KDiePfq4i64DCZSZY26QA20UDJF1hUd4V6bUdU+872eG5p5S46d6unfBflpN+kioKxN 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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add devicetree bindings for ad4080 family. Reviewed-by: Rob Herring (Arm) Signed-off-by: Antoniu Miclaus --- .../bindings/iio/adc/adi,ad4080.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad4080.ya= ml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad4080.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad4080.yaml new file mode 100644 index 000000000000..ed849ba1b77b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad4080.yaml @@ -0,0 +1,96 @@ +# 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,ad4080.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD4080 20-Bit, 40 MSPS, Differential SAR ADC + +maintainers: + - Antoniu Miclaus + +description: | + The AD4080 is a high speed, low noise, low distortion, 20-bit, Easy Driv= e, + successive approximation register (SAR) analog-to-digital converter (ADC= ). + Maintaining high performance (signal-to-noise and distortion (SINAD) rat= io + > 90 dBFS) at signal frequencies in excess of 1 MHz enables the AD4080 to + service a wide variety of precision, wide bandwidth data acquisition + applications. + + https://www.analog.com/media/en/technical-documentation/data-sheets/ad40= 80.pdf + +$ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + enum: + - adi,ad4080 + + reg: + maxItems: 1 + + spi-max-frequency: + description: Configuration of the SPI bus. + maximum: 50000000 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: cnv + + vdd33-supply: true + + vdd11-supply: true + + vddldo-supply: true + + iovdd-supply: true + + vrefin-supply: true + + io-backends: + maxItems: 1 + + adi,lvds-cnv-enable: + description: Enable the LVDS signal type on the CNV pin. Default is CM= OS. + type: boolean + + adi,num-lanes: + description: + Number of lanes on which the data is sent on the output (DA, DB pins= ). + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2] + default: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - vdd33-supply + - vrefin-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@0 { + compatible =3D "adi,ad4080"; + reg =3D <0>; + spi-max-frequency =3D <10000000>; + vdd33-supply =3D <&vdd33>; + vddldo-supply =3D <&vddldo>; + vrefin-supply =3D <&vrefin>; + clocks =3D <&cnv>; + clock-names =3D "cnv"; + io-backends =3D <&iio_backend>; + }; + }; +... --=20 2.49.0 From nobody Sun Feb 8 23:42:00 2026 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 55A8524EAAF; Fri, 25 Apr 2025 11:26:10 +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=1745580372; cv=none; b=G8NXi3AFKwBx6wJalvWrhTVRiWxw7XXfeVSRffzR5gZI1QQxXvgV/t+yXTuLYTOtQ883AH7wR4Bvkh2pvIURbLdiE1lJdFm3s+n4Wll1fzCZmsCul3a1NlA0ZiDOXCChaYWYbc/wEersrJy2HiruOPMRmpvjFlQlOwpKAo47q7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745580372; c=relaxed/simple; bh=8UkEEbhL1s79Vw5IwC5Ld8PX0aC0CvK5Fu8IaH5sBzA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EQBBbsdXi86RssrRDcWNWY4ty2s6U7W/sLRSXh/kfNyW8hZbvpJCQblZ5sHxdh0c4+TfeZ0u/dGuvD5W42Ww2+ZH0xzZFij0fcDJ/RFQvktx9P26oBS9tVHfwGyeb35rWWsHTx5rd5isXg5SUglxbBzWBreebNcMfF6nR1iCKR8= 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=f+AI/IUE; 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="f+AI/IUE" 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 53P8g6NN016641; Fri, 25 Apr 2025 07:26: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=gq+l5 CuX7xPpACZ2N7XjAq8g3H8yeK+V+kdvFHp9+Rc=; b=f+AI/IUEwrA9kcqlZpLF9 oNDW3E1jRHTrA58URqNjD23yqBfeFBpbMwM7W9Sd1xMSm9XjfNTtLizCfOY00dBv pcV1pkCtmicS0euL6e/NIKgPUUjA9sXLtW5v4UsGZ22h//mxrwCIJR81LDLTkQSK fGdaIBaXq+XLkYV0KXNIJbctv5tObuTz2X1Abc2jEGd0n0vpzycXBOclMjcPfPT7 58+t1qJAN5JKAWEzeHJIX+Ntm4AfzhZQ2x+ynfloMhc0XC1NiYfAW2qBph5w1kz7 m4b5z1tevNjnXVRA3pgaimwoxRVUcDxibN+Gx3Kenv9KUXO7aepPdlyutN+NzB7n w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 46833j9qu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Apr 2025 07:26: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 53PBQ5k6049245 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 07:26: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; Fri, 25 Apr 2025 07:26:05 -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; Fri, 25 Apr 2025 07:26: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; Fri, 25 Apr 2025 07:26:05 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.211]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 53PBPjc3003881; Fri, 25 Apr 2025 07:26:02 -0400 From: Antoniu Miclaus To: , , , , , CC: Antoniu Miclaus Subject: [PATCH v3 11/11] iio: adc: ad4080: add driver support Date: Fri, 25 Apr 2025 14:25:38 +0300 Message-ID: <20250425112538.59792-12-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250425112538.59792-1-antoniu.miclaus@analog.com> References: <20250425112538.59792-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: 9BnDYB3nwgQvSMH-aBo_bUjVvot-bIUF X-Proofpoint-GUID: 9BnDYB3nwgQvSMH-aBo_bUjVvot-bIUF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNDI1MDA4MiBTYWx0ZWRfX5+BVnyYjzl7d TNHLOkZQFQ2YzP0VFi9tDxKSNJIrMMg7ytLDmwaM/QN2B0HolXElnn8lY+g8OZDmeCsFGl6Ednz 8gE78A6r/6jKDHjO7dvOfPmFPVZRqZvzfRRq1mrOKiVOfzi12qYE4spmIY96IWjrFTRwRW/D7EY BNE+iWugA1RoHuIW9rWU4/dkIMd7vRNdTEn7myxkSw/HUyrvUzizV8geHmFuZzkwxjnIRuROI61 nz28QeZybrPzYaaX7lvMOdznLn+E4fe4A4tYFm/SElszYEdz0H4xP7F0nMVVfwF2JPsdcc/Ag88 6CmemraCtVWMF0mj1sP/PDOvPQuLyzcNFVK4Hf1TYMP92IdOxTBN1d94CzlilgTD0fyNJT3K4ig wajHKQ69gu8PYg+NAeLB9lzk7P9hoZ97ULe4P7Buu4oPL7YFiGyWMq9UlvFb7Jo+LZDYwUHh X-Authority-Analysis: v=2.4 cv=Hu52G1TS c=1 sm=1 tr=0 ts=680b714e cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=XR8D0OoHHMoA:10 a=gAnH3GRIAAAA:8 a=XWQM0tir05fXBLfBid0A: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-04-25_03,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2504250082 Content-Type: text/plain; charset="utf-8" Add support for AD4080 high-speed, low noise, low distortion, 20-bit, Easy Drive, successive approximation register (SAR) analog-to-digital converter (ADC). Signed-off-by: Antoniu Miclaus --- changes in v3: - name the defines to make associacion with register name. - drop redundant defines. - add trailing comma when needed. - drop explicit masking and use field_prep instead - add fsleep during sync process. - do not wrap where 80 chars is not exceeded. - use space for { } - drop channel definition macro - return dev_info on chip id mismatch. - flip expression to `if (!st->lvds_cnv_en)` - rework num_lanes property parse. - update the driver based on the new edits on the backend interface relate= d to this part and the last disscussions in v2. drivers/iio/adc/Kconfig | 14 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad4080.c | 618 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 633 insertions(+) create mode 100644 drivers/iio/adc/ad4080.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 27413516216c..17df328f5322 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -47,6 +47,20 @@ config AD4030 To compile this driver as a module, choose M here: the module will be called ad4030. =20 +config AD4080 + tristate "Analog Devices AD4080 high speed ADC" + depends on SPI + select REGMAP_SPI + select IIO_BACKEND + help + Say yes here to build support for Analog Devices AD4080 + high speed, low noise, low distortion, 20-bit, Easy Drive, + successive approximation register (SAR) analog-to-digital + converter (ADC). Supports iio_backended devices for AD4080. + + To compile this driver as a module, choose M here: the module will be + called ad4080. + config AD4130 tristate "Analog Device AD4130 ADC Driver" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 9f26d5eca822..e6efed5b4e7a 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_AB8500_GPADC) +=3D ab8500-gpadc.o obj-$(CONFIG_AD_SIGMA_DELTA) +=3D ad_sigma_delta.o obj-$(CONFIG_AD4000) +=3D ad4000.o obj-$(CONFIG_AD4030) +=3D ad4030.o +obj-$(CONFIG_AD4080) +=3D ad4080.o obj-$(CONFIG_AD4130) +=3D ad4130.o obj-$(CONFIG_AD4695) +=3D ad4695.o obj-$(CONFIG_AD4851) +=3D ad4851.o diff --git a/drivers/iio/adc/ad4080.c b/drivers/iio/adc/ad4080.c new file mode 100644 index 000000000000..b51893253941 --- /dev/null +++ b/drivers/iio/adc/ad4080.c @@ -0,0 +1,618 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Analog Devices AD4080 SPI ADC driver + * + * Copyright 2025 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +/* Register Definition */ +#define AD4080_REG_INTERFACE_CONFIG_A 0x00 +#define AD4080_REG_INTERFACE_CONFIG_B 0x01 +#define AD4080_REG_DEVICE_CONFIG 0x02 +#define AD4080_REG_CHIP_TYPE 0x03 +#define AD4080_REG_PRODUCT_ID_L 0x04 +#define AD4080_REG_PRODUCT_ID_H 0x05 +#define AD4080_REG_CHIP_GRADE 0x06 +#define AD4080_REG_SCRATCH_PAD 0x0A +#define AD4080_REG_SPI_REVISION 0x0B +#define AD4080_REG_VENDOR_L 0x0C +#define AD4080_REG_VENDOR_H 0x0D +#define AD4080_REG_STREAM_MODE 0x0E +#define AD4080_REG_TRANSFER_CONFIG 0x0F +#define AD4080_REG_INTERFACE_CONFIG_C 0x10 +#define AD4080_REG_INTERFACE_STATUS_A 0x11 +#define AD4080_REG_DEVICE_STATUS 0x14 +#define AD4080_REG_ADC_DATA_INTF_CONFIG_A 0x15 +#define AD4080_REG_ADC_DATA_INTF_CONFIG_B 0x16 +#define AD4080_REG_ADC_DATA_INTF_CONFIG_C 0x17 +#define AD4080_REG_PWR_CTRL 0x18 +#define AD4080_REG_GPIO_CONFIG_A 0x19 +#define AD4080_REG_GPIO_CONFIG_B 0x1A +#define AD4080_REG_GPIO_CONFIG_C 0x1B +#define AD4080_REG_GENERAL_CONFIG 0x1C +#define AD4080_REG_FIFO_WATERMARK_LSB 0x1D +#define AD4080_REG_FIFO_WATERMARK_MSB 0x1E +#define AD4080_REG_EVENT_HYSTERESIS_LSB 0x1F +#define AD4080_REG_EVENT_HYSTERESIS_MSB 0x20 +#define AD4080_REG_EVENT_DETECTION_HI_LSB 0x21 +#define AD4080_REG_EVENT_DETECTION_HI_MSB 0x22 +#define AD4080_REG_EVENT_DETECTION_LO_LSB 0x23 +#define AD4080_REG_EVENT_DETECTION_LO_MSB 0x24 +#define AD4080_REG_OFFSET_LSB 0x25 +#define AD4080_REG_OFFSET_MSB 0x26 +#define AD4080_REG_GAIN_LSB 0x27 +#define AD4080_REG_GAIN_MSB 0x28 +#define AD4080_REG_FILTER_CONFIG 0x29 + +/* AD4080_REG_INTERFACE_CONFIG_A Bit Definition */ +#define AD4080_INTERFACE_CONFIG_A_SW_RESET_MSK (BIT(7) | BIT(0)) +#define AD4080_INTERFACE_CONFIG_A_ADDR_ASC_MSK BIT(5) +#define AD4080_INTERFACE_CONFIG_A_SDO_ENABLE_MSK BIT(4) + +/* AD4080_REG_INTERFACE_CONFIG_B Bit Definition */ +#define AD4080_INTERFACE_CONFIG_B_SINGLE_INST_MSK BIT(7) +#define AD4080_INTERFACE_CONFIG_B_SHORT_INST_MSK BIT(3) + +/* AD4080_REG_DEVICE_CONFIG Bit Definition */ +#define AD4080_DEVICE_CONFIG_OPERATING_MODES_MSK GENMASK(1, 0) + +/* AD4080_REG_TRANSFER_CONFIG Bit Definition */ +#define AD4080_TRANSFER_CONFIG_KEEP_STREAM_LENGTH_VAL_MSK BIT(2) + +/* AD4080_REG_INTERFACE_CONFIG_C Bit Definition */ +#define AD4080_INTERFACE_CONFIG_C_STRICT_REG_ACCESS_MSK BIT(5) + +/* AD4080_REG_ADC_DATA_INTF_CONFIG_A Bit Definition */ +#define AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK BIT(6) +#define AD4080_ADC_DATA_INTF_CONFIG_A_INTF_CHK_EN_MSK BIT(4) +#define AD4080_ADC_DATA_INTF_CONFIG_A_SPI_LVDS_LANES_MSK BIT(2) +#define AD4080_ADC_DATA_INTF_CONFIG_A_DATA_INTF_MODE_MSK BIT(0) + +/* AD4080_REG_ADC_DATA_INTF_CONFIG_B Bit Definition */ +#define AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_CNV_CLK_CNT_MSK GENMASK(7, 4) +#define AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_SELF_CLK_MODE_MSK BIT(3) +#define AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_CNV_EN_MSK BIT(0) + +/* AD4080_REG_ADC_DATA_INTF_CONFIG_C Bit Definition */ +#define AD4080_ADC_DATA_INTF_CONFIG_C_LVDS_VOD_MSK GENMASK(6, 4) + +/* AD4080_REG_PWR_CTRL Bit Definition */ +#define AD4080_PWR_CTRL_ANA_DIG_LDO_PD_MSK BIT(1) +#define AD4080_PWR_CTRL_INTF_LDO_PD_MSK BIT(0) + +/* AD4080_REG_GPIO_CONFIG_A Bit Definition */ +#define AD4080_GPIO_CONFIG_A_GPO_1_EN_MSK BIT(1) +#define AD4080_GPIO_CONFIG_A_GPO_0_EN_MSK BIT(0) + +/* AD4080_REG_GPIO_CONFIG_B Bit Definition */ +#define AD4080_GPIO_CONFIG_B_GPIO_1_SEL GENMASK(7, 4) +#define AD4080_GPIO_CONFIG_B_GPIO_0_SEL GENMASK(3, 0) + +/* AD4080_REG_FIFO_CONFIG Bit Definition */ +#define AD4080_FIFO_CONFIG_FIFO_MODE_MSK GENMASK(1, 0) + +/* AD4080_REG_FILTER_CONFIG Bit Definition */ +#define AD4080_FILTER_CONFIG_SINC_DEC_RATE_MSK GENMASK(6, 3) +#define AD4080_FILTER_CONFIG_FILTER_SEL_MSK GENMASK(1, 0) + +/* Miscellaneous Definitions */ +#define AD4080_SPI_READ BIT(7) +#define AD4080_CHIP_ID GENMASK(2, 0) + +#define AD4080_MAX_SAMP_FREQ 40000000 +#define AD4080_MIN_SAMP_FREQ 1250000 + +enum ad4080_filter_type { + FILTER_DISABLE, + SINC_1, + SINC_5, + SINC_5_COMP +}; + +static const unsigned int ad4080_scale_table[][2] =3D { + { 6000, 0}, +}; + +static const char *const ad4080_filter_type_iio_enum[] =3D { + [FILTER_DISABLE] =3D "disabled", + [SINC_1] =3D "sinc1", + [SINC_5] =3D "sinc5", + [SINC_5_COMP] =3D "sinc5_plus_compensation", +}; + +static const int ad4080_dec_rate_iio_enum[] =3D { + 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, +}; + +static const char * const ad4080_power_supplies[] =3D { + "vdd33", "vdd11", "vddldo", "iovdd", "vrefin", +}; + +struct ad4080_chip_info { + const char *name; + unsigned int product_id; + int num_scales; + const unsigned int (*scale_table)[2]; + const struct iio_chan_spec *channels; + unsigned int num_channels; +}; + +struct ad4080_state { + struct spi_device *spi; + struct regmap *regmap; + struct clk *clk; + struct iio_backend *back; + const struct ad4080_chip_info *info; + /* + * Synchronize access to members the of driver state, and ensure + * atomicity of consecutive regmap operations. + */ + struct mutex lock; + unsigned int num_lanes; + unsigned int dec_rate; + enum ad4080_filter_type filter_type; + bool lvds_cnv_en; +}; + +static const struct regmap_config ad4080_regmap_config =3D { + .reg_bits =3D 16, + .val_bits =3D 8, + .read_flag_mask =3D BIT(7), + .max_register =3D 0x29, +}; + +static int ad4080_reg_access(struct iio_dev *indio_dev, unsigned int reg, + unsigned int writeval, unsigned int *readval) +{ + struct ad4080_state *st =3D iio_priv(indio_dev); + + if (readval) + return regmap_read(st->regmap, reg, readval); + + return regmap_write(st->regmap, reg, writeval); +} + +static int ad4080_get_scale(struct ad4080_state *st, int *val, int *val2) +{ + unsigned int tmp; + + tmp =3D (st->info->scale_table[0][0] * 1000000ULL) >> + st->info->channels[0].scan_type.realbits; + *val =3D tmp / 1000000; + *val2 =3D tmp % 1000000; + + return IIO_VAL_INT_PLUS_NANO; +} + +static unsigned int ad4080_get_dec_rate(struct iio_dev *dev, + const struct iio_chan_spec *chan) +{ + struct ad4080_state *st =3D iio_priv(dev); + int ret; + unsigned int data; + + ret =3D regmap_read(st->regmap, AD4080_REG_FILTER_CONFIG, &data); + if (ret) + return ret; + + return (1 << (FIELD_GET(AD4080_FILTER_CONFIG_SINC_DEC_RATE_MSK, data) + 1= )); +} + +static int ad4080_set_dec_rate(struct iio_dev *dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct ad4080_state *st =3D iio_priv(dev); + int ret; + + if (st->filter_type >=3D SINC_5 && mode >=3D 512) + return -EINVAL; + + guard(mutex)(&st->lock); + ret =3D regmap_update_bits(st->regmap, AD4080_REG_FILTER_CONFIG, + AD4080_FILTER_CONFIG_SINC_DEC_RATE_MSK, + FIELD_PREP(AD4080_FILTER_CONFIG_SINC_DEC_RATE_MSK, + (ilog2(mode) - 1))); + if (ret) + return ret; + + st->dec_rate =3D mode; + + return 0; +} + +static int ad4080_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long m) +{ + struct ad4080_state *st =3D iio_priv(indio_dev); + int dec_rate; + + switch (m) { + case IIO_CHAN_INFO_SCALE: + return ad4080_get_scale(st, val, val2); + case IIO_CHAN_INFO_SAMP_FREQ: + if (st->filter_type =3D=3D SINC_5_COMP) + dec_rate =3D st->dec_rate * 2; + else + dec_rate =3D st->dec_rate; + if (st->filter_type) + *val =3D DIV_ROUND_CLOSEST(clk_get_rate(st->clk), dec_rate); + else + *val =3D clk_get_rate(st->clk); + return IIO_VAL_INT; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *val =3D ad4080_get_dec_rate(indio_dev, chan); + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int ad4080_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SCALE: + return -EINVAL; + case IIO_CHAN_INFO_SAMP_FREQ: + return -EINVAL; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + return ad4080_set_dec_rate(indio_dev, chan, val); + default: + return -EINVAL; + } +} + +static int ad4080_lvds_sync_write(struct ad4080_state *st) +{ + unsigned int timeout =3D 100; + bool sync_en; + int ret; + + guard(mutex)(&st->lock); + if (st->num_lanes =3D=3D 1) + ret =3D regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK | + AD4080_ADC_DATA_INTF_CONFIG_A_INTF_CHK_EN_MSK); + else + ret =3D regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK | + AD4080_ADC_DATA_INTF_CONFIG_A_INTF_CHK_EN_MSK | + AD4080_ADC_DATA_INTF_CONFIG_A_SPI_LVDS_LANES_MSK); + if (ret) + return ret; + + ret =3D iio_backend_data_alignment_enable(st->back); + if (ret) + return ret; + + do { + ret =3D iio_backend_sync_status_get(st->back, &sync_en); + if (ret) + return ret; + + if (!sync_en) + dev_dbg(&st->spi->dev, "Not Locked: Running Bit Slip\n"); + + fsleep(500); + } while (--timeout && !sync_en); + + if (timeout) { + dev_info(&st->spi->dev, "Success: Pattern correct and Locked!\n"); + if (st->num_lanes =3D=3D 1) + return regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK); + else + return regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK | + AD4080_ADC_DATA_INTF_CONFIG_A_SPI_LVDS_LANES_MSK); + } else { + dev_info(&st->spi->dev, "LVDS Sync Timeout.\n"); + if (st->num_lanes =3D=3D 1) { + ret =3D regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK); + if (ret) + return ret; + } else { + ret =3D regmap_write(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, + AD4080_ADC_DATA_INTF_CONFIG_A_RESERVED_CONFIG_A_MSK | + AD4080_ADC_DATA_INTF_CONFIG_A_SPI_LVDS_LANES_MSK); + if (ret) + return ret; + } + + return -ETIMEDOUT; + } +} + +static ssize_t ad4080_get_filter_type(struct iio_dev *dev, + const struct iio_chan_spec *chan) +{ + struct ad4080_state *st =3D iio_priv(dev); + unsigned int data; + int ret; + + ret =3D regmap_read(st->regmap, AD4080_REG_FILTER_CONFIG, &data); + if (ret) + return ret; + + return FIELD_GET(AD4080_FILTER_CONFIG_FILTER_SEL_MSK, data); +} + +static int ad4080_set_filter_type(struct iio_dev *dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct ad4080_state *st =3D iio_priv(dev); + int ret; + + if (mode >=3D SINC_5 && st->dec_rate >=3D 512) + return -EINVAL; + + guard(mutex)(&st->lock); + ret =3D iio_backend_filter_type_set(st->back, mode); + if (ret) + return ret; + + ret =3D regmap_update_bits(st->regmap, AD4080_REG_FILTER_CONFIG, + AD4080_FILTER_CONFIG_FILTER_SEL_MSK, + FIELD_PREP(AD4080_FILTER_CONFIG_FILTER_SEL_MSK, + mode)); + if (ret) + return ret; + + st->filter_type =3D mode; + + return 0; +} + +static int ad4080_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *vals =3D ad4080_dec_rate_iio_enum; + *length =3D ARRAY_SIZE(ad4080_dec_rate_iio_enum); + *type =3D IIO_VAL_INT; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static const struct iio_info ad4080_iio_info =3D { + .debugfs_reg_access =3D ad4080_reg_access, + .read_raw =3D ad4080_read_raw, + .write_raw =3D ad4080_write_raw, + .read_avail =3D ad4080_read_avail, +}; + +static const struct iio_enum ad4080_filter_type_enum =3D { + .items =3D ad4080_filter_type_iio_enum, + .num_items =3D ARRAY_SIZE(ad4080_filter_type_iio_enum), + .set =3D ad4080_set_filter_type, + .get =3D ad4080_get_filter_type, +}; + +static struct iio_chan_spec_ext_info ad4080_ext_info[] =3D { + IIO_ENUM("filter_type", IIO_SHARED_BY_ALL, &ad4080_filter_type_enum), + IIO_ENUM_AVAILABLE("filter_type", IIO_SHARED_BY_ALL, + &ad4080_filter_type_enum), + { } +}; + +static const struct iio_chan_spec ad4080_channels[] =3D { + { + .type =3D IIO_VOLTAGE, + .indexed =3D 1, + .channel =3D 0, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all =3D BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .info_mask_shared_by_all_available =3D + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .ext_info =3D ad4080_ext_info, + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 's', + .realbits =3D 20, + .storagebits =3D 32, + .shift =3D 0, + }, + } +}; + +static const struct ad4080_chip_info ad4080_chip_info =3D { + .name =3D "AD4080", + .product_id =3D AD4080_CHIP_ID, + .scale_table =3D ad4080_scale_table, + .num_scales =3D ARRAY_SIZE(ad4080_scale_table), + .num_channels =3D 1, + .channels =3D ad4080_channels, +}; + +static int ad4080_setup(struct iio_dev *indio_dev) +{ + struct ad4080_state *st =3D iio_priv(indio_dev); + unsigned int id; + int ret; + + ret =3D regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A, + AD4080_INTERFACE_CONFIG_A_SW_RESET_MSK); + if (ret) + return ret; + + ret =3D regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A, + AD4080_INTERFACE_CONFIG_A_SDO_ENABLE_MSK); + if (ret) + return ret; + + ret =3D regmap_read(st->regmap, AD4080_REG_CHIP_TYPE, &id); + if (ret) + return ret; + + if (id !=3D AD4080_CHIP_ID) + dev_info(&st->spi->dev, "Unrecognized CHIP_ID 0x%X\n", id); + + ret =3D regmap_set_bits(st->regmap, AD4080_REG_GPIO_CONFIG_A, + AD4080_GPIO_CONFIG_A_GPO_1_EN_MSK); + if (ret) + return ret; + + ret =3D regmap_write(st->regmap, AD4080_REG_GPIO_CONFIG_B, + FIELD_PREP(AD4080_GPIO_CONFIG_B_GPIO_1_SEL, 3)); + if (ret) + return ret; + + ret =3D iio_backend_num_lanes_set(st->back, st->num_lanes); + if (ret) + return ret; + + if (!st->lvds_cnv_en) + return 0; + + if (st->num_lanes) { + ret =3D regmap_update_bits(st->regmap, + AD4080_REG_ADC_DATA_INTF_CONFIG_B, + AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_CNV_CLK_CNT_MSK, + FIELD_PREP(AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_CNV_CLK_CNT_MSK, + 7)); + if (ret) + return ret; + } + + ret =3D regmap_set_bits(st->regmap, + AD4080_REG_ADC_DATA_INTF_CONFIG_B, + AD4080_ADC_DATA_INTF_CONFIG_B_LVDS_CNV_EN_MSK); + if (ret) + return ret; + + return ad4080_lvds_sync_write(st); +} + +static void ad4080_properties_parse(struct ad4080_state *st) +{ + st->lvds_cnv_en =3D device_property_read_bool(&st->spi->dev, + "adi,lvds-cnv-enable"); + + st->num_lanes =3D 1; + device_property_read_u32(&st->spi->dev, "adi,num_lanes", &st->num_lanes); +} + +static int ad4080_probe(struct spi_device *spi) +{ + struct iio_dev *indio_dev; + struct device *dev =3D &spi->dev; + struct ad4080_state *st; + int ret; + + indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st =3D iio_priv(indio_dev); + st->spi =3D spi; + + ret =3D devm_regulator_bulk_get_enable(dev, + ARRAY_SIZE(ad4080_power_supplies), + ad4080_power_supplies); + if (ret) + return dev_err_probe(dev, ret, + "failed to get and enable supplies\n"); + + st->regmap =3D devm_regmap_init_spi(spi, &ad4080_regmap_config); + if (IS_ERR(st->regmap)) + return PTR_ERR(st->regmap); + + st->info =3D spi_get_device_match_data(spi); + if (!st->info) + return -ENODEV; + + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; + + st->info =3D spi_get_device_match_data(spi); + if (!st->info) + return -ENODEV; + + indio_dev->name =3D st->info->name; + indio_dev->channels =3D st->info->channels; + indio_dev->num_channels =3D st->info->num_channels; + indio_dev->info =3D &ad4080_iio_info; + indio_dev->modes =3D INDIO_DIRECT_MODE; + + ad4080_properties_parse(st); + + st->clk =3D devm_clk_get_enabled(&spi->dev, "cnv"); + if (IS_ERR(st->clk)) + return PTR_ERR(st->clk); + + st->back =3D devm_iio_backend_get(dev, NULL); + if (IS_ERR(st->back)) + return PTR_ERR(st->back); + + 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 ad4080_setup(indio_dev); + if (ret) + return ret; + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct spi_device_id ad4080_id[] =3D { + { "ad4080", (kernel_ulong_t)&ad4080_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(spi, ad4080_id); + +static const struct of_device_id ad4080_of_match[] =3D { + { .compatible =3D "adi,ad4080", &ad4080_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad4080_of_match); + +static struct spi_driver ad4080_driver =3D { + .driver =3D { + .name =3D "ad4080", + .of_match_table =3D ad4080_of_match, + }, + .probe =3D ad4080_probe, + .id_table =3D ad4080_id, +}; +module_spi_driver(ad4080_driver); + +MODULE_AUTHOR("Antoniu Miclaus