From patchwork Sun Jan 14 20:32:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Stevanovic X-Patchwork-Id: 10162773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2237602A7 for ; Sun, 14 Jan 2018 20:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 974BC28A62 for ; Sun, 14 Jan 2018 20:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B62A28AC5; Sun, 14 Jan 2018 20:32:59 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 6156D28A62 for ; Sun, 14 Jan 2018 20:32:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751920AbeANUcx (ORCPT ); Sun, 14 Jan 2018 15:32:53 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44939 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbeANUcw (ORCPT ); Sun, 14 Jan 2018 15:32:52 -0500 Received: by mail-wr0-f195.google.com with SMTP id w50so9757572wrc.11; Sun, 14 Jan 2018 12:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ESRgFnV51T1/WcMYPnPhA+vxb44AhMLzT/k8zHqI8PA=; b=sKHS3cZDDQ2hBhxF5w/yycrA2vHn/A6T6fuzyBwk8GWtEudDZWTVtvz28iFwb9cyx9 zDyDwR2V3HFXM91ztkUtrWIWhdua6jJvswc9ApZbwFLsbssil1e04AExdMHBzFucJlVD /xYXSZngz7Hw27EvvJyujFk5eO5iv7a8kOLviy0Khqm2hKCpoAg55bUZbBDhgh+OykJ/ 24uXbdaQL4DTXVMySsfSd5qlyq3LFonU/VG/PnXWS7tGm4cjj54Wjcx4Y2bch90DOelp HWvSGQisoMkIDsO2tE4Qs8CanbVfnLtGQE3De2O+fmr9E5JarLptjQpNqb9nGY/K7Hc2 i8dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ESRgFnV51T1/WcMYPnPhA+vxb44AhMLzT/k8zHqI8PA=; b=pKw6FdZKs+d4oSOJlrLYCq7Kv27J/zXR0Wx0yeS4ZP5CX46DOy9l8Lp6ieArTPf1uV WjSu4KKyHoVL5SyfBNhUg63cCNkwSzW8vu735dOqcDkrBqrXsuB3vL8AZZ7orJtEACRc VB83mNzWtX96kM/FQhpZ/ykWvBDvDivrWYFMArYwla2ZSfFlA0uEEZR0cDd1x/2ifSHr FdLY+WFekNtd00LTukL/QC2wsbNJHT5FPI31UqNpxZ2/rYkiqPRZI2wdKDpu2XJ0W8F5 SIuY+dkgYCZr8q8vDlf/UpxA7FYya4kRxi062ettss0eVVDlsHpeY00r0h0M1fXVQbTZ emUA== X-Gm-Message-State: AKwxytdfyhxZ++yG6UqK7Kfn5+Pjcl4Gj5EqFDvO7NC70TGBZhcpEmVb dNX6aDHK+3InJga+xX+iNSY= X-Google-Smtp-Source: ACJfBosgDhirP4jkSzdEPu40m8oZGz79ie3YMdM1P4KpugDuPTmAMWd3jEP+Gj0H4sMypYai2j/+bA== X-Received: by 10.223.173.131 with SMTP id w3mr11400963wrc.214.1515961971062; Sun, 14 Jan 2018 12:32:51 -0800 (PST) Received: from localhost.localdomain (LFbn-1-8169-84.w90-112.abo.wanadoo.fr. [90.112.78.84]) by smtp.gmail.com with ESMTPSA id b8sm15918148wma.2.2018.01.14.12.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Jan 2018 12:32:50 -0800 (PST) From: Milan Stevanovic To: jic23@kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com Cc: linux-kernel@vger.kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, pombredanne@nexb.com, Milan Stevanovic Subject: [PATCH v3 1/2] iio: adc: driver for ti adc081s/adc101s/adc121s Date: Sun, 14 Jan 2018 21:32:39 +0100 Message-Id: <1515961960-35157-1-git-send-email-milan.o.stevanovic@gmail.com> X-Mailer: git-send-email 2.7.4 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 Linux device driver for TI single-channel CMOS 8/10/12-bit analog-to-digital converter with a high-speed serial interface. Signed-off-by: Milan Stevanovic --- Changes in v2: - Fix typo error - Keep Copyright comment Changes in v3: - Split patch in two patches. - Second patch is license description --- drivers/iio/adc/ad7476.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index b7706bf..0ea0f90 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -1,5 +1,6 @@ /* - * AD7466/7/8 AD7476/5/7/8 (A) SPI ADC driver + * Analog Devices AD7466/7/8 AD7476/5/7/8 (A) SPI ADC driver + * TI ADC081S/ADC101S/ADC121S 8/10/12-bit SPI ADC driver * * Copyright 2010 Analog Devices Inc. * @@ -56,6 +57,9 @@ enum ad7476_supported_device_ids { ID_AD7468, ID_AD7495, ID_AD7940, + ID_ADC081S, + ID_ADC101S, + ID_ADC121S, }; static irqreturn_t ad7476_trigger_handler(int irq, void *p) @@ -147,6 +151,8 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, }, \ } +#define ADC081S_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \ + BIT(IIO_CHAN_INFO_RAW)) #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits), \ BIT(IIO_CHAN_INFO_RAW)) #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \ @@ -192,6 +198,18 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { .channel[0] = AD7940_CHAN(14), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, + [ID_ADC081S] = { + .channel[0] = ADC081S_CHAN(8), + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), + }, + [ID_ADC101S] = { + .channel[0] = ADC081S_CHAN(10), + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), + }, + [ID_ADC121S] = { + .channel[0] = ADC081S_CHAN(12), + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), + }, }; static const struct iio_info ad7476_info = { @@ -294,6 +312,9 @@ static const struct spi_device_id ad7476_id[] = { {"ad7910", ID_AD7467}, {"ad7920", ID_AD7466}, {"ad7940", ID_AD7940}, + {"adc081s", ID_ADC081S}, + {"adc101s", ID_ADC101S}, + {"adc121s", ID_ADC121S}, {} }; MODULE_DEVICE_TABLE(spi, ad7476_id);