Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1999965imu; Sat, 12 Jan 2019 12:39:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7lya5otmUmDhwcptvYlC0WKAuwXS65yiZ12+oP7F4aC7uX4qCionn1g6kRY6paRxhVvIT2 X-Received: by 2002:a63:c904:: with SMTP id o4mr17722222pgg.331.1547325562685; Sat, 12 Jan 2019 12:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547325562; cv=none; d=google.com; s=arc-20160816; b=GCavijkUWsImlWk3x6Af8JWJMLPqEe5ByI1tB1Wldr5RbO70IcQkNCb43xrYT9or3N 8MDxry6WTl2MAYik3j54SRsrYO/a96vF+fYFANkpIKCdaFCjFnpTZNuFYA0tpJFZJd4l 68hlBisNwR75tzDDdR6Juy1g+Ne0NGQaUbsH4ww3g1SwbBg/Wh4eUUs/z4c82uLclS8J E9r3NRoL1MYdYmPJEbSbOyoMCbvWWFolRAirJuRgyTTxOkRmfD4oYt2v5NLCTL2Fs1j2 IeoJ0wN1GNdGzXV5847q6NmQIBBeJWf0Ol6FnarJoRsBfCx3YlGDoVPVk+YyaRYOJ3xI WBGw== 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=3vb+28HuW5WRpW401doYcdLDGBZgSlpu+XGs/ahRqFA=; b=ty1mDj1CTt6meQlqaG7Vn7Wg4xlSIyPqcKzNNUfbiTcGNVPoBk5B0FCg6d4IDcqvK5 +bPtSNjEiSkAoKWoJCdJm/MB0/CFnDF/8W1wIFgNVCRp79dz4urcv2MbrpX9q0Cl+FVO oJPNcLqTdGB+ayCIWQAK7D47W93+KXH6uO2x84s5j0jy7q044f8yySJANQLq/ReXnsA6 tS6NS53Fa4+IQg6h08GhkbX0q88kW5m6CaTZopAEHI4QbBbFrwKYox9lMtEDNMLTRDcw RSTHK7zwauhLP0UZKSmd/SCX++/jlIXfAj0agefr9I3KMmU/2omGifoiupXnQguaOHTC KjDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="WsCxB/f3"; 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 k18si13962103pfd.241.2019.01.12.12.38.38; Sat, 12 Jan 2019 12:39:22 -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=@kernel.org header.s=default header.b="WsCxB/f3"; 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 S1726534AbfALS5z (ORCPT + 99 others); Sat, 12 Jan 2019 13:57:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:39082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725851AbfALS5y (ORCPT ); Sat, 12 Jan 2019 13:57:54 -0500 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 44CDC20836; Sat, 12 Jan 2019 18:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547319473; bh=rsDB393On6co7N5TK8mmmuL05w2x2LiSmKOC9CGOZxE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WsCxB/f3keoLgqMDQ6GTRqQz8nZ88NalRVAptMTPdYrQ/BmNcluZFGirVwLHbRAyE f5lsy+PetvcyGB0PhX3QnIlT+ei/au+6A29cK32CRZ4u08BmIZKB2oigDEaKy1375d o3ZC9UyjDHXQyfndfurGqbVRoNz5wYDCWdseYq+g= Date: Sat, 12 Jan 2019 18:57:49 +0000 From: Jonathan Cameron To: Mircea Caprioru Cc: , , , , Subject: Re: [PATCH] iio: dac: ad5686: Add support for AD5674R/AD5679R Message-ID: <20190112185749.15eb02e3@archlinux> In-Reply-To: <20190109091416.12060-1-mircea.caprioru@analog.com> References: <20190109091416.12060-1-mircea.caprioru@analog.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 Wed, 9 Jan 2019 11:14:16 +0200 Mircea Caprioru wrote: > The AD5674R/AD5679R are low power, 16-channel, 12-/16-bit buffered voltage > output digital-to-analog converters (DACs). They include a 2.5 V internal > reference (enabled by default). > > These devices are very similar to AD5684R/AD5686R, except that they have 16 > channels. > > Signed-off-by: Mircea Caprioru Looks good to me. One comment inline, but just ignore it ;) Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/dac/Kconfig | 6 +++--- > drivers/iio/dac/ad5686-spi.c | 7 ++++-- > drivers/iio/dac/ad5686.c | 42 ++++++++++++++++++++++++++++++++++-- > drivers/iio/dac/ad5686.h | 2 ++ > 4 files changed, 50 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig > index 851b61eaf3da..f28daf67db6a 100644 > --- a/drivers/iio/dac/Kconfig > +++ b/drivers/iio/dac/Kconfig > @@ -148,9 +148,9 @@ config AD5686_SPI > depends on SPI > select AD5686 > help > - Say yes here to build support for Analog Devices AD5672R, AD5676, > - AD5676R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, AD5686R. > - Voltage Output Digital to Analog Converter. > + Say yes here to build support for Analog Devices AD5672R, AD5674R, > + AD5676, AD5676R, AD5679R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, > + AD5686R Voltage Output Digital to Analog Converter. > > To compile this driver as a module, choose M here: the > module will be called ad5686. > diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c > index 665fa6bd9ced..4d857c8da2d2 100644 > --- a/drivers/iio/dac/ad5686-spi.c > +++ b/drivers/iio/dac/ad5686-spi.c > @@ -1,7 +1,8 @@ > // SPDX-License-Identifier: GPL-2.0+ > /* > - * AD5672R, AD5676, AD5676R, AD5681R, AD5682R, AD5683, AD5683R, > - * AD5684, AD5684R, AD5685R, AD5686, AD5686R > + * AD5672R, AD5674R, AD5676, AD5676R, AD5679R, > + * AD5681R, AD5682R, AD5683, AD5683R, AD5684, > + * AD5684R, AD5685R, AD5686, AD5686R This goes to show that listing the parts supported by the driver at the top is more trouble than it's worth. The nice id tables tell us the same thing and have much less churn ;) oh well. I don't really care obviously. > * Digital to analog converters driver > * > * Copyright 2018 Analog Devices Inc. > @@ -102,8 +103,10 @@ static int ad5686_spi_remove(struct spi_device *spi) > static const struct spi_device_id ad5686_spi_id[] = { > {"ad5310r", ID_AD5310R}, > {"ad5672r", ID_AD5672R}, > + {"ad5674r", ID_AD5674R}, > {"ad5676", ID_AD5676}, > {"ad5676r", ID_AD5676R}, > + {"ad5679r", ID_AD5679R}, > {"ad5681r", ID_AD5681R}, > {"ad5682r", ID_AD5682R}, > {"ad5683", ID_AD5683}, > diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c > index a332b93ca2c4..6dd2759b9092 100644 > --- a/drivers/iio/dac/ad5686.c > +++ b/drivers/iio/dac/ad5686.c > @@ -71,7 +71,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, > int ret; > struct ad5686_state *st = iio_priv(indio_dev); > unsigned int val, ref_bit_msk; > - u8 shift; > + u8 shift, address = 0; > > ret = strtobool(buf, &readin); > if (ret) > @@ -94,6 +94,9 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, > case AD5686_REGMAP: > shift = 0; > ref_bit_msk = 0; > + /* AD5674R/AD5679R have 16 channels and 2 powerdown registers */ > + if (chan->channel > 0x7) > + address = 0x8; > break; > case AD5693_REGMAP: > shift = 13; > @@ -107,7 +110,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, > if (!st->use_internal_vref) > val |= ref_bit_msk; > > - ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, 0, val); > + ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, > + address, val >> (address * 2)); > > return ret ? ret : len; > } > @@ -226,10 +230,32 @@ static struct iio_chan_spec name[] = { \ > AD5868_CHANNEL(7, 7, bits, _shift), \ > } > > +#define DECLARE_AD5679_CHANNELS(name, bits, _shift) \ > +static struct iio_chan_spec name[] = { \ > + AD5868_CHANNEL(0, 0, bits, _shift), \ > + AD5868_CHANNEL(1, 1, bits, _shift), \ > + AD5868_CHANNEL(2, 2, bits, _shift), \ > + AD5868_CHANNEL(3, 3, bits, _shift), \ > + AD5868_CHANNEL(4, 4, bits, _shift), \ > + AD5868_CHANNEL(5, 5, bits, _shift), \ > + AD5868_CHANNEL(6, 6, bits, _shift), \ > + AD5868_CHANNEL(7, 7, bits, _shift), \ > + AD5868_CHANNEL(8, 8, bits, _shift), \ > + AD5868_CHANNEL(9, 9, bits, _shift), \ > + AD5868_CHANNEL(10, 10, bits, _shift), \ > + AD5868_CHANNEL(11, 11, bits, _shift), \ > + AD5868_CHANNEL(12, 12, bits, _shift), \ > + AD5868_CHANNEL(13, 13, bits, _shift), \ > + AD5868_CHANNEL(14, 14, bits, _shift), \ > + AD5868_CHANNEL(15, 15, bits, _shift), \ > +} > + > DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); > DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); > DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); > +DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); > DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); > +DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0); > DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4); > DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); > DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0); > @@ -262,6 +288,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { > .num_channels = 8, > .regmap_type = AD5686_REGMAP, > }, > + [ID_AD5674R] = { > + .channels = ad5674r_channels, > + .int_vref_mv = 2500, > + .num_channels = 16, > + .regmap_type = AD5686_REGMAP, > + }, > [ID_AD5675R] = { > .channels = ad5676_channels, > .int_vref_mv = 2500, > @@ -279,6 +311,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { > .num_channels = 8, > .regmap_type = AD5686_REGMAP, > }, > + [ID_AD5679R] = { > + .channels = ad5679r_channels, > + .int_vref_mv = 2500, > + .num_channels = 16, > + .regmap_type = AD5686_REGMAP, > + }, > [ID_AD5681R] = { > .channels = ad5691r_channels, > .int_vref_mv = 2500, > diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h > index 19f6917d4738..4c3e171ce0cc 100644 > --- a/drivers/iio/dac/ad5686.h > +++ b/drivers/iio/dac/ad5686.h > @@ -54,9 +54,11 @@ enum ad5686_supported_device_ids { > ID_AD5311R, > ID_AD5671R, > ID_AD5672R, > + ID_AD5674R, > ID_AD5675R, > ID_AD5676, > ID_AD5676R, > + ID_AD5679R, > ID_AD5681R, > ID_AD5682R, > ID_AD5683,