Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp632464imc; Sat, 16 Mar 2019 10:56:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyuEI7sVvYrERAk0tCr++5X/B6CvqWZ2ZU+5RkpFOBclg4X2ifPPFJ9CZ176iK6qJ5e+UB X-Received: by 2002:a17:902:b196:: with SMTP id s22mr9067399plr.33.1552759008324; Sat, 16 Mar 2019 10:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552759008; cv=none; d=google.com; s=arc-20160816; b=oqPjCIDvhq8TmW5IMd3u83wUXDZqfa+t+dfKL7ydFTfiTgGjQdpPirqQdjlDeWuXEe TjUOgNg/scJq2qIX9X4BH64rnfp9eJxnmYcZ7RvTEdDL8A18P2PfjToISiyNLAM4uX9N WQPjhRFUFCt4B67Em1OY8mHFy4ZSz9RteQLZWqjC6COjxMQnCX62noQ77yZ0881lsbgv /QlfD1EZ0hLV5+LW4aP4koHag71iKgfBn/eJgFsHukpyAqED51qkQBN1zcn2ccgL8ZqK rPZT+wQuYKkPzv9MwpQMCldm3LOytabXPtQLhoWXmW1spmH7CmdDKmCNHz9Zyv/sURAU RQXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=mYCOcALaf1Tfh4InEBi9O3AbEmetSTitImOIQ92Tqgs=; b=XhQU1Q3nu9+HiJm5YCNypCFyGQ91Wv1FDIM76+jE7nTP3K0rEv2TGx7aHmFVbHqoke 6OfKm8EkiP6nCvZRxZQNP6Qf9TGMsRPOuWg4g4Ok0MixO34h73Hyruh9FuIpxIjAF2IM 32bU/b3U1wBuiHGLE+axGjAOlFyN2Kr91EmqPCxv3ToBWqI4G7ag3XQdArhOlbYIfkqI q7ZKv1iXRhXOY5mcVBrUZM24G8kHF9HGcfFR0gIMDXTKNX2aABj0RUJQYuVFXqbn92R7 51YwyiJohNEqEvlS19G1MGRo+OtXjVAVxRQlU4THtVvXGjm0HA0mnKFxLGkpNnmLPrZM 8OLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nLGRAMgO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si1396650pfd.93.2019.03.16.10.56.32; Sat, 16 Mar 2019 10:56:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nLGRAMgO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbfCPRz4 (ORCPT + 99 others); Sat, 16 Mar 2019 13:55:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfCPRz4 (ORCPT ); Sat, 16 Mar 2019 13:55:56 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 357F3218D0; Sat, 16 Mar 2019 17:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552758955; bh=zrzXPciFGASrB1+lQG4H/u1D6sELZcPgSHAhBz16scg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nLGRAMgONXJMnhW6PSvALgAzzrikbRrzfZyF7Etn7QWaAy7zGe0OjkblCP6UB/JRi RlHvVHH8pCXORotGMRXbA7fBiylrh2PdvaIMfGBPGlTlCrkz7UX6ZkwRZf+0ciA+eM +FJDvBQM9t0lJm0AZsIxpPkWusGA1e+6BO+gJ6Xs= Date: Sat, 16 Mar 2019 17:55:48 +0000 From: Jonathan Cameron To: Renato Lui Geh Cc: lars@metafoo.de, Michael.Hennerich@analog.com, 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, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: Re: [PATCH v5 04/11] staging: iio: ad7780: add filter reading to ad778x Message-ID: <20190316175548.2873277a@archlinux> In-Reply-To: <66a914ed7d1512f5aedfc5a0c6cbae38f5588e35.1552700652.git.renatogeh@gmail.com> References: <66a914ed7d1512f5aedfc5a0c6cbae38f5588e35.1552700652.git.renatogeh@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Mar 2019 23:13:42 -0300 Renato Lui Geh wrote: > 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 Applied, Thanks, Jonathan > --- > Changes in v4: > - As mentioned in the previous patch, this was originally as part of > the 'add gain & filter gpio support' patch > Changes in v5: > - Moved ad778x_odr_avail declaration from GPIO patch to this one > > drivers/staging/iio/adc/ad7780.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c > index fbcc0d3345ca..8ff74427d975 100644 > --- a/drivers/staging/iio/adc/ad7780.c > +++ b/drivers/staging/iio/adc/ad7780.c > @@ -42,7 +42,8 @@ > #define AD7780_GAIN_MIDPOINT 64 > #define AD7780_FILTER_MIDPOINT 13350 > > -static const unsigned int ad778x_gain[2] = { 1, 128 }; > +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; > @@ -58,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; > @@ -120,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; > } > @@ -162,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: > @@ -181,8 +187,10 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, > ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) > return -EIO; > > - if (chip_info->is_ad778x) > + if (chip_info->is_ad778x) { > st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; > + st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER]; > + } > > return 0; > } > @@ -194,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,