From patchwork Mon Oct 21 17:06:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11202271 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 F04BC913 for ; Mon, 21 Oct 2019 14:08:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0EAB20882 for ; Mon, 21 Oct 2019 14:08:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="UuSNOG+n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728810AbfJUOIl (ORCPT ); Mon, 21 Oct 2019 10:08:41 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:25530 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbfJUOIk (ORCPT ); Mon, 21 Oct 2019 10:08:40 -0400 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 x9LE31Ye013898; Mon, 21 Oct 2019 10:06:08 -0400 Received: from nam04-bn3-obe.outbound.protection.outlook.com (mail-bn3nam04lp2057.outbound.protection.outlook.com [104.47.46.57]) by mx0a-00128a01.pphosted.com with ESMTP id 2vqyd6ubtg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Oct 2019 10:06:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cx+2A3RLw6x4eSoDhPjFdyWVZfiKmXAY3l9CvSc5EJW7QOKs3VMImtEqzKxBaktGH3muBT3Ph9agY57wfAx8tjQjNbgqoYZ4WP20P2bElWaLdNnpJMMFUk/4K9NBvCwZTD6zbz8IE+FlBZnWu/tXk5mJ/wJvSJcvb6f/0udlo8wlL2ZnFz/ie8F4JxZBKEHpfRZ8z5MgqIUR7heeGt2H8YRumrVTRIbnLauwQn6ppBO7DIJwrdDF5Fz0/7GUH7jWFn6XfL+Hm9vmXr2tbbdtw7nBOJCwKbHuQJLxMTU3GFlAiUi5tsUUiDacVn5Sn0BQf003dmvfABqvWfm3awosFQ== 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=7LkLHYF9+AcgnZnsjMroP//oyqGRGXaZQlmEMitedqw=; b=ASMFu83zAtyY+KSLc7Hg08M6x3UNebHTH4cYcamVac7XCFymcGomqvIS6+61InpdXxLmplPLlb39t2b3OI6zAxct1Si5Dd63qXA2Y4MrzgMZF+aVXe4RKHJ4PhODWU04oBFwzp1G4uyJShifTTeN6m7a5LakOuRSIhtKqHTq1JLL4u4+nvcme3r+YFnd1ohayYJZ+M86xHTVOds2fwIz+FIQLwkbFs2lLWpTos/cGRmOgle6K7UMGswvGNb8jbVVkFCZPVKtKjiQKGOTGlTJOi7S1iU3ndWZZFhOVPYfZRzFVv0XAX74lgopIzOMtH05biHB+SRwF+cheta+64LGyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.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=7LkLHYF9+AcgnZnsjMroP//oyqGRGXaZQlmEMitedqw=; b=UuSNOG+ngwDM0dm/E635eAYi7BLmbfNLslBlZTMgIcrKuhpMYV2KnamsGa5He+eSzVvCTLiVL59tcVlkY5Jg7DTvEub0DWH/VqIo9fhBez+/npV2KrSCR97o1tTqFghjJGyWPhkRTtajyMelBnT9vad5EetPZ/mrfbdBXMY0Cn0= Received: from CY1PR03CA0014.namprd03.prod.outlook.com (2603:10b6:600::24) by MWHPR03MB2591.namprd03.prod.outlook.com (2603:10b6:300:47::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Mon, 21 Oct 2019 14:06:05 +0000 Received: from SN1NAM02FT006.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::206) by CY1PR03CA0014.outlook.office365.com (2603:10b6:600::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.21 via Frontend Transport; Mon, 21 Oct 2019 14:06:05 +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 SN1NAM02FT006.mail.protection.outlook.com (10.152.72.68) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2367.14 via Frontend Transport; Mon, 21 Oct 2019 14:06:04 +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 x9LE5ug8013193 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 21 Oct 2019 07:05:56 -0700 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.163) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 21 Oct 2019 10:06:03 -0400 From: Beniamin Bia To: CC: , , , , , , , , , , , , , , , , Paul Cercueil , Beniamin Bia Subject: [PATCH 1/4] iio: adc: Add support for AD7091R5 ADC Date: Mon, 21 Oct 2019 20:06:05 +0300 Message-ID: <20191021170608.26412-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)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(246002)(966005)(86362001)(1076003)(356004)(50466002)(478600001)(6916009)(8936002)(8676002)(50226002)(70206006)(426003)(70586007)(44832011)(486006)(126002)(476003)(186003)(2351001)(5660300002)(14444005)(30864003)(2616005)(26005)(336012)(47776003)(51416003)(7696005)(7636002)(7416002)(305945005)(107886003)(4326008)(36756003)(6306002)(2906002)(106002)(48376002)(16586007)(54906003)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2591;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: 83b4ae52-9ffc-432f-44f4-08d7562fd016 X-MS-TrafficTypeDiagnostic: MWHPR03MB2591: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 0197AFBD92 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UoO9Mzy0EFGyUK6/Qa/cxd5G9UjT5r4dtwkpB5G5JmKVQv0FsdgTWs6x1qTUOjiezlDZrUHh4gM0qFOosPauBvRQIg6X1yd7TvAP7XKLdSVvzgJkxy5h8Z2egvJJZwSSVmNM9zO7jJNiG9OtAwzCcscYIcXnSreykIrLrxBSjdkQY8G77shluya9ZhF03HYbk0GSMFe9RqiSlE6O+AZltFBWFsxGdlLCDEkdDYfifHcokj6IYEux8PIj7FyLA1D5DnTPUxu0Q+wC6WxyV59dI+11OQ+LVuBYjXRQqjPCbDklZTl0CtYaHTeWMnaURJJMcxexm2rY2MoLxATDA2XjhASagCoLdirHT7qvZJrCBljkfqqXfuciUzn7dgalOuctT42Gv0rHUEtGGvSHMchThJyYqlxQw5zqKaT15Upk++CzeIbJDFDgufOpy+JAxKCDoVQx5SDlT+WjUxC4JnkYm615gwnW/7SqluXjUtOz9Zo= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 14:06:04.8784 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83b4ae52-9ffc-432f-44f4-08d7562fd016 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: MWHPR03MB2591 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-21_04:2019-10-21,2019-10-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1011 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910210133 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Paul Cercueil AD7091 is 4-Channel, I2C, Ultra Low Power,12-Bit ADC. 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 --- drivers/iio/adc/Kconfig | 7 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7091r-base.c | 273 +++++++++++++++++++++++++++++++++ drivers/iio/adc/ad7091r-base.h | 30 ++++ drivers/iio/adc/ad7091r5.c | 108 +++++++++++++ 5 files changed, 419 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..140413329754 --- /dev/null +++ b/drivers/iio/adc/ad7091r-base.c @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AD7091RX Analog to Digital converter driver + * + * Copyright 2014 Analog Devices Inc. + * + */ + +#include "ad7091r-base.h" + +#include +#include +#include +#include +#include +#include + +#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 REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) +#define REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) + +/* AD7091R_REG_CONF */ +#define REG_CONF_AUTO BIT(8) +#define REG_CONF_CMD BIT(10) + +#define REG_CONF_MODE_MASK (REG_CONF_AUTO | 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; +}; + +static int ad7091r_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode) +{ + int ret; + + switch (mode) { + case AD7091R_MODE_SAMPLE: + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, + REG_CONF_MODE_MASK, 0); + break; + case AD7091R_MODE_COMMAND: + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, + REG_CONF_MODE_MASK, REG_CONF_CMD); + break; + case AD7091R_MODE_AUTOCYCLE: + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, + REG_CONF_MODE_MASK, REG_CONF_AUTO); + break; + default: + ret = -EINVAL; + break; + } + + if (!ret) + st->mode = mode; + return ret; +} + +static int ad7091r_set_channel(struct ad7091r_state *st, unsigned int channel) +{ + unsigned int foo; + int ret; + + /* AD7091R_REG_CHANNEL is a 8-bit register */ + 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, &foo); +} + +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; + + /* TODO: locking */ + ret = ad7091r_set_channel(st, channel); + if (ret) + return ret; + + ret = regmap_read(st->map, AD7091R_REG_RESULT, &val); + if (ret) + return ret; + + if (REG_RESULT_CH_ID(val) != channel) + return -EIO; + + *read_val = 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(&iio_dev->mlock); + + 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(&iio_dev->mlock); + 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; /* TODO */ + + 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; + dev_set_drvdata(dev, iio_dev); + + 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 */ + ret = ad7091r_set_mode(st, AD7091R_MODE_COMMAND); + if (ret < 0) + return ret; + + ret = iio_device_register(iio_dev); + if (ret) + return ret; + + dev_dbg(dev, "Probed\n"); + return 0; +} +EXPORT_SYMBOL_GPL(ad7091r_probe); + +int ad7091r_remove(struct device *dev) +{ + struct iio_dev *iio_dev = dev_get_drvdata(dev); + + iio_device_unregister(iio_dev); + return 0; +} +EXPORT_SYMBOL_GPL(ad7091r_remove); + +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("Paul Cercueil "); +//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..7a29f86ea82b --- /dev/null +++ b/drivers/iio/adc/ad7091r-base.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AD7091RX Analog to Digital converter driver + * + * Copyright 2014 Analog Devices Inc. + * + */ + +#ifndef __DRIVERS_IIO_DAC_AD7091R_BASE_H__ +#define __DRIVERS_IIO_DAC_AD7091R_BASE_H__ + +#include +#include + +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); +int ad7091r_remove(struct device *dev); + +#endif /* __DRIVERS_IIO_DAC_AD7091R5_BASE_H__ */ diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c new file mode 100644 index 000000000000..1ba838c58c31 --- /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 Analog Devices Inc. + * + */ + +#include "ad7091r-base.h" + +#include +#include +#include + +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), +}; +#undef AD7091R_CHANNEL + +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 int ad7091r5_i2c_remove(struct i2c_client *i2c) +{ + return ad7091r_remove(&i2c->dev); +} + +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", + }, + .probe = ad7091r5_i2c_probe, + .remove = ad7091r5_i2c_remove, + .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 Mon Oct 21 17:06:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11202273 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 DC2B2913 for ; Mon, 21 Oct 2019 14:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A698521A4A for ; Mon, 21 Oct 2019 14:08:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="2rDhyAFL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728969AbfJUOIl (ORCPT ); Mon, 21 Oct 2019 10:08:41 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:25588 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728098AbfJUOIl (ORCPT ); Mon, 21 Oct 2019 10:08:41 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9LE31Ed003914; Mon, 21 Oct 2019 10:06:23 -0400 Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp2050.outbound.protection.outlook.com [104.47.33.50]) by mx0a-00128a01.pphosted.com with ESMTP id 2vqvb9kexr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 21 Oct 2019 10:06:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd/OvAfn4rWjjNKzP1oEXvCRnZptc8/EVcrMIbL6otdjsWJ8YxOnMMhMxURi44h0nzXfC6Gs0mrWlIX3DsGS0J9W92NRmDNwkZSL6d/GHntSXLf5vctYfRf/LSImwgDMWSB8P0b2qUZteoVfQzi7YgJVpINEFt5HlmWE8jjo8FIB8J1OZB530dkRIYoNVS4BzSUf4rlmW1IsSb6cEtu7MC5aWix00Exchz2IfDwAygiCy6DMCyYey8ct1D25mQHnCd7Zebsmz4GJFrKXs8ki5OGY9OdCOe9pYWW6NsmueZxntRUTbZLJYv8FNyiMLpRayk3/vck/rXEktZx3+W2c2A== 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=PWXXnHubRB/EPPkt4jriIO5RDoEYpjxW5LUL53EoYE8=; b=K1ghiB2scrqTOus2DpzqU+Y9dyBKoAp2xzroCGMiHt4+rkMexhJlcHrpYEyqGl2jwDXkdRsaoUMeciYuscP7gS/VsG7EeKav++zBLw5bTqtAbJodJRvlbtokZxt/t/ll0V1OjsRhIiMCBSPwUj2QsO3KK+CHt5EDw9JL54Sxo6J5BLLDNiRCKkTqcRvCAce8db9zNmwvSlcEAO9ZCNmqcwcFVbRsHollenVO67oLDRY9JixFgySRDwIqMqzEik8XD8sIy1cxnDPUd8Uyjbsh/P6xCN+ORnFD4+iurIGtroeJ6jAHTN3FsE4rkvBevNRo1/3v5dGHKE9muv8UsFYBOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.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=PWXXnHubRB/EPPkt4jriIO5RDoEYpjxW5LUL53EoYE8=; b=2rDhyAFLtEESiRVuvzkfoPSgt0U/MyRx2Gm6MyEyoL43u2vYfMobHiHYyRkKbD0QypxAZvpSv5q0WnNq6YZviUrelCFxijD4qPWTp8sHk4b34RRDW2HAmRYZje+x/oMeGAP4gQIWlpwjuehPMqkAI7St73I5OSsUK1CQRuN+Erc= Received: from DM6PR03CA0037.namprd03.prod.outlook.com (2603:10b6:5:100::14) by DM6PR03MB4812.namprd03.prod.outlook.com (2603:10b6:5:186::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.19; Mon, 21 Oct 2019 14:06:16 +0000 Received: from SN1NAM02FT044.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::208) by DM6PR03CA0037.outlook.office365.com (2603:10b6:5:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.20 via Frontend Transport; Mon, 21 Oct 2019 14:06:15 +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 SN1NAM02FT044.mail.protection.outlook.com (10.152.72.173) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2367.14 via Frontend Transport; Mon, 21 Oct 2019 14:06:15 +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 x9LE68aA013241 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 21 Oct 2019 07:06:08 -0700 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.163) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 21 Oct 2019 10:06:14 -0400 From: Beniamin Bia To: CC: , , , , , , , , , , , , , , , , Paul Cercueil , Beniamin Bia Subject: [PATCH 2/4] iio: adc: ad7091r5: Add scale and external VREF support Date: Mon, 21 Oct 2019 20:06:06 +0300 Message-ID: <20191021170608.26412-2-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021170608.26412-1-beniamin.bia@analog.com> References: <20191021170608.26412-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)(346002)(396003)(136003)(376002)(199004)(189003)(8676002)(86362001)(2351001)(50226002)(246002)(6916009)(50466002)(48376002)(4326008)(47776003)(70206006)(70586007)(5660300002)(36756003)(1076003)(478600001)(8936002)(336012)(107886003)(7636002)(6666004)(486006)(186003)(305945005)(44832011)(14444005)(16586007)(316002)(7416002)(26005)(356004)(76176011)(2616005)(476003)(2906002)(426003)(7696005)(51416003)(11346002)(126002)(446003)(54906003)(106002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB4812;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: 6e26f08d-0092-4e55-93dd-08d7562fd672 X-MS-TrafficTypeDiagnostic: DM6PR03MB4812: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0197AFBD92 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ZLB/zUBrH13PQNUAQObHUAWWTZyEkJhCI9p2gAmHAgaNCAHlbFxHGBuZ1G6lFoi498g8IH3HfLHEJ9+UeshFQAnNIgvwVAgNxzLcRPGpCKzKQUoYqDytcfFKs4dRnF/aw7Vzih0xf9HkskwZDs+YizHmFwrC95hCBG2xMo4hI1xvKWbH10qFvl4fe8U8A/BV+m7p9JkyS0oE/nFAOcMn28CDJw2PiCCMA4F4gaLKPufBisR6fLVxlsC+Wf9eVenSZs1Dxp58lFHE8pwnzsQjK+ROhRHsd2Ti5ODOWKU4K1rrv5afhlUlPDtkzyJATo26YSxKf4BvEIAiquwRwTHhcb9U4CdGbf+uYwxYxYLhyWwq1pDSYjf2fAyPb6DOQKlyjJn/0yAe6fuCEFxXIn6dIc8GRMdaj3ojKsBG81ZBwg= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 14:06:15.6208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e26f08d-0092-4e55-93dd-08d7562fd672 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: DM6PR03MB4812 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-21_04:2019-10-21,2019-10-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 suspectscore=1 mlxscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910210133 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 --- drivers/iio/adc/ad7091r-base.c | 42 +++++++++++++++++++++++++++++++++- drivers/iio/adc/ad7091r-base.h | 1 + drivers/iio/adc/ad7091r5.c | 5 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 140413329754..d416f0912531 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -14,6 +14,7 @@ #include #include #include +#include #define AD7091R_REG_RESULT 0 #define AD7091R_REG_CHANNEL 1 @@ -42,6 +43,7 @@ enum ad7091r_mode { struct ad7091r_state { struct device *dev; struct regmap *map; + struct regulator *reg; const struct ad7091r_chip_info *chip_info; enum ad7091r_mode mode; }; @@ -139,6 +141,21 @@ static int ad7091r_read_raw(struct iio_dev *iio_dev, ret = IIO_VAL_INT; break; + case IIO_CHAN_INFO_SCALE: + if (st->reg) { + ret = regulator_get_voltage(st->reg); + 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; @@ -215,6 +232,18 @@ int ad7091r_probe(struct device *dev, const char *name, return ret; } + st->reg = devm_regulator_get_optional(dev, "vref"); + if (IS_ERR(st->reg)) { + if (PTR_ERR(st->reg) == EPROBE_DEFER) + return -EPROBE_DEFER; + + st->reg = NULL; + } else { + ret = regulator_enable(st->reg); + if (ret) + return ret; + } + /* Use command mode by default */ ret = ad7091r_set_mode(st, AD7091R_MODE_COMMAND); if (ret < 0) @@ -222,18 +251,29 @@ int ad7091r_probe(struct device *dev, const char *name, ret = iio_device_register(iio_dev); if (ret) - return ret; + goto err_disable_reg; dev_dbg(dev, "Probed\n"); return 0; + +err_disable_reg: + if (st->reg) + regulator_disable(st->reg); + + return ret; } EXPORT_SYMBOL_GPL(ad7091r_probe); int ad7091r_remove(struct device *dev) { struct iio_dev *iio_dev = dev_get_drvdata(dev); + struct ad7091r_state *st = iio_priv(iio_dev); iio_device_unregister(iio_dev); + + if (st->reg) + regulator_disable(st->reg); + return 0; } EXPORT_SYMBOL_GPL(ad7091r_remove); diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index 7a29f86ea82b..cec4fb75fecc 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -18,6 +18,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 1ba838c58c31..65bcd8bb692a 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)), @@ -58,11 +61,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 Mon Oct 21 17:06:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11202275 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 669541515 for ; Mon, 21 Oct 2019 14:08:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3ABF62070B for ; Mon, 21 Oct 2019 14:08:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="KMg3a8xR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728924AbfJUOIl (ORCPT ); Mon, 21 Oct 2019 10:08:41 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:25426 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbfJUOIk (ORCPT ); Mon, 21 Oct 2019 10:08:40 -0400 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 x9LE3192013899; Mon, 21 Oct 2019 10:06:23 -0400 Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2053.outbound.protection.outlook.com [104.47.42.53]) by mx0a-00128a01.pphosted.com with ESMTP id 2vqyd6ubup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Oct 2019 10:06:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JcXr1YM7DMQkP+lW4K9TBb8uBSIazTUirOdKjQt4OnHMfTEgbaKpbNkRTSnMLEgRCajc6sl2CxSnLtKkakMKLtBzeSioCtKIpszjdC3L9qr9xTpDtHA03irEol1+EdYfJ6SDA18U9xmUBLZ/M/TBlA3TmEjgzBLz6buxnb2t9uji63q4qKRX3tNyI7BchgIM0+FjQFnOi7XA1hRtLM8xac0HUhrELZVm8jGAs9xzlPTR1tTEAxhg9cj7dzv1mwScx0JSRauBWeR47PEQu391AruYPbH7YeY9sIUf5Iaa69/4qD0+a3GU0afXcIPIGVuYNyesyyUXTfY4VJpYpIHBbQ== 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=cosLumCQObGjPwYhk++HWshLh6bROs/p50RbsBNFK1s=; b=X7OzIhYOw8wPvpvdQSmLeF1lmFMjYiH/MOEcryhBJXVE6dPLoELf9NLxrNlBSG6PahEpL49I6cfLjQZwJHUNtPg9TNyLBEYqQjYqe/h5hyeKs1uLCa0+vu2O9/V5D3vZNawsGASXKzrHqDwvq199fbbYz9QgqWe/S2SC3jsW47NYwKvArzCCzgQMfXBy/UOmq9AROAuzi1DAKJJ3DzwFcAHTJ3rElFUuySQq4Himw3XgU206oyAATCFeRJZXkPbVtgoVDYyXyclju5+9fVkyowaIPs8XNiG1tPLSnSxcan/nlWKO3pD6K/dWq3MiS6edm6AHVXc8ZudNph6zP7ieFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.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=cosLumCQObGjPwYhk++HWshLh6bROs/p50RbsBNFK1s=; b=KMg3a8xR4EYFfowZDqqL8SG6l/0g+FAIV6zZt9KrgL1y/5ZpynDPn27kEXpFQmhdVhGgUdOAZlHbGziEP0OWEc/hUXZerVQcyU0tHlNbmqQilzSolPV1MTEAwoxyYDmgUy472za5pIEgLq3M4V13vI9BNx2B1KmEzJEdoDwrBSE= Received: from BN6PR03CA0022.namprd03.prod.outlook.com (2603:10b6:404:23::32) by DM5PR03MB3067.namprd03.prod.outlook.com (2603:10b6:4:47::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Mon, 21 Oct 2019 14:06:21 +0000 Received: from SN1NAM02FT033.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::209) by BN6PR03CA0022.outlook.office365.com (2603:10b6:404:23::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.20 via Frontend Transport; Mon, 21 Oct 2019 14:06:21 +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 SN1NAM02FT033.mail.protection.outlook.com (10.152.72.133) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2367.14 via Frontend Transport; Mon, 21 Oct 2019 14:06:21 +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 x9LE6DRR013280 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 21 Oct 2019 07:06:13 -0700 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.163) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 21 Oct 2019 10:06:20 -0400 From: Beniamin Bia To: CC: , , , , , , , , , , , , , , , , Beniamin Bia Subject: [PATCH 3/4] dt-binding: iio: Add documentation for AD7091R5 Date: Mon, 21 Oct 2019 20:06:07 +0300 Message-ID: <20191021170608.26412-3-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021170608.26412-1-beniamin.bia@analog.com> References: <20191021170608.26412-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)(346002)(136003)(396003)(376002)(199004)(189003)(7636002)(305945005)(107886003)(4326008)(7696005)(51416003)(47776003)(76176011)(48376002)(16586007)(7416002)(54906003)(316002)(6306002)(36756003)(106002)(2906002)(50466002)(50226002)(478600001)(6916009)(8676002)(8936002)(246002)(86362001)(446003)(966005)(1076003)(6666004)(356004)(5660300002)(26005)(336012)(2616005)(486006)(126002)(426003)(70206006)(70586007)(44832011)(2351001)(11346002)(476003)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB3067;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: f660cded-0e82-4aef-10f9-08d7562fd9c2 X-MS-TrafficTypeDiagnostic: DM5PR03MB3067: X-MS-Exchange-PUrlCount: 3 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 0197AFBD92 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qpjuIYFhaFKIXYN9bssaSzta2Nz7eadO5MWfxJKGCvYxP02F6BTIAFsgJ23tOd106w/ujhaQCrNMZ3knaFTFoTYh9mAxAXnaSczWSS8DoCbH7UBJ46jPilxvQLjvYZwoDOfln3jeVqvwS2IZKu1nZa30vuxI26G08WlGjNhHdsYWXSTwaPxW0GsyQtI2HJegk4jqTb24nyo+D6obo7OWWaYh3BnLyQxO3gEib7GSLlKHrRPyjE+X4dq4cLuADRODNpitGn1hpQ9G1X7q61JDYzvH/ksKSlb0MQVby4I4c/Qi4qP05nsw2Oaqff10AeZz6ThM5AIH/WTud4enaXF4oe0gdvEamomoGG9Xa/dVIMQ9fzmRkMaroDcSIT3dh0i3YaIj3PixG8huA8hM+LpN9oQNGdH9FpbADYqEFgfHSY1Qib5k0gZTMgV58OJ3+E62AlZwfja5WU+gnG7Ekt6L9QCCcXe2Y02bzWrD0upZ4c8= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 14:06:21.1739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f660cded-0e82-4aef-10f9-08d7562fd9c2 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: DM5PR03MB3067 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-21_04:2019-10-21,2019-10-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910210133 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 --- .../bindings/iio/adc/adi,ad7091r5.yaml | 53 +++++++++++++++++++ 1 file changed, 53 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..d041cd76804e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: GPL-2.0 +%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 + + avcc-supply: + description: + Phandle to the Avcc power supply + maxItems: 1 + + interrupts: + maxItems: 1 + + +required: + - compatible + - reg + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "adi,ad7091r5"; + reg = <0x2F>; + + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio>; + }; + }; +... From patchwork Mon Oct 21 17:06:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamin Bia X-Patchwork-Id: 11202267 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 D46F1913 for ; Mon, 21 Oct 2019 14:07:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A94C421783 for ; Mon, 21 Oct 2019 14:07:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="W5Wz9/Pa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbfJUOHT (ORCPT ); Mon, 21 Oct 2019 10:07:19 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:19410 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728098AbfJUOHT (ORCPT ); Mon, 21 Oct 2019 10:07:19 -0400 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 x9LE31KR000487; Mon, 21 Oct 2019 10:06:29 -0400 Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp2052.outbound.protection.outlook.com [104.47.33.52]) by mx0b-00128a01.pphosted.com with ESMTP id 2vqv8akt3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 21 Oct 2019 10:06:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PxAwjfXbsKsGNjUmf/Xc+cAx3NiIn2unxqFA3Yfc0KZt8Yzl36OJ440YDn/g5pJY1vSPD7f9kWU4rloM6Pb0Pqns5uFeIYQP7RzJ6koeEk65Ro1PXWs1Dj2aqYIHStoXnmRSp9qiUnKGGOAo9q3FVvGanVKbVlPc3v1WGhHpnq4ipUt+OHSVMlBP3ggyyOHlGY0sV/YXimQl6/u5X2khVJdLQQfVjyyR3mNjWTVuGyEKvL0EJCzliYEROrR+f6ICHbVMzVK+RPL/sybRvyRzQyOj62Qh7d3g1OwTU9rKvsUin/FF8xHkSWfFub22bl/FMDVoNHqHxQ7zywwWnB4eJg== 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=84bgcNDK4gm60A+wcL4TAAWpl70oA/CilePQmCoZguE=; b=Gs3WDnp/w4wF/2Xirm0thskCiFzOIhSvBgl+lJnls3ewF0Qeyw0trtKPYYFc3rUEAZb2SFbIhTgnmMu2rGjlJvscUcxGOS5svzDKgBanD4H2d1bSQHQl/NBuMZtrX2tAjavMbYjZe+SLwslEUox265CVEbT0uS9kznP3fl59uPKh3a0/tlkLxr7suln1Ap6K5RUIEhSufihzoYxsTrKA5DMJxBbRMqNcvRr3RWCdqY0zoD6lOn1hKGLxHZurREz1Gp9CPxulJePwU+5/5gqLF+cozwMi7GxvIwUotp5bAEqYEAKBIxnugCcdjyxDQO97c05QNuKOq9oTsbFdJzxBvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.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=84bgcNDK4gm60A+wcL4TAAWpl70oA/CilePQmCoZguE=; b=W5Wz9/PaXVMmLgahgNQjcQ7/AJLKLwTpqo0GYpri/Zr0dtXch8Ad0/yYFG59kxNG92QYy+MyZXw0+ZDoW8+n+8rrcb5EzgDTnqSS8RSZvQevuTrYwVa/fGR/4R+FjaHmyF5l51LpeCjusV4ICSw6ulJQY0d+4PHwT/VsmmhacsU= Received: from MWHPR03CA0017.namprd03.prod.outlook.com (2603:10b6:300:117::27) by CY4PR03MB2695.namprd03.prod.outlook.com (2603:10b6:903:76::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.20; Mon, 21 Oct 2019 14:06:28 +0000 Received: from CY1NAM02FT051.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::200) by MWHPR03CA0017.outlook.office365.com (2603:10b6:300:117::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.21 via Frontend Transport; Mon, 21 Oct 2019 14:06:28 +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 CY1NAM02FT051.mail.protection.outlook.com (10.152.74.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2367.14 via Frontend Transport; Mon, 21 Oct 2019 14:06:27 +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 x9LE6KMr013315 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 21 Oct 2019 07:06:20 -0700 Received: from ben-Latitude-E6540.ad.analog.com (10.48.65.163) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 21 Oct 2019 10:06:26 -0400 From: Beniamin Bia To: CC: , , , , , , , , , , , , , , , , Beniamin Bia Subject: [PATCH 4/4] MAINTAINERS: add entry for AD7091R5 driver Date: Mon, 21 Oct 2019 20:06:08 +0300 Message-ID: <20191021170608.26412-4-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021170608.26412-1-beniamin.bia@analog.com> References: <20191021170608.26412-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)(376002)(136003)(396003)(346002)(189003)(199004)(106002)(316002)(8936002)(48376002)(8676002)(246002)(2906002)(5660300002)(4744005)(76176011)(26005)(50466002)(356004)(6666004)(7696005)(51416003)(1076003)(11346002)(86362001)(446003)(44832011)(54906003)(186003)(336012)(50226002)(16586007)(426003)(2616005)(126002)(476003)(486006)(6916009)(4326008)(6306002)(107886003)(47776003)(36756003)(70586007)(70206006)(7636002)(966005)(2351001)(7416002)(478600001)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB2695;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: d2a81c24-8299-4bdc-bc19-08d7562fddaa X-MS-TrafficTypeDiagnostic: CY4PR03MB2695: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-Forefront-PRVS: 0197AFBD92 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JthcmkJu5xOaIt69rjiqgnBHzmqWOswsrTN2oi8gcobX5k9RzVgLe5e8CoFANhBJVb4WL46ZzzmJv6yvRmmmAdJ8Tivo0LWFBAkR46tCddTeHUPtA9Q0sVNqJ2N4b43g3MkdRCWmfyNRoWS8gEYysYcCreV+MdBoIMbLZEJpGs0FvJ8Sc7h/V1P86smYKjQrHTBsWNPd5e+G0mcR9vMnZ1WbT9n/67v6LPd3j9RfWQqMEQCbO1ut0bZSVeY2tzUpJmy9sCeSp34z68PTSXcn2W5Q19A0Neolntsp/vsAWkzWfVXHCc9k3Ti4cfYLnjRSXI+/THaZc4ONR1WKIExXzHdH/Rx5h31PUUaCBWN7NS6d6nmwYW3uUYSpi6c/54uOim6lywXqy4dhq7AP7tX25TvXgB/KqswZTJ95vjEEIFKqd/S1kyJ20ZvEYPdOnRf8k1x+JN60LKm+FvIoTEwrmq68C4MYpJKzBEdOSMOAKAs= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 14:06:27.7219 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2a81c24-8299-4bdc-bc19-08d7562fddaa 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: CY4PR03MB2695 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-21_04:2019-10-21,2019-10-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 phishscore=0 adultscore=0 suspectscore=1 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910210133 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 --- 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