Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1580902ybh; Sun, 15 Mar 2020 06:16:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvsnNf7jFC+l5BOG/UcMJvpCpC/0lGQPlz+WUKG56ajtCoaUZoyTkurFyK3YrNg1JOf5Zv9 X-Received: by 2002:aca:b205:: with SMTP id b5mr14164554oif.21.1584278179836; Sun, 15 Mar 2020 06:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584278179; cv=none; d=google.com; s=arc-20160816; b=t8KmzlkfDaN4ywygaxYPM/lAF7dwYO7kMKnf+Ag+Y0gy/1DpYr9x/6GSlVRudGJKku 1upEcWED+iKFdmF4Guk5dtiNGEm68XcYUN4InyEDk+xqFdQdo9ABohWz1OxGHg6FUyQf d2J+JdeG6ROatRhMDUjLzBMBy2MLHXfnO98Imat6jmPfX5a0UiBKqwh2E2ixKJGxnMvl q10C4KnQc3rmDAYpumc5ye1+Bf+AevA39z4LdRH64ovWD3vDw/pzWt3AZJFsC33QL2qr ivyVPkKsYs7QCJSl+erPwoccEbaRip0rL0NbXghmjnj0xyCrkxeZwnb4bCbaS/aym0Jd T6zg== 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=0fRkG3i4NRkz9bobYlk2U0aP2A4tItePp3W4blCcEHQ=; b=WXPky1HCFYPuvMQoVMU6zhcl435EbaymzxylsvRfDHEszOIfNHq6cfI1rpFDkBFciT UMYcKjzzLBd0OeiVry0kgf4nSl/gOnfPtQnwjtb7BYIfLJrIxRJpbC2AGKP4O6hVhfG5 2B7JpyxAw9A5y64DCRNw2c1g5Xyh1End89JlVXbJlTwRMTkhtoUVuydqMMFB10Nd5IwP uP5zWBnkwjsjCQYKBZqW0v+hpavfXe/YSlGKy7S6aIyTHqyheXwubtP998WhM67cQe3E AuScRv785cg/Cl1LVmPhhEgAQ3K7j/hwLYGM8L22cKoMns20cwgJXsM7ZVHcKSCSdnoG U/zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g15s06qB; 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 u137si4713083oie.160.2020.03.15.06.16.05; Sun, 15 Mar 2020 06:16:19 -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=g15s06qB; 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 S1728585AbgCONPd (ORCPT + 99 others); Sun, 15 Mar 2020 09:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728541AbgCONPd (ORCPT ); Sun, 15 Mar 2020 09:15:33 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 2018E205ED; Sun, 15 Mar 2020 13:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584278132; bh=L9TCRCZ/dfS6izNS/TAi3NM2t9evQsFx3I2zI4Tegkc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=g15s06qBzzuM92lhLrGFDokl0lsw+cXpgaPI7cKoOez5Z157aY6qcgEvwo8KMaO1d lZASTNIpjepve7914QQf1mrfjsL+iNuhbJlfdb0ihwIWaildxFuljalkyWyTQOLqIB XqkruAHyyfHGdiJD+ceapuOJw1kQF+yAHv8PSFzA= Date: Sun, 15 Mar 2020 13:15:28 +0000 From: Jonathan Cameron To: Beniamin Bia Cc: , , , , , , Dragos Bogdan Subject: Re: [PATCH 1/4] iio: adc: ad7476: Generate CONVST signal internally Message-ID: <20200315131528.11d1b8bd@archlinux> In-Reply-To: <20200311084328.17680-1-beniamin.bia@analog.com> References: <20200311084328.17680-1-beniamin.bia@analog.com> X-Mailer: Claws Mail 3.17.4 (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 Wed, 11 Mar 2020 10:43:25 +0200 Beniamin Bia wrote: > From: Dragos Bogdan > > Compared to the other supported parts, AD7091R are dependent of > a CONVST signal that initiates the conversion. At this moment, only > sampling in buffered mode is supported for AD7091R and the only > option until now was to generate this signal externally using an > IIO trigger. This patch adds the option of generating it internally, > more compatible triggers being available in this case. > > Also, it is an intermiate step of adding support more devices. > > Signed-off-by: Dragos Bogdan > Signed-off-by: Beniamin Bia Seems sensible. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/adc/ad7476.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c > index 76747488044b..32e857dfec9c 100644 > --- a/drivers/iio/adc/ad7476.c > +++ b/drivers/iio/adc/ad7476.c > @@ -12,9 +12,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > > #include > #include > @@ -34,6 +36,7 @@ struct ad7476_state { > struct spi_device *spi; > const struct ad7476_chip_info *chip_info; > struct regulator *reg; > + struct gpio_desc *convst_gpio; > struct spi_transfer xfer; > struct spi_message msg; > /* > @@ -64,6 +67,17 @@ enum ad7476_supported_device_ids { > ID_ADS7868, > }; > > +static void ad7091_convst(struct ad7476_state *st) > +{ > + if (!st->convst_gpio) > + return; > + > + gpiod_set_value(st->convst_gpio, 0); > + udelay(1); /* CONVST pulse width: 10 ns min */ > + gpiod_set_value(st->convst_gpio, 1); > + udelay(1); /* Conversion time: 650 ns max */ > +} > + > static irqreturn_t ad7476_trigger_handler(int irq, void *p) > { > struct iio_poll_func *pf = p; > @@ -71,6 +85,8 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) > struct ad7476_state *st = iio_priv(indio_dev); > int b_sent; > > + ad7091_convst(st); > + > b_sent = spi_sync(st->spi, &st->msg); > if (b_sent < 0) > goto done; > @@ -254,6 +270,12 @@ static int ad7476_probe(struct spi_device *spi) > if (ret) > return ret; > > + st->convst_gpio = devm_gpiod_get_optional(&spi->dev, > + "adi,conversion-start", > + GPIOD_OUT_LOW); > + if (IS_ERR(st->convst_gpio)) > + return PTR_ERR(st->convst_gpio); > + > spi_set_drvdata(spi, indio_dev); > > st->spi = spi;