From patchwork Thu Feb 28 14:23:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 422BB1575 for ; Thu, 28 Feb 2019 14:23:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30A472F080 for ; Thu, 28 Feb 2019 14:23:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2422D2F0BA; Thu, 28 Feb 2019 14:23:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DF122F080 for ; Thu, 28 Feb 2019 14:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730851AbfB1OXj (ORCPT ); Thu, 28 Feb 2019 09:23:39 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37546 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbfB1OXj (ORCPT ); Thu, 28 Feb 2019 09:23:39 -0500 Received: by mail-qk1-f194.google.com with SMTP id m9so12159906qkl.4; Thu, 28 Feb 2019 06:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DHEBv4Q2zYB3htWqIruxgGEurudCHBmc91Ab9FY6wqU=; b=lo05kdHPpBA/qNqZBlUtOeGO4g9poRVrZ8Ak95EDTvBc5gtt0UQzqI2ZjeR2UNdPRt WwdAaSRMreda9PuYtYeHqbFX1JyiCCJ8Eh53RO1dazuUYK9u9ylCD1KQNTbw59N8lJIx wQ6tXabm18e4de3bu7y94mXoZapTin+PoqfX/0xKwiqM4QvpzU42W4nJk0DtbtOG2ICN m1Ry1MijWOCqTeuSDWQR0vFJmjhfjLBi+ScZyJsLOcWbDJcKp0u1qDRdk0I/MjuCHnTd 70Y9nNBdXZgFBtqP3A/P69InqxYKeLMmXjGwtfbk29XymFI0NjLy5ZD3ekV88G1pZIN5 6bYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DHEBv4Q2zYB3htWqIruxgGEurudCHBmc91Ab9FY6wqU=; b=TzbLri5yEYII3T5hdEs7/QrXjrqQsM0to6RBT2MX8Him0XHE8xm4vqiqPupLnUQao1 QRKwQFWkdziN0mqBT5M/3WLB1GbWSabjSRtsyMxNa6a2QsRlsIBdJrS1HxULre90onqj mb1reI+mlc6VPZ5BhCpL+zoS7DshHYxPqn74sPQY9XaFWX47d/RXqv6m2g7LX2wsKmgn 0LGHTws9ROZ6eVDoq0Mku6MvQ+tX/NiYVP0kF6iEPg8RIejrKxW3rviRw9f9b/SFuZ+Q zfzb5AOBtW5V8DUQe0B2QuwI9kPpMC2aT1l3ZhxJyB9gBVBo9Eql7S/cDEzKs5iZ6U1t C+AA== X-Gm-Message-State: APjAAAUhVCTzZOXlTkRi7fElz5NNVtzZ1FrjEWjcGGnGgEgSAGXhhFBy fx9t5Ujfusc8BTUwhyKavxQ= X-Google-Smtp-Source: APXvYqxNKfUra2XLtUIzq21rw/+LakWYWFbWoSTjDmR3FYlriwmSSE6mQh8q/xBTN1CqEFdOotMfNw== X-Received: by 2002:ae9:e20e:: with SMTP id c14mr6713656qkc.155.1551363818027; Thu, 28 Feb 2019 06:23:38 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id g33sm812541qtk.44.2019.02.28.06.23.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:23:37 -0800 (PST) Date: Thu, 28 Feb 2019 11:23:32 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 1/9] staging: iio: ad7780: add gain & filter gpio support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, the AD7780 driver only supported gpio for the 'powerdown' pin. This commit adds suppport for the 'gain' and 'filter' pin. Signed-off-by: Renato Lui Geh Signed-off-by: Giuliano Belinassi Co-developed-by: Giuliano Belinassi --- Changes in v3: - Renamed ad7780_chip_info's filter to odr - Renamed ad778x_filter to ad778x_odr_avail - Changed vref variable from unsigned int to unsigned long long to avoid overflow - Removed unnecessary AD_SD_CHANNEL macro Changes in v4: - Removed useless macro - Added default case for switch to suppress warning - Removed chunks belonging to filter reading, adding these as a patch for itself drivers/staging/iio/adc/ad7780.c | 90 +++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index c4a85789c2db..87fbcf510d45 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -39,6 +39,12 @@ #define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2) #define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | AD7170_PAT2) +#define AD7780_GAIN_MIDPOINT 64 +#define AD7780_FILTER_MIDPOINT 13350 + +static const unsigned int ad778x_gain[2] = { 1, 128 }; +static const unsigned int ad778x_odr_avail[2] = { 10000, 16700 }; + struct ad7780_chip_info { struct iio_chan_spec channel; unsigned int pattern_mask; @@ -50,7 +56,10 @@ struct ad7780_state { const struct ad7780_chip_info *chip_info; struct regulator *reg; struct gpio_desc *powerdown_gpio; - unsigned int gain; + struct gpio_desc *gain_gpio; + struct gpio_desc *filter_gpio; + unsigned int gain; + unsigned int int_vref_mv; struct ad_sigma_delta sd; }; @@ -104,17 +113,65 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, voltage_uv = regulator_get_voltage(st->reg); if (voltage_uv < 0) return voltage_uv; - *val = (voltage_uv / 1000) * st->gain; + voltage_uv /= 1000; + *val = voltage_uv * st->gain; *val2 = chan->scan_type.realbits - 1; + st->int_vref_mv = voltage_uv; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; + default: + break; } return -EINVAL; } +static int ad7780_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long m) +{ + struct ad7780_state *st = iio_priv(indio_dev); + const struct ad7780_chip_info *chip_info = st->chip_info; + unsigned long long vref; + unsigned int full_scale, gain; + + if (!chip_info->is_ad778x) + return 0; + + switch (m) { + case IIO_CHAN_INFO_SCALE: + if (val != 0) + return -EINVAL; + + vref = st->int_vref_mv * 1000000LL; + full_scale = 1 << (chip_info->channel.scan_type.realbits - 1); + gain = DIV_ROUND_CLOSEST(vref, full_scale); + gain = DIV_ROUND_CLOSEST(gain, val2); + st->gain = gain; + if (gain < AD7780_GAIN_MIDPOINT) + gain = 0; + else + gain = 1; + gpiod_set_value(st->gain_gpio, gain); + break; + case IIO_CHAN_INFO_SAMP_FREQ: + if (1000*val + val2/1000 < AD7780_FILTER_MIDPOINT) + val = 0; + else + val = 1; + gpiod_set_value(st->filter_gpio, val); + break; + default: + break; + } + + return 0; +} + static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, unsigned int raw_sample) { @@ -126,10 +183,7 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, return -EIO; if (chip_info->is_ad778x) { - if (raw_sample & AD7780_GAIN) - st->gain = 1; - else - st->gain = 128; + st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; } return 0; @@ -173,6 +227,7 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { static const struct iio_info ad7780_info = { .read_raw = ad7780_read_raw, + .write_raw = ad7780_write_raw, }; static int ad7780_probe(struct spi_device *spi) @@ -222,6 +277,29 @@ static int ad7780_probe(struct spi_device *spi) goto error_disable_reg; } + if (st->chip_info->is_ad778x) { + st->gain_gpio = devm_gpiod_get_optional(&spi->dev, + "adi,gain", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gain_gpio)) { + ret = PTR_ERR(st->gain_gpio); + dev_err(&spi->dev, "Failed to request gain GPIO: %d\n", + ret); + goto error_disable_reg; + } + + st->filter_gpio = devm_gpiod_get_optional(&spi->dev, + "adi,filter", + GPIOD_OUT_HIGH); + if (IS_ERR(st->filter_gpio)) { + ret = PTR_ERR(st->filter_gpio); + dev_err(&spi->dev, + "Failed to request filter GPIO: %d\n", + ret); + goto error_disable_reg; + } + } + ret = ad_sd_setup_buffer_and_trigger(indio_dev); if (ret) goto error_disable_reg; From patchwork Thu Feb 28 14:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38E0A1805 for ; Thu, 28 Feb 2019 14:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 294C12E90B for ; Thu, 28 Feb 2019 14:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CEE22EC4F; Thu, 28 Feb 2019 14:24:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB1FE2E90B for ; Thu, 28 Feb 2019 14:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732388AbfB1OYT (ORCPT ); Thu, 28 Feb 2019 09:24:19 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38178 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbfB1OYS (ORCPT ); Thu, 28 Feb 2019 09:24:18 -0500 Received: by mail-qk1-f194.google.com with SMTP id p15so12150813qkl.5; Thu, 28 Feb 2019 06:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=s2xJk5kuw9HzXyjOYa9ht3wKQWc0/gmfp6f0SF77AbQ=; b=PoryDmHwTvBgL6wqXaBkxyEHWXpwVAFtQE2cJwM/Ev7UWc5YNZ1LXUu52pw9IW9dYM p45vKrFuhDGFUHc9kX8Tboe0FSqeQbyOrqPFyEPCzet0gPNHmB32gm3ty6/VOUkRLp25 43MKyAGwes0baq2nCpBsykZPAoBOALDWj5OmaHjb1ddl+YWKiOTLOGrLISoqm0aPEhhr YP7L7nYvwZPeqIKmCUkWFTPCDJQzJFLmYf8jXj8XTgls5cgmuJC6QAFMEIN4HsU8eHJf 7S4mQAxIvZRBaolxCKWwyDdB4i5utuRKCMZAYzs7Y1wxh11Qb7XkWCJusqlYpaiE+mg6 nlAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=s2xJk5kuw9HzXyjOYa9ht3wKQWc0/gmfp6f0SF77AbQ=; b=Fst573rbJOit1Tqd0s04DCyiwgvh5zyyCBAQZwKQaWnCvrsc4fjPoNP8fAQL59aTEr GwLpXFjEr7/8+ff6K4kb9jMmitEI4oRX8feVTZcqHipGUbYVUzC6yG59Vtb6kmnqy673 SkXH0lFTrPIHNZbLm9l5bh44FjdUjudIGQ4KxiBy6ZaYa4Ox0xXTcobQHzdF2bfDBJ5s YxPCnMfVv2GRKPq0Ov/15E9A3qiXqiQef/JZZNChLoRFo5flWAIBJgMWkK8G2GtCtVmj 2Rk8f1CcI8s8w6WZPLwFV0nGM9+L9KrjuTe5xng5kqXbQujDcHmzReT9mkD8KOHo7See WODA== X-Gm-Message-State: AHQUAuaAHvZO1d9hWY0nZXXalf/PWEt5dMk5K32sGePl81CKFiuYX6zz 19MMNH6JhDX9Ljm6hbGN7Po= X-Google-Smtp-Source: AHgI3Iby+xRWdyi1Udkr4G521b/6JPimbQBCpy0Nmu3wtyHHwxQfaLPtZAPFvLXM9oiwRtCOqUF1Fg== X-Received: by 2002:ae9:f112:: with SMTP id k18mr6600576qkg.231.1551363857085; Thu, 28 Feb 2019 06:24:17 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id g24sm13418021qtc.61.2019.02.28.06.24.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:24:16 -0800 (PST) Date: Thu, 28 Feb 2019 11:24:10 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 2/9] staging: iio: ad7780: add filter reading to ad778x Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the new feature of reading the filter odr value for ad778x chips. This value is stored in the chip's state struct whenever a read or write call is performed on the chip's driver. This feature requires sharing SAMP_FREQ. Since the ad717x does not have a filter option, the driver only shares the relevant info mask for the ad778x family. Signed-off-by: Renato Lui Geh --- Changes in v4: - As mentioned in the previous patch, this was originally as part of the 'add gain & filter gpio support' patch drivers/staging/iio/adc/ad7780.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 87fbcf510d45..7a68e90ddf14 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -59,6 +59,7 @@ struct ad7780_state { struct gpio_desc *gain_gpio; struct gpio_desc *filter_gpio; unsigned int gain; + unsigned int odr; unsigned int int_vref_mv; struct ad_sigma_delta sd; @@ -121,6 +122,9 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_OFFSET: *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = st->odr; + return IIO_VAL_INT; default: break; } @@ -163,6 +167,7 @@ static int ad7780_write_raw(struct iio_dev *indio_dev, val = 0; else val = 1; + st->odr = ad778x_odr_avail[val]; gpiod_set_value(st->filter_gpio, val); break; default: @@ -184,6 +189,7 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, if (chip_info->is_ad778x) { st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; + st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER]; } return 0; @@ -196,17 +202,19 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { }; #define AD7780_CHANNEL(bits, wordsize) \ + AD_SD_CHANNEL(1, 0, 0, bits, 32, wordsize - bits) +#define AD7170_CHANNEL(bits, wordsize) \ AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits) static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { [ID_AD7170] = { - .channel = AD7780_CHANNEL(12, 24), + .channel = AD7170_CHANNEL(12, 24), .pattern = AD7170_PATTERN, .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, }, [ID_AD7171] = { - .channel = AD7780_CHANNEL(16, 24), + .channel = AD7170_CHANNEL(16, 24), .pattern = AD7170_PATTERN, .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, From patchwork Thu Feb 28 14:24:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 572A61805 for ; Thu, 28 Feb 2019 14:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4694D2ECB4 for ; Thu, 28 Feb 2019 14:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39AEA2ECC9; Thu, 28 Feb 2019 14:24:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11212ECB4 for ; Thu, 28 Feb 2019 14:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732154AbfB1OYk (ORCPT ); Thu, 28 Feb 2019 09:24:40 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:40216 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfB1OYk (ORCPT ); Thu, 28 Feb 2019 09:24:40 -0500 Received: by mail-qt1-f193.google.com with SMTP id j36so23629840qta.7; Thu, 28 Feb 2019 06:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=T7e+fs7V+yeM3EHke7E+9+CDMITg0TvBzaawUe6DGE8=; b=KkaLNZlLNvaSNKFwYsREkTpos9mfrvRMlZpcoK7BV/ChTlT31olFWCOpqY43KizRq0 fZhqUXszAgPEw0iuH74ETCL5vPtAPT1wZMteBnPJ7oWvHaHGu+vGjCos6gtYZg25n6Eh xfkPDxFcJi5Ve+aTE/U7Kr4kCaFvt06xm/KS9ntn+qroRHgmQBtREbhSAG05BdZEMptI eE0bQwXkB7lc0cGvBKj4JY+6O/uZtkLtbfIbsKYxWUmCA5lsND3Tm7/VEMyy8+SQ4HM8 NC4gMd/qq+/Ed7qQuFiJTdtKcClchkghHj9CnzGKw+geuENpPAsABD4ouoNsRc+Ve7e+ Vzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=T7e+fs7V+yeM3EHke7E+9+CDMITg0TvBzaawUe6DGE8=; b=Q6j1iO4LfpI1wcTGqUWQxMla21td0GG0XPIeYfdq/dN/52O3AihkrQ7naZAbjTV/wi 0WEcGIwSXnoU5IU0kjV+O99zY6+MBKjbiuXkWeMt9b8qJlu3jk2jVFTu85IWjjeEW6ov n+Zu1ZpW6b4vmCNZfixbm9NpiHA7dDwYWTYSKwqP7fGwUXLd0Qyy5fLNHeak9vndq3rT m3Kc4rOctqzrPgcoxrkmK8rRYoZSkpbCLEy/CbmnOspDmYuJhdyKKvQRYvtA9JI5x++P DWyJoKS10H3PYeC7pKt2Xbv+oK6Wm02Sj+XdvB+wPrKJc6ydwkufzd33FKBundNAw1UM 3AbA== X-Gm-Message-State: APjAAAU4H5D670xUXlII+i1+2YCE6KcQTYLamw8Wvl98sLysnFCa5su8 1XGQc56LprdT10LI/UdW4eE= X-Google-Smtp-Source: AHgI3IaEUOjl1HQHYg19WGwPEwf84thp23Dc/vDhd5NkTB59jmMBCkiGGE54D4qNH2ztfZkR0Z9X1Q== X-Received: by 2002:ac8:734a:: with SMTP id q10mr6509687qtp.106.1551363878724; Thu, 28 Feb 2019 06:24:38 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id 24sm14133433qtu.17.2019.02.28.06.24.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:24:38 -0800 (PST) Date: Thu, 28 Feb 2019 11:24:32 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 3/9] staging: iio: ad7780: set pattern values and masks directly Message-ID: <9c8331166124ec2bd52794a9c9f844bfb70d1cd9.1551358569.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The AD7780 driver contains status pattern bits designed for checking whether serial transfers have been correctly performed. Pattern macros were previously generated through bit fields. This patch sets good pattern values directly and masks through GENMASK. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 7a68e90ddf14..56c49e28f432 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -28,16 +29,13 @@ #define AD7780_ID1 BIT(4) #define AD7780_ID0 BIT(3) #define AD7780_GAIN BIT(2) -#define AD7780_PAT1 BIT(1) -#define AD7780_PAT0 BIT(0) -#define AD7780_PATTERN (AD7780_PAT0) -#define AD7780_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1) -#define AD7170_PAT2 BIT(2) +#define AD7780_PATTERN_GOOD 1 +#define AD7780_PATTERN_MASK GENMASK(1, 0) -#define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2) -#define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | AD7170_PAT2) +#define AD7170_PATTERN_GOOD 5 +#define AD7170_PATTERN_MASK GENMASK(2, 0) #define AD7780_GAIN_MIDPOINT 64 #define AD7780_FILTER_MIDPOINT 13350 @@ -209,25 +207,25 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { [ID_AD7170] = { .channel = AD7170_CHANNEL(12, 24), - .pattern = AD7170_PATTERN, + .pattern = AD7170_PATTERN_GOOD, .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, }, [ID_AD7171] = { .channel = AD7170_CHANNEL(16, 24), - .pattern = AD7170_PATTERN, + .pattern = AD7170_PATTERN_GOOD, .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, }, [ID_AD7780] = { .channel = AD7780_CHANNEL(24, 32), - .pattern = AD7780_PATTERN, + .pattern = AD7780_PATTERN_GOOD, .pattern_mask = AD7780_PATTERN_MASK, .is_ad778x = true, }, [ID_AD7781] = { .channel = AD7780_CHANNEL(20, 32), - .pattern = AD7780_PATTERN, + .pattern = AD7780_PATTERN_GOOD, .pattern_mask = AD7780_PATTERN_MASK, .is_ad778x = true, }, From patchwork Thu Feb 28 14:24:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F6D41575 for ; Thu, 28 Feb 2019 14:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B6362ECB4 for ; Thu, 28 Feb 2019 14:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BB162ECC9; Thu, 28 Feb 2019 14:25:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E97F62ECB4 for ; Thu, 28 Feb 2019 14:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731538AbfB1OZC (ORCPT ); Thu, 28 Feb 2019 09:25:02 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46762 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfB1OZC (ORCPT ); Thu, 28 Feb 2019 09:25:02 -0500 Received: by mail-qt1-f193.google.com with SMTP id z25so23591916qti.13; Thu, 28 Feb 2019 06:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JlOPTet1jflBzo+5BdxF8+Muf08K1vBJXDoi85DvXoE=; b=D1at2AIpfc4kQH9PDPQ7Hu+KVHj75AmMkEbR48B5PmKzB21NL+YaM/YbuU1NgyXguE MpacssVkC+snup9EkdUDD59MyG/u6NQfg8Tc3xMw2u10WC4jb/lnhrBuVIPBCj9QN5jW L7DK8cp58FC0QDc4p0gsuhOZU4hwvj/wie0rIolWWFo9yL/4+v7+bdi+x4iIJKiR1NYp Rnzrr9XE7nltNUiZjJ84wV4VF+lN3V0x5MUZ3yPudPlxdB0szmop3brD2qBevAFj5xkm fCvas5JWXMGI8TG/e9SAL9sjtwPD2kBIEP0IA/Dllz0+PT0UXN/qVmlvvUlfNRy5/shA yhgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JlOPTet1jflBzo+5BdxF8+Muf08K1vBJXDoi85DvXoE=; b=K+I47oz2jTTD+t9ARSdpUxjBsxXplaEWLhTLMI2OSY/j0KbOEzp91RRyOb32Tb/Ahd 399JFoUD9c2OOyl5+m+QkTf63tDlZ9QradeBUv7m0jlyfdwsTDuu8Q5RatbVDJScNYdX qiaQM2WlgmWjdkCP3Be0j8/m1wKEg6xQfRCH9KHHcAL30ElMw7nTeU5tyvNU3E14mrVy XJz12xrxiMHV/sfRlWVe3Qf0Y5/j/gKy3YobDsxyLCcS6QU87XSd/XgIYoZdgDNiftk4 pB8755NCtMAl9Tw2uPo/V+1hKKPwP8OeLauwhHZz/B9O/Veu5wAQUVrtnn0qMCjDNEz3 MZ7Q== X-Gm-Message-State: AHQUAuZ0670Vt8rVPACX4wghKzWnLDVNLPloUUgR3KMasb5/bWTwtIra GsbHkrEfPQzOsuXf6H0fDxA= X-Google-Smtp-Source: AHgI3IbNBQSWJZ7YL9OnkX9z4vP0Vihqwk9J8bKDwKdnWuks71j/SYxjKVcOlli3gz3ODWhqUMTQmQ== X-Received: by 2002:ac8:3474:: with SMTP id v49mr6334393qtb.132.1551363901206; Thu, 28 Feb 2019 06:25:01 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id e4sm10608705qta.84.2019.02.28.06.24.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:25:00 -0800 (PST) Date: Thu, 28 Feb 2019 11:24:55 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 4/9] staging:iio:ad7780: add chip ID values and mask Message-ID: <90c573cd53bb54d49de6ac270bcff66880ccfeb5.1551358569.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ad7780 supports both the ad778x and ad717x families. Each chip has a corresponding ID. This patch provides a mask for extracting ID values from the status bits and also macros for the correct values for the ad7170, ad7171, ad7780 and ad7781. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 56c49e28f432..ad7617a3a141 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -26,10 +26,14 @@ #define AD7780_RDY BIT(7) #define AD7780_FILTER BIT(6) #define AD7780_ERR BIT(5) -#define AD7780_ID1 BIT(4) -#define AD7780_ID0 BIT(3) #define AD7780_GAIN BIT(2) +#define AD7170_ID 0 +#define AD7171_ID 1 +#define AD7780_ID 1 +#define AD7781_ID 0 + +#define AD7780_ID_MASK (BIT(3) | BIT(4)) #define AD7780_PATTERN_GOOD 1 #define AD7780_PATTERN_MASK GENMASK(1, 0) From patchwork Thu Feb 28 14:25:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA242180E for ; Thu, 28 Feb 2019 14:25:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F6D2ECB4 for ; Thu, 28 Feb 2019 14:25:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC8E32ECCA; Thu, 28 Feb 2019 14:25:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62B642ECB4 for ; Thu, 28 Feb 2019 14:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732852AbfB1OZR (ORCPT ); Thu, 28 Feb 2019 09:25:17 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42864 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732841AbfB1OZQ (ORCPT ); Thu, 28 Feb 2019 09:25:16 -0500 Received: by mail-qt1-f193.google.com with SMTP id u7so14432483qtg.9; Thu, 28 Feb 2019 06:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7IjTEn/vSJKDmLNmxTfgAiOgC0kjjMvr7wAaLhI+NQw=; b=tTp8qRSXsofJF+XuoEKGP3DhVSrrCLPYQim2iMK9FbzOojDAMcBqp4a9N1PyyMkMX6 X3HmpjMyMptSfQOgAu3gBtHmVuVZIBkxMNbjpVNjTaoy0X2VKzhTlwBfBaZAdGsKhUUY o2XK13B4eY7AqcMq8CmywCL00gyACUsqpf6/rfWvxkTvOET6FTFCxdY3C2fgO5V/Un8Q tvYSSjNOLkKqQyTmgUE2tk7R8B6UE185ZMQ3Yz79OjKnfX1MDMHLOycZMEVDbe8xfmMt +wvwBi8eFC7uOTbavvWln3bAGKzhk+jjCVFAeQWdxmbveM0x5E4ofg5mWM89Ptbwtjoq EbnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7IjTEn/vSJKDmLNmxTfgAiOgC0kjjMvr7wAaLhI+NQw=; b=iLDp+nJ4ZN+bfhzjwzvdFLf/c0NUEXZcZChFVz5zbRp5YOl1WqpeO2CXDH9htKbKQJ Ca1kOoFjxQgGH42vC/JWFHbwuMcSTVkK7bubcW8giAiwRT3C269qzuDMPm6NYrD8Ptod kocYx3mGndWrdynJ+bUNl+671F2ESGHiB+uXmewPN3EZ/Vsfugu6aYi+9JM4DaJlf3x1 yxzZGVWXt6dQHed5zmx6UuJda9bctsPM89is2pP/W71s2AztgandeZZoc6uCXoJxJ5sG kWzWeoPj0REQb5uXsQhas+vxXgNv7XVQbxztYUtpTcdmR212BoeyP5JhvA7ckMIeFu6+ yiQQ== X-Gm-Message-State: AHQUAuZDOwNluXEQw6YaQOe4YeDTmq60JgfWTir4LwW45iJPGrMYE+fZ IykDuD+ix3ZpOU71VJZwI+d1HeSbGfE= X-Google-Smtp-Source: AHgI3IZKH/KcRhkXWV3NEWKKP/hULaaU1gfc7Gn7mS4D4fsTmW3F4mQLWFHA7xWHToxqPINP434b8w== X-Received: by 2002:ac8:2314:: with SMTP id a20mr6523370qta.127.1551363915303; Thu, 28 Feb 2019 06:25:15 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id p64sm3673740qkc.62.2019.02.28.06.25.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:25:15 -0800 (PST) Date: Thu, 28 Feb 2019 11:25:09 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 5/9] staging: iio: ad7780: move regulator to after GPIO init Message-ID: <93cabb081605ac356f2f0d9a9a41d5bc5e63820d.1551358569.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To maintain consistency between ad7780_probe and ad7780_remove orders, regulator initialization has been moved to after GPIO initializations. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index ad7617a3a141..12aef0f101bc 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -255,16 +255,6 @@ static int ad7780_probe(struct spi_device *spi) ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info); - st->reg = devm_regulator_get(&spi->dev, "avdd"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) { - dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); - return ret; - } - st->chip_info = &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; @@ -284,7 +274,7 @@ static int ad7780_probe(struct spi_device *spi) ret = PTR_ERR(st->powerdown_gpio); dev_err(&spi->dev, "Failed to request powerdown GPIO: %d\n", ret); - goto error_disable_reg; + return ret; } if (st->chip_info->is_ad778x) { @@ -295,7 +285,7 @@ static int ad7780_probe(struct spi_device *spi) ret = PTR_ERR(st->gain_gpio); dev_err(&spi->dev, "Failed to request gain GPIO: %d\n", ret); - goto error_disable_reg; + return ret; } st->filter_gpio = devm_gpiod_get_optional(&spi->dev, @@ -306,10 +296,20 @@ static int ad7780_probe(struct spi_device *spi) dev_err(&spi->dev, "Failed to request filter GPIO: %d\n", ret); - goto error_disable_reg; + return ret; } } + st->reg = devm_regulator_get(&spi->dev, "avdd"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + + ret = regulator_enable(st->reg); + if (ret) { + dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); + return ret; + } + ret = ad_sd_setup_buffer_and_trigger(indio_dev); if (ret) goto error_disable_reg; From patchwork Thu Feb 28 14:25:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F005B1805 for ; Thu, 28 Feb 2019 14:25:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E03252ECCA for ; Thu, 28 Feb 2019 14:25:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D35762ECFF; Thu, 28 Feb 2019 14:25:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 054EE2ECFC for ; Thu, 28 Feb 2019 14:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728050AbfB1OZc (ORCPT ); Thu, 28 Feb 2019 09:25:32 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:45207 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbfB1OZa (ORCPT ); Thu, 28 Feb 2019 09:25:30 -0500 Received: by mail-qt1-f193.google.com with SMTP id d18so23585453qtg.12; Thu, 28 Feb 2019 06:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=N+SXRHRLZhhPwlRAxJVBPVqgau/fj3ODE0mnJv33yTA=; b=qF8e/poWGsMA1PpBoZQeiLQHP7yctDWZTilZXpqf8PpmnSgW8DabvzcO6zdTvl0Hj/ JFFR3Z6uhj9c45RQ5YoDz3S2NWTrlBXwsZHU5iiDqivRKRjCy9Au/jC3tol4iVZ6rgAe sHhbBrJzyvbm5Y75SLfAs2M5nKNE9MDpoaXthVX4WMyhJ6LYBWoKo90129Ff6czW5x82 0/wXiompMmrIe5fNeGu4qb2eKZ99XTwkCdlQRkN+Jm39zf5//OoHt8jPOmScn/fLxCAD Rt4S8Z2XIKKM3bxapnEtmwrxdUUnHa1QzEX4Q4yzr8Thd0v3NswNQNwGwH1w0wB8hDbu 4GsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=N+SXRHRLZhhPwlRAxJVBPVqgau/fj3ODE0mnJv33yTA=; b=FvftYNOCtqglF8LQbaY5egfpmx4CTNog74mVRoV0PFJ6mxL5ULfAvqfmHg4JjCy62c OoyWa9ByNdo/ZPN38zGIy/twHPzC0IFYgAyAX2KolioW4xTP/u+jaVNgiBvWlXBH2gU6 n1DaS37mIx5ElddDH7m1NtqAcrddK13T2f+hPFCHAKNtCjynbeCdwGKHhH/1tYRQ4toy wOpjtJiFgSEhfihXoid6omCWl/2z0Z6T9g1/miJvOD4VjFD1sjUB07TzfE/HXyXRnGJi PiRT+3V89W/0/dz/OnR6X2huGJxvBYELwnt027r79R6RGYJ8RxRvD1cOXNKB8WCohTx9 R+aw== X-Gm-Message-State: APjAAAUgytZPLECNSLT5+KERMr6r+RFR/B4BjNCrEcO8EiLR1vdnLDVA IapDpTekL6bU4aHMKD9frxc= X-Google-Smtp-Source: AHgI3IbFHFvGCVLn4niuhpQHVVOposQgM6MbDRhhE9Kcb6B7nLcSlrvpVAnFU+A4v7UmFiTrcuIRbg== X-Received: by 2002:ac8:3f3b:: with SMTP id c56mr6257277qtk.81.1551363929683; Thu, 28 Feb 2019 06:25:29 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id o26sm10219525qkk.51.2019.02.28.06.25.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:25:29 -0800 (PST) Date: Thu, 28 Feb 2019 11:25:23 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 6/9] staging: iio: ad7780: add SPDX identifier Message-ID: <907e3a63a16dbf5d98c027d528f12cb12577a7bd.1551358569.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add SPDX identifier (GPL-2.0) to the AD7780 driver. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 12aef0f101bc..b1d4909ba025 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver * * Copyright 2011 Analog Devices Inc. - * - * Licensed under the GPL-2. */ #include From patchwork Thu Feb 28 14:25:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A68831805 for ; Thu, 28 Feb 2019 14:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96C6C2ECCA for ; Thu, 28 Feb 2019 14:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A5BD2ECFF; Thu, 28 Feb 2019 14:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 387C12ECCA for ; Thu, 28 Feb 2019 14:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbfB1OZu (ORCPT ); Thu, 28 Feb 2019 09:25:50 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:42675 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727861AbfB1OZu (ORCPT ); Thu, 28 Feb 2019 09:25:50 -0500 Received: by mail-qk1-f196.google.com with SMTP id y140so12151267qkb.9; Thu, 28 Feb 2019 06:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/moDS2OpQE/nqH0aWZ6ItXxCv+7ncdyFsR0tyjCOKQE=; b=evzUFNaoPnyb643CWAEVh3M9dBsJgEMfbOp15s38H9yjTCOE3EEUwA9tM8a0uLRsU7 0IndHBWAjAEWqWaDaoC3nVzlycUhT6B00PHv0DBiNqOvGzjF2cUEVFsWyBkr4UNWW8P7 lZXFHjvBlLZCbWcRjM+KE6znpYKJhZpqaV4ry1gJDn+0rusiIyG+2UUdfixyL7y5bJfF LGtmg5RhrXPKkMXwyCxyH7iICN1j057bskawM0Via9r+kq/BTnU42dI5KpGT3szVzIAA m52jchH9MDftVS0izHhV0bLULEA0nz+z/+oeclClZQNpFspB3ucDYnA/cuinksbxrbb6 lyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/moDS2OpQE/nqH0aWZ6ItXxCv+7ncdyFsR0tyjCOKQE=; b=SZVOqnIR5SrFdlhaUTUQeag24z4hALBO5K9DLD9j1TFJXEf8Rb3pDFAxc6VeRr2wKF x9mipmngic4xNKMWayqYgPrCDGXlBk7GrxD5DLFkbGrYVDKsVCjWlx1Yva0C8kVyuuys b9beg9wzE9ydz2/UW4VaN+hv8HYtlc91Gf2OjArFdNHfgQK4tM9BeDzYCLYC74nJXR5X uFp0VFlvAa5mbpB6+tc8qMYp9a4YJkdYJCVzht5jBXjh1jEq2VRdr26yKFd5CmVEGp3+ 44zrQ5QtnE34XYWdhCa2gG61eTjP0icKvikgf9rN6GdIZrRxCOErn+bnNly8i9EOtzO1 17hw== X-Gm-Message-State: APjAAAXZeH08iaTcbghtplv2zwOVusWah1erhrOUEvgwD7x+BplYZWam zcQTPee1qVpQQVVQtVy9a4M= X-Google-Smtp-Source: AHgI3IYDqpQNLN5ARptEOsQ48stKn7/aVsf1dYgAK56ktP22cAUpcLSmmy1I3Y0oSGD/7qqidz5hPA== X-Received: by 2002:a37:d4d7:: with SMTP id s84mr6912222qks.28.1551363948767; Thu, 28 Feb 2019 06:25:48 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id h58sm12931725qtb.89.2019.02.28.06.25.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:25:48 -0800 (PST) Date: Thu, 28 Feb 2019 11:25:43 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 7/9] staging: iio: ad7780: add new copyright holder Message-ID: <0c2d36187b526c56b073185d1a9b7d99052ffbca.1551358569.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a new copyright holder to the ad7780 driver. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b1d4909ba025..aa1ddd0c45ee 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -3,6 +3,7 @@ * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver * * Copyright 2011 Analog Devices Inc. + * Copyright 2019 Renato Lui Geh */ #include From patchwork Thu Feb 28 14:26:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 492341575 for ; Thu, 28 Feb 2019 14:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3212F2ECCA for ; Thu, 28 Feb 2019 14:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25EF82ED00; Thu, 28 Feb 2019 14:26:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AABF52ECCA for ; Thu, 28 Feb 2019 14:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732957AbfB1O0R (ORCPT ); Thu, 28 Feb 2019 09:26:17 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:47094 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732946AbfB1O0Q (ORCPT ); Thu, 28 Feb 2019 09:26:16 -0500 Received: by mail-qk1-f196.google.com with SMTP id i5so12137499qkd.13; Thu, 28 Feb 2019 06:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LhLBOUVEFdkrOLZyvw0gu9evm3wKITUpm71PjNrrlnI=; b=gHwaeLAG+eCrRH7+FXF3SXn7JybsidgytdVVfbtXfbDj8yP+HFCamy+4RqtVKDkY3F LRO1IY6B8fxq7Exti9/SHGKmHBx+xy7ffdHxnkgNA8w7Th9TEDMPMWa9ObqwL0aAjUMQ GEFvdVQwjRl1YN1oVe6XjQc41sYPS0t8Ft3j7mBVHk+4GHoEu0ZUW4y561aJN1upAD2M paVAJy4eaaDwbVVs7veyurSQUl3ZHsEi6s9jy2JyBfp73ma/Zk2KO3D0zEGRezmjMHIv XN2AdaipZHwLibpJNmLu+qn1rIMImq/pv7UTwgBH3ynrxOYEzcHpei15/XK6RLRoZ6Oh GQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LhLBOUVEFdkrOLZyvw0gu9evm3wKITUpm71PjNrrlnI=; b=liFqd+quh89WeRipZ/dgxT53XAN25GleMisp62TokD4BPjy8HWeVaOjiHONWjYu8Sr jw6rZZJ2g9PkgkooIUJ1FbYlj3Bj3smEHPxnm6l3hHDAcVGWi8PQd8DgdeKGqR2x64lX Mi7CijGQDT04xXjXhCqC40JgrPPZOQ09SjzElIpRaQkLeWdOhPP1qG5RxuVgJDzs9lT/ fkmWCbztobPH7ks6VVPTh8cxp3HYKC2LqOgqDfy9IpzhTvCE61LgWS4g+GUscBGINbdN zS6QKPbehGvdbw6YNYbOdKfKhaM6e06AkFYdup+SGlOXnRgwM47wYv6FJFYStu3mD2Yl 6gTg== X-Gm-Message-State: AHQUAuYnDTryqPINIlOHGtlsFGGKDNnfLlzEPSJIl7kcXRo3viLLvPIk R9QX5G3xOwR5ML1E8FkElEQ= X-Google-Smtp-Source: APXvYqxxr4H4nNGiTsjAG1s9TNWSpDMrW1LiqE/X5fY3fKJCDrW5yWaSMi+bR5oH/zqMClv36v3PZg== X-Received: by 2002:a37:4887:: with SMTP id v129mr6923351qka.100.1551363973946; Thu, 28 Feb 2019 06:26:13 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id r44sm12107321qtb.53.2019.02.28.06.26.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:26:13 -0800 (PST) Date: Thu, 28 Feb 2019 11:26:08 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 8/9] staging: iio: ad7780: moving ad7780 out of staging Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move ad7780 ADC driver out of staging and into the mainline. The ad7780 is a sigma-delta analog to digital converter. This driver provides reading voltage values and status bits from both the ad778x and ad717x series. Its interface also allows writing on the FILTER and GAIN GPIO pins on the ad778x. Signed-off-by: Renato Lui Geh Signed-off-by: Giuliano Belinassi Co-developed-by: Giuliano Belinassi --- Changes in v3: - Changes unrelated to moving the driver to main tree were resent as individual patches Changes in v4: - Removed line warning it was safe to build the ad7780 driver by default About the above change in v4, I was unsure whether it was ok to add this in this patch, as 'move out of staging' patches should be just that. But this change is so minimal I'm willing to risk a v5. Bottom line: should I add this change as another patch? drivers/iio/adc/Kconfig | 12 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7780.c | 365 +++++++++++++++++++++++++++++++ drivers/staging/iio/adc/Kconfig | 13 -- drivers/staging/iio/adc/Makefile | 1 - drivers/staging/iio/adc/ad7780.c | 365 ------------------------------- 6 files changed, 378 insertions(+), 379 deletions(-) create mode 100644 drivers/iio/adc/ad7780.c delete mode 100644 drivers/staging/iio/adc/ad7780.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index f3cc7a31bce5..6b36a45bd09f 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -108,6 +108,18 @@ config AD7766 To compile this driver as a module, choose M here: the module will be called ad7766. +config AD7780 + tristate "Analog Devices AD7780 and similar ADCs driver" + depends on SPI + depends on GPIOLIB || COMPILE_TEST + select AD_SIGMA_DELTA + help + Say yes here to build support for Analog Devices AD7170, AD7171, + AD7780 and AD7781 SPI analog to digital converters (ADC). + + To compile this driver as a module, choose M here: the + module will be called ad7780. + config AD7791 tristate "Analog Devices AD7791 ADC driver" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index ea5031348052..b48852157115 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o obj-$(CONFIG_AD7766) += ad7766.o +obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c new file mode 100644 index 000000000000..aa1ddd0c45ee --- /dev/null +++ b/drivers/iio/adc/ad7780.c @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver + * + * Copyright 2011 Analog Devices Inc. + * Copyright 2019 Renato Lui Geh + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define AD7780_RDY BIT(7) +#define AD7780_FILTER BIT(6) +#define AD7780_ERR BIT(5) +#define AD7780_GAIN BIT(2) + +#define AD7170_ID 0 +#define AD7171_ID 1 +#define AD7780_ID 1 +#define AD7781_ID 0 + +#define AD7780_ID_MASK (BIT(3) | BIT(4)) + +#define AD7780_PATTERN_GOOD 1 +#define AD7780_PATTERN_MASK GENMASK(1, 0) + +#define AD7170_PATTERN_GOOD 5 +#define AD7170_PATTERN_MASK GENMASK(2, 0) + +#define AD7780_GAIN_MIDPOINT 64 +#define AD7780_FILTER_MIDPOINT 13350 + +static const unsigned int ad778x_gain[2] = { 1, 128 }; +static const unsigned int ad778x_odr_avail[2] = { 10000, 16700 }; + +struct ad7780_chip_info { + struct iio_chan_spec channel; + unsigned int pattern_mask; + unsigned int pattern; + bool is_ad778x; +}; + +struct ad7780_state { + const struct ad7780_chip_info *chip_info; + struct regulator *reg; + struct gpio_desc *powerdown_gpio; + struct gpio_desc *gain_gpio; + struct gpio_desc *filter_gpio; + unsigned int gain; + unsigned int odr; + unsigned int int_vref_mv; + + struct ad_sigma_delta sd; +}; + +enum ad7780_supported_device_ids { + ID_AD7170, + ID_AD7171, + ID_AD7780, + ID_AD7781, +}; + +static struct ad7780_state *ad_sigma_delta_to_ad7780(struct ad_sigma_delta *sd) +{ + return container_of(sd, struct ad7780_state, sd); +} + +static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta, + enum ad_sigma_delta_mode mode) +{ + struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); + unsigned int val; + + switch (mode) { + case AD_SD_MODE_SINGLE: + case AD_SD_MODE_CONTINUOUS: + val = 1; + break; + default: + val = 0; + break; + } + + gpiod_set_value(st->powerdown_gpio, val); + + return 0; +} + +static int ad7780_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv; + + switch (m) { + case IIO_CHAN_INFO_RAW: + return ad_sigma_delta_single_conversion(indio_dev, chan, val); + case IIO_CHAN_INFO_SCALE: + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv < 0) + return voltage_uv; + voltage_uv /= 1000; + *val = voltage_uv * st->gain; + *val2 = chan->scan_type.realbits - 1; + st->int_vref_mv = voltage_uv; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_OFFSET: + *val = -(1 << (chan->scan_type.realbits - 1)); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = st->odr; + return IIO_VAL_INT; + default: + break; + } + + return -EINVAL; +} + +static int ad7780_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long m) +{ + struct ad7780_state *st = iio_priv(indio_dev); + const struct ad7780_chip_info *chip_info = st->chip_info; + unsigned long long vref; + unsigned int full_scale, gain; + + if (!chip_info->is_ad778x) + return 0; + + switch (m) { + case IIO_CHAN_INFO_SCALE: + if (val != 0) + return -EINVAL; + + vref = st->int_vref_mv * 1000000LL; + full_scale = 1 << (chip_info->channel.scan_type.realbits - 1); + gain = DIV_ROUND_CLOSEST(vref, full_scale); + gain = DIV_ROUND_CLOSEST(gain, val2); + st->gain = gain; + if (gain < AD7780_GAIN_MIDPOINT) + gain = 0; + else + gain = 1; + gpiod_set_value(st->gain_gpio, gain); + break; + case IIO_CHAN_INFO_SAMP_FREQ: + if (1000*val + val2/1000 < AD7780_FILTER_MIDPOINT) + val = 0; + else + val = 1; + st->odr = ad778x_odr_avail[val]; + gpiod_set_value(st->filter_gpio, val); + break; + default: + break; + } + + return 0; +} + +static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, + unsigned int raw_sample) +{ + struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); + const struct ad7780_chip_info *chip_info = st->chip_info; + + if ((raw_sample & AD7780_ERR) || + ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) + return -EIO; + + if (chip_info->is_ad778x) { + st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; + st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER]; + } + + return 0; +} + +static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { + .set_mode = ad7780_set_mode, + .postprocess_sample = ad7780_postprocess_sample, + .has_registers = false, +}; + +#define AD7780_CHANNEL(bits, wordsize) \ + AD_SD_CHANNEL(1, 0, 0, bits, 32, wordsize - bits) +#define AD7170_CHANNEL(bits, wordsize) \ + AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits) + +static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { + [ID_AD7170] = { + .channel = AD7170_CHANNEL(12, 24), + .pattern = AD7170_PATTERN_GOOD, + .pattern_mask = AD7170_PATTERN_MASK, + .is_ad778x = false, + }, + [ID_AD7171] = { + .channel = AD7170_CHANNEL(16, 24), + .pattern = AD7170_PATTERN_GOOD, + .pattern_mask = AD7170_PATTERN_MASK, + .is_ad778x = false, + }, + [ID_AD7780] = { + .channel = AD7780_CHANNEL(24, 32), + .pattern = AD7780_PATTERN_GOOD, + .pattern_mask = AD7780_PATTERN_MASK, + .is_ad778x = true, + }, + [ID_AD7781] = { + .channel = AD7780_CHANNEL(20, 32), + .pattern = AD7780_PATTERN_GOOD, + .pattern_mask = AD7780_PATTERN_MASK, + .is_ad778x = true, + }, +}; + +static const struct iio_info ad7780_info = { + .read_raw = ad7780_read_raw, + .write_raw = ad7780_write_raw, +}; + +static int ad7780_probe(struct spi_device *spi) +{ + struct ad7780_state *st; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + st->gain = 1; + + ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info); + + st->chip_info = + &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; + + spi_set_drvdata(spi, indio_dev); + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = &st->chip_info->channel; + indio_dev->num_channels = 1; + indio_dev->info = &ad7780_info; + + st->powerdown_gpio = devm_gpiod_get_optional(&spi->dev, + "powerdown", + GPIOD_OUT_LOW); + if (IS_ERR(st->powerdown_gpio)) { + ret = PTR_ERR(st->powerdown_gpio); + dev_err(&spi->dev, "Failed to request powerdown GPIO: %d\n", + ret); + return ret; + } + + if (st->chip_info->is_ad778x) { + st->gain_gpio = devm_gpiod_get_optional(&spi->dev, + "adi,gain", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gain_gpio)) { + ret = PTR_ERR(st->gain_gpio); + dev_err(&spi->dev, "Failed to request gain GPIO: %d\n", + ret); + return ret; + } + + st->filter_gpio = devm_gpiod_get_optional(&spi->dev, + "adi,filter", + GPIOD_OUT_HIGH); + if (IS_ERR(st->filter_gpio)) { + ret = PTR_ERR(st->filter_gpio); + dev_err(&spi->dev, + "Failed to request filter GPIO: %d\n", + ret); + return ret; + } + } + + st->reg = devm_regulator_get(&spi->dev, "avdd"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + + ret = regulator_enable(st->reg); + if (ret) { + dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); + return ret; + } + + ret = ad_sd_setup_buffer_and_trigger(indio_dev); + if (ret) + goto error_disable_reg; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_cleanup_buffer_and_trigger; + + return 0; + +error_cleanup_buffer_and_trigger: + ad_sd_cleanup_buffer_and_trigger(indio_dev); +error_disable_reg: + regulator_disable(st->reg); + + return ret; +} + +static int ad7780_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad7780_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + ad_sd_cleanup_buffer_and_trigger(indio_dev); + + regulator_disable(st->reg); + + return 0; +} + +static const struct spi_device_id ad7780_id[] = { + {"ad7170", ID_AD7170}, + {"ad7171", ID_AD7171}, + {"ad7780", ID_AD7780}, + {"ad7781", ID_AD7781}, + {} +}; +MODULE_DEVICE_TABLE(spi, ad7780_id); + +static struct spi_driver ad7780_driver = { + .driver = { + .name = "ad7780", + }, + .probe = ad7780_probe, + .remove = ad7780_remove, + .id_table = ad7780_id, +}; +module_spi_driver(ad7780_driver); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD7780 and similar ADCs"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 7a93d3a5c113..404a53c743a6 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -3,19 +3,6 @@ # menu "Analog to digital converters" -config AD7780 - tristate "Analog Devices AD7780 and similar ADCs driver" - depends on SPI - depends on GPIOLIB || COMPILE_TEST - select AD_SIGMA_DELTA - help - Say yes here to build support for Analog Devices AD7170, AD7171, - AD7780 and AD7781 SPI analog to digital converters (ADC). - If unsure, say N (but it's safe to say "Y"). - - To compile this driver as a module, choose M here: the - module will be called ad7780. - config AD7816 tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 7a421088ff82..4b76769b32bc 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -3,7 +3,6 @@ # Makefile for industrial I/O ADC drivers # -obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7816) += ad7816.o obj-$(CONFIG_AD7192) += ad7192.o obj-$(CONFIG_AD7280) += ad7280a.o diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c deleted file mode 100644 index aa1ddd0c45ee..000000000000 --- a/drivers/staging/iio/adc/ad7780.c +++ /dev/null @@ -1,365 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver - * - * Copyright 2011 Analog Devices Inc. - * Copyright 2019 Renato Lui Geh - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define AD7780_RDY BIT(7) -#define AD7780_FILTER BIT(6) -#define AD7780_ERR BIT(5) -#define AD7780_GAIN BIT(2) - -#define AD7170_ID 0 -#define AD7171_ID 1 -#define AD7780_ID 1 -#define AD7781_ID 0 - -#define AD7780_ID_MASK (BIT(3) | BIT(4)) - -#define AD7780_PATTERN_GOOD 1 -#define AD7780_PATTERN_MASK GENMASK(1, 0) - -#define AD7170_PATTERN_GOOD 5 -#define AD7170_PATTERN_MASK GENMASK(2, 0) - -#define AD7780_GAIN_MIDPOINT 64 -#define AD7780_FILTER_MIDPOINT 13350 - -static const unsigned int ad778x_gain[2] = { 1, 128 }; -static const unsigned int ad778x_odr_avail[2] = { 10000, 16700 }; - -struct ad7780_chip_info { - struct iio_chan_spec channel; - unsigned int pattern_mask; - unsigned int pattern; - bool is_ad778x; -}; - -struct ad7780_state { - const struct ad7780_chip_info *chip_info; - struct regulator *reg; - struct gpio_desc *powerdown_gpio; - struct gpio_desc *gain_gpio; - struct gpio_desc *filter_gpio; - unsigned int gain; - unsigned int odr; - unsigned int int_vref_mv; - - struct ad_sigma_delta sd; -}; - -enum ad7780_supported_device_ids { - ID_AD7170, - ID_AD7171, - ID_AD7780, - ID_AD7781, -}; - -static struct ad7780_state *ad_sigma_delta_to_ad7780(struct ad_sigma_delta *sd) -{ - return container_of(sd, struct ad7780_state, sd); -} - -static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta, - enum ad_sigma_delta_mode mode) -{ - struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); - unsigned int val; - - switch (mode) { - case AD_SD_MODE_SINGLE: - case AD_SD_MODE_CONTINUOUS: - val = 1; - break; - default: - val = 0; - break; - } - - gpiod_set_value(st->powerdown_gpio, val); - - return 0; -} - -static int ad7780_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - struct ad7780_state *st = iio_priv(indio_dev); - int voltage_uv; - - switch (m) { - case IIO_CHAN_INFO_RAW: - return ad_sigma_delta_single_conversion(indio_dev, chan, val); - case IIO_CHAN_INFO_SCALE: - voltage_uv = regulator_get_voltage(st->reg); - if (voltage_uv < 0) - return voltage_uv; - voltage_uv /= 1000; - *val = voltage_uv * st->gain; - *val2 = chan->scan_type.realbits - 1; - st->int_vref_mv = voltage_uv; - return IIO_VAL_FRACTIONAL_LOG2; - case IIO_CHAN_INFO_OFFSET: - *val = -(1 << (chan->scan_type.realbits - 1)); - return IIO_VAL_INT; - case IIO_CHAN_INFO_SAMP_FREQ: - *val = st->odr; - return IIO_VAL_INT; - default: - break; - } - - return -EINVAL; -} - -static int ad7780_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long m) -{ - struct ad7780_state *st = iio_priv(indio_dev); - const struct ad7780_chip_info *chip_info = st->chip_info; - unsigned long long vref; - unsigned int full_scale, gain; - - if (!chip_info->is_ad778x) - return 0; - - switch (m) { - case IIO_CHAN_INFO_SCALE: - if (val != 0) - return -EINVAL; - - vref = st->int_vref_mv * 1000000LL; - full_scale = 1 << (chip_info->channel.scan_type.realbits - 1); - gain = DIV_ROUND_CLOSEST(vref, full_scale); - gain = DIV_ROUND_CLOSEST(gain, val2); - st->gain = gain; - if (gain < AD7780_GAIN_MIDPOINT) - gain = 0; - else - gain = 1; - gpiod_set_value(st->gain_gpio, gain); - break; - case IIO_CHAN_INFO_SAMP_FREQ: - if (1000*val + val2/1000 < AD7780_FILTER_MIDPOINT) - val = 0; - else - val = 1; - st->odr = ad778x_odr_avail[val]; - gpiod_set_value(st->filter_gpio, val); - break; - default: - break; - } - - return 0; -} - -static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, - unsigned int raw_sample) -{ - struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); - const struct ad7780_chip_info *chip_info = st->chip_info; - - if ((raw_sample & AD7780_ERR) || - ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) - return -EIO; - - if (chip_info->is_ad778x) { - st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; - st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER]; - } - - return 0; -} - -static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { - .set_mode = ad7780_set_mode, - .postprocess_sample = ad7780_postprocess_sample, - .has_registers = false, -}; - -#define AD7780_CHANNEL(bits, wordsize) \ - AD_SD_CHANNEL(1, 0, 0, bits, 32, wordsize - bits) -#define AD7170_CHANNEL(bits, wordsize) \ - AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits) - -static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { - [ID_AD7170] = { - .channel = AD7170_CHANNEL(12, 24), - .pattern = AD7170_PATTERN_GOOD, - .pattern_mask = AD7170_PATTERN_MASK, - .is_ad778x = false, - }, - [ID_AD7171] = { - .channel = AD7170_CHANNEL(16, 24), - .pattern = AD7170_PATTERN_GOOD, - .pattern_mask = AD7170_PATTERN_MASK, - .is_ad778x = false, - }, - [ID_AD7780] = { - .channel = AD7780_CHANNEL(24, 32), - .pattern = AD7780_PATTERN_GOOD, - .pattern_mask = AD7780_PATTERN_MASK, - .is_ad778x = true, - }, - [ID_AD7781] = { - .channel = AD7780_CHANNEL(20, 32), - .pattern = AD7780_PATTERN_GOOD, - .pattern_mask = AD7780_PATTERN_MASK, - .is_ad778x = true, - }, -}; - -static const struct iio_info ad7780_info = { - .read_raw = ad7780_read_raw, - .write_raw = ad7780_write_raw, -}; - -static int ad7780_probe(struct spi_device *spi) -{ - struct ad7780_state *st; - struct iio_dev *indio_dev; - int ret; - - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - - st = iio_priv(indio_dev); - st->gain = 1; - - ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info); - - st->chip_info = - &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; - - spi_set_drvdata(spi, indio_dev); - - indio_dev->dev.parent = &spi->dev; - indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = &st->chip_info->channel; - indio_dev->num_channels = 1; - indio_dev->info = &ad7780_info; - - st->powerdown_gpio = devm_gpiod_get_optional(&spi->dev, - "powerdown", - GPIOD_OUT_LOW); - if (IS_ERR(st->powerdown_gpio)) { - ret = PTR_ERR(st->powerdown_gpio); - dev_err(&spi->dev, "Failed to request powerdown GPIO: %d\n", - ret); - return ret; - } - - if (st->chip_info->is_ad778x) { - st->gain_gpio = devm_gpiod_get_optional(&spi->dev, - "adi,gain", - GPIOD_OUT_HIGH); - if (IS_ERR(st->gain_gpio)) { - ret = PTR_ERR(st->gain_gpio); - dev_err(&spi->dev, "Failed to request gain GPIO: %d\n", - ret); - return ret; - } - - st->filter_gpio = devm_gpiod_get_optional(&spi->dev, - "adi,filter", - GPIOD_OUT_HIGH); - if (IS_ERR(st->filter_gpio)) { - ret = PTR_ERR(st->filter_gpio); - dev_err(&spi->dev, - "Failed to request filter GPIO: %d\n", - ret); - return ret; - } - } - - st->reg = devm_regulator_get(&spi->dev, "avdd"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) { - dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); - return ret; - } - - ret = ad_sd_setup_buffer_and_trigger(indio_dev); - if (ret) - goto error_disable_reg; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_buffer_and_trigger; - - return 0; - -error_cleanup_buffer_and_trigger: - ad_sd_cleanup_buffer_and_trigger(indio_dev); -error_disable_reg: - regulator_disable(st->reg); - - return ret; -} - -static int ad7780_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7780_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - ad_sd_cleanup_buffer_and_trigger(indio_dev); - - regulator_disable(st->reg); - - return 0; -} - -static const struct spi_device_id ad7780_id[] = { - {"ad7170", ID_AD7170}, - {"ad7171", ID_AD7171}, - {"ad7780", ID_AD7780}, - {"ad7781", ID_AD7781}, - {} -}; -MODULE_DEVICE_TABLE(spi, ad7780_id); - -static struct spi_driver ad7780_driver = { - .driver = { - .name = "ad7780", - }, - .probe = ad7780_probe, - .remove = ad7780_remove, - .id_table = ad7780_id, -}; -module_spi_driver(ad7780_driver); - -MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("Analog Devices AD7780 and similar ADCs"); -MODULE_LICENSE("GPL v2"); From patchwork Thu Feb 28 14:26:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10833201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F5CB1575 for ; Thu, 28 Feb 2019 14:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E4C02ECCA for ; Thu, 28 Feb 2019 14:26:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8239B2ECFF; Thu, 28 Feb 2019 14:26:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2779A2ECCA for ; Thu, 28 Feb 2019 14:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731575AbfB1O0i (ORCPT ); Thu, 28 Feb 2019 09:26:38 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:47022 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732966AbfB1O0f (ORCPT ); Thu, 28 Feb 2019 09:26:35 -0500 Received: by mail-qt1-f196.google.com with SMTP id z25so23598580qti.13; Thu, 28 Feb 2019 06:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NMeP2IkzSEftRMF6nNz8Vv+P/xn7p6xmxsCj+g6jPfw=; b=sQR+qDtc8jyLsD5XL9nIDbQ8lVGl854SLtlpi6Aeq2X6lAixeiEEL4KjPd5basebBd xI0exudRxd6vzI0W2Kb/Uz171EncvAqV36P7dev9sPHcpKaKTPD3frAhfclpUQHfjJTl /XzoyWT7zINSgZXH74KLKJGgOsCvds8ZJqj+1bXTDobE3YhIcnrB9RyuaI0qwdVFWDP8 /y4RLV6fJn28qiB/qEe3dqacjYBy6IZASevAQugDFPnNV1aCqCz12LvWcy63JKzviEGG /G+5clmktRrU76b37jvN6mF+objE+CJ51lSAZY/vMHzdJK25TXAQ7frzkbLC8kbi/0oS viiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NMeP2IkzSEftRMF6nNz8Vv+P/xn7p6xmxsCj+g6jPfw=; b=KQMPgxY97Q2B7fnMkA5MvRRxZcEuk1Cf5H7RUzJyj7fMTegUd6JsMN0rIfeg2rib31 Z2FlJLa8kgelHdZM50UsgUFbyb81ua/0u/dbEqXNTSmLAkjpUgkLzgTlt7Puo5CTm0c+ 5o0chY+/ku6zn9NQ+YadHkcWlZszojS2dVFnjfJxELPJ2kbSvt5exuo+gfhjciO7au4Q 5gMDUkhve1drEHk4v1Yrww5qU4TSECGZink5Pr3ZJygoR8O9MMMkXpn8/F3ZScT+3JNW J4m1ARKJg3tpzCeQRUTX9aGd0fS2JhqANr5yG3jEPj4f61ZRFVouYt9FSpaEvIYfoj7b y74g== X-Gm-Message-State: APjAAAWvCOTUIq8GAzrPCj34QOUZoRjHcx4LxUHV04c2TDQcu0a2Uv0k NchNIV8HeL1mXrEkcG2IoH4= X-Google-Smtp-Source: APXvYqzkIG/AukRKqyW66hRHpX5dMPnkXmYJ+bjeA0ml8TGONocgZ0ekvecIPlygYWo27xVtDnoGrg== X-Received: by 2002:a0c:bd15:: with SMTP id m21mr6560189qvg.246.1551363994191; Thu, 28 Feb 2019 06:26:34 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id r68sm9554072qkd.68.2019.02.28.06.26.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 06:26:33 -0800 (PST) Date: Thu, 28 Feb 2019 11:26:28 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v4 9/9] staging: iio: ad7780: add device tree binding Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds a device tree binding for the ad7780 driver. Signed-off-by: Renato Lui Geh Reviewed-by: Rob Herring --- .../bindings/iio/adc/adi,ad7780.txt | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt new file mode 100644 index 000000000000..440e52555349 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt @@ -0,0 +1,48 @@ +* Analog Devices AD7170/AD7171/AD7780/AD7781 + +Data sheets: + +- AD7170: + * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7170.pdf +- AD7171: + * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7171.pdf +- AD7780: + * https://www.analog.com/media/en/technical-documentation/data-sheets/ad7780.pdf +- AD7781: + * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7781.pdf + +Required properties: + +- compatible: should be one of + * "adi,ad7170" + * "adi,ad7171" + * "adi,ad7780" + * "adi,ad7781" +- reg: spi chip select number for the device +- vref-supply: the regulator supply for the ADC reference voltage + +Optional properties: + +- powerdown-gpios: must be the device tree identifier of the PDRST pin. If + specified, it will be asserted during driver probe. As the + line is active high, it should be marked GPIO_ACTIVE_HIGH. +- adi,gain-gpios: must be the device tree identifier of the GAIN pin. Only for + the ad778x chips. If specified, it will be asserted during + driver probe. As the line is active low, it should be marked + GPIO_ACTIVE_LOW. +- adi,filter-gpios: must be the device tree identifier of the FILTER pin. Only + for the ad778x chips. If specified, it will be asserted + during driver probe. As the line is active low, it should be + marked GPIO_ACTIVE_LOW. + +Example: + +adc@0 { + compatible = "adi,ad7780"; + reg = <0>; + vref-supply = <&vdd_supply> + + powerdown-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + adi,gain-gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + adi,filter-gpios = <&gpio 15 GPIO_ACTIVE_LOW>; +};