From nobody Wed Dec 17 20:38:27 2025 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 BC61BC61D85 for ; Tue, 21 Nov 2023 21:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234504AbjKUVfU (ORCPT ); Tue, 21 Nov 2023 16:35:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjKUVfS (ORCPT ); Tue, 21 Nov 2023 16:35:18 -0500 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27858F4; Tue, 21 Nov 2023 13:35:15 -0800 (PST) Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALIokTR013720; Tue, 21 Nov 2023 16:35:02 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 3uh26h0htd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:35:01 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLYvi8056941 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:34:57 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:34:56 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:34:56 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLYjH1019804; Tue, 21 Nov 2023 16:34:47 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 1/7] iio: adc: ad7091r-base: Set alert config and drvdata Date: Tue, 21 Nov 2023 18:34:45 -0300 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: 1gOjFPJyWy5OsUdd5U-hk2rLpsH2Lh7y X-Proofpoint-GUID: 1gOjFPJyWy5OsUdd5U-hk2rLpsH2Lh7y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210169 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Write 1 to bit 4 in the configuration register to set ALERT/BUSY/GPO pin to be used as ALERT. Set device driver data so it can be retrieved when handling alert events, avoiding null pointer dereference. Fixes: (iio: adc: Add support for AD7091R5 ADC) Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 8e252cde735b..3ecac3164446 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -28,6 +28,7 @@ #define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) =20 /* AD7091R_REG_CONF */ +#define AD7091R_REG_CONF_ALERT_EN BIT(4) #define AD7091R_REG_CONF_AUTO BIT(8) #define AD7091R_REG_CONF_CMD BIT(10) =20 @@ -232,9 +233,16 @@ int ad7091r_probe(struct device *dev, const char *name, iio_dev->channels =3D chip_info->channels; =20 if (irq) { + ret =3D regmap_update_bits(st->map, AD7091R_REG_CONF, + AD7091R_REG_CONF_ALERT_EN, BIT(4)); + if (ret) + return ret; + + dev_set_drvdata(st->dev, iio_dev); ret =3D devm_request_threaded_irq(dev, irq, NULL, - ad7091r_event_handler, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st); + ad7091r_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, name, st); if (ret) return ret; } --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 630A4C61D90 for ; Tue, 21 Nov 2023 21:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234515AbjKUVfh (ORCPT ); Tue, 21 Nov 2023 16:35:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234498AbjKUVfg (ORCPT ); Tue, 21 Nov 2023 16:35:36 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02155B9; Tue, 21 Nov 2023 13:35:32 -0800 (PST) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALGheNC024638; Tue, 21 Nov 2023 16:35:19 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3ueu275f05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:35:19 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLZHn1056973 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:35:17 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:35:16 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:35:16 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLZ5SE019986; Tue, 21 Nov 2023 16:35:07 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 2/7] MAINTAINERS: Add MAINTAINERS entry for AD7091R Date: Tue, 21 Nov 2023 18:35:05 -0300 Message-ID: <1a36ac71c6b9fbde68e29ad3dc030cef10e3d252.1700595310.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: _8W0S1nH5ZkRbu7g5WqsFXfFnWSuONuY X-Proofpoint-GUID: _8W0S1nH5ZkRbu7g5WqsFXfFnWSuONuY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 clxscore=1015 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=885 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210168 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt The driver for AD7091R was added in ca693001: iio: adc: Add support for AD7091R5 ADC but no MAINTAINERS file entry was added for it since then. Add a proper MAINTAINERS file entry for the AD7091R driver. Signed-off-by: Marcelo Schmitt --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8e0a91dc8251..008f0e73bead 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1126,6 +1126,16 @@ F: Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130 F: Documentation/devicetree/bindings/iio/adc/adi,ad4130.yaml F: drivers/iio/adc/ad4130.c =20 +ANALOG DEVICES INC AD7091R DRIVER +M: Marcelo Schmitt +L: linux-iio@vger.kernel.org +S: Supported +W: http://ez.analog.com/community/linux-device-drivers +F: Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml +F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.c +F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.h +F: drivers/iio/adc/drivers/iio/adc/ad7091r5.c + ANALOG DEVICES INC AD7192 DRIVER M: Alexandru Tachici L: linux-iio@vger.kernel.org --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 68765C61D85 for ; Tue, 21 Nov 2023 21:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234549AbjKUVf6 (ORCPT ); Tue, 21 Nov 2023 16:35:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234482AbjKUVfz (ORCPT ); Tue, 21 Nov 2023 16:35:55 -0500 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E00EDF4; Tue, 21 Nov 2023 13:35:51 -0800 (PST) Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALIokBc013729; Tue, 21 Nov 2023 16:35:38 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 3uh26h0hvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:35:38 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLZbY2057043 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:35:37 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:35:36 -0500 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; Tue, 21 Nov 2023 16:35:36 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:35:36 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLZOBS019992; Tue, 21 Nov 2023 16:35:27 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 3/7] iio: adc: ad7091r: Move defines to header file Date: Tue, 21 Nov 2023 18:35:24 -0300 Message-ID: <8aa859817e86408733a81cf31b932f0efa273c71.1700595310.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: t_u_dO_EdpMSSk5hFVbD_gKFHzO5nlGF X-Proofpoint-GUID: t_u_dO_EdpMSSk5hFVbD_gKFHzO5nlGF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210169 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Move AD7091R register, channel and event definitions to the header file so other AD7091R device drivers may use those declaration in follow up patches. Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 14 +++-------- drivers/iio/adc/ad7091r-base.h | 45 ++++++++++++++++++++++++++++++++++ drivers/iio/adc/ad7091r5.c | 39 +++-------------------------- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 3ecac3164446..ebf1c8cca25c 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -15,14 +15,6 @@ =20 #include "ad7091r-base.h" =20 -#define AD7091R_REG_RESULT 0 -#define AD7091R_REG_CHANNEL 1 -#define AD7091R_REG_CONF 2 -#define AD7091R_REG_ALERT 3 -#define AD7091R_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4) -#define AD7091R_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5) -#define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) - /* AD7091R_REG_RESULT */ #define AD7091R_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) #define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) @@ -270,7 +262,7 @@ int ad7091r_probe(struct device *dev, const char *name, } EXPORT_SYMBOL_NS_GPL(ad7091r_probe, IIO_AD7091R); =20 -static bool ad7091r_writeable_reg(struct device *dev, unsigned int reg) +bool ad7091r_writeable_reg(struct device *dev, unsigned int reg) { switch (reg) { case AD7091R_REG_RESULT: @@ -280,8 +272,9 @@ static bool ad7091r_writeable_reg(struct device *dev, u= nsigned int reg) return true; } } +EXPORT_SYMBOL_NS_GPL(ad7091r_writeable_reg, IIO_AD7091R); =20 -static bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) +bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { case AD7091R_REG_RESULT: @@ -291,6 +284,7 @@ static bool ad7091r_volatile_reg(struct device *dev, un= signed int reg) return false; } } +EXPORT_SYMBOL_NS_GPL(ad7091r_volatile_reg, IIO_AD7091R); =20 const struct regmap_config ad7091r_regmap_config =3D { .reg_bits =3D 8, diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index 509748aef9b1..2efed8ddc59a 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -8,6 +8,27 @@ #ifndef __DRIVERS_IIO_ADC_AD7091R_BASE_H__ #define __DRIVERS_IIO_ADC_AD7091R_BASE_H__ =20 +#define AD7091R_REG_RESULT 0 +#define AD7091R_REG_CHANNEL 1 +#define AD7091R_REG_CONF 2 +#define AD7091R_REG_ALERT 3 + +#define AD7091R_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4) +#define AD7091R_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5) +#define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) + +#define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ + .type =3D IIO_VOLTAGE, \ + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE), \ + .indexed =3D 1, \ + .channel =3D idx, \ + .event_spec =3D ev, \ + .num_event_specs =3D num_ev, \ + .scan_type.storagebits =3D 16, \ + .scan_type.realbits =3D bits, \ +} + struct device; struct ad7091r_state; =20 @@ -17,10 +38,34 @@ struct ad7091r_chip_info { unsigned int vref_mV; }; =20 +static const struct iio_event_spec ad7091r_events[] =3D { + { + .type =3D IIO_EV_TYPE_THRESH, + .dir =3D IIO_EV_DIR_RISING, + .mask_separate =3D BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, + { + .type =3D IIO_EV_TYPE_THRESH, + .dir =3D IIO_EV_DIR_FALLING, + .mask_separate =3D BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, + { + .type =3D IIO_EV_TYPE_THRESH, + .dir =3D IIO_EV_DIR_EITHER, + .mask_separate =3D BIT(IIO_EV_INFO_HYSTERESIS), + }, +}; + extern const struct regmap_config ad7091r_regmap_config; =20 int ad7091r_probe(struct device *dev, const char *name, const struct ad7091r_chip_info *chip_info, struct regmap *map, int irq); =20 +bool ad7091r_volatile_reg(struct device *dev, unsigned int reg); + +bool ad7091r_writeable_reg(struct device *dev, unsigned int reg); + #endif /* __DRIVERS_IIO_ADC_AD7091R_BASE_H__ */ diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c index 2f048527b7b7..9d3ccfca94ec 100644 --- a/drivers/iio/adc/ad7091r5.c +++ b/drivers/iio/adc/ad7091r5.c @@ -12,42 +12,11 @@ =20 #include "ad7091r-base.h" =20 -static const struct iio_event_spec ad7091r5_events[] =3D { - { - .type =3D IIO_EV_TYPE_THRESH, - .dir =3D IIO_EV_DIR_RISING, - .mask_separate =3D BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, - { - .type =3D IIO_EV_TYPE_THRESH, - .dir =3D IIO_EV_DIR_FALLING, - .mask_separate =3D BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, - { - .type =3D IIO_EV_TYPE_THRESH, - .dir =3D IIO_EV_DIR_EITHER, - .mask_separate =3D BIT(IIO_EV_INFO_HYSTERESIS), - }, -}; - -#define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ - .type =3D IIO_VOLTAGE, \ - .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE), \ - .indexed =3D 1, \ - .channel =3D idx, \ - .event_spec =3D ev, \ - .num_event_specs =3D num_ev, \ - .scan_type.storagebits =3D 16, \ - .scan_type.realbits =3D bits, \ -} static const struct iio_chan_spec ad7091r5_channels_irq[] =3D { - AD7091R_CHANNEL(0, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), - AD7091R_CHANNEL(1, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), - AD7091R_CHANNEL(2, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), - AD7091R_CHANNEL(3, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), }; =20 static const struct iio_chan_spec ad7091r5_channels_noirq[] =3D { --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 8BC32C61D90 for ; Tue, 21 Nov 2023 21:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234527AbjKUVgR (ORCPT ); Tue, 21 Nov 2023 16:36:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbjKUVgP (ORCPT ); Tue, 21 Nov 2023 16:36:15 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9B50B9; Tue, 21 Nov 2023 13:36:10 -0800 (PST) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALGheNL024638; Tue, 21 Nov 2023 16:35:58 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3ueu275f33-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:35:57 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLZujq057065 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:35:56 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:35:55 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:35:55 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLZidd020005; Tue, 21 Nov 2023 16:35:46 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 4/7] iio: adc: ad7091r: Alloc IIO device before generic probe Date: Tue, 21 Nov 2023 18:35:44 -0300 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: vW2cHRDoqkw-T9MK5f6KrsNPqsD5q1pK X-Proofpoint-GUID: vW2cHRDoqkw-T9MK5f6KrsNPqsD5q1pK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 clxscore=1015 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210168 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Rework ad7091r probe functions so the IIO device is allocated before the generic device probe function is called. This change is needed for a follow up patch that passes a pointer to the IIO device to a couple of regmap callback functions. Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 35 +++++++--------------------------- drivers/iio/adc/ad7091r-base.h | 22 +++++++++++++++++---- drivers/iio/adc/ad7091r5.c | 14 ++++++++++++-- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index ebf1c8cca25c..69cb5ccdbc49 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -27,21 +27,6 @@ #define AD7091R_REG_CONF_MODE_MASK \ (AD7091R_REG_CONF_AUTO | AD7091R_REG_CONF_CMD) =20 -enum ad7091r_mode { - AD7091R_MODE_SAMPLE, - AD7091R_MODE_COMMAND, - AD7091R_MODE_AUTOCYCLE, -}; - -struct ad7091r_state { - struct device *dev; - struct regmap *map; - struct regulator *vref; - const struct ad7091r_chip_info *chip_info; - enum ad7091r_mode mode; - struct mutex lock; /*lock to prevent concurent reads */ -}; - static int ad7091r_set_mode(struct ad7091r_state *st, enum ad7091r_mode mo= de) { int ret, conf; @@ -200,20 +185,14 @@ static void ad7091r_remove(void *data) regulator_disable(st->vref); } =20 -int ad7091r_probe(struct device *dev, const char *name, - const struct ad7091r_chip_info *chip_info, - struct regmap *map, int irq) +int ad7091r_probe(struct iio_dev *iio_dev, const char *name, + const struct ad7091r_chip_info *chip_info, + struct regmap *map, int irq) { - struct iio_dev *iio_dev; struct ad7091r_state *st; int ret; =20 - iio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); - if (!iio_dev) - return -ENOMEM; - st =3D iio_priv(iio_dev); - st->dev =3D dev; st->chip_info =3D chip_info; st->map =3D map; =20 @@ -231,7 +210,7 @@ int ad7091r_probe(struct device *dev, const char *name, return ret; =20 dev_set_drvdata(st->dev, iio_dev); - ret =3D devm_request_threaded_irq(dev, irq, NULL, + ret =3D devm_request_threaded_irq(st->dev, irq, NULL, ad7091r_event_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st); @@ -239,7 +218,7 @@ int ad7091r_probe(struct device *dev, const char *name, return ret; } =20 - st->vref =3D devm_regulator_get_optional(dev, "vref"); + st->vref =3D devm_regulator_get_optional(st->dev, "vref"); if (IS_ERR(st->vref)) { if (PTR_ERR(st->vref) =3D=3D -EPROBE_DEFER) return -EPROBE_DEFER; @@ -248,7 +227,7 @@ int ad7091r_probe(struct device *dev, const char *name, ret =3D regulator_enable(st->vref); if (ret) return ret; - ret =3D devm_add_action_or_reset(dev, ad7091r_remove, st); + ret =3D devm_add_action_or_reset(st->dev, ad7091r_remove, st); if (ret) return ret; } @@ -258,7 +237,7 @@ int ad7091r_probe(struct device *dev, const char *name, if (ret) return ret; =20 - return devm_iio_device_register(dev, iio_dev); + return devm_iio_device_register(st->dev, iio_dev); } EXPORT_SYMBOL_NS_GPL(ad7091r_probe, IIO_AD7091R); =20 diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index 2efed8ddc59a..405939f4eee0 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -30,7 +30,21 @@ } =20 struct device; -struct ad7091r_state; + +enum ad7091r_mode { + AD7091R_MODE_SAMPLE, + AD7091R_MODE_COMMAND, + AD7091R_MODE_AUTOCYCLE, +}; + +struct ad7091r_state { + struct device *dev; + struct regmap *map; + struct regulator *vref; + const struct ad7091r_chip_info *chip_info; + enum ad7091r_mode mode; + struct mutex lock; /*lock to prevent concurent reads */ +}; =20 struct ad7091r_chip_info { unsigned int num_channels; @@ -60,9 +74,9 @@ static const struct iio_event_spec ad7091r_events[] =3D { =20 extern const struct regmap_config ad7091r_regmap_config; =20 -int ad7091r_probe(struct device *dev, const char *name, - const struct ad7091r_chip_info *chip_info, - struct regmap *map, int irq); +int ad7091r_probe(struct iio_dev *iio_dev, const char *name, + const struct ad7091r_chip_info *chip_info, + struct regmap *map, int irq); =20 bool ad7091r_volatile_reg(struct device *dev, unsigned int reg); =20 diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c index 9d3ccfca94ec..1a27841d1bbc 100644 --- a/drivers/iio/adc/ad7091r5.c +++ b/drivers/iio/adc/ad7091r5.c @@ -42,8 +42,18 @@ static int ad7091r5_i2c_probe(struct i2c_client *i2c) { const struct i2c_device_id *id =3D i2c_client_get_device_id(i2c); const struct ad7091r_chip_info *chip_info; - struct regmap *map =3D devm_regmap_init_i2c(i2c, &ad7091r_regmap_config); + struct ad7091r_state *st; + struct iio_dev *iio_dev; + struct regmap *map; =20 + iio_dev =3D devm_iio_device_alloc(&i2c->dev, sizeof(*st)); + if (!iio_dev) + return -ENOMEM; + + st =3D iio_priv(iio_dev); + st->dev =3D &i2c->dev; + + map =3D devm_regmap_init_i2c(i2c, &ad7091r_regmap_config); if (IS_ERR(map)) return PTR_ERR(map); =20 @@ -52,7 +62,7 @@ static int ad7091r5_i2c_probe(struct i2c_client *i2c) else chip_info =3D &ad7091r5_chip_info_noirq; =20 - return ad7091r_probe(&i2c->dev, id->name, chip_info, map, i2c->irq); + return ad7091r_probe(iio_dev, id->name, chip_info, map, i2c->irq); } =20 static const struct of_device_id ad7091r5_dt_ids[] =3D { --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 5A84AC61D85 for ; Tue, 21 Nov 2023 21:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234523AbjKUVgh (ORCPT ); Tue, 21 Nov 2023 16:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234482AbjKUVgf (ORCPT ); Tue, 21 Nov 2023 16:36:35 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320BF1AC; Tue, 21 Nov 2023 13:36:32 -0800 (PST) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALIY4aj027136; Tue, 21 Nov 2023 16:36:19 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3uer08e1ns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:36:19 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLaHQG057106 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:36:17 -0500 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:36:17 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:36:16 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:36:16 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLa45o020012; Tue, 21 Nov 2023 16:36:07 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 5/7] dt-bindings: iio: Add binding documentation for AD7091R-8 Date: Tue, 21 Nov 2023 18:36:04 -0300 Message-ID: <566503a54feba35178c778a7929bced66ebd8870.1700595310.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: vz-JdBsH_myxB9kCTeCk2GGfC32oeuPb X-Proofpoint-GUID: vz-JdBsH_myxB9kCTeCk2GGfC32oeuPb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210169 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Add device tree binding documentation for AD7091R-8. Signed-off-by: Marcelo Schmitt --- .../bindings/iio/adc/adi,ad7091r8.yaml | 101 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 102 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7091r8.= yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7091r8.yaml b/= Documentation/devicetree/bindings/iio/adc/adi,ad7091r8.yaml new file mode 100644 index 000000000000..f10b6727737f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7091r8.yaml @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7091r8.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7091R8 8-Channel 12-Bit ADC + +maintainers: + - Marcelo Schmitt + +description: | + Analog Devices AD7091R-8 8-Channel 12-Bit ADC + https://www.analog.com/media/en/technical-documentation/data-sheets/AD70= 91R-2_7091R-4_7091R-8.pdf + +properties: + compatible: + enum: + - adi,ad7091r2 + - adi,ad7091r4 + - adi,ad7091r8 + + reg: + maxItems: 1 + + vref-supply: true + + spi-max-frequency: true + + adi,conversion-start-gpios: + description: + Device tree identifier of the CONVST pin. + This logic input is used to initiate conversions on the analog + input channels. + maxItems: 1 + + reset-gpios: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - adi,conversion-start-gpios + +patternProperties: + "^channel@[0-7]$": + $ref: "adc.yaml" + type: object + description: Represents the external channels which are connected to t= he ADC. + + properties: + reg: + minimum: 0 + maximum: 7 + + required: + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + + # AD7091R-2 does not have ALERT/BUSY/GPO pin + - if: + properties: + compatible: + contains: + enum: + - adi,ad7091r4 + - adi,ad7091r8 + then: + properties: + interrupts: true + else: + properties: + interrupts: false + +unevaluatedProperties: false + +examples: + - | + #include + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@0 { + compatible =3D "adi,ad7091r8"; + reg =3D <0x0>; + spi-max-frequency =3D <45454545>; + vref-supply =3D <&adc_vref>; + adi,conversion-start-gpios =3D <&gpio 25 GPIO_ACTIVE_LOW>; + reset-gpios =3D <&gpio 27 GPIO_ACTIVE_LOW>; + interrupts =3D <22 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent =3D <&gpio>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 008f0e73bead..6e7c6c866396 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1132,6 +1132,7 @@ L: linux-iio@vger.kernel.org S: Supported W: http://ez.analog.com/community/linux-device-drivers F: Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml +F: Documentation/devicetree/bindings/iio/adc/adi,ad7091r8.yaml F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.c F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.h F: drivers/iio/adc/drivers/iio/adc/ad7091r5.c --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 258E4C61D85 for ; Tue, 21 Nov 2023 21:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234542AbjKUVhF (ORCPT ); Tue, 21 Nov 2023 16:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjKUVhE (ORCPT ); Tue, 21 Nov 2023 16:37:04 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A6F5BB; Tue, 21 Nov 2023 13:37:00 -0800 (PST) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALK4dkw027130; Tue, 21 Nov 2023 16:36:46 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3uer08e1r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:36:46 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLai3I057161 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:36:45 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:36:44 -0500 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; Tue, 21 Nov 2023 16:36:43 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:36:43 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLaTHb020018; Tue, 21 Nov 2023 16:36:33 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 6/7] iio: adc: Add support for AD7091R-8 Date: Tue, 21 Nov 2023 18:36:24 -0300 Message-ID: <514295a9b760b44a710425803a41decddd3e8df8.1700595310.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: zD83nzK1WfhuWX5He1McylIDv8Y-vw9x X-Proofpoint-GUID: zD83nzK1WfhuWX5He1McylIDv8Y-vw9x X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210169 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Add support for Analog Devices AD7091R-2, AD7091R-4, and AD7091R-8 low power 12-Bit SAR ADCs. Extend ad7091r-base driver so it can be used by AD7091R-8 drivers. Signed-off-by: Marcelo Schmitt --- Device read/write might look odd due to the transfer protocol for these dev= ices. I'm glad to hear any suggestions on how to make it better. MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 16 ++ drivers/iio/adc/Makefile | 4 +- drivers/iio/adc/ad7091r-base.c | 25 ++- drivers/iio/adc/ad7091r-base.h | 15 ++ drivers/iio/adc/ad7091r5.c | 2 + drivers/iio/adc/ad7091r8.c | 272 +++++++++++++++++++++++++++++++++ 7 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 drivers/iio/adc/ad7091r8.c diff --git a/MAINTAINERS b/MAINTAINERS index 6e7c6c866396..54eff6f0c358 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1136,6 +1136,7 @@ F: Documentation/devicetree/bindings/iio/adc/adi,ad70= 91r8.yaml F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.c F: drivers/iio/adc/drivers/iio/adc/ad7091r-base.h F: drivers/iio/adc/drivers/iio/adc/ad7091r5.c +F: drivers/iio/adc/drivers/iio/adc/ad7091r8.c =20 ANALOG DEVICES INC AD7192 DRIVER M: Alexandru Tachici diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 1e2b7a2c67c6..284d898790a2 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -36,13 +36,29 @@ config AD4130 To compile this driver as a module, choose M here: the module will be called ad4130. =20 +config AD7091R + tristate + config AD7091R5 tristate "Analog Devices AD7091R5 ADC Driver" depends on I2C + select AD7091R select REGMAP_I2C help Say yes here to build support for Analog Devices AD7091R-5 ADC. =20 +config AD7091R8 + tristate "Analog Devices AD7091R8 ADC Driver" + depends on SPI + select AD7091R + select REGMAP_SPI + help + Say yes here to build support for Analog Devices AD7091R-2, AD7091R-4, + and AD7091R-8 ADC. + + To compile this driver as a module, choose M here: the module will be + called ad7091r8. + config AD7124 tristate "Analog Devices AD7124 and similar sigma-delta ADCs driver" depends on SPI_MASTER diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index c0803383a7cc..d2fda54a3259 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -7,7 +7,9 @@ obj-$(CONFIG_AB8500_GPADC) +=3D ab8500-gpadc.o obj-$(CONFIG_AD_SIGMA_DELTA) +=3D ad_sigma_delta.o obj-$(CONFIG_AD4130) +=3D ad4130.o -obj-$(CONFIG_AD7091R5) +=3D ad7091r5.o ad7091r-base.o +obj-$(CONFIG_AD7091R) +=3D ad7091r-base.o +obj-$(CONFIG_AD7091R5) +=3D ad7091r5.o +obj-$(CONFIG_AD7091R8) +=3D ad7091r8.o obj-$(CONFIG_AD7124) +=3D ad7124.o obj-$(CONFIG_AD7192) +=3D ad7192.o obj-$(CONFIG_AD7266) +=3D ad7266.o diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 69cb5ccdbc49..f9b4f91d1c4f 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -16,7 +17,8 @@ #include "ad7091r-base.h" =20 /* AD7091R_REG_RESULT */ -#define AD7091R_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) +#define AD7091R5_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) +#define AD7091R8_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x7) #define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) =20 /* AD7091R_REG_CONF */ @@ -45,10 +47,14 @@ static int ad7091r_set_mode(struct ad7091r_state *st, e= num ad7091r_mode mode) return -EINVAL; } =20 - ret =3D regmap_update_bits(st->map, AD7091R_REG_CONF, - AD7091R_REG_CONF_MODE_MASK, conf); - if (ret) - return ret; + /* AD7091R-2/4/8 don't set normal, command, autocycle modes in conf reg */ + if (st->chip_info->type =3D=3D AD7091R5) { + return 0; + ret =3D regmap_update_bits(st->map, AD7091R_REG_CONF, + AD7091R_REG_CONF_MODE_MASK, conf); + if (ret) + return ret; + } =20 st->mode =3D mode; =20 @@ -88,8 +94,13 @@ static int ad7091r_read_one(struct iio_dev *iio_dev, if (ret) return ret; =20 - if (AD7091R_REG_RESULT_CH_ID(val) !=3D channel) - return -EIO; + if (st->chip_info->type =3D=3D AD7091R5) { + if (AD7091R5_REG_RESULT_CH_ID(val) !=3D channel) + return -EIO; + } else { + if (AD7091R8_REG_RESULT_CH_ID(val) !=3D channel) + return -EIO; + } =20 *read_val =3D AD7091R_REG_RESULT_CONV_RESULT(val); =20 diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index 405939f4eee0..99e5053d1f44 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -29,6 +29,8 @@ .scan_type.realbits =3D bits, \ } =20 +#include + struct device; =20 enum ad7091r_mode { @@ -40,13 +42,26 @@ enum ad7091r_mode { struct ad7091r_state { struct device *dev; struct regmap *map; + struct gpio_desc *convst_gpio; + struct gpio_desc *reset_gpio; struct regulator *vref; const struct ad7091r_chip_info *chip_info; enum ad7091r_mode mode; struct mutex lock; /*lock to prevent concurent reads */ + __be16 tx_buf __aligned(IIO_DMA_MINALIGN); + __be16 rx_buf; +}; + +enum ad7091r_device_type { + AD7091R2, + AD7091R4, + AD7091R5, + AD7091R8, }; =20 struct ad7091r_chip_info { + const char *name; + enum ad7091r_device_type type; unsigned int num_channels; const struct iio_chan_spec *channels; unsigned int vref_mV; diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c index 1a27841d1bbc..5f587e0b55df 100644 --- a/drivers/iio/adc/ad7091r5.c +++ b/drivers/iio/adc/ad7091r5.c @@ -27,12 +27,14 @@ static const struct iio_chan_spec ad7091r5_channels_noi= rq[] =3D { }; =20 static const struct ad7091r_chip_info ad7091r5_chip_info_irq =3D { + .type =3D AD7091R5, .channels =3D ad7091r5_channels_irq, .num_channels =3D ARRAY_SIZE(ad7091r5_channels_irq), .vref_mV =3D 2500, }; =20 static const struct ad7091r_chip_info ad7091r5_chip_info_noirq =3D { + .type =3D AD7091R5, .channels =3D ad7091r5_channels_noirq, .num_channels =3D ARRAY_SIZE(ad7091r5_channels_noirq), .vref_mV =3D 2500, diff --git a/drivers/iio/adc/ad7091r8.c b/drivers/iio/adc/ad7091r8.c new file mode 100644 index 000000000000..806d858d4c0e --- /dev/null +++ b/drivers/iio/adc/ad7091r8.c @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Analog Devices AD7091R8 12-bit SAR ADC driver + * + * Copyright 2023 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "ad7091r-base.h" + +#define AD7091R8_REG_ADDR_MSK GENMASK(15, 11) +#define AD7091R8_RD_WR_FLAG_MSK BIT(10) +#define AD7091R8_REG_DATA_MSK GENMASK(9, 0) + +#define AD7091R2_DEV_NAME "ad7091r-2" +#define AD7091R4_DEV_NAME "ad7091r-4" +#define AD7091R8_DEV_NAME "ad7091r-8" + +#define AD7091R_SPI_CHIP_INFO(n) { \ + .name =3D AD7091R##n##_DEV_NAME, \ + .type =3D AD7091R##n, \ + .channels =3D ad7091r##n##_channels, \ + .num_channels =3D ARRAY_SIZE(ad7091r##n##_channels), \ + .vref_mV =3D 2500, \ +} + +#define AD7091R_SPI_CHIP_INFO_IRQ(n) { \ + .name =3D AD7091R##n##_DEV_NAME, \ + .type =3D AD7091R##n, \ + .channels =3D ad7091r##n##_channels_irq, \ + .num_channels =3D ARRAY_SIZE(ad7091r##n##_channels_irq), \ + .vref_mV =3D 2500, \ +} + +static const struct iio_chan_spec ad7091r2_channels[] =3D { + AD7091R_CHANNEL(0, 12, NULL, 0), + AD7091R_CHANNEL(1, 12, NULL, 0), +}; + +static const struct iio_chan_spec ad7091r4_channels[] =3D { + AD7091R_CHANNEL(0, 12, NULL, 0), + AD7091R_CHANNEL(1, 12, NULL, 0), + AD7091R_CHANNEL(2, 12, NULL, 0), + AD7091R_CHANNEL(3, 12, NULL, 0), +}; + +static const struct iio_chan_spec ad7091r4_channels_irq[] =3D { + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), +}; + +static const struct iio_chan_spec ad7091r8_channels[] =3D { + AD7091R_CHANNEL(0, 12, NULL, 0), + AD7091R_CHANNEL(1, 12, NULL, 0), + AD7091R_CHANNEL(2, 12, NULL, 0), + AD7091R_CHANNEL(3, 12, NULL, 0), + AD7091R_CHANNEL(4, 12, NULL, 0), + AD7091R_CHANNEL(5, 12, NULL, 0), + AD7091R_CHANNEL(6, 12, NULL, 0), + AD7091R_CHANNEL(7, 12, NULL, 0), +}; + +static const struct iio_chan_spec ad7091r8_channels_irq[] =3D { + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(4, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(5, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(6, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), + AD7091R_CHANNEL(7, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), +}; + +static const struct ad7091r_chip_info ad7091r_spi_chip_info[] =3D { + [AD7091R2] =3D AD7091R_SPI_CHIP_INFO(2), + [AD7091R4] =3D AD7091R_SPI_CHIP_INFO(4), + [AD7091R8] =3D AD7091R_SPI_CHIP_INFO(8), +}; + +static const struct ad7091r_chip_info ad7091r_spi_chip_info_irq[] =3D { + [AD7091R4] =3D AD7091R_SPI_CHIP_INFO_IRQ(4), + [AD7091R8] =3D AD7091R_SPI_CHIP_INFO_IRQ(8), +}; + +static void ad7091r_pulse_convst(struct ad7091r_state *st) +{ + gpiod_set_value_cansleep(st->convst_gpio, 1); + gpiod_set_value_cansleep(st->convst_gpio, 0); +} + +static const struct regmap_config ad7091r_spi_regmap_config[] =3D { + [AD7091R2] =3D { + .reg_bits =3D 5, + .pad_bits =3D 3, + .val_bits =3D 16, + .volatile_reg =3D ad7091r_volatile_reg, + .writeable_reg =3D ad7091r_writeable_reg, + .max_register =3D AD7091R_REG_CH_HYSTERESIS(2), + }, + [AD7091R4] =3D { + .reg_bits =3D 5, + .pad_bits =3D 3, + .val_bits =3D 16, + .volatile_reg =3D ad7091r_volatile_reg, + .writeable_reg =3D ad7091r_writeable_reg, + .max_register =3D AD7091R_REG_CH_HYSTERESIS(4), + }, + [AD7091R8] =3D { + .reg_bits =3D 5, + .pad_bits =3D 3, + .write_flag_mask =3D BIT(2), + .val_bits =3D 16, + .volatile_reg =3D ad7091r_volatile_reg, + .writeable_reg =3D ad7091r_writeable_reg, + .max_register =3D AD7091R_REG_CH_HYSTERESIS(8), + }, +}; + +static int ad7091r_regmap_bus_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct ad7091r_state *st =3D context; + struct spi_device *spi =3D container_of(st->dev, struct spi_device, dev); + const struct regmap_config *conf =3D &ad7091r_spi_regmap_config[st->chip_= info->type]; + int ret; + + struct spi_transfer t[] =3D { + { + .tx_buf =3D &st->tx_buf, + .len =3D 2, + .cs_change =3D 1, + }, { + .rx_buf =3D &st->rx_buf, + .len =3D 2, + } + }; + + if (reg =3D=3D AD7091R_REG_RESULT) + ad7091r_pulse_convst(st); + + reg <<=3D conf->pad_bits; + st->tx_buf =3D cpu_to_be16(reg << 8); + + ret =3D spi_sync_transfer(spi, t, ARRAY_SIZE(t)); + if (ret < 0) + return ret; + + *val =3D be16_to_cpu(st->rx_buf); + return 0; +} + +static int ad7091r_regmap_bus_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct ad7091r_state *st =3D context; + struct spi_device *spi =3D container_of(st->dev, struct spi_device, dev); + + /* + * AD7091R-2/-4/-8 protocol (datasheet page 31) is to do a single SPI + * transfer with reg address set in bits B15:B11 and value set in B9:B0. + */ + st->tx_buf =3D cpu_to_be16(FIELD_PREP(AD7091R8_REG_DATA_MSK, val) | + FIELD_PREP(AD7091R8_RD_WR_FLAG_MSK, 1) | + FIELD_PREP(AD7091R8_REG_ADDR_MSK, reg)); + + return spi_write(spi, &st->tx_buf, 2); +} + +static struct regmap_bus ad7091r8_regmap_bus =3D { + .reg_read =3D ad7091r_regmap_bus_reg_read, + .reg_write =3D ad7091r_regmap_bus_reg_write, + .reg_format_endian_default =3D REGMAP_ENDIAN_BIG, + .val_format_endian_default =3D REGMAP_ENDIAN_BIG, +}; + +static int ad7091r8_gpio_setup(struct ad7091r_state *st) +{ + st->convst_gpio =3D devm_gpiod_get(st->dev, "adi,conversion-start", + GPIOD_OUT_LOW); + if (IS_ERR(st->convst_gpio)) + return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio), + "Error getting convst GPIO: %ld\n", + PTR_ERR(st->convst_gpio)); + + st->reset_gpio =3D devm_gpiod_get_optional(st->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(st->reset_gpio)) + return PTR_ERR(st->reset_gpio); + + if (st->reset_gpio) { + fsleep(20); + gpiod_set_value_cansleep(st->reset_gpio, 0); + } + + return 0; +} + +static int ad7091r8_spi_probe(struct spi_device *spi) +{ + const struct ad7091r_chip_info *chip_info; + struct ad7091r_state *st; + struct iio_dev *iio_dev; + struct regmap *map; + int ret; + + chip_info =3D spi_get_device_match_data(spi); + if (!chip_info) + return -EINVAL; + + iio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!iio_dev) + return -ENOMEM; + + st =3D iio_priv(iio_dev); + st->dev =3D &spi->dev; + + map =3D devm_regmap_init(&spi->dev, &ad7091r8_regmap_bus, st, + &ad7091r_spi_regmap_config[chip_info->type]); + + if (IS_ERR(map)) + return dev_err_probe(&spi->dev, PTR_ERR(map), + "Error initializing spi regmap: %ld\n", + PTR_ERR(map)); + + ret =3D ad7091r8_gpio_setup(st); + if (ret < 0) + return ret; + + if (spi->irq) + chip_info =3D &ad7091r_spi_chip_info_irq[chip_info->type]; + + return ad7091r_probe(iio_dev, chip_info->name, chip_info, map, spi->irq); +} + +static const struct of_device_id ad7091r8_of_match[] =3D { + { .compatible =3D "adi,ad7091r2", .data =3D &ad7091r_spi_chip_info[AD7091= R2] }, + { .compatible =3D "adi,ad7091r4", .data =3D &ad7091r_spi_chip_info[AD7091= R4] }, + { .compatible =3D "adi,ad7091r8", .data =3D &ad7091r_spi_chip_info[AD7091= R8] }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad7091r8_of_match); + +static const struct spi_device_id ad7091r8_spi_id[] =3D { + { "ad7091r2", (kernel_ulong_t)&ad7091r_spi_chip_info[AD7091R2] }, + { "ad7091r4", (kernel_ulong_t)&ad7091r_spi_chip_info[AD7091R4] }, + { "ad7091r8", (kernel_ulong_t)&ad7091r_spi_chip_info[AD7091R8] }, + { }, +}; +MODULE_DEVICE_TABLE(spi, ad7091r8_spi_id); + +static struct spi_driver ad7091r8_driver =3D { + .driver =3D { + .name =3D "ad7091r8", + .of_match_table =3D ad7091r8_of_match, + }, + .probe =3D ad7091r8_spi_probe, + .id_table =3D ad7091r8_spi_id, +}; +module_spi_driver(ad7091r8_driver); + +MODULE_AUTHOR("Marcelo Schmitt "); +MODULE_DESCRIPTION("Analog Devices AD7091R8 ADC driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_AD7091R); --=20 2.42.0 From nobody Wed Dec 17 20:38:27 2025 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 B5EC6C61D85 for ; Tue, 21 Nov 2023 21:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234573AbjKUVhY (ORCPT ); Tue, 21 Nov 2023 16:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbjKUVhW (ORCPT ); Tue, 21 Nov 2023 16:37:22 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AAADD56; Tue, 21 Nov 2023 13:37:19 -0800 (PST) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3ALJCwNP027036; Tue, 21 Nov 2023 16:37:06 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3uer08e1sq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 16:37:06 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3ALLb50d057183 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Nov 2023 16:37:05 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 21 Nov 2023 16:37:04 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 21 Nov 2023 16:37:04 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3ALLaqiC020026; Tue, 21 Nov 2023 16:36:55 -0500 From: To: , , , , , CC: Marcelo Schmitt , , Subject: [PATCH 7/7] iio: adc: ad7091r-base: Add debugfs reg access Date: Tue, 21 Nov 2023 18:36:52 -0300 Message-ID: <3fdf3d1815b5181dc01490e2500b4eb4fe3fe579.1700595310.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: SJ1pnIOPXoI6aswxSRZj1tMCS0ZsKlAS X-Proofpoint-GUID: SJ1pnIOPXoI6aswxSRZj1tMCS0ZsKlAS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_11,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311210169 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marcelo Schmitt Add direct register access support for AD7091R-2/-4/-5/-8 ADCs. Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index f9b4f91d1c4f..798f7b3cc7e1 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -157,8 +157,20 @@ static int ad7091r_read_raw(struct iio_dev *iio_dev, return ret; } =20 +static int ad7091r_reg_access(struct iio_dev *indio_dev, unsigned int reg, + unsigned int writeval, unsigned int *readval) +{ + struct ad7091r_state *st =3D iio_priv(indio_dev); + + if (readval) + return regmap_read(st->map, reg, readval); + + return regmap_write(st->map, reg, writeval); +} + static const struct iio_info ad7091r_info =3D { .read_raw =3D ad7091r_read_raw, + .debugfs_reg_access =3D &ad7091r_reg_access, }; =20 static irqreturn_t ad7091r_event_handler(int irq, void *private) --=20 2.42.0