From patchwork Mon Feb 13 16:38:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 9570249 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 DAAFA6045D for ; Mon, 13 Feb 2017 16:41:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA1AE26E77 for ; Mon, 13 Feb 2017 16:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDDBF2711E; Mon, 13 Feb 2017 16:41:25 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 272A326E77 for ; Mon, 13 Feb 2017 16:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EitqwJxfnCddKdHeVNRhPOEJEkb7CVrSMDOjW1S6aY0=; b=Cm/q5dMJ1ustcl rs1KRn1G8daHbnElHTnJxFL0mrA9uo0N6HVaqVksJt9jRTvpQCkSAESiYbSm40UG6TE+kr8o0e7uW W2nv7zX4opn8H/B3j7mn30bFCcfX89dscLQNoJOJfztrMs/dW7Lij+CVv3yKEtqOmS5hnLMvpS5tF j5jdIISC18klate2GyG7cFPgFufacnlQyMmfsOKsICf/CjQXFMGzIsoZ9HziuCkcOGu55hEcbxi01 JwoszYhzTl8fMrY2o6dCT6P3nQ6tRgV4cNvNXi62Xez3E3VidaqoiJsJSWhD+ZQej//cEVHfrVBdy 259gPHifSQSiq6nM0nGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cdJgq-0008K7-Px; Mon, 13 Feb 2017 16:41:24 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cdJfE-000632-DD for linux-arm-kernel@lists.infradead.org; Mon, 13 Feb 2017 16:39:57 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v1DGcMXH026157; Mon, 13 Feb 2017 17:39:10 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 28hry1uf0u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 13 Feb 2017 17:39:10 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7FAD53D; Mon, 13 Feb 2017 16:39:09 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 47FB22996; Mon, 13 Feb 2017 16:39:09 +0000 (GMT) Received: from localhost (10.201.23.162) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 13 Feb 2017 17:39:08 +0100 From: Arnaud Pouliquen To: Rob Herring , Mark Rutland , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Subject: [RFC v2 3/7] IIO: ADC: add sigma delta modulator support Date: Mon, 13 Feb 2017 17:38:25 +0100 Message-ID: <1487003909-11710-4-git-send-email-arnaud.pouliquen@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487003909-11710-1-git-send-email-arnaud.pouliquen@st.com> References: <1487003909-11710-1-git-send-email-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.162] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-13_09:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170213_083945_331219_6D4EE0D9 X-CRM114-Status: GOOD ( 18.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, olivier moysan , kernel@stlinux.com, linux-iio@vger.kernel.org, arnaud.pouliquen@st.com, Maxime Coquelin , linux-arm-kernel@lists.infradead.org, Alexandre Torgue Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add dummy driver to support sigma delta modulators. Signed-off-by: Arnaud Pouliquen --- drivers/iio/adc/Kconfig | 11 ++++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/simple_sd_adc.c | 112 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/iio/adc/simple_sd_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index e0b3c09..d4366ac 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -419,6 +419,17 @@ config ROCKCHIP_SARADC To compile this driver as a module, choose M here: the module will be called rockchip_saradc. +config SIMPLE_SD_ADC + tristate "Simple sigma delta modulator" + depends on OF + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Select this option to enables generic sigma delta modulator. + + This driver can also be built as a module. If so, the module + will be called simple-sd-adc. + config STM32_ADC_CORE tristate "STMicroelectronics STM32 adc core" depends on ARCH_STM32 || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 8e02a94..bd67144 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_VF610_ADC) += vf610_adc.o obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o xilinx-xadc-y := xilinx-xadc-core.o xilinx-xadc-events.o obj-$(CONFIG_XILINX_XADC) += xilinx-xadc.o +obj-$(CONFIG_SIMPLE_SD_ADC) += simple_sd_adc.o diff --git a/drivers/iio/adc/simple_sd_adc.c b/drivers/iio/adc/simple_sd_adc.c new file mode 100644 index 0000000..4bc8b3c --- /dev/null +++ b/drivers/iio/adc/simple_sd_adc.c @@ -0,0 +1,112 @@ +/* + * simple sigma delta modulator driver + * + * Copyright (C) 2016, STMicroelectronics - All Rights Reserved + * Author: Arnaud Pouliquen . + * + * License type: GPLv2 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include + +#include + +static int simple_sd_of_xlate(struct iio_dev *iio, + const struct of_phandle_args *iiospec) +{ + dev_dbg(&iio->dev, "%s:\n", __func__); + if (iiospec->args[0] != 0) { + dev_err(&iio->dev, "Only one channel supported\n"); + return -EINVAL; + } + + return 0; +} + +static const struct iio_info simple_sd_iio_info = { + .of_xlate = simple_sd_of_xlate, +}; + +static const struct iio_buffer_setup_ops simple_sd_buffer_ops; + +static int simple_sd_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct iio_dev *iio; + struct iio_chan_spec *ch; + + dev_dbg(&pdev->dev, "%s:\n", __func__); + iio = devm_iio_device_alloc(dev, 0); + if (!iio) + return -ENOMEM; + + /* Define one channel */ + ch = devm_kzalloc(&iio->dev, sizeof(*ch), GFP_KERNEL); + if (!ch) + return -ENOMEM; + + iio->dev.parent = dev; + iio->dev.of_node = dev->of_node; + iio->name = dev_name(dev); + iio->info = &simple_sd_iio_info; + iio->modes = INDIO_BUFFER_HARDWARE; + + ch->type = IIO_VOLTAGE; + ch->indexed = 1; + ch->scan_index = 0; + ch->scan_type.sign = 'u'; + ch->scan_type.realbits = 1; + ch->scan_type.storagebits = 1; + ch->scan_type.shift = 0; + + iio->num_channels = 1; + iio->channels = ch; + + platform_set_drvdata(pdev, iio); + + return iio_device_register(iio); +} + +static int simple_sd_remove(struct platform_device *pdev) +{ + struct iio_dev *iio = platform_get_drvdata(pdev); + + iio_device_unregister(iio); + + return 0; +} + +static const struct of_device_id sd_adc_of_match[] = { + { .compatible = "sd-modulator" }, + { } +}; +MODULE_DEVICE_TABLE(of, adc081c_of_match); + +static struct platform_driver simple_sd_adc = { + .driver = { + .name = "simple_sd_adc", + .of_match_table = of_match_ptr(sd_adc_of_match), + }, + .probe = simple_sd_probe, + .remove = simple_sd_remove, +}; + +module_platform_driver(simple_sd_adc); + +MODULE_DESCRIPTION("simple signma delta modulator"); +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_LICENSE("GPL v2");