From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC398C04A6A for ; Thu, 27 Jul 2023 15:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234101AbjG0PEF (ORCPT ); Thu, 27 Jul 2023 11:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234256AbjG0PEB (ORCPT ); Thu, 27 Jul 2023 11:04:01 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E0F30DC; Thu, 27 Jul 2023 08:03:57 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCa9bg025977; Thu, 27 Jul 2023 17:03:37 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=4QX9Z5N4IBM3jR26vAY1wmUBBclNiX7yJiB7oyvXpaY=; b=SbICJBKEE06AVt/6QZ8YwTym9UXq5fUHXrwtyuLUR9vrUJY5/oeyHOsTnDd2tXTGuN1Y vt9PJkAYOo/oH3ODcYtiy7KkvEN+Ddbsrsb5Ey2UVwTt289oy67QyGRDcmluBKuQcBrH aiSQN+42dRh65xy7lcIE4ibqP0ItFxqTcUTTaflRLKW2ut06Vq8tKGozQiZ/tHjfMLJU 1pdAupouRV7+kLQytLSJsCDdqHcAtC6nMAfcnuSdlHwpL3GkhYZYEiV4GXuTDZ2Ozq7I DT8cSilKgi0q7fSm1ne81nRj/X+jnxLmkKEy1mwwlads0de6svtfW5x4H0Bui7w6weV1 1A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3n7wtbr0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:03:37 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D5AE710002A; Thu, 27 Jul 2023 17:03:36 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id CE3D3209BA0; Thu, 27 Jul 2023 17:03:36 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:03:36 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen CC: Olivier Moysan , , Subject: [RFC v2 01/11] iio: introduce iio backend device Date: Thu, 27 Jul 2023 17:03:12 +0200 Message-ID: <20230727150324.1157933-2-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a new device type in IIO framework. This backend device does not compute channel attributes and does not expose them through sysfs, as done typically in iio-rescale frontend device. Instead, it allows to report information applying to channel attributes through callbacks. These backend devices can be cascaded to represent chained components. An IIO device configured as a consumer of a backend device can compute the channel attributes of the whole chain. Signed-off-by: Olivier Moysan --- drivers/iio/Makefile | 1 + drivers/iio/industrialio-backend.c | 107 +++++++++++++++++++++++++++++ include/linux/iio/backend.h | 56 +++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 drivers/iio/industrialio-backend.c create mode 100644 include/linux/iio/backend.h diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 9622347a1c1b..9b59c6ab1738 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -5,6 +5,7 @@ =20 obj-$(CONFIG_IIO) +=3D industrialio.o industrialio-y :=3D industrialio-core.o industrialio-event.o inkern.o +industrialio-$(CONFIG_IIO_BACKEND) +=3D industrialio-backend.o industrialio-$(CONFIG_IIO_BUFFER) +=3D industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) +=3D industrialio-trigger.o =20 diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c new file mode 100644 index 000000000000..7d0625889873 --- /dev/null +++ b/drivers/iio/industrialio-backend.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0 +/* The industrial I/O core, backend handling functions + * + */ + +#include +#include +#include +#include +#include + +static DEFINE_IDA(iio_backend_ida); + +#define to_iio_backend(_device) container_of((_device), struct iio_backend= , dev) + +static void iio_backend_release(struct device *device) +{ + struct iio_backend *backend =3D to_iio_backend(device); + + kfree(backend->name); + kfree(backend); +} + +static const struct device_type iio_backend_type =3D { + .release =3D iio_backend_release, + .name =3D "iio_backend_device", +}; + +struct iio_backend *iio_backend_alloc(struct device *parent) +{ + struct iio_backend *backend; + + backend =3D devm_kzalloc(parent, sizeof(*backend), GFP_KERNEL); + + backend->dev.parent =3D parent; + backend->dev.type =3D &iio_backend_type; + backend->dev.bus =3D &iio_bus_type; + device_initialize(&backend->dev); + + return backend; +}; +EXPORT_SYMBOL(iio_backend_alloc); + +void iio_backend_free(struct device *dev) +{ + if (dev) + put_device(dev); +} +EXPORT_SYMBOL(iio_backend_free); + +int iio_backend_register(struct iio_backend *backend) +{ + struct fwnode_handle *fwnode; + int id; + + id =3D ida_alloc(&iio_backend_ida, GFP_KERNEL); + if (id < 0) + return id; + backend->id =3D id; + + dev_set_name(&backend->dev, "backend%d", backend->id); + + if (dev_fwnode(&backend->dev)) + fwnode =3D dev_fwnode(&backend->dev); + else + fwnode =3D dev_fwnode(backend->dev.parent); + device_set_node(&backend->dev, fwnode); + + return device_add(&backend->dev); +}; +EXPORT_SYMBOL(iio_backend_register); + +void iio_backend_unregister(struct iio_backend *backend) +{ + device_del(&backend->dev); +}; +EXPORT_SYMBOL(iio_backend_unregister); + +struct iio_backend *fwnode_iio_backend_get(struct fwnode_handle *fwnode, i= nt index) +{ + struct iio_backend *backend; + struct fwnode_reference_args iiospec; + struct device *bdev; + int ret; + + if (index < 0) + return ERR_PTR(-EINVAL); + + ret =3D fwnode_property_get_reference_args(fwnode, "io-backends", + "#io-backend-cells", 0, + index, &iiospec); + if (ret) + return ERR_PTR(ret); + + bdev =3D bus_find_device_by_fwnode(&iio_bus_type, iiospec.fwnode); + if (!bdev) { + fwnode_handle_put(iiospec.fwnode); + return ERR_PTR(-EPROBE_DEFER); + } + + backend =3D to_iio_backend(bdev); + + fwnode_handle_put(iiospec.fwnode); + + return backend; +}; +EXPORT_SYMBOL(fwnode_iio_backend_get); diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h new file mode 100644 index 000000000000..d90d345a4625 --- /dev/null +++ b/include/linux/iio/backend.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * The industrial I/O core, backend handling functions + * + * Author: Olivier Moysan . + */ + +#ifndef _IIO_BACKEND_H_ +#define _IIO_BACKEND_H_ +#include + +struct iio_backend_ops; +struct iio_backend; + +/** + * struct iio_backend_ops - operations structure for an iio_backend + * @enable: switch on backend + * @disable: switch off backend + * @read_raw: read data from backend + **/ +struct iio_backend_ops { + int (*enable)(struct iio_backend *backend); + int (*disable)(struct iio_backend *backend); + int (*read_raw)(struct iio_backend *backend, int *val, int *val2, long ma= sk); +}; + +/** + * truct iio_backend - industrial I/O backend device + * @ops: operations structure + * @module: owner of this driver module + * @id: unique id number + * @name: unique name + * @dev: associated device + * @priv: private data pointer + **/ +struct iio_backend { + const struct iio_backend_ops *ops; + struct module *owner; + int id; + const char *name; + struct device dev; + struct list_head list; + void *priv; +}; + +struct iio_backend *iio_backend_alloc(struct device *parent); + +void iio_backend_free(struct device *dev); + +int iio_backend_register(struct iio_backend *backend); + +void iio_backend_unregister(struct iio_backend *backend); + +struct iio_backend *fwnode_iio_backend_get(struct fwnode_handle *fwnode, i= nt index); + +#endif /* _IIO_BACKEND_H_ */ --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF561C04A94 for ; Thu, 27 Jul 2023 15:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234190AbjG0PDx (ORCPT ); Thu, 27 Jul 2023 11:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234241AbjG0PDv (ORCPT ); Thu, 27 Jul 2023 11:03:51 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157C3B5; Thu, 27 Jul 2023 08:03:47 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCaNnw025960; Thu, 27 Jul 2023 17:03:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=kgwPhXs1Maa25udKJpXQZWNhB3KaaHj5JLRCEEzOU1U=; b=I4TEnSw0wcy0ori4+4VXxUOZq+V9oYq0Ohc/rzs9UIX9h+7Dx8b7qMrth6Ax5bwYaVQl rb5CvSXYbisiBDEnan20dLUR7f0AEVKDX1+Nx0PmbksPcBK6p9XCV6k7f8YMDJqc9Dzd miQRg4g3Ig/mzaMKu9vpts6BYShTY/90BmE3ntr3XlPx8b8FkcqjovrS2wxSmczEqEWt 8eSu/v85886gyMh0LcHqWH2a6zpGTu1toUdwv5k3Yba1OFovPdiNG1TEoriPqJqomRoK HBBylzkU4HUXMq63mH76re+phXeDDOIjs1s+b9lGDuU83rlcsx6zGd8lLLLGzPkHDnXV Bg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3n7wtbr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:03:38 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2993310002A; Thu, 27 Jul 2023 17:03:38 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 231A9209BA0; Thu, 27 Jul 2023 17:03:38 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:03:37 +0200 From: Olivier Moysan To: Rob Herring , Frank Rowand CC: Olivier Moysan , , Subject: [RFC v2 02/11] of: property: add device link support for io-backends Date: Thu, 27 Jul 2023 17:03:13 +0200 Message-ID: <20230727150324.1157933-3-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for creating device links out of more DT properties. Signed-off-by: Olivier Moysan --- drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index ddc75cd50825..864e29e4707c 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1244,6 +1244,7 @@ DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#= interconnect-cells") DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells") DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells") DEFINE_SIMPLE_PROP(io_channels, "io-channel", "#io-channel-cells") +DEFINE_SIMPLE_PROP(io_backends, "io-backend", "#io-backend-cells") DEFINE_SIMPLE_PROP(interrupt_parent, "interrupt-parent", NULL) DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") @@ -1332,6 +1333,7 @@ static const struct supplier_bindings of_supplier_bin= dings[] =3D { { .parse_prop =3D parse_iommu_maps, .optional =3D true, }, { .parse_prop =3D parse_mboxes, }, { .parse_prop =3D parse_io_channels, }, + { .parse_prop =3D parse_io_backends, }, { .parse_prop =3D parse_interrupt_parent, }, { .parse_prop =3D parse_dmas, .optional =3D true, }, { .parse_prop =3D parse_power_domains, }, --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0423CC04A6A for ; Thu, 27 Jul 2023 15:05:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234370AbjG0PF3 (ORCPT ); Thu, 27 Jul 2023 11:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234326AbjG0PFV (ORCPT ); Thu, 27 Jul 2023 11:05:21 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3A5A0; Thu, 27 Jul 2023 08:05:11 -0700 (PDT) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RE3U0q003285; Thu, 27 Jul 2023 17:04:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=54e2m5OKuocPe4dp4QsV6CEA9XKHKLdL/q4eaLhIrXU=; b=MQkN1j5NB6wKg/+mjQuh6n12Igh2DkCf1Mi06ZiIs84zKithAtkes8mIfA7akc6Sf48Y UlrRmvQWkx8P2YmSK3KZi5WmYZQMnvwXHT9jvNah+QSwDIjFFYrBnU0juugvuXeyLqW9 jbPZbo8y10GmxjSSRv3HfzApHzvP2cLBvrD8yfqNAsAxdJfxBQHnkrg4iWZAuC3CKBlG 58IezRMAaRQH9C5wkGmOsXCroYDlRu0NEsAUgQKf8hJYWQBcPBaw70/d6zyf5wDD8OZ4 Qqis3TJmx9ON0UvdcN13Qe5h4DP32foHhA1PQbIcgLn+bqA1kntjBLuJQ1FcScoDZg1c Bw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3nyg9x5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:04:41 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9F44410002A; Thu, 27 Jul 2023 17:04:39 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9751D209BA2; Thu, 27 Jul 2023 17:04:39 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:04:39 +0200 From: Olivier Moysan To: Olivier Moysan , Arnaud Pouliquen , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue , Fabrice Gasnier CC: , , , , , Subject: [RFC v2 03/11] dt-bindings: iio: stm32-dfsdm-adc: add scaling support Date: Thu, 27 Jul 2023 17:03:14 +0200 Message-ID: <20230727150324.1157933-4-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add scaling support to STM32 DFSDM. This introduces the following changes: - Add ADC generic channel binding and remove support of deprecated channel bindings. - DFSDM is now implemented as a channel provider, so remove io-channels properties. - Add iio-backend property to connect DFSDM to an SD modulator. Signed-off-by: Olivier Moysan --- .../bindings/iio/adc/st,stm32-dfsdm-adc.yaml | 189 ++++++------------ 1 file changed, 63 insertions(+), 126 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.y= aml b/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml index 1970503389aa..128545cedc7f 100644 --- a/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml @@ -85,22 +85,14 @@ patternProperties: description: Specifies the DFSDM filter instance used. maxItems: 1 =20 - interrupts: - maxItems: 1 + '#address-cells': + const: 1 =20 - st,adc-channels: - description: | - List of single-ended channels muxed for this ADC. - On stm32h7 and stm32mp1: - - For st,stm32-dfsdm-adc: up to 8 channels numbered from 0 to 7. - - For st,stm32-dfsdm-dmic: 1 channel numbered from 0 to 7. - $ref: /schemas/types.yaml#/definitions/uint32-array - items: - minimum: 0 - maximum: 7 + '#size-cells': + const: 0 =20 - st,adc-channel-names: - description: List of single-ended channel names. + interrupts: + maxItems: 1 =20 st,filter-order: description: | @@ -111,39 +103,6 @@ patternProperties: $ref: /schemas/types.yaml#/definitions/uint32 maximum: 5 =20 - "#io-channel-cells": - const: 1 - - st,adc-channel-types: - description: | - Single-ended channel input type. - - "SPI_R": SPI with data on rising edge (default) - - "SPI_F": SPI with data on falling edge - - "MANCH_R": manchester codec, rising edge =3D logic 0, falling = edge =3D logic 1 - - "MANCH_F": manchester codec, rising edge =3D logic 1, falling = edge =3D logic 0 - items: - enum: [ SPI_R, SPI_F, MANCH_R, MANCH_F ] - $ref: /schemas/types.yaml#/definitions/non-unique-string-array - - st,adc-channel-clk-src: - description: | - Conversion clock source. - - "CLKIN": external SPI clock (CLKIN x) - - "CLKOUT": internal SPI clock (CLKOUT) (default) - - "CLKOUT_F": internal SPI clock divided by 2 (falling edge). - - "CLKOUT_R": internal SPI clock divided by 2 (rising edge). - items: - enum: [ CLKIN, CLKOUT, CLKOUT_F, CLKOUT_R ] - $ref: /schemas/types.yaml#/definitions/non-unique-string-array - - st,adc-alt-channel: - description: - Must be defined if two sigma delta modulators are - connected on same SPI input. - If not set, channel n is connected to SPI input n. - If set, channel n is connected to SPI input n + 1. - type: boolean - st,filter0-sync: description: Set to 1 to synchronize with DFSDM filter instance 0. @@ -157,14 +116,68 @@ patternProperties: items: - const: rx =20 + patternProperties: + "^channel@([0-9]|1[0-9])$": + type: object + $ref: "adc.yaml" + description: Represents the external channels which are connected = to the DFSDM. + + properties: + reg: + items: + minimum: 0 + maximum: 19 + + label: + description: | + Unique name to identify channel. + + st,adc-channel-types: + description: | + Single-ended channel input type. + - "SPI_R": SPI with data on rising edge (default) + - "SPI_F": SPI with data on falling edge + - "MANCH_R": manchester codec, rising edge =3D logic 0, fall= ing edge =3D logic 1 + - "MANCH_F": manchester codec, rising edge =3D logic 1, fall= ing edge =3D logic 0 + items: + enum: [ SPI_R, SPI_F, MANCH_R, MANCH_F ] + $ref: /schemas/types.yaml#/definitions/non-unique-string-array + + st,adc-channel-clk-src: + description: | + Conversion clock source. + - "CLKIN": external SPI clock (CLKIN x) + - "CLKOUT": internal SPI clock (CLKOUT) (default) + - "CLKOUT_F": internal SPI clock divided by 2 (falling edge). + - "CLKOUT_R": internal SPI clock divided by 2 (rising edge). + items: + enum: [ CLKIN, CLKOUT, CLKOUT_F, CLKOUT_R ] + $ref: /schemas/types.yaml#/definitions/non-unique-string-array + + st,adc-alt-channel: + description: + Must be defined if two sigma delta modulators are + connected on same SPI input. + If not set, channel n is connected to SPI input n. + If set, channel n is connected to SPI input n + 1. + type: boolean + + io-backends: + description: | + phandle to an external sigma delta modulator or internal ADC= output. + $ref: /schemas/types.yaml#/definitions/phandle + + required: + - reg + - io-backends + + additionalProperties: false + required: - compatible - reg - interrupts - - st,adc-channels - - st,adc-channel-names - st,filter-order - - "#io-channel-cells" =20 allOf: - if: @@ -175,14 +188,6 @@ patternProperties: =20 then: properties: - st,adc-channels: - minItems: 1 - maxItems: 8 - - st,adc-channel-names: - minItems: 1 - maxItems: 8 - st,adc-channel-types: minItems: 1 maxItems: 8 @@ -191,14 +196,6 @@ patternProperties: minItems: 1 maxItems: 8 =20 - io-channels: - description: - From common IIO binding. Used to pipe external sigma delta - modulator or internal ADC output to DFSDM channel. - - required: - - io-channels - - if: properties: compatible: @@ -207,12 +204,6 @@ patternProperties: =20 then: properties: - st,adc-channels: - maxItems: 1 - - st,adc-channel-names: - maxItems: 1 - st,adc-channel-types: maxItems: 1 =20 @@ -237,15 +228,9 @@ patternProperties: "#sound-dai-cells": const: 0 =20 - io-channels: - description: - From common IIO binding. Used to pipe external sigma d= elta - modulator or internal ADC output to DFSDM channel. - required: - compatible - "#sound-dai-cells" - - io-channels =20 allOf: - if: @@ -278,52 +263,4 @@ allOf: minimum: 0 maximum: 5 =20 -examples: - - | - #include - #include - dfsdm: dfsdm@4400d000 { - compatible =3D "st,stm32mp1-dfsdm"; - reg =3D <0x4400d000 0x800>; - clocks =3D <&rcc DFSDM_K>, <&rcc ADFSDM_K>; - clock-names =3D "dfsdm", "audio"; - #address-cells =3D <1>; - #size-cells =3D <0>; - - dfsdm0: filter@0 { - compatible =3D "st,stm32-dfsdm-dmic"; - reg =3D <0>; - interrupts =3D ; - dmas =3D <&dmamux1 101 0x400 0x01>; - dma-names =3D "rx"; - #io-channel-cells =3D <1>; - st,adc-channels =3D <1>; - st,adc-channel-names =3D "dmic0"; - st,adc-channel-types =3D "SPI_R"; - st,adc-channel-clk-src =3D "CLKOUT"; - st,filter-order =3D <5>; - - asoc_pdm0: dfsdm-dai { - compatible =3D "st,stm32h7-dfsdm-dai"; - #sound-dai-cells =3D <0>; - io-channels =3D <&dfsdm0 0>; - }; - }; - - dfsdm_pdm1: filter@1 { - compatible =3D "st,stm32-dfsdm-adc"; - reg =3D <1>; - interrupts =3D ; - dmas =3D <&dmamux1 102 0x400 0x01>; - dma-names =3D "rx"; - #io-channel-cells =3D <1>; - st,adc-channels =3D <2 3>; - st,adc-channel-names =3D "in2", "in3"; - st,adc-channel-types =3D "SPI_R", "SPI_R"; - st,adc-channel-clk-src =3D "CLKOUT_F", "CLKOUT_F"; - io-channels =3D <&sd_adc2 &sd_adc3>; - st,filter-order =3D <1>; - }; - }; - ... --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 615D7C001E0 for ; Thu, 27 Jul 2023 15:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234299AbjG0PFW (ORCPT ); Thu, 27 Jul 2023 11:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbjG0PFS (ORCPT ); Thu, 27 Jul 2023 11:05:18 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 292F62D64; Thu, 27 Jul 2023 08:05:07 -0700 (PDT) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RDknRl003322; Thu, 27 Jul 2023 17:04:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=Afh2YP4unr7IlnkC/kl5oBvqDQEhhE5u42q4w1Ahs2o=; b=asDWYAXlGuSxGBQOH54LrtYWpLc0Ahk9ZpgAn8XNbRDG/ZDWobZUmHGSRA6Th5R8iHib d9Dx8cBBVIVu4ez455JJSlSrBmgUSdzTvCv4m2MvtoCQFUYstJ/F/29Lc2ni5wDBonwF L+XlZOGhdYTB8ILjMFzWNT1t9pC/g4culm+LjvInz/LJpA7hAV71mT4AcJQANir2tJuR n25iLKjV7KzPWJbOAoEBbbueYQtrL5vtKtZtE7jLOnqvYqwba4qHQiGJzXRWUfq6ryA/ 1WcTh/i88/0rB0B684zmEnPS9HURWbxMnp1lmXtFGA75ftU4POd1ynQKoS1XMKl/5tsM Rw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3nyg9x5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:04:41 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E75FF100049; Thu, 27 Jul 2023 17:04:40 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DFFA2209BA2; Thu, 27 Jul 2023 17:04:40 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:04:40 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnaud Pouliquen CC: Olivier Moysan , , , Subject: [RFC v2 04/11] dt-bindings: iio: adc: add scaling support to sd modulator Date: Thu, 27 Jul 2023 17:03:15 +0200 Message-ID: <20230727150324.1157933-5-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add scaling support to SD modulator. Signed-off-by: Olivier Moysan --- .../bindings/iio/adc/sigma-delta-modulator.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulato= r.yaml b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.ya= ml index cab0d425eaa4..bcc446c6428c 100644 --- a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.yaml +++ b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.yaml @@ -18,12 +18,15 @@ properties: - sd-modulator - ads1201 =20 - '#io-channel-cells': + '#io-backend-cells': const: 0 =20 + vref-supply: + description: Phandle to the SD modulator reference voltage. + required: - compatible - - '#io-channel-cells' + - '#io-backend-cells' =20 additionalProperties: false =20 @@ -31,7 +34,7 @@ examples: - | ads1202: adc { compatible =3D "sd-modulator"; - #io-channel-cells =3D <0>; + #io-backend-cells =3D <0>; }; =20 ... --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AFCEC04A6A for ; Thu, 27 Jul 2023 15:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234309AbjG0PFT (ORCPT ); Thu, 27 Jul 2023 11:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234285AbjG0PFP (ORCPT ); Thu, 27 Jul 2023 11:05:15 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B880D2D6A; Thu, 27 Jul 2023 08:05:02 -0700 (PDT) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RDwsH6003283; Thu, 27 Jul 2023 17:04:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=1HexxHO3uTDqpGlWTz+VbBPKNGXF+V4IZdmqjKDA/WM=; b=keUKRDlcIWr/doP4QvHqbpQfbh0mjl1KQZI2PhDswc0ahFkiPnGzQtLzFKgnQs1hODzz 19/VuqFRJ1LYFyx7IC1L9WGfuJghbwFfbU/af+Z9arh0smggBP0Vnw/A3VgXTOpu5rUj txA+fzhQ4Q7/A4mac0jvkY/9JsahJg1KS8QXJ5iZeEMCe5ZCldRar1C1j1hwYBbPA87S k7Bx3jM3tFmmwqKkG8qJD1PTX1sbn8XQUK1z683+4vndHuI3ZW3HpTkTBY6WKhrUkJZN Iip5rwlMAkZktwHxu6cZfHz+BC5tEu6kv26S39X2nu8tQJLt0ZrEBPnfDtJ3mwrXYvxS /g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3nyg9x5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:04:42 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 515F310002A; Thu, 27 Jul 2023 17:04:42 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4A5C1209BA2; Thu, 27 Jul 2023 17:04:42 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:04:41 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 05/11] iio: adc: stm32-dfsdm: manage dfsdm as a channel provider Date: Thu, 27 Jul 2023 17:03:16 +0200 Message-ID: <20230727150324.1157933-6-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The STM32 is currently implemented as a channels consumer of the sigma delta modulator. Change the topology to expose a single IIO device for DFSDM and remove the IIO device associated to the SD modulator. Manage the DFSDM as a channel provider to allow this change. Signed-off-by: Olivier Moysan --- drivers/iio/adc/stm32-dfsdm-adc.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsd= m-adc.c index b5cc43d12b6f..20f7dffcecdd 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -77,7 +77,6 @@ struct stm32_dfsdm_adc { =20 /* ADC specific */ unsigned int oversamp; - struct iio_hw_consumer *hwc; struct completion completion; u32 *buffer; =20 @@ -1007,12 +1006,6 @@ static int stm32_dfsdm_postenable(struct iio_dev *in= dio_dev) /* Reset adc buffer index */ adc->bufi =3D 0; =20 - if (adc->hwc) { - ret =3D iio_hw_consumer_enable(adc->hwc); - if (ret < 0) - return ret; - } - ret =3D stm32_dfsdm_start_dfsdm(adc->dfsdm); if (ret < 0) goto err_stop_hwc; @@ -1036,8 +1029,6 @@ static int stm32_dfsdm_postenable(struct iio_dev *ind= io_dev) stop_dfsdm: stm32_dfsdm_stop_dfsdm(adc->dfsdm); err_stop_hwc: - if (adc->hwc) - iio_hw_consumer_disable(adc->hwc); =20 return ret; } @@ -1052,9 +1043,6 @@ static int stm32_dfsdm_predisable(struct iio_dev *ind= io_dev) =20 stm32_dfsdm_stop_dfsdm(adc->dfsdm); =20 - if (adc->hwc) - iio_hw_consumer_disable(adc->hwc); - return 0; } =20 @@ -1231,7 +1219,6 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio= _dev, ret =3D iio_device_claim_direct_mode(indio_dev); if (ret) return ret; - ret =3D iio_hw_consumer_enable(adc->hwc); if (ret < 0) { dev_err(&indio_dev->dev, "%s: IIO enable failed (channel %d)\n", @@ -1240,7 +1227,6 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio= _dev, return ret; } ret =3D stm32_dfsdm_single_conv(indio_dev, chan, val); - iio_hw_consumer_disable(adc->hwc); if (ret < 0) { dev_err(&indio_dev->dev, "%s: Conversion failed (channel %d)\n", @@ -1450,11 +1436,6 @@ static int stm32_dfsdm_adc_init(struct device *dev, = struct iio_dev *indio_dev) return num_ch < 0 ? num_ch : -EINVAL; } =20 - /* Bind to SD modulator IIO device */ - adc->hwc =3D devm_iio_hw_consumer_alloc(&indio_dev->dev); - if (IS_ERR(adc->hwc)) - return -EPROBE_DEFER; - ch =3D devm_kcalloc(&indio_dev->dev, num_ch, sizeof(*ch), GFP_KERNEL); if (!ch) --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D75C0015E for ; Thu, 27 Jul 2023 15:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234354AbjG0PGg (ORCPT ); Thu, 27 Jul 2023 11:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234297AbjG0PGZ (ORCPT ); Thu, 27 Jul 2023 11:06:25 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3837530D8; Thu, 27 Jul 2023 08:06:04 -0700 (PDT) Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RBD3Kf020177; Thu, 27 Jul 2023 17:05:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=zmIPHW6iVYvOYi7oMUl9xnnwWipA141Ebb8TXiBkQXc=; b=6QX4TiYSntWcuysnOPTpYG03Wm8TzRkJ2LtxGD897emCWqelSVFabxXtNYesNFEari5Y EPbSbqwllTxW+63FnHlS5Ol410zrPFRa7RRnazGh3VbjNzvWUxYFErLg54IKtooVLh3G 56NnH6bT7XIj07WguEpme4jKCNC/Tr9WZXUWMg3L8TuN1Pn+cQsn+QITX3muFVJQBSu0 Uh+k4nQ8Vhfmo5U7bHDOaFEiwjbmawtCziBNjD7YsjtHwPrj4EFLzmdZPea0ucHk+Ppq YqkI82l3qQQa3D/NWP7Sztoc1piiJi2IFDm3n0ZH37fWgvRuIOSg0BHKlj1VDQnkJJrz 7A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3qgy988r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:05:44 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B36C810002A; Thu, 27 Jul 2023 17:05:43 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AA361209BA7; Thu, 27 Jul 2023 17:05:43 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:05:43 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 06/11] iio: adc: stm32-dfsdm: adopt generic channel bindings Date: Thu, 27 Jul 2023 17:03:17 +0200 Message-ID: <20230727150324.1157933-7-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Adopt the generic channel bindings to ease the configuration of the DFSDM channels as consumers of the SD modulator backend device. Also adopt unified device property API in the same patch for this RFC. Signed-off-by: Olivier Moysan --- drivers/iio/adc/stm32-dfsdm-adc.c | 93 ++++++++++++++++--------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsd= m-adc.c index 20f7dffcecdd..96f4e0c64cdc 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -596,45 +596,35 @@ static int stm32_dfsdm_filter_configure(struct iio_de= v *indio_dev, =20 static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm, struct iio_dev *indio_dev, + struct fwnode_handle *node, struct iio_chan_spec *ch) { struct stm32_dfsdm_channel *df_ch; const char *of_str; - int chan_idx =3D ch->scan_index; int ret, val; =20 - ret =3D of_property_read_u32_index(indio_dev->dev.of_node, - "st,adc-channels", chan_idx, - &ch->channel); + ret =3D fwnode_property_read_u32(node, "reg", &ch->channel); if (ret < 0) { - dev_err(&indio_dev->dev, - " Error parsing 'st,adc-channels' for idx %d\n", - chan_idx); + dev_err(&indio_dev->dev, "Missing channel index %d\n", ret); return ret; } if (ch->channel >=3D dfsdm->num_chs) { - dev_err(&indio_dev->dev, - " Error bad channel number %d (max =3D %d)\n", + dev_err(&indio_dev->dev, " Error bad channel number %d (max =3D %d)\n", ch->channel, dfsdm->num_chs); return -EINVAL; } =20 - ret =3D of_property_read_string_index(indio_dev->dev.of_node, - "st,adc-channel-names", chan_idx, - &ch->datasheet_name); + ret =3D fwnode_property_read_string(node, "label", &ch->datasheet_name); if (ret < 0) { dev_err(&indio_dev->dev, - " Error parsing 'st,adc-channel-names' for idx %d\n", - chan_idx); + " Error parsing 'label' for idx %d\n", ch->channel); return ret; } =20 df_ch =3D &dfsdm->ch_list[ch->channel]; df_ch->id =3D ch->channel; =20 - ret =3D of_property_read_string_index(indio_dev->dev.of_node, - "st,adc-channel-types", chan_idx, - &of_str); + ret =3D fwnode_property_read_string(node, "st,adc-channel-types", &of_str= ); if (!ret) { val =3D stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type); if (val < 0) @@ -644,9 +634,7 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_df= sdm *dfsdm, } df_ch->type =3D val; =20 - ret =3D of_property_read_string_index(indio_dev->dev.of_node, - "st,adc-channel-clk-src", chan_idx, - &of_str); + ret =3D fwnode_property_read_string(node, "st,adc-channel-clk-src", &of_s= tr); if (!ret) { val =3D stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src); if (val < 0) @@ -656,10 +644,8 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_d= fsdm *dfsdm, } df_ch->src =3D val; =20 - ret =3D of_property_read_u32_index(indio_dev->dev.of_node, - "st,adc-alt-channel", chan_idx, - &df_ch->alt_si); - if (ret < 0) + ret =3D fwnode_property_read_u32(node, "st,adc-alt-channel", &df_ch->alt_= si); + if (ret !=3D -EINVAL) df_ch->alt_si =3D 0; =20 return 0; @@ -1354,17 +1340,21 @@ static int stm32_dfsdm_dma_request(struct device *d= ev, } =20 static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, + struct fwnode_handle *child, struct iio_chan_spec *ch) { struct stm32_dfsdm_adc *adc =3D iio_priv(indio_dev); int ret; =20 - ret =3D stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, ch); - if (ret < 0) + ret =3D stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, child, ch); + if (ret < 0) { + dev_err(&indio_dev->dev, "Failed to parse channel\n"); return ret; + } =20 ch->type =3D IIO_VOLTAGE; ch->indexed =3D 1; + ch->scan_index =3D ch->channel; =20 /* * IIO_CHAN_INFO_RAW: used to compute regular conversion @@ -1387,6 +1377,30 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_= dev *indio_dev, &adc->dfsdm->ch_list[ch->channel]); } =20 +static int stm32_dfsdm_generic_chan_init(struct iio_dev *indio_dev, struct= stm32_dfsdm_adc *adc, + struct iio_chan_spec *channels) +{ + struct fwnode_handle *child; + int chan_idx =3D 0, ret; + + device_for_each_child_node(&indio_dev->dev, child) { + ret =3D stm32_dfsdm_adc_chan_init_one(indio_dev, child, &channels[chan_i= dx]); + if (ret < 0) { + dev_err(&indio_dev->dev, "Channels init failed\n"); + goto err; + } + + chan_idx++; + } + + return chan_idx; + +err: + fwnode_handle_put(child); + + return ret; +} + static int stm32_dfsdm_audio_init(struct device *dev, struct iio_dev *indi= o_dev) { struct iio_chan_spec *ch; @@ -1400,7 +1414,7 @@ static int stm32_dfsdm_audio_init(struct device *dev,= struct iio_dev *indio_dev) =20 ch->scan_index =3D 0; =20 - ret =3D stm32_dfsdm_adc_chan_init_one(indio_dev, ch); + ret =3D stm32_dfsdm_generic_chan_init(indio_dev, adc, ch); if (ret < 0) { dev_err(&indio_dev->dev, "Channels init failed\n"); return ret; @@ -1422,33 +1436,24 @@ static int stm32_dfsdm_adc_init(struct device *dev,= struct iio_dev *indio_dev) struct iio_chan_spec *ch; struct stm32_dfsdm_adc *adc =3D iio_priv(indio_dev); int num_ch; - int ret, chan_idx; + int ret; =20 adc->oversamp =3D DFSDM_DEFAULT_OVERSAMPLING; ret =3D stm32_dfsdm_compute_all_osrs(indio_dev, adc->oversamp); if (ret < 0) return ret; =20 - num_ch =3D of_property_count_u32_elems(indio_dev->dev.of_node, - "st,adc-channels"); - if (num_ch < 0 || num_ch > adc->dfsdm->num_chs) { - dev_err(&indio_dev->dev, "Bad st,adc-channels\n"); - return num_ch < 0 ? num_ch : -EINVAL; - } + num_ch =3D device_get_child_node_count(&indio_dev->dev); + if (!num_ch) + return -EINVAL; =20 - ch =3D devm_kcalloc(&indio_dev->dev, num_ch, sizeof(*ch), - GFP_KERNEL); + ch =3D devm_kcalloc(&indio_dev->dev, num_ch, sizeof(*ch), GFP_KERNEL); if (!ch) return -ENOMEM; =20 - for (chan_idx =3D 0; chan_idx < num_ch; chan_idx++) { - ch[chan_idx].scan_index =3D chan_idx; - ret =3D stm32_dfsdm_adc_chan_init_one(indio_dev, &ch[chan_idx]); - if (ret < 0) { - dev_err(&indio_dev->dev, "Channels init failed\n"); - return ret; - } - } + stm32_dfsdm_generic_chan_init(indio_dev, adc, ch); + if (ret < 0) + return ret; =20 indio_dev->num_channels =3D num_ch; indio_dev->channels =3D ch; --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00CE5C0015E for ; Thu, 27 Jul 2023 15:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234332AbjG0PGd (ORCPT ); Thu, 27 Jul 2023 11:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234071AbjG0PGY (ORCPT ); Thu, 27 Jul 2023 11:06:24 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8952D78; Thu, 27 Jul 2023 08:06:03 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RCaFWb026230; Thu, 27 Jul 2023 17:05:45 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=YgyxpEp3AxX/oTnC63UwO2tMjhlVZ0Pi4rcy64P8JJM=; b=55s7MqVytyRvNCS1kj1Fe5g/EiwS9go9S9KmZAPt69ZtVywmmxK8Jf4Y9Q7sl9mnIdqC pG/Pp64c61u3egD9Sm4KbWXNl09G3Fns1nJ1q7fmS8VDc5S5cUMsqKat5GpGw2JKr1zo RMSBSEdw5CW7jtE8o44kWWpNVdNc3W0aa+o0Ojy5VdHbRoERrP4BYWShO/cCjk/hJoZ4 vOoNin2xIWg9zndD7yz7xI2/U4DMAwwKeUwbbyZVM8T50GIJvdj/uJLMo/+sMSv5uPy+ MdhbWuuMncIFq2X/1R3tpNYQZlzEWtJPj04Hv4q3YVyYqX9I+te9ueqxAmCoOTLULLzY Tw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3n7wtc1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:05:45 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1782010002A; Thu, 27 Jul 2023 17:05:45 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0F7B7209BA7; Thu, 27 Jul 2023 17:05:45 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:05:44 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 07/11] iio: adc: stm32-dfsdm: add scaling support to dfsdm Date: Thu, 27 Jul 2023 17:03:18 +0200 Message-ID: <20230727150324.1157933-8-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add scaling support to STM32 DFSDM. Signed-off-by: Olivier Moysan --- drivers/iio/adc/stm32-dfsdm-adc.c | 77 +++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsd= m-adc.c index 96f4e0c64cdc..dba1a8ef5451 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ struct stm32_dfsdm_adc { =20 /* ADC specific */ unsigned int oversamp; + struct iio_backend **backend; struct completion completion; u32 *buffer; =20 @@ -600,6 +602,8 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_df= sdm *dfsdm, struct iio_chan_spec *ch) { struct stm32_dfsdm_channel *df_ch; + struct stm32_dfsdm_adc *adc =3D iio_priv(indio_dev); + struct iio_backend *backend; const char *of_str; int ret, val; =20 @@ -648,6 +652,12 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_d= fsdm *dfsdm, if (ret !=3D -EINVAL) df_ch->alt_si =3D 0; =20 + backend =3D fwnode_iio_backend_get(node, 0); + if (IS_ERR(backend)) + return dev_err_probe(&indio_dev->dev, PTR_ERR(backend), "Failed to get b= ackend\n"); + + adc->backend[df_ch->id] =3D backend; + return 0; } =20 @@ -1091,7 +1101,7 @@ static int stm32_dfsdm_single_conv(struct iio_dev *in= dio_dev, { struct stm32_dfsdm_adc *adc =3D iio_priv(indio_dev); long timeout; - int ret; + int ret, idx =3D chan->scan_index; =20 reinit_completion(&adc->completion); =20 @@ -1101,6 +1111,13 @@ static int stm32_dfsdm_single_conv(struct iio_dev *i= ndio_dev, if (ret < 0) return ret; =20 + if (!adc->backend[idx]->ops->enable) + return -EINVAL; + + ret =3D adc->backend[idx]->ops->enable(adc->backend[idx]); + if (ret < 0) + return ret; + ret =3D regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id), DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(1)); if (ret < 0) @@ -1134,6 +1151,8 @@ static int stm32_dfsdm_single_conv(struct iio_dev *in= dio_dev, stm32_dfsdm_process_data(adc, res); =20 stop_dfsdm: + ret =3D adc->backend[idx]->ops->disable(adc->backend[idx]); + stm32_dfsdm_stop_dfsdm(adc->dfsdm); =20 return ret; @@ -1198,7 +1217,14 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indi= o_dev, int *val2, long mask) { struct stm32_dfsdm_adc *adc =3D iio_priv(indio_dev); - int ret; + + struct stm32_dfsdm_filter *fl =3D &adc->dfsdm->fl_list[adc->fl_id]; + struct stm32_dfsdm_filter_osr *flo =3D &fl->flo[fl->fast]; + u32 max =3D flo->max << (flo->lshift - chan->scan_type.shift); + int ret, idx =3D chan->scan_index; + + if (flo->lshift < chan->scan_type.shift) + max =3D flo->max >> (chan->scan_type.shift - flo->lshift); =20 switch (mask) { case IIO_CHAN_INFO_RAW: @@ -1232,6 +1258,41 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indi= o_dev, *val =3D adc->sample_freq; =20 return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + /* + * Scale is expressed in mV. + * When fast mode is disabled, actual resolution may be lower + * than 2^n, where n=3Drealbits-1. + * This leads to underestimating input voltage. To + * compensate this deviation, the voltage reference can be + * corrected with a factor =3D realbits resolution / actual max + */ + adc->backend[idx]->ops->read_raw(adc->backend[idx], val, val2, mask); + + *val =3D div_u64((u64)*val * (u64)BIT(DFSDM_DATA_RES - 1), max); + *val2 =3D chan->scan_type.realbits; + if (chan->differential) + *val *=3D 2; + return IIO_VAL_FRACTIONAL_LOG2; + + case IIO_CHAN_INFO_OFFSET: + /* + * DFSDM output data are in the range [-2^n,2^n], + * with n=3Drealbits-1. + * - Differential modulator: + * Offset correspond to SD modulator offset. + * - Single ended modulator: + * Input is in [0V,Vref] range, where 0V corresponds to -2^n, and Vref t= o 2^n. + * Add 2^n to offset. (i.e. middle of input range) + * offset =3D offset(sd) * vref / res(sd) * max / vref. + */ + adc->backend[idx]->ops->read_raw(adc->backend[idx], val, val2, mask); + + *val =3D div_u64((u64)max * *val, BIT(*val2 - 1)); + if (!chan->differential) + *val +=3D max; + return IIO_VAL_INT; } =20 return -EINVAL; @@ -1360,7 +1421,10 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_= dev *indio_dev, * IIO_CHAN_INFO_RAW: used to compute regular conversion * IIO_CHAN_INFO_OVERSAMPLING_RATIO: used to set oversampling */ - ch->info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW); + ch->info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET); + ch->info_mask_shared_by_all =3D BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) | BIT(IIO_CHAN_INFO_SAMP_FREQ); =20 @@ -1451,7 +1515,12 @@ static int stm32_dfsdm_adc_init(struct device *dev, = struct iio_dev *indio_dev) if (!ch) return -ENOMEM; =20 - stm32_dfsdm_generic_chan_init(indio_dev, adc, ch); + adc->backend =3D devm_kzalloc(&indio_dev->dev, sizeof(*adc->backend) * ad= c->dfsdm->num_chs, + GFP_KERNEL); + if (!adc->backend) + return -ENOMEM; + + ret =3D stm32_dfsdm_generic_chan_init(indio_dev, adc, ch); if (ret < 0) return ret; =20 --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BAAC04A6A for ; Thu, 27 Jul 2023 15:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbjG0PG3 (ORCPT ); Thu, 27 Jul 2023 11:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbjG0PGX (ORCPT ); Thu, 27 Jul 2023 11:06:23 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ABF33A99; Thu, 27 Jul 2023 08:06:02 -0700 (PDT) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RE2Egv003290; Thu, 27 Jul 2023 17:05:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=Pt5jUqqdSOoqnjMTkcAHM3VXQXCIBKFvR/ivoinfamw=; b=zymx3FJupVczr0LBeD96k642Kl+8JvVTWEb6uyhk5jRRlfIBW/x+Nh70E3455exT2npq 4BQnfQptu3kS6UynsE+t30eo8dIY5JwzxZnU04dmu8kzntl8tV4sE8Ivk3fRyk6jrb96 bxXZr3F6b9R1jWz2r4KdooUDAdMdnWeIMQW9NEuz6g3R8fM2mZN/QKB9TzklCmuq5k/z VAwm2vUp6SGttvIwFeCRjiAmuRKg5S8nyk2soBsdjhQpyEsGfkPYpHY8mQS6Oru+lO4f lOqdSYWoqiJMkdyNGwJ9PIq95tbyz8MyxPOcsNClxW/JSUZSkheZJ8y0ZJ2qI740mbmu zg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3nyg9xc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:05:46 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6F00410002A; Thu, 27 Jul 2023 17:05:46 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 67EFE209BA7; Thu, 27 Jul 2023 17:05:46 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:05:46 +0200 From: Olivier Moysan To: Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown CC: Olivier Moysan , , Subject: [RFC v2 08/11] iio: adc: sd modulator: add scale and offset support Date: Thu, 27 Jul 2023 17:03:19 +0200 Message-ID: <20230727150324.1157933-9-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Register the SD modulator as an IIO backend device instead of a standard IIO device. Expose scale and offset information to IIO backend consumer. Signed-off-by: Olivier Moysan --- drivers/iio/adc/sd_adc_modulator.c | 106 +++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/sd_adc_modulator.c b/drivers/iio/adc/sd_adc_mo= dulator.c index 327cc2097f6c..e77e7884c403 100644 --- a/drivers/iio/adc/sd_adc_modulator.c +++ b/drivers/iio/adc/sd_adc_modulator.c @@ -6,44 +6,110 @@ * Author: Arnaud Pouliquen . */ =20 +#include #include #include #include #include #include +#include =20 -static const struct iio_info iio_sd_mod_iio_info; +struct iio_sd_mod_priv { + struct regulator *vref; + int vref_mv; +}; =20 -static const struct iio_chan_spec iio_sd_mod_ch =3D { - .type =3D IIO_VOLTAGE, - .indexed =3D 1, - .scan_type =3D { - .sign =3D 'u', - .realbits =3D 1, - .shift =3D 0, - }, +static int sd_mod_enable(struct iio_backend *backend) +{ + struct iio_sd_mod_priv *priv =3D backend->priv; + int ret; + + ret =3D regulator_enable(priv->vref); + if (ret) { + dev_err(&backend->dev, "Failed to enable regulator: %d\n", ret); + return ret; + } + + ret =3D regulator_get_voltage(priv->vref); + priv->vref_mv =3D ret / 1000; + + return 0; +}; + +static int sd_mod_disable(struct iio_backend *backend) +{ + struct iio_sd_mod_priv *priv =3D backend->priv; + + return regulator_disable(priv->vref); +}; + +static int sd_mod_read(struct iio_backend *backend, int *val, int *val2, l= ong mask) +{ + struct iio_sd_mod_priv *priv =3D backend->priv; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + *val =3D priv->vref_mv; + *val2 =3D 0; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_OFFSET: + *val =3D 0; + *val2 =3D 0; + return IIO_VAL_INT; + } + + return -EINVAL; +}; + +static const struct iio_backend_ops sd_mod_ops =3D { + .enable =3D sd_mod_enable, + .disable =3D sd_mod_disable, + .read_raw =3D sd_mod_read, }; =20 static int iio_sd_mod_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct iio_dev *iio; + struct regulator *vref; + struct iio_backend *backend; + struct iio_sd_mod_priv *priv; + int ret; =20 - iio =3D devm_iio_device_alloc(dev, 0); - if (!iio) + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) return -ENOMEM; =20 - iio->name =3D dev_name(dev); - iio->info =3D &iio_sd_mod_iio_info; - iio->modes =3D INDIO_BUFFER_HARDWARE; + vref =3D devm_regulator_get_optional(dev, "vref"); + if (IS_ERR(vref)) { + if (PTR_ERR(vref) !=3D -ENODEV) + return dev_err_probe(dev, PTR_ERR(vref), "Failed to get vref\n"); + } else { + priv->vref =3D vref; + } =20 - iio->num_channels =3D 1; - iio->channels =3D &iio_sd_mod_ch; + backend =3D iio_backend_alloc(dev); + if (!backend) { + dev_err(dev, "Failed to allocate sd modulator backend data\n"); + return -ENOMEM; + } + + backend->priv =3D priv; + backend->ops =3D &sd_mod_ops; + + ret =3D iio_backend_register(backend); + if (ret) { + dev_err(dev, "Failed to register backend: %d\n", ret); + goto err_free_backend; + } =20 - platform_set_drvdata(pdev, iio); + return 0; =20 - return devm_iio_device_register(&pdev->dev, iio); -} +err_free_backend: + iio_backend_free(&backend->dev); + + return ret; +}; =20 static const struct of_device_id sd_adc_of_match[] =3D { { .compatible =3D "sd-modulator" }, --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A38AC04A6A for ; Thu, 27 Jul 2023 15:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234398AbjG0PHd (ORCPT ); Thu, 27 Jul 2023 11:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234379AbjG0PH3 (ORCPT ); Thu, 27 Jul 2023 11:07:29 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646333A99; Thu, 27 Jul 2023 08:07:05 -0700 (PDT) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RAGCGk027809; Thu, 27 Jul 2023 17:06:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=cHJNhS5VpKNo5Y4bSY2x6zUc/+E49ZZVtd0aUR299gM=; b=ve2AIh0qTQh8YWjBZD9RLiywztDKv6ciGlP7kjkD4DhKWNfj0l7SeS3tqY4PYr83bift /oWSNgEw8v1B/OZCH9yEHbO6A97N/4T2MgAscuGF9IBohhHb75XHhCdL8vx7iY3iNecg p7FLQB5a6etgQxJBt/wuzi/u3wIgJkrMZcSZjX8LHu/DCwDapvsqwfZKSpmEGcXjiN2Z DueUSzVd8qgcuxEJo6t+Ihx76bh/tGVRtFnYzWxUFm8PVRKctGm2J5usA8e4mwZvJuBs bWYckD7nTC4/xHTQjrW0Q2FKDl4qD/QVYe9V3T3GdxE9/a9+ybZfewAO+53RX10ZIK16 Tw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3kn2b2ay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:06:48 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BE1A6100049; Thu, 27 Jul 2023 17:06:47 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B663E209BA8; Thu, 27 Jul 2023 17:06:47 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:06:47 +0200 From: Olivier Moysan To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 09/11] ARM: dts: stm32: adopt new dfsdm bindings on stm32mp151 Date: Thu, 27 Jul 2023 17:03:20 +0200 Message-ID: <20230727150324.1157933-10-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Adapt STM32MP151 device tree to match DFSDM new bindings. Signed-off-by: Olivier Moysan --- arch/arm/boot/dts/st/stm32mp151.dtsi | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/st/stm32mp151.dtsi b/arch/arm/boot/dts/st/st= m32mp151.dtsi index 61508917521c..338457357248 100644 --- a/arch/arm/boot/dts/st/stm32mp151.dtsi +++ b/arch/arm/boot/dts/st/stm32mp151.dtsi @@ -970,7 +970,8 @@ dfsdm: dfsdm@4400d000 { =20 dfsdm0: filter@0 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <0>; interrupts =3D ; dmas =3D <&dmamux1 101 0x400 0x01>; @@ -980,7 +981,8 @@ dfsdm0: filter@0 { =20 dfsdm1: filter@1 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <1>; interrupts =3D ; dmas =3D <&dmamux1 102 0x400 0x01>; @@ -990,7 +992,8 @@ dfsdm1: filter@1 { =20 dfsdm2: filter@2 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <2>; interrupts =3D ; dmas =3D <&dmamux1 103 0x400 0x01>; @@ -1000,7 +1003,8 @@ dfsdm2: filter@2 { =20 dfsdm3: filter@3 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <3>; interrupts =3D ; dmas =3D <&dmamux1 104 0x400 0x01>; @@ -1010,7 +1014,8 @@ dfsdm3: filter@3 { =20 dfsdm4: filter@4 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <4>; interrupts =3D ; dmas =3D <&dmamux1 91 0x400 0x01>; @@ -1020,7 +1025,8 @@ dfsdm4: filter@4 { =20 dfsdm5: filter@5 { compatible =3D "st,stm32-dfsdm-adc"; - #io-channel-cells =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; reg =3D <5>; interrupts =3D ; dmas =3D <&dmamux1 92 0x400 0x01>; --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39D25C04A94 for ; Thu, 27 Jul 2023 15:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbjG0PH1 (ORCPT ); Thu, 27 Jul 2023 11:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbjG0PHW (ORCPT ); Thu, 27 Jul 2023 11:07:22 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409833A8D; Thu, 27 Jul 2023 08:07:01 -0700 (PDT) Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RBDDmt020326; Thu, 27 Jul 2023 17:06:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=8ilBa9ENL6W8qkN0huPj8difUZwDj7XXO0BtfO8LZt0=; b=TrOjk7VSKIuMIgTb6XMQC61nQWauKcz+zT/GAotTJt7FpjvT7+ibD4Ef340qd9nVuKxG c3lxHSqcwnZdFGzaiz+IALEc7yLV+utyfoCigHL43CjCO8R9FtraT9HVJZ3vbOqTUd5A UG4YxufAcMQa842sGasuWa97EiA3aSs/UQw/QAKR2tsj1QqzAYZbstJDWDvoM3A6BzYk UG2bwWfTXL8obP1nV/y5ihciMEyk33QCX9f/pC+ycj7r+SPOMrA8maEJ4ANd9tT+D02t yDfI6aEF8yEcFanJREJQz7tMQqwOYqqfnzPtZMjy+2Vr8dSSWhltX5RFcg8z82gTenFK Ng== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3qgy98ee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:06:50 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1A37D10002A; Thu, 27 Jul 2023 17:06:49 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 12B50209BA8; Thu, 27 Jul 2023 17:06:49 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:06:48 +0200 From: Olivier Moysan To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 10/11] ARM: dts: stm32: add dfsdm pins muxing on stm32mp15 Date: Thu, 27 Jul 2023 17:03:21 +0200 Message-ID: <20230727150324.1157933-11-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add STM32 DFSDM pin muxings to STM32MP15. Signed-off-by: Olivier Moysan --- arch/arm/boot/dts/st/stm32mp15-pinctrl.dtsi | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/arm/boot/dts/st/stm32mp15-pinctrl.dtsi b/arch/arm/boot/dt= s/st/stm32mp15-pinctrl.dtsi index 05c9c4f8064c..f4dd46c176f9 100644 --- a/arch/arm/boot/dts/st/stm32mp15-pinctrl.dtsi +++ b/arch/arm/boot/dts/st/stm32mp15-pinctrl.dtsi @@ -188,6 +188,45 @@ pins { }; }; =20 + dfsdm_clkout_pins_a: dfsdm-clkout-pins-0 { + pins { + pinmux =3D ; /* DFSDM_CKOUT */ + bias-disable; + drive-push-pull; + slew-rate =3D <0>; + }; + }; + + dfsdm_clkout_sleep_pins_a: dfsdm-clkout-sleep-pins-0 { + pins { + pinmux =3D ; /* DFSDM_CKOUT */ + }; + }; + + dfsdm_data1_pins_a: dfsdm-data1-pins-0 { + pins { + pinmux =3D ; /* DFSDM_DATA1 */ + }; + }; + + dfsdm_data1_sleep_pins_a: dfsdm-data1-sleep-pins-0 { + pins { + pinmux =3D ; /* DFSDM_DATA1 */ + }; + }; + + dfsdm_data3_pins_a: dfsdm-data3-pins-0 { + pins { + pinmux =3D ; /* DFSDM_DATA3 */ + }; + }; + + dfsdm_data3_sleep_pins_a: dfsdm-data3-sleep-pins-0 { + pins { + pinmux =3D ; /* DFSDM_DATA3 */ + }; + }; + ethernet0_rgmii_pins_a: rgmii-0 { pins1 { pinmux =3D , /* ETH_RGMII_CLK125 */ --=20 2.25.1 From nobody Mon Feb 9 01:12:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F124C04A94 for ; Thu, 27 Jul 2023 15:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234395AbjG0PHf (ORCPT ); Thu, 27 Jul 2023 11:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbjG0PHa (ORCPT ); Thu, 27 Jul 2023 11:07:30 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DB433583; Thu, 27 Jul 2023 08:07:06 -0700 (PDT) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36RF3OLG027833; Thu, 27 Jul 2023 17:06:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=8kootPtuej1akXRgIZj40uYTNZjB/maQQhJwmvSicyU=; b=ukz8m6iJxzBb3Iryqt8KSx1TdcAXmPHXaXAnow3s4oMHhq4vyctKF8FRhPUc4weEnZhr egQPpPvzivCZQdhWOlR3B5ND4PUcUisSUzgcXbiqcgjrTsIrQqp0n29/5csw44YzeuxF j7pfEXdLbd6Aqe1AYrMCS5TL2WZZt5LBXmVc/loMIrsiLUCQzy1tUTwC2c73GcKMVLBN C2qzboWQ9hKtk6i2PRzkbCGsMgHkw1FxsTEvFFsCbMLnSV88fNJhMtMYpXhAYsBU/29X FCwJ3HesQuO9tQzkvATT1ZfzeTAQ6qXls61BSH75XYf0F/8TQ/tPA/Y6lnf/2RtTLZNB lQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3s3kn2b2b8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 17:06:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6E06D100049; Thu, 27 Jul 2023 17:06:50 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 65852209BA8; Thu, 27 Jul 2023 17:06:50 +0200 (CEST) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Jul 2023 17:06:50 +0200 From: Olivier Moysan To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [RFC v2 11/11] ARM: dts: stm32: add dfsdm iio support on stm32mp157c-ev Date: Thu, 27 Jul 2023 17:03:22 +0200 Message-ID: <20230727150324.1157933-12-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727150324.1157933-1-olivier.moysan@foss.st.com> References: <20230727150324.1157933-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_07,2023-07-26_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This DT is an example of backend iio device used for STM32 DFSDM. DFSDM filter1 has a single input channel, while filter0 is configured to support scan mode with two input channels. Signed-off-by: Olivier Moysan --- arch/arm/boot/dts/st/stm32mp157c-ev1.dts | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/arch/arm/boot/dts/st/stm32mp157c-ev1.dts b/arch/arm/boot/dts/s= t/stm32mp157c-ev1.dts index af3800501875..edeac26f39a4 100644 --- a/arch/arm/boot/dts/st/stm32mp157c-ev1.dts +++ b/arch/arm/boot/dts/st/stm32mp157c-ev1.dts @@ -73,6 +73,27 @@ panel_backlight: panel-backlight { default-on; status =3D "okay"; }; + + sd_adc0: sd-adc0 { + compatible =3D "sd-modulator"; + #io-backend-cells =3D <0>; + vref-supply =3D <&v3v3>; + status =3D "okay"; + }; + + sd_adc1: sd-adc1 { + compatible =3D "sd-modulator"; + #io-backend-cells =3D <0>; + vref-supply =3D <&v3v3>; + status =3D "okay"; + }; + + sd_adc2: sd-adc2 { + compatible =3D "sd-modulator"; + #io-backend-cells =3D <0>; + vref-supply =3D <&v3v3>; + status =3D "okay"; + }; }; =20 &cec { @@ -99,6 +120,53 @@ dcmi_0: endpoint { }; }; =20 +&dfsdm { + pinctrl-names =3D "default", "sleep"; + pinctrl-0 =3D <&dfsdm_clkout_pins_a + &dfsdm_data1_pins_a &dfsdm_data3_pins_a>; + pinctrl-1 =3D <&dfsdm_clkout_sleep_pins_a + &dfsdm_data1_sleep_pins_a &dfsdm_data3_sleep_pins_a>; + spi-max-frequency =3D <2048000>; + status =3D "okay"; + + dfsdm0: filter@0 { + compatible =3D "st,stm32-dfsdm-adc"; + st,filter-order =3D <3>; + status =3D "okay"; + + channel@0 { + reg =3D <0>; + label =3D "in0"; + st,adc-channel-types =3D "SPI_F"; + st,adc-channel-clk-src =3D "CLKOUT"; + st,adc-alt-channel; + io-backends =3D <&sd_adc0>; + }; + + channel@1 { + reg =3D <1>; + label =3D "in1"; + st,adc-channel-types =3D "SPI_R"; + st,adc-channel-clk-src =3D "CLKOUT"; + io-backends =3D <&sd_adc1>; + }; + }; + + dfsdm1: filter@1 { + compatible =3D "st,stm32-dfsdm-adc"; + st,filter-order =3D <3>; + status =3D "okay"; + + channel@3 { + reg =3D <3>; + label =3D "in3"; + st,adc-channel-types =3D "SPI_R"; + st,adc-channel-clk-src =3D "CLKOUT"; + io-backends =3D <&sd_adc2>; + }; + }; +}; + &dsi { phy-dsi-supply =3D <®18>; #address-cells =3D <1>; --=20 2.25.1