Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp728406img; Thu, 28 Feb 2019 07:00:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IahKyJD6Vzot1ygDNt1pWdcAhIejDyklGX+fQsFWdEbgXOL09t/Ngfppp93pQKb1x4pFHjy X-Received: by 2002:a17:902:8e82:: with SMTP id bg2mr8428980plb.217.1551366048401; Thu, 28 Feb 2019 07:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551366048; cv=none; d=google.com; s=arc-20160816; b=Ucmw4Dru+EXL5v+yLDbyblHPMV609ndoNIIE0oY+WHbCpR8QDf7RLTPe/TbWMskJxe W54c7ldIhsHbLM2UAxUUNsETRo7rFchP5m8joIjSxK7J/PD/JUFr2FCmdPNG67ZfMsMW bZSjEwg6Uj6fFjF1ZbfMbftgloA8EloCUUdc8lh67WWX7LfN9rAWvLFO7aSN/H7FcPa1 p8gN0oPVSHwmE7k7gC9evQiqEdXzrck7/8pWpk/JHNqi3nR6//e9hXRqOzu4JFFkAlKf lSXpV+u5asgZf/hue2phdIsPOMq9W/CM8oDNuV5DVjLtG3/W3zlvOKXR3Cuwtw3KpvyM 1ecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=s2xJk5kuw9HzXyjOYa9ht3wKQWc0/gmfp6f0SF77AbQ=; b=nWhrbd+DmJ+EM4d6rCORTx8Nm3yTnq6fx4TQuuMs6ODDE7p/Vw8UNa2dFsg5kFsUoe MC9w4Q95XF8ki6NyxcP/Om9npUNtz2SLaP0s+ZezFOlBtiAsXp4u8sZomeiwqJdsyw4W rBlWbuMuHQ8CgxGzJcjBQFc/EhYH+GPKAAaAByYmrWuSkTTb+bd8t+grx7RikGzUFTPx 1lnM372nU5mBewSxjh0kwHeVRgdNIK06+GM7XEQV1+fJI1p+HOP+ekTkuijMjGO2CTPh KXNc4vs0m17yYW+HfsStzlB0EjbGFmx1djhAVtUtet0gPxpLiJCebvDNguzOe2YHG4c/ RMBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PoryDmHw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si17834388pgc.21.2019.02.28.07.00.32; Thu, 28 Feb 2019 07:00:48 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=PoryDmHw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732752AbfB1OYT (ORCPT + 99 others); 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-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-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.21.0