From patchwork Fri Nov 15 13:57:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11246393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E252A930 for ; Fri, 15 Nov 2019 13:57:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAAFA2073A for ; Fri, 15 Nov 2019 13:57:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="You3WFPF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727659AbfKON52 (ORCPT ); Fri, 15 Nov 2019 08:57:28 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:41652 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfKON51 (ORCPT ); Fri, 15 Nov 2019 08:57:27 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFDm0xN000401; Fri, 15 Nov 2019 08:56:55 -0500 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2056.outbound.protection.outlook.com [104.47.49.56]) by mx0a-00128a01.pphosted.com with ESMTP id 2w7prk1k8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 08:56:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bcNq8Gci/U9rrD+EFV9G0d39D9FAjhrCzeDuna61QSUI1zZqqmuRQtvgcbSz6KP1rZ+XJX7kPeJ+oz68fU7r/3Tkf9tNlmn2vlPbCi3LUOOanMJO1KoWWxe3AKxItHWc3vCagBORAxGdfeTHuM2fUU8Fg4UYe9vil1bkR16If6duXAUL5FGGmQIHrPd+uWIVs/y6DDg5rPifE+yComYzrFTI9LpCGhIh8NeRevUpsulk6HovcpYU122wreDma2Jsek66jM5u8W83eg7xMHv7VRTr450Js0SwynB03cQjB83u7LZR8U7kSq/iitHkinXm16o4gKWz5zAAigN9l4FGrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iokQfkBUrZdmlsXIZOPlgHsjlMAWrQBYkL7CoRBeVI0=; b=kcFkpmViDv2dkgosHmGrhthc+53xD09yhvuZW+X2SgQwtU+bCWKSTIcGkVikqCoIIefyMvGh8jjFHWh8L7Pi50IWOgxTLchoYwxROIslSyxW4faaJdhyk3RqWB4aAl2t9Ph0RniWXYPN5r/Y3HVeQDto9ZwTyr4IzZX/8kCikXkSxY1Zybby/4dQNlwcTOx+pUWcnE4jhNxMGy6stYmGFbTo5GMC57uJAxBksyLXB/nfCVXcXk7F4lhJ9Tsy6XS1xsER1f3oOgswYm8k5TAewyweDH/ShLR8IhnosD7wU5ysIX/iJ50fox9I2mr4EADCDfn7E3LaBor3FAhtzCaw6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iokQfkBUrZdmlsXIZOPlgHsjlMAWrQBYkL7CoRBeVI0=; b=You3WFPFZGKWq8/49zBoPbTuLMw1pt7f95MOYrxqzqSBd/S/WeVNI+edJ4TsogD0AQ8ma1E6oX29Lc8T/tL8zVWAZ1LylhBQ/axfxA+2nevWUl9btXwAAXV7UcvOZ6VGBO0SrSIXiEiWZDBcYZh2jeMp01jGMJaJ8x7SIfatlQ4= Received: from BN6PR03CA0089.namprd03.prod.outlook.com (2603:10b6:405:6f::27) by MWHPR03MB2495.namprd03.prod.outlook.com (2603:10b6:300:8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.27; Fri, 15 Nov 2019 13:56:52 +0000 Received: from SN1NAM02FT018.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::201) by BN6PR03CA0089.outlook.office365.com (2603:10b6:405:6f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.27 via Frontend Transport; Fri, 15 Nov 2019 13:56:51 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT018.mail.protection.outlook.com (10.152.72.122) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:56:51 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAFDugEr003023 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2019 05:56:42 -0800 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.231) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Nov 2019 08:56:49 -0500 From: Beniamin Bia To: CC: , , , , , , , , , , , , Paul Cercueil , Beniamin Bia Subject: [PATCH v5 1/4] iio: adc: Add support for AD7091R5 ADC Date: Fri, 15 Nov 2019 15:57:20 +0200 Message-ID: <20191115135723.12219-1-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(136003)(376002)(396003)(189003)(199004)(6666004)(356004)(2906002)(36756003)(486006)(7636002)(70586007)(70206006)(305945005)(47776003)(5660300002)(54906003)(2616005)(30864003)(2351001)(7696005)(4326008)(476003)(16586007)(126002)(186003)(7416002)(44832011)(106002)(316002)(6916009)(26005)(51416003)(6306002)(8676002)(966005)(246002)(86362001)(50226002)(426003)(8936002)(336012)(50466002)(478600001)(14444005)(48376002)(107886003)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2495;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46fd23c0-39b0-4526-4076-08d769d3aa8a X-MS-TrafficTypeDiagnostic: MWHPR03MB2495: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 02229A4115 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rr8/+Hi0/kR5J8RGvUX1wU2L2ZNsrMyxVZUSHzedcg/5DigzHl+4KM8qGp7M5PvU/Vfc+RmalOr4TQcjF5mR9TX7YeQwqz9VmU8bpb8Ensqoa0tK9LMEYigeJ8r7+K1v5WTE9qYqIUNz/YSU3OY9BeF3Z4kxho9uYP7VJ4CeF81DC+G1zQ9bgrU+pkT1UFsDO/JNv+5kieHWDKDKDJ+IIR5sNaeqhKImGfuho4FnLeJuc1IC0ANUBvAkc8kZi2jh9hZr5yJ6TKxT3G0p365oluq6vt42H1k3eTDPnAWQbAf84MfPNGN67nFssJvsCfGwNHAKWKcazABf5pvBO2pa7WhKPtS3PEADJxtCzrNaBDgFjjFAyI7LItyoT19bUPwNgWz99807muwaH0UEwtyXff/LSsED7IurlXTu8p/5ekr5dGYL7ULXE7tkLs5cWQpAjSqPV6Po9YfmTA9SjK3Uonm5l08+BcZ5/8/4Zy0CsfY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2019 13:56:51.5176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46fd23c0-39b0-4526-4076-08d769d3aa8a X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2495 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150126 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Paul Cercueil AD7091R5 is 4-Channel, I2C, Ultra Low Power,12-Bit ADC. This driver will also support AD7091R2/4/8 in the future. Datasheet: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad7091r-5.pdf Signed-off-by: Paul Cercueil Co-developed-by: Beniamin Bia Signed-off-by: Beniamin Bia --- Changes in v5: -nothing changed drivers/iio/adc/Kconfig | 7 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7091r-base.c | 260 +++++++++++++++++++++++++++++++++ drivers/iio/adc/ad7091r-base.h | 25 ++++ drivers/iio/adc/ad7091r5.c | 108 ++++++++++++++ 5 files changed, 401 insertions(+) create mode 100644 drivers/iio/adc/ad7091r-base.c create mode 100644 drivers/iio/adc/ad7091r-base.h create mode 100644 drivers/iio/adc/ad7091r5.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 7e3286265a38..80b1b9551749 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -22,6 +22,13 @@ config AD7124 To compile this driver as a module, choose M here: the module will be called ad7124. +config AD7091R5 + tristate "Analog Devices AD7091R5 ADC Driver" + depends on I2C + select REGMAP_I2C + help + Say yes here to build support for Analog Devices AD7091R-5 ADC. + config AD7266 tristate "Analog Devices AD7265/AD7266 ADC driver" depends on SPI_MASTER diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index ef9cc485fb67..55e44735aaac 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -6,6 +6,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o obj-$(CONFIG_AD7124) += ad7124.o +obj-$(CONFIG_AD7091R5) += ad7091r5.o ad7091r-base.o obj-$(CONFIG_AD7266) += ad7266.o obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7298) += ad7298.o diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c new file mode 100644 index 000000000000..854de7c654c2 --- /dev/null +++ b/drivers/iio/adc/ad7091r-base.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AD7091RX Analog to Digital converter driver + * + * Copyright 2014-2019 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "ad7091r-base.h" + +#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) + +/* AD7091R_REG_CONF */ +#define AD7091R_REG_CONF_AUTO BIT(8) +#define AD7091R_REG_CONF_CMD BIT(10) + +#define AD7091R_REG_CONF_MODE_MASK \ + (AD7091R_REG_CONF_AUTO | AD7091R_REG_CONF_CMD) + +enum ad7091r_mode { + AD7091R_MODE_SAMPLE, + AD7091R_MODE_COMMAND, + AD7091R_MODE_AUTOCYCLE, +}; + +struct ad7091r_state { + struct device *dev; + struct regmap *map; + 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 mode) +{ + int ret, conf; + + switch (mode) { + case AD7091R_MODE_SAMPLE: + conf = 0; + break; + case AD7091R_MODE_COMMAND: + conf = AD7091R_REG_CONF_CMD; + break; + case AD7091R_MODE_AUTOCYCLE: + conf = AD7091R_REG_CONF_AUTO; + break; + default: + return -EINVAL; + } + + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, + AD7091R_REG_CONF_MODE_MASK, conf); + if (ret) + return ret; + + st->mode = mode; + + return 0; +} + +static int ad7091r_set_channel(struct ad7091r_state *st, unsigned int channel) +{ + unsigned int dummy; + int ret; + + /* AD7091R_REG_CHANNEL specified which channels to be converted */ + ret = regmap_write(st->map, AD7091R_REG_CHANNEL, + BIT(channel) | (BIT(channel) << 8)); + if (ret) + return ret; + + /* + * There is a latency of one conversion before the channel conversion + * sequence is updated + */ + return regmap_read(st->map, AD7091R_REG_RESULT, &dummy); +} + +static int ad7091r_read_one(struct iio_dev *iio_dev, + unsigned int channel, unsigned int *read_val) +{ + struct ad7091r_state *st = iio_priv(iio_dev); + unsigned int val; + int ret; + + ret = ad7091r_set_channel(st, channel); + if (ret) + return ret; + + ret = regmap_read(st->map, AD7091R_REG_RESULT, &val); + if (ret) + return ret; + + if (AD7091R_REG_RESULT_CH_ID(val) != channel) + return -EIO; + + *read_val = AD7091R_REG_RESULT_CONV_RESULT(val); + + return 0; +} + +static int ad7091r_read_raw(struct iio_dev *iio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long m) +{ + struct ad7091r_state *st = iio_priv(iio_dev); + unsigned int read_val; + int ret; + + mutex_lock(&st->lock); + + switch (m) { + case IIO_CHAN_INFO_RAW: + if (st->mode != AD7091R_MODE_COMMAND) { + ret = -EBUSY; + goto unlock; + } + + ret = ad7091r_read_one(iio_dev, chan->channel, &read_val); + if (ret) + goto unlock; + + *val = read_val; + ret = IIO_VAL_INT; + break; + + default: + ret = -EINVAL; + break; + } + +unlock: + mutex_unlock(&st->lock); + return ret; +} + +static const struct iio_info ad7091r_info = { + .read_raw = ad7091r_read_raw, +}; + +static irqreturn_t ad7091r_event_handler(int irq, void *private) +{ + struct ad7091r_state *st = (struct ad7091r_state *) private; + struct iio_dev *iio_dev = dev_get_drvdata(st->dev); + unsigned int i, read_val; + int ret; + s64 timestamp = iio_get_time_ns(iio_dev); + + ret = regmap_read(st->map, AD7091R_REG_ALERT, &read_val); + if (ret) + return IRQ_HANDLED; + + for (i = 0; i < st->chip_info->num_channels; i++) { + if (read_val & BIT(i * 2)) + iio_push_event(iio_dev, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), timestamp); + if (read_val & BIT(i * 2 + 1)) + iio_push_event(iio_dev, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), timestamp); + } + + return IRQ_HANDLED; +} + +int ad7091r_probe(struct device *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; + + iio_dev = devm_iio_device_alloc(dev, sizeof(*st)); + if (!iio_dev) + return -ENOMEM; + + st = iio_priv(iio_dev); + st->dev = dev; + st->chip_info = chip_info; + st->map = map; + + iio_dev->dev.parent = dev; + iio_dev->name = name; + iio_dev->info = &ad7091r_info; + iio_dev->modes = INDIO_DIRECT_MODE; + + iio_dev->num_channels = chip_info->num_channels; + iio_dev->channels = chip_info->channels; + + if (irq) { + ret = devm_request_threaded_irq(dev, irq, NULL, + ad7091r_event_handler, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st); + if (ret) + return ret; + } + + /* Use command mode by default to convert only desired channels*/ + ret = ad7091r_set_mode(st, AD7091R_MODE_COMMAND); + if (ret) + return ret; + + return devm_iio_device_register(dev, iio_dev); +} +EXPORT_SYMBOL_GPL(ad7091r_probe); + +static bool ad7091r_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case AD7091R_REG_RESULT: + case AD7091R_REG_ALERT: + return false; + default: + return true; + } +} + +static bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case AD7091R_REG_RESULT: + case AD7091R_REG_ALERT: + return true; + default: + return false; + } +} + +const struct regmap_config ad7091r_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + .writeable_reg = ad7091r_writeable_reg, + .volatile_reg = ad7091r_volatile_reg, +}; +EXPORT_SYMBOL_GPL(ad7091r_regmap_config); + +MODULE_AUTHOR("Beniamin Bia "); +MODULE_DESCRIPTION("Analog Devices AD7091Rx multi-channel converters"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h new file mode 100644 index 000000000000..b0b4fe01a681 --- /dev/null +++ b/drivers/iio/adc/ad7091r-base.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AD7091RX Analog to Digital converter driver + * + * Copyright 2014-2019 Analog Devices Inc. + */ + +#ifndef __DRIVERS_IIO_ADC_AD7091R_BASE_H__ +#define __DRIVERS_IIO_ADC_AD7091R_BASE_H__ + +struct device; +struct ad7091r_state; + +struct ad7091r_chip_info { + unsigned int num_channels; + const struct iio_chan_spec *channels; +}; + +extern const struct regmap_config ad7091r_regmap_config; + +int ad7091r_probe(struct device *dev, const char *name, + const struct ad7091r_chip_info *chip_info, + struct regmap *map, int irq); + +#endif /* __DRIVERS_IIO_ADC_AD7091R_BASE_H__ */ diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c new file mode 100644 index 000000000000..30ff0108a6ed --- /dev/null +++ b/drivers/iio/adc/ad7091r5.c @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AD7091R5 Analog to Digital converter driver + * + * Copyright 2014-2019 Analog Devices Inc. + */ + +#include +#include +#include +#include + +#include "ad7091r-base.h" + +static const struct iio_event_spec ad7091r5_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), + }, +}; + +#define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ + .type = IIO_VOLTAGE, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .indexed = 1, \ + .channel = idx, \ + .event_spec = ev, \ + .num_event_specs = num_ev, \ +} +static const struct iio_chan_spec ad7091r5_channels_irq[] = { + 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)), +}; + +static const struct iio_chan_spec ad7091r5_channels_noirq[] = { + 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 ad7091r_chip_info ad7091r5_chip_info_irq = { + .channels = ad7091r5_channels_irq, + .num_channels = ARRAY_SIZE(ad7091r5_channels_irq), +}; + +static const struct ad7091r_chip_info ad7091r5_chip_info_noirq = { + .channels = ad7091r5_channels_noirq, + .num_channels = ARRAY_SIZE(ad7091r5_channels_noirq), +}; + +static int ad7091r5_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + const struct ad7091r_chip_info *chip_info; + struct regmap *map = devm_regmap_init_i2c(i2c, &ad7091r_regmap_config); + + if (IS_ERR(map)) + return PTR_ERR(map); + + if (i2c->irq) + chip_info = &ad7091r5_chip_info_irq; + else + chip_info = &ad7091r5_chip_info_noirq; + + return ad7091r_probe(&i2c->dev, id->name, chip_info, map, i2c->irq); +} + +static const struct of_device_id ad7091r5_dt_ids[] = { + { .compatible = "adi,ad7091r5" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ad7091r5_dt_ids); + +static const struct i2c_device_id ad7091r5_i2c_ids[] = { + {"ad7091r5", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, ad7091r5_i2c_ids); + +static struct i2c_driver ad7091r5_driver = { + .driver = { + .name = "ad7091r5", + .of_match_table = ad7091r5_dt_ids, + }, + .probe = ad7091r5_i2c_probe, + .id_table = ad7091r5_i2c_ids, +}; +module_i2c_driver(ad7091r5_driver); + +MODULE_AUTHOR("Beniamin Bia "); +MODULE_DESCRIPTION("Analog Devices AD7091R5 multi-channel ADC driver"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Nov 15 13:57:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11246395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9389D13B2 for ; Fri, 15 Nov 2019 13:57:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62D3D2073A for ; Fri, 15 Nov 2019 13:57:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="iQIwGcRo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727509AbfKON50 (ORCPT ); Fri, 15 Nov 2019 08:57:26 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:41654 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbfKON50 (ORCPT ); Fri, 15 Nov 2019 08:57:26 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFDm0xO000401; Fri, 15 Nov 2019 08:56:58 -0500 Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp2051.outbound.protection.outlook.com [104.47.33.51]) by mx0a-00128a01.pphosted.com with ESMTP id 2w7prk1k8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 08:56:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ku/VeAjIWWBMFLj2FukU1O/NpjBRSwN9d7DB7+NT3CWtQc+oSFYm3wgxuvSMCw7wbWdajZGxO1ecDXggps9TNLEo1K9F/YVZPOIeDVmoVVW+GYcicjJmSq38mByc/KCLMOuhmX9goiqsJ0AJFQHqU0AW3uZowQtEBgf4GpKlCZxboizd5tAcpScPb9UK558Votf/zi3lxDHgBndvVNk7BVQbgnMvnq2fkxR6QLBY8sj2UNxHfikQoaUDgvXe/QAEjIhcZ+adEeci/So02Z3zxgJX8IS892ceKTDKfMPWDDxy2rKE9BX3joUgEtizbQiSMgOE4rUbnJxFmztv/GDKFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d+rQS7dnye0s1FzYn4rQvwNFg7kcB959BXD/vqi0hoc=; b=kZN6flqh3X+2naN1yFAfXBwVKeTAVyZyI+mGC5QzCkBcDapDwNYyJz3YnY1IekDlniS6ts4WIi2TpV8msarCnoEyjZFImDSWGHSAuBjQ981bvJM+kdTxDxh0ode2THGKS/w/xBX/iRt2XzaCI3Bq1Ud4cv/tZCUs6krl5ae914fvzx+VPZ/7wu+1eGQM4DAbQC45c5l/JV1Nndl2FppYNgLO8rXjwFfdw5NU9sKZzSYjnE016ItheclSJUjrtDtEOnUETKiyz91OfzC8bpVyvfVEBB4Agwv/v6eQKZIMzRKEolXN6yLglsafbSWz35QqHs7gNiY0zIzEJ8mRctgr3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d+rQS7dnye0s1FzYn4rQvwNFg7kcB959BXD/vqi0hoc=; b=iQIwGcRoWPkzMDL78FfgvJDgaDrlTy5jrAAbyNKa9YRKaWQ68JGTpP89S6W/HIp48c0TjS7X+EOZ7Vwhu/20V8NYhRkbYEnxOo81mkMh77/YQBxLAA9Txq1oTQ5GRmpAC7710SN+P0Et2JPN+MRZtDCbhDX33mYdkZrsOPTxqUY= Received: from BN6PR03CA0092.namprd03.prod.outlook.com (2603:10b6:405:6f::30) by CO2PR03MB2197.namprd03.prod.outlook.com (2603:10b6:102:12::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.29; Fri, 15 Nov 2019 13:56:56 +0000 Received: from SN1NAM02FT043.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::201) by BN6PR03CA0092.outlook.office365.com (2603:10b6:405:6f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22 via Frontend Transport; Fri, 15 Nov 2019 13:56:56 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT043.mail.protection.outlook.com (10.152.72.184) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:56:56 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAFDulUA003076 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2019 05:56:47 -0800 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.231) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Nov 2019 08:56:55 -0500 From: Beniamin Bia To: CC: , , , , , , , , , , , , Paul Cercueil , Beniamin Bia Subject: [PATCH v5 2/4] iio: adc: ad7091r5: Add scale and external VREF support Date: Fri, 15 Nov 2019 15:57:21 +0200 Message-ID: <20191115135723.12219-2-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115135723.12219-1-beniamin.bia@analog.com> References: <20191115135723.12219-1-beniamin.bia@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(396003)(136003)(376002)(189003)(199004)(7416002)(5660300002)(7636002)(305945005)(26005)(8676002)(478600001)(1076003)(106002)(2906002)(186003)(70586007)(70206006)(8936002)(246002)(2351001)(50226002)(50466002)(51416003)(14444005)(36756003)(76176011)(48376002)(7696005)(426003)(336012)(107886003)(6916009)(54906003)(47776003)(316002)(2616005)(476003)(446003)(44832011)(486006)(4326008)(86362001)(356004)(126002)(11346002)(16586007)(6666004);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2197;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cca9f709-6320-490a-ef73-08d769d3ad35 X-MS-TrafficTypeDiagnostic: CO2PR03MB2197: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 02229A4115 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m1FEAImiamyZkP+F9W/EDOkvBLcr/8NZ0QkP6JKbDf+F0q/yyB5XkihFVMHjm9+W6i8BMQonLXY3Xo514jrDa8o8BQVAs5uj3RQZSEssDzEIJBiUa7iah84umaexHDXgpVy7HJfDYg1OHT6b6Im/mLlr6f/8V5m0/58wDSUfWMxLp/8PnDrsiICfLo89Ki2JoaE1y9bU/d62i0qTtcN4lYs/v8qc/gBaulrk7PbNSv2IEK/RB51/tFkJXXcSPAq+qlfy52okFU/MbcKGOZsWqRfKp7ZPvjJ7AG5Y7UaTg0++0INg1gAi17qu0GEKpDJt3i1dufvaE7VBzOjGNgRDPLpbRNFSpk5YgeVz4/rNdkiPNDln6tAa25YzAi9PU+Zsl29HPoQl3/fKVO9xEVXJdwrsXuNwD++l7wrGu/yTZD7OorNZXrw7JQjxfPkgGwsc X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2019 13:56:56.0022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cca9f709-6320-490a-ef73-08d769d3ad35 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2197 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxlogscore=999 suspectscore=1 clxscore=1015 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150126 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Paul Cercueil The scale can now be obtained with the "in_voltage_scale" file. By default, the scale returned corresponds to the internal VREF of 2.5V. It is possible to use an external VREF (through the REFIN/REFOUT pin of the chip), by passing a regulator to the driver. The scale will then be calculated according to the voltage reported by the regulator. Signed-off-by: Paul Cercueil Co-developed-by: Beniamin Bia Signed-off-by: Beniamin Bia --- Changes in v5: -check if error is -eprobe instead of eprobe -one bracket aligned drivers/iio/adc/ad7091r-base.c | 38 ++++++++++++++++++++++++++++++++++ drivers/iio/adc/ad7091r-base.h | 1 + drivers/iio/adc/ad7091r5.c | 5 +++++ 3 files changed, 44 insertions(+) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 854de7c654c2..58fcf1ff8c76 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "ad7091r-base.h" @@ -42,6 +43,7 @@ enum ad7091r_mode { 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 */ @@ -141,6 +143,21 @@ static int ad7091r_read_raw(struct iio_dev *iio_dev, ret = IIO_VAL_INT; break; + case IIO_CHAN_INFO_SCALE: + if (st->vref) { + ret = regulator_get_voltage(st->vref); + if (ret < 0) + goto unlock; + + *val = ret / 1000; + } else { + *val = st->chip_info->vref_mV; + } + + *val2 = chan->scan_type.realbits; + ret = IIO_VAL_FRACTIONAL_LOG2; + break; + default: ret = -EINVAL; break; @@ -183,6 +200,13 @@ static irqreturn_t ad7091r_event_handler(int irq, void *private) return IRQ_HANDLED; } +static void ad7091r_remove(void *data) +{ + struct ad7091r_state *st = data; + + regulator_disable(st->vref); +} + int ad7091r_probe(struct device *dev, const char *name, const struct ad7091r_chip_info *chip_info, struct regmap *map, int irq) @@ -216,6 +240,20 @@ int ad7091r_probe(struct device *dev, const char *name, return ret; } + st->vref = devm_regulator_get_optional(dev, "vref"); + if (IS_ERR(st->vref)) { + if (PTR_ERR(st->reg) == -EPROBE_DEFER) + return -EPROBE_DEFER; + st->vref = NULL; + } else { + ret = regulator_enable(st->vref); + if (ret) + return ret; + ret = devm_add_action_or_reset(dev, ad7091r_remove, st); + if (ret) + return ret; + } + /* Use command mode by default to convert only desired channels*/ ret = ad7091r_set_mode(st, AD7091R_MODE_COMMAND); if (ret) diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index b0b4fe01a681..509748aef9b1 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -14,6 +14,7 @@ struct ad7091r_state; struct ad7091r_chip_info { unsigned int num_channels; const struct iio_chan_spec *channels; + unsigned int vref_mV; }; extern const struct regmap_config ad7091r_regmap_config; diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c index 30ff0108a6ed..9665679c3ea6 100644 --- a/drivers/iio/adc/ad7091r5.c +++ b/drivers/iio/adc/ad7091r5.c @@ -35,10 +35,13 @@ static const struct iio_event_spec ad7091r5_events[] = { #define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ .type = IIO_VOLTAGE, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ .indexed = 1, \ .channel = idx, \ .event_spec = ev, \ .num_event_specs = num_ev, \ + .scan_type.storagebits = 16, \ + .scan_type.realbits = bits, \ } static const struct iio_chan_spec ad7091r5_channels_irq[] = { AD7091R_CHANNEL(0, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), @@ -57,11 +60,13 @@ static const struct iio_chan_spec ad7091r5_channels_noirq[] = { static const struct ad7091r_chip_info ad7091r5_chip_info_irq = { .channels = ad7091r5_channels_irq, .num_channels = ARRAY_SIZE(ad7091r5_channels_irq), + .vref_mV = 2500, }; static const struct ad7091r_chip_info ad7091r5_chip_info_noirq = { .channels = ad7091r5_channels_noirq, .num_channels = ARRAY_SIZE(ad7091r5_channels_noirq), + .vref_mV = 2500, }; static int ad7091r5_i2c_probe(struct i2c_client *i2c, From patchwork Fri Nov 15 13:57:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11246397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 368BE930 for ; Fri, 15 Nov 2019 13:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D84F2073A for ; Fri, 15 Nov 2019 13:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="TUyAIH7F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727508AbfKON5x (ORCPT ); Fri, 15 Nov 2019 08:57:53 -0500 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:54426 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbfKON5x (ORCPT ); Fri, 15 Nov 2019 08:57:53 -0500 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFDlo4a005536; Fri, 15 Nov 2019 08:57:33 -0500 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2058.outbound.protection.outlook.com [104.47.49.58]) by mx0b-00128a01.pphosted.com with ESMTP id 2w7pr6t499-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 08:57:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cDjZRCdUmpcJWJrSHFVNgNjGwLJ34fnO6ApGM3zunWSqgzkXAV7Lj3cSoPykZHFtj+OpRry5kv/OeDAMxo2WJInE0q+1JIT/JZjESqdphY8j4HwedYAztc/BHxVC+egTm/leh/YYYVUlQrDOPflONAiEqVrb2jbodp3VgoSTQr9NWi1PKxJ7Y+ftvQ7sgbEhz259e+qXu+1jeeU1ZSZPOnMF8+jT/r26pZOTUYJIWTjPPAy6uyz0sXICiJ1iHlf6jG3s4UEohgKZPhJlUJvLGq9i5hts1cFI8CxnU4wfVpSdxizeu2WCDNJjs8DVYmwPkUgblb9bl43M8jVxbAvvjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M04F2C9o4js6J6QnEpHb0CRH9AxEa5A/7C0KTQZ2v94=; b=nb3RCq6OwEjeCDPnow1BDfuBFWsgLsjPRn5Qx6HZ+RPnGTJ+z6rq2+PsRDh40SDgvE0V65q/bd5iXFTscf9CPmjnJOPQ3xXGJLRW2NZjI3zt7U6f4GoKUGfb7d1uDEOkvyXC88AvzbcYLSJJ1Az20G78vn0exyvj/zxGqhUQtgTsj0c9dMdZ903sARZKQWpK8Nn4FV84W5BbEIAUG63mElKMFfbSlPs/XJtaPgFY6f9Oxk9GJWUBMCyLQpw5aAFAynV8QRExalv2CvuNdrQbrkDWqprqF4TTuyfqmxzwcl8+pJhZyGdH5q7JMkMvaeu/c08smrOIxgKiNFisdpYMlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M04F2C9o4js6J6QnEpHb0CRH9AxEa5A/7C0KTQZ2v94=; b=TUyAIH7FkktI+TMETVOVnLsuSDYoLvX9TNUEcmoRokN5MWMJTRJC/MkVT3ADWPNemOqztakyp0VGkJ7tlNJpsfdhGNKyot4yw8WfjRlNkFe2fwQ444pe5a187A/uUQnm/2A6oEyHk9HhRfiNMz5iTj0XjSdMPypkYYsW0FHA//U= Received: from BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) by BN7PR03MB3601.namprd03.prod.outlook.com (2603:10b6:406:c7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22; Fri, 15 Nov 2019 13:57:00 +0000 Received: from SN1NAM02FT050.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::200) by BY5PR03CA0023.outlook.office365.com (2603:10b6:a03:1e0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:57:00 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT050.mail.protection.outlook.com (10.152.72.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:56:59 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAFDuoAP003082 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2019 05:56:50 -0800 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.231) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Nov 2019 08:56:58 -0500 From: Beniamin Bia To: CC: , , , , , , , , , , , , Beniamin Bia Subject: [PATCH v5 3/4] dt-binding: iio: Add documentation for AD7091R5 Date: Fri, 15 Nov 2019 15:57:22 +0200 Message-ID: <20191115135723.12219-3-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115135723.12219-1-beniamin.bia@analog.com> References: <20191115135723.12219-1-beniamin.bia@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(396003)(136003)(346002)(376002)(189003)(199004)(6306002)(48376002)(478600001)(7696005)(44832011)(76176011)(1076003)(50466002)(11346002)(446003)(2616005)(186003)(5660300002)(356004)(126002)(426003)(51416003)(7636002)(26005)(336012)(2906002)(86362001)(6666004)(36756003)(106002)(486006)(476003)(7416002)(54906003)(305945005)(4326008)(2351001)(16586007)(316002)(966005)(70206006)(6916009)(47776003)(107886003)(70586007)(50226002)(246002)(8676002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR03MB3601;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8d290b1-4547-466e-1991-08d769d3af62 X-MS-TrafficTypeDiagnostic: BN7PR03MB3601: X-MS-Exchange-PUrlCount: 3 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 02229A4115 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Oxlytygu9aBVhKRW52HW2CVzJXiRPXttU+EMJxYzi9enEv5g2xhedjLbtYZP+F9eaC6mEQgf1gk6tTPOlK7/0mbzvQNRgkQberrLirbIXCR5A9okXlVGtJwTtkKw0d99wpqBzliPY4yAQC0fEMR0rNfjstvohFlQmp8yKVIfgNuyidlF6FYH44MZbr5NAn8E/zSViOf/WCB6iaH3HxgqR4688R+Ncc2aMyUruqQXdxfXSiSmgQqHjJP+McnyV+nPm+zcSFcoczbJSMkeHyTvDGU7V66DuIQBAIDB3t/MPht68JH5wozUBjk7QEsT9ItOjhYds2Uqcqdw5qAlbbScGT/uPZTHmG6538mL4eeAVijuEnVHxuCJU8KSvbG6r/QLyRIZKPtSbYsGsXp9QmDcSgXxwNzyIqnsbekVUEGnfsRM6Ls07BRHE9k8D6qDTDgkozBE7ECFu1XY4WuaOhTqCV/48YGTGX9+8vGUO2SZco= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2019 13:56:59.6451 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8d290b1-4547-466e-1991-08d769d3af62 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3601 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150126 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Documentation for AD7091R5 ADC was added. Signed-off-by: Beniamin Bia Reviewed-by: Rob Herring --- Changes in v5: -nothing changed .../bindings/iio/adc/adi,ad7091r5.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml new file mode 100644 index 000000000000..31ffa275f5fa --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7091r5.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7091R5 4-Channel 12-Bit ADC + +maintainers: + - Beniamin Bia + +description: | + Analog Devices AD7091R5 4-Channel 12-Bit ADC + https://www.analog.com/media/en/technical-documentation/data-sheets/ad7091r-5.pdf + +properties: + compatible: + enum: + - adi,ad7091r5 + + reg: + maxItems: 1 + + vref-supply: + description: + Phandle to the vref power supply + + interrupts: + maxItems: 1 + + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + adc@2f { + compatible = "adi,ad7091r5"; + reg = <0x2f>; + + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio>; + }; + }; +... From patchwork Fri Nov 15 13:57:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11246391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04154930 for ; Fri, 15 Nov 2019 13:57:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D05392073A for ; Fri, 15 Nov 2019 13:57:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="ckM6OXTi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbfKON5c (ORCPT ); Fri, 15 Nov 2019 08:57:32 -0500 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:33776 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfKON5b (ORCPT ); Fri, 15 Nov 2019 08:57:31 -0500 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFDm2Ap000883; Fri, 15 Nov 2019 08:57:05 -0500 Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2054.outbound.protection.outlook.com [104.47.36.54]) by mx0b-00128a01.pphosted.com with ESMTP id 2w7prg200r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 08:57:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/0KGkJ0DjGIhRj5Q2VUqgLhUR8PRj2WWI8pZUvFrECUFHwHl7sTNWUYmc5FY02rPpoCsisYG4vlLwyYAHurbpCkFg8bu3bqn6tzrnD7A6/7Ed36M5Eqp7g3v28r9L4shdXOKXfrLw1DAPWzRHhfn3TNxg6giIvEkUnXIHXo3+cJxplHADxzWVcrsFs5iOI4apnJIFQpeWaSMvO/NvXmFNK+6PzUM/bTzqJ4HKvaUhGA7bXtz1VzIK/G38RftDTTwLFT6TTVnmBFesn8pOe6iHCjmng9k52WkO4Umcljl51NX0dJyy/7Gx1uzQ1H9XYx9PcSwg+gM/d87zJ1imN6+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k0vzK/qgF7I7l4GXj3CMMNUnGg2gI5RHY1JdLyJDCaw=; b=lmbpt6eu3Kckv+eLraoq6VWHk3umytzcY3ybP0Uhq/1eVy7RbkXg1UjX+DHn1sf2rkR8iBdPwY4JQDImuGILKCkZE2Gl7ykdPaemDZTMAohavVy1BIJtWNxCzWAqtfq6ePR6+SK6Wr66PDEZww3HztUM4t2TYarDxirt5FnquusbZRa2XSgt9gsuSOXbXhhOtCGLzcmE2oO8lZNAffW7lx3et/j8G+1Nd+s0Mmv+fljRblDjhWasYIEBMT+dGIRh8jfrBY7y0wtCKV3VkVWzgh+kv4bdMta8NMmx9oDyIB1npUIY2N7sl8T+DU4vs4FQhYu4uUgasL5Ux8eXcsoLtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k0vzK/qgF7I7l4GXj3CMMNUnGg2gI5RHY1JdLyJDCaw=; b=ckM6OXTiTsHrA5NTdywxGZtgZkKSP/0w7iZPbad3+XLKFnQ7Lue317O/nn4ToN4v0dpfVI/81fCvtyk8zQ2sIo+tkPi4bx9HYxyN0B/Qj7ZJmF8dYcWcJdhcgQYJkz+yohs8IsWsIyhPGHpBBUHX9JeyMCszghupj7zXRQMdOTU= Received: from BN3PR03CA0057.namprd03.prod.outlook.com (2a01:111:e400:7a4d::17) by BN6PR03MB2740.namprd03.prod.outlook.com (2603:10b6:404:5b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Fri, 15 Nov 2019 13:57:03 +0000 Received: from BL2NAM02FT017.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::204) by BN3PR03CA0057.outlook.office365.com (2a01:111:e400:7a4d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:57:03 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT017.mail.protection.outlook.com (10.152.77.174) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 13:57:03 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAFDuslW003086 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2019 05:56:54 -0800 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.231) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Nov 2019 08:57:02 -0500 From: Beniamin Bia To: CC: , , , , , , , , , , , , Beniamin Bia Subject: [PATCH v5 4/4] MAINTAINERS: add entry for AD7091R5 driver Date: Fri, 15 Nov 2019 15:57:23 +0200 Message-ID: <20191115135723.12219-4-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115135723.12219-1-beniamin.bia@analog.com> References: <20191115135723.12219-1-beniamin.bia@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(39860400002)(346002)(136003)(396003)(199004)(189003)(486006)(106002)(107886003)(48376002)(7416002)(126002)(44832011)(16586007)(47776003)(5660300002)(8676002)(50226002)(8936002)(336012)(316002)(356004)(6666004)(246002)(7636002)(305945005)(26005)(186003)(6916009)(6306002)(478600001)(70586007)(36756003)(54906003)(70206006)(966005)(2351001)(76176011)(426003)(446003)(1076003)(50466002)(7696005)(4744005)(2906002)(4326008)(11346002)(476003)(51416003)(86362001)(2616005);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2740;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f394538d-e087-4a7a-9ddc-08d769d3b175 X-MS-TrafficTypeDiagnostic: BN6PR03MB2740: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-Forefront-PRVS: 02229A4115 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8BhPCSYCS70yMvfqHFw9CABCbnBqu38Yx3OlVZN0LeHvzbwLp4KEYaRJbxSZSjk07eR0bkIGPOi/ei8TeO0zG0spgfgSabOz8pgpOOREtHg5uKjBULPiDXr6lnEq1EJa7vZqk/qab8fhKso4r9abiFxa6N9MIDJZc3/BPBoq/RbkKO7LcZwCv4fp6i7upL6MplCNiieemwn8VkYyIMgcgeBHAbtsoB9AIF+90FHVvHJOg3MioJ3yvney5r9JkYawaPrMhVz4XETH+OOy9+mp2+c+nG+VUWrX35Ut4hJpkH9gupi/fbVlICTsogbaOrcgE0PlY1C+ZE5J6HwGBHKxWdMTtz8501dml+rQIfDbfiBIYNok4y+9fHF1Lb449sFsBpGu19N67dPYb7zyNKaFWf2pOwS7uaIwd0dq0S9yxx5RirTjp6wh1WWEhQEzBviXe46dwlPqnomvNKsziCU2EqIOOV316R5OAec1aDZV0Lg= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2019 13:57:03.1905 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f394538d-e087-4a7a-9ddc-08d769d3b175 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2740 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 mlxlogscore=999 bulkscore=0 clxscore=1015 adultscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150126 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add Beniamin Bia as a maintainer for AD7091R5 ADC. Signed-off-by: Beniamin Bia --- Changes in v5: -nothing changed MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2e01d0f0b0e5..7f1e4b88688f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -893,6 +893,14 @@ S: Supported F: drivers/iio/dac/ad5758.c F: Documentation/devicetree/bindings/iio/dac/ad5758.txt +ANALOG DEVICES INC AD7091R5 DRIVER +M: Beniamin Bia +L: linux-iio@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: drivers/iio/adc/ad7091r5.c +F: Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml + ANALOG DEVICES INC AD7124 DRIVER M: Stefan Popa L: linux-iio@vger.kernel.org