From patchwork Sun Mar 10 17:45:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB997139A for ; Sun, 10 Mar 2019 17:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5CD28C79 for ; Sun, 10 Mar 2019 17:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD67B28F78; Sun, 10 Mar 2019 17:45:13 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 67F4D28C79 for ; Sun, 10 Mar 2019 17:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725816AbfCJRpM (ORCPT ); Sun, 10 Mar 2019 13:45:12 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:36243 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfCJRpM (ORCPT ); Sun, 10 Mar 2019 13:45:12 -0400 Received: by mail-qk1-f195.google.com with SMTP id c2so1435923qkb.3; Sun, 10 Mar 2019 10:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=lobLDAlrnYC0TAuM5nbXmB+CxrZAEtQnGAufgWBeZPs=; b=Kh0jZyfvcC6VXiDhLEMg0ACDNX0MrlOwCoe2pU1IqHhp68rUj4Z+b2DlydpvnHEzVf C1LJfkyGkjCgHm2w6w+h5ZY7u9otQfZc+TMsbBB6j5gyoMggOEaucI0+/H1+dq+XdYf4 1CwtHu4FE+lWZosQUm5uo3HmXDB8ulGzRxnOcP9wH/o/0mQuIsRUYhnf9ZdEj4jtYTWw y+mfV5jsr7EYFASyaxrg1QBOkf6KqVY7cpAYh+T5mcZIx8dnLyMAMM146q0WXHzoRIoQ V9aEwPzQWHY3BufSOT3aHdKPrBtZsI6K1BLMBMijSJP192su/r/Nfpzo9EEDsG7GjHKI JQSw== 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:mime-version :content-disposition:user-agent; bh=lobLDAlrnYC0TAuM5nbXmB+CxrZAEtQnGAufgWBeZPs=; b=cL09ytyxJNiUfJYQsTW8uu0PPRHCHP+XM0q+U6PV4ZZF2evqMNDU2eaAC61zlxrMfT LXOcYI+4GVQFGwkT8SrEVUiREf4phgf1JrMrm1vETJM2p22/7KciNpEZXHLn7PnCHAPL Zmt1rhtI3dCxT4y6p0rAZS/PEU2lJpV/IIORFzB6Xo0/MRfvXInrQWKw7PKlw954yaxS AnqITX6150lOU88a3qMrHxO+ejgMI5gkcG6C0m1kwibqsZ2LHacw+pRYCbrIFnn5/jX1 ueMLLNrUK/GFSXI0nGMPl8cyT71YWK7by/jS52EdTpnPu9bJQ27RmZAUtsR1YRYpYucX Ak0A== X-Gm-Message-State: APjAAAUN64ogfN4aO4+zuhqGVsAABe9ty1gOPzFv7r9N8s3ovDjgoxD5 oND0sVxvEf2CrhZIEshcbJqFB5Rmh5v0ew== X-Google-Smtp-Source: APXvYqy62foxczrhHce78frLo12VCLyy66yGeHEoegGHuomol2+HzIZHNSHXH8edm/QK+u0d8KefDg== X-Received: by 2002:ae9:e10c:: with SMTP id g12mr4386898qkm.86.1552239910875; Sun, 10 Mar 2019 10:45:10 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id v31sm2150904qtc.62.2019.03.10.10.45.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:45:10 -0700 (PDT) Date: Sun, 10 Mar 2019 14:45:06 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 1/7] staging: iio: ad5933: change multi-line comment style Message-ID: <20190310174506.u7tbukmns3hyeq3b@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 Make multi-line comments compliant with the preferred code style. Signed-off-by: Marcelo Schmitt --- drivers/staging/iio/impedance-analyzer/ad5933.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3134295f014f..05e2185bfdae 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -474,7 +474,8 @@ static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 0644, ad5933_store, AD5933_OUT_SETTLING_CYCLES); -/* note: +/* + * note: * ideally we would handle the scale attributes via the iio_info * (read|write)_raw methods, however this part is a untypical since we * don't create dedicated sysfs channel attributes for out0 and in0. @@ -572,7 +573,8 @@ static int ad5933_ring_postenable(struct iio_dev *indio_dev) { struct ad5933_state *st = iio_priv(indio_dev); - /* AD5933_CTRL_INIT_START_FREQ: + /* + * AD5933_CTRL_INIT_START_FREQ: * High Q complex circuits require a long time to reach steady state. * To facilitate the measurement of such impedances, this mode allows * the user full control of the settling time requirement before @@ -663,7 +665,8 @@ static void ad5933_work(struct work_struct *work) } if (status & AD5933_STAT_SWEEP_DONE) { - /* last sample received - power down do + /* + * last sample received - power down do * nothing until the ring enable is toggled */ ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); From patchwork Sun Mar 10 17:45:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83EA31390 for ; Sun, 10 Mar 2019 17:45:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF4828F78 for ; Sun, 10 Mar 2019 17:45:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F16528C79; Sun, 10 Mar 2019 17:45:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0509A28C79 for ; Sun, 10 Mar 2019 17:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbfCJRp3 (ORCPT ); Sun, 10 Mar 2019 13:45:29 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33737 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfCJRp3 (ORCPT ); Sun, 10 Mar 2019 13:45:29 -0400 Received: by mail-qt1-f196.google.com with SMTP id z39so2656475qtz.0; Sun, 10 Mar 2019 10:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Na8cn6ZpM3g5SgVUX/cLn0sa0oxjd9imZV6NYEIWFu0=; b=ltsMJJUFXpu1LYE7umoiwKJWeI6J9rIlGON924T0CFSl0DwyN3gW4OXJlsFa98mQW5 RdlrNjYdOL1Rmkg4VO41Sr9VYKjOC1mwsIHzSreGiOJ8G6YM0R2035oc9ypz8fX3Sac6 lXNihAQGREpzXJlIE8BxXtZ52oCg2k8Lvju7p9b1QlfN3AOv/93Wi6Ur8LEFqTw66o3R EPtUAXW+hh3jNRx50peBsWbOza/oGISjO38QzbikVBtDngbARLNDTW5sujkRGqzFqktk aZqnn1W+9tmH2KSxKj8kQSXpwrRNe9T8SgCmaOBLgfJOKc6a7npzZNW/mE/XHExLUQHM LflQ== 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:mime-version :content-disposition:user-agent; bh=Na8cn6ZpM3g5SgVUX/cLn0sa0oxjd9imZV6NYEIWFu0=; b=JDMjPrPhuQaW3u8Y/sr8KYiZtnl54hvEndt8q+16bjaz5KSGMJY/TtCSxyGt0nwJBP coJ42EOisz6zxcTxc0GtqqAuua03cBRhWm8u+af5PysjsYbT3wN6M2FQKk0L5UmLRQ1d kpUliPUZwUASPTHXbxj/j1DiF9z0dAw6R1F/cCrNR5lU5XbBMgqvN1L1cgh5t23g0d28 DMeS6V/PtCou6tLyR2/T78sGnKL9Zn35YlQVIVosAQnJg6CffEqBRVUHUErMsu8TtglR PR9hDFKMzdVKT6fuF/SRlnEYxsaCFwe+HgOjax0KF2vK0v0OYaECYJcmEXBC+gxe9xch 4j5w== X-Gm-Message-State: APjAAAX83op71/IU4h/jKtLkiYw8ItMPiGFaIldBp9/DM+mGhOGVzevT 3fteGXsr+EbNgFs2c28gCh8= X-Google-Smtp-Source: APXvYqycfl2QcY/lYYXLU8ty2wDUocZd7DZ4hHhYAKTVaPye6QXc1NI2w+S5GN+2Ulc4tJ9C9Lr6DQ== X-Received: by 2002:aed:3608:: with SMTP id e8mr22989488qtb.31.1552239928105; Sun, 10 Mar 2019 10:45:28 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id q23sm1826222qkc.64.2019.03.10.10.45.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:45:27 -0700 (PDT) Date: Sun, 10 Mar 2019 14:45:24 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 2/7] staging: iio: ad5933: organize includes Message-ID: <20190310174524.taz6riaojgjyody3@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 Organize includes to list them in lexicographic order. Signed-off-by: Marcelo Schmitt --- .../staging/iio/impedance-analyzer/ad5933.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 05e2185bfdae..c2a7a59e469c 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -6,22 +6,22 @@ * Licensed under the GPL-2. */ -#include +#include +#include #include -#include -#include +#include #include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include +#include #include +#include /* AD5933/AD5934 Registers */ #define AD5933_REG_CONTROL_HB 0x80 /* R/W, 1 byte */ From patchwork Sun Mar 10 17:45:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D924A139A for ; Sun, 10 Mar 2019 17:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF69128C79 for ; Sun, 10 Mar 2019 17:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF95E28F78; Sun, 10 Mar 2019 17:45:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 609A828C79 for ; Sun, 10 Mar 2019 17:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726793AbfCJRpr (ORCPT ); Sun, 10 Mar 2019 13:45:47 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:46125 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726679AbfCJRpr (ORCPT ); Sun, 10 Mar 2019 13:45:47 -0400 Received: by mail-qk1-f196.google.com with SMTP id i5so1425438qkd.13; Sun, 10 Mar 2019 10:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Et0COeORfa9jig2CdFxD5Z1J1otj4MFOV8zBbjVTkA0=; b=Hn4IZHV2Ztq8qOc63lkCyyA/k5ZDuoLAYMKpyRk3o6WZsKjEXW3dXlLNyinM8LwG7d 4XXOP3BbJVodiflFdPXUsaIyfCqNA95O9rImvs6X/p0LwtskeCk69zKU6ePBRyRuVAsX uRMK1Xnm2UOToh4A+gkCfZM+LtsaVP/OSgCJTs5scCFhUyTvY/U9V/tF4LPIc9smo5RC /CSucwZep7xZ1A+/qk2nFFZ09E6MJ7YR54CEtX8EKwsdOksNXmz/QYIzsmFsjt4/APFK IHBldEYSa6lMmOCydBUUbQMCTh9flsn9gfObM0SalvO5LX5p9tXsRfMyGo2KZvaA4N3z o1Pw== 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:mime-version :content-disposition:user-agent; bh=Et0COeORfa9jig2CdFxD5Z1J1otj4MFOV8zBbjVTkA0=; b=Voe/Atu3nqzsmTj7Vf7Z6HeH3nIa1v9Cb/HvdB6CalCbOfWt5ff3MVTiSlewru15WO XM7skgUC87DnWCxa9gnbAJlGXSoRbDhTKOLBZohYw1yho1++iAzFOuMaEy/BNuSyNsoY PbuYlD4WvQycFqMYjwwZ/kY2nVhH4j+nHCz/vsQHbMmJPZ6FL4/atDwlnoi/YtD3VbVL 4cf4pMldfqDAQd6hOshvI+vpqXx/+4UW1dOcw/F9VQ5Bc2etM74MTWGfK+mPBcK6KcUg 0XesvKMWp9vn9jD76gzFvo7b50x70VTFdagSPQYmWMPD7GxYZmqQplztKu6WCaxQlHXK B50Q== X-Gm-Message-State: APjAAAW0CzyObyPckpaGDzj0U7mPZlEE3DqhF0rJtgB6VIiH+odYvewM C4HInREx4gSPCeGdYfCqnAA= X-Google-Smtp-Source: APXvYqzf5fv2XmEyyIv8Vkhz/TAsvx+pzbVKflA1aVfO7r63+EU6+x0QAac8mKYXctOwYYjiwnRqEw== X-Received: by 2002:a05:620a:14b2:: with SMTP id x18mr21143480qkj.82.1552239946660; Sun, 10 Mar 2019 10:45:46 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id g7sm1352838qkd.12.2019.03.10.10.45.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:45:46 -0700 (PDT) Date: Sun, 10 Mar 2019 14:45:42 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 3/7] staging: iio: ad5933: add SPDX identifier Message-ID: <20190310174542.3qsy6bmb654ej3a7@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 SPDX identifier of GPL-2.0 for the ad5933 driver. Signed-off-by: Marcelo Schmitt --- drivers/staging/iio/impedance-analyzer/ad5933.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index c2a7a59e469c..d75bdfbf93de 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * AD5933 AD5934 Impedance Converter, Network Analyzer * * Copyright 2011 Analog Devices Inc. - * - * Licensed under the GPL-2. */ #include From patchwork Sun Mar 10 17:45:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC4491390 for ; Sun, 10 Mar 2019 17:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3B8228C79 for ; Sun, 10 Mar 2019 17:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 957F828F78; Sun, 10 Mar 2019 17:46:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 34F7228C79 for ; Sun, 10 Mar 2019 17:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726679AbfCJRqE (ORCPT ); Sun, 10 Mar 2019 13:46:04 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39635 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfCJRqE (ORCPT ); Sun, 10 Mar 2019 13:46:04 -0400 Received: by mail-qt1-f194.google.com with SMTP id i14so2647044qtp.6; Sun, 10 Mar 2019 10:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=1dWlSdF/VUs9/9K5esBtgLKSgLb9YgXrY3lBZ+V781M=; b=YW+PNz9wMKDGle/+pZjLroqEbxn/1SdTfz5xkyN7+ow/sTRRpsH8frIkLB0g9MDxGk K6dIaHg5T6ICn7SRDy3aD4fT0Nkvnc8mdglrp1TfhM7BzGFGPMbCJL4ddDVPepCchT9/ xXDy9mTOGp/RcYj+zSXEi607qMDlHTOViyCq0lp/2d0GDrAIYvFAtVVczw/6hCUYWocZ QfrWvl7PyEdH2FvudxImS35G6gTLpNhw0evveK8bI7mIREi8Ys3HQXWl49DaqdHauLKw YwWRByOLulYx44MRNTqhgB/kVfGR6I/Yqv0gSQfT82hEQj1U5SbbBOv3uhGcwNB7Z6LV N3aw== 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:mime-version :content-disposition:user-agent; bh=1dWlSdF/VUs9/9K5esBtgLKSgLb9YgXrY3lBZ+V781M=; b=e9qDVQXyi1yhkbMjLhHHKCQDWDmXEXoT1+OfqwgwA6JdmaBVDChiNM80QkX8Qus4oi zSS79sm3vPOxkATN7ITRnfK4WC9UBllsNtpjluHVQRrYYIA2sO2SqsC59O0WKf+n6qlz DHF7b7EbGtH7qSo49Qp9AW+7caPMlnXbmz0GmQ+PlwU184UtsYF+sLR1hsOs8gerQHm5 lsE36sIdiPdho0Q4/19l48/DVKxWbDb9YIpxtoz1ZRs9psmM1TTdCYqxrZNBEZQwuhgA jfjqKkdOGLpJnfW7CFAcTQroWpVSH/UftcVS4n73jagfMfnlt0Et5ImzqWknvuTj69XR FK1A== X-Gm-Message-State: APjAAAVigsEnt0Uku1IeltOij0qVBao9bdv8xrw+Nrq9PnFlhglw3e3j TsB3Xi6qOlLeMw3YQTbn7XE= X-Google-Smtp-Source: APXvYqwE/4WvCwW5YFbzOqni0L6BSw+OV8ZnH7yYKbSnCpzunCQdnpo/3s74B7YiEIGhFAr8TeBfiA== X-Received: by 2002:ac8:2392:: with SMTP id q18mr22657620qtq.11.1552239963470; Sun, 10 Mar 2019 10:46:03 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id l36sm1957319qte.82.2019.03.10.10.46.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:46:03 -0700 (PDT) Date: Sun, 10 Mar 2019 14:45:59 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 4/7] staging: iio: ad5933: change help rule message Message-ID: <20190310174559.dq33lxdg4omdvhmg@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 Remove the previous comment about direct access via sysfs which would lead one think ad5933 driver has limitations it actually doesn't. Signed-off-by: Marcelo Schmitt --- drivers/staging/iio/impedance-analyzer/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig index dd97b6bb3fd0..b9a679cdd146 100644 --- a/drivers/staging/iio/impedance-analyzer/Kconfig +++ b/drivers/staging/iio/impedance-analyzer/Kconfig @@ -10,7 +10,7 @@ config AD5933 select IIO_KFIFO_BUF help Say yes here to build support for Analog Devices Impedance Converter, - Network Analyzer, AD5933/4, provides direct access via sysfs. + Network Analyzer, AD5933/4. To compile this driver as a module, choose M here: the module will be called ad5933. From patchwork Sun Mar 10 17:46:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 755021390 for ; Sun, 10 Mar 2019 17:46:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D45D28C79 for ; Sun, 10 Mar 2019 17:46:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5171D28F78; Sun, 10 Mar 2019 17:46:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 EF35C28C79 for ; Sun, 10 Mar 2019 17:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbfCJRqq (ORCPT ); Sun, 10 Mar 2019 13:46:46 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40219 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfCJRqq (ORCPT ); Sun, 10 Mar 2019 13:46:46 -0400 Received: by mail-qt1-f194.google.com with SMTP id f11so2645858qti.7; Sun, 10 Mar 2019 10:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=hbbIv4Vo3awyWNnS89ULbDFSxYn6LzfN95WMByYY4YQ=; b=nXzkVbieUAPZWlevcCZli84Ay/onIUf9XII0o1nL27SwJt0kRkz4VrS5QyaH422W7S 5gCYwou+Son2Koq9dnmcRwzOsyJkWiUdM21ULrEZfmwV9oR39bYnmdOluXnM/DwRvpOm f06lwZySpRQh9N5n5XI+uXFcUjYtsG9NUsTeeLvBWPpiqyYdW5f2H2e63KmBDeSTVHAS c2IFydQ6UttxqhKBw/S/oODCi4nihZSzAsPBFKKgpyRCr2I+pz/tML0g9kQTyINHNKxa MvqvDkQTXW7vDa8fhiDUShxabvK/uMEpYyuU/oovC7SFQKsXhJ87uphOFc73PFj+OLpv lW6A== 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:mime-version :content-disposition:user-agent; bh=hbbIv4Vo3awyWNnS89ULbDFSxYn6LzfN95WMByYY4YQ=; b=EJBYBE56MJVQWn2keUA2R38OWlt6Wtw6GmC5hVsuD42xtrJu/zWRnUasl1uIo1TUB1 Cs0fTEpXsjuDjo+7ZfhAJE4YeXIKX3nkmDFeIRkY85lF4nmJbrr8Yr7FmkM9CNJVl8JI UN7H+d1HjRhTLqXOa8271oVZfJNx962RrIuSxZ3yrlvJBfceMayauFAd5gZWJYfs7Pa9 G2LPRDzxZlo5zuLrRW5FKOOz0ZKiDq4dReih4JPesxVp6NtU9RDEm1LpKUxDt6pT1XfM M0aa1zXeDrIKjILhScn/irejtRQU2vLz5d0AJKFCsZ6PRQrSCSqiRbWenbL70jBMdxo9 B5Ew== X-Gm-Message-State: APjAAAWiJ6M8ClLNlM42ojQggx8Ejky5Z+7M5Zssh/1ws4OC13NOJWSE U5N/0h1KVI1Kqb7tdir9dZQ= X-Google-Smtp-Source: APXvYqwZjx/QWMxdBPYnnOz03fp2NwxodHwGfqMCWrebN5WP/MWwCVI0XMzguROizvhfD59snGRwOw== X-Received: by 2002:ad4:5103:: with SMTP id g3mr296575qvp.214.1552240004890; Sun, 10 Mar 2019 10:46:44 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id i1sm2001897qtb.0.2019.03.10.10.46.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:46:44 -0700 (PDT) Date: Sun, 10 Mar 2019 14:46:40 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 5/7] staging: iio: ad5933: add ABI documentation Message-ID: <20190310174640.dksy7pfkptrbcdgj@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 an ABI documentation for the ad5933 driver. Signed-off-by: Marcelo Schmitt --- .../ABI/testing/sysfs-bus-iio-ad5933 | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-ad5933 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-ad5933 b/Documentation/ABI/testing/sysfs-bus-iio-ad5933 new file mode 100644 index 000000000000..8a60dd178b1f --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-ad5933 @@ -0,0 +1,39 @@ +What:/sys/bus/iio/devices/iio:deviceX/out_voltage0_freq_start +Date: March 2019 +KernelVersion: Kernel 4.19 +Contact: linux-iio@vger.kernel.org +Description: + The start frequency. Set this to define the frequency point at + which the device should start the next frequency sweep. + +What:/sys/bus/iio/devices/iio:deviceX/out_voltage0_freq_increment +Date: March 2019 +KernelVersion: Kernel 4.19 +Contact: linux-iio@vger.kernel.org +Description: + The frequency sweep increment. Set this to define the amount by + which the frequency is incremented after each scan point. After + the measurement at a frequency point is completed, the next + measurement will be made at a frequency point + 'frequency increment'Hz higher than the previous one unless a + repeat frequency command is issued. This behavior will follow + until the defined number of frequency points have been measured + or frequency sweep is somewhat reset. + +What:/sys/bus/iio/devices/iio:deviceX/out_voltage0_freq_points +Date: March 2019 +KernelVersion: Kernel 4.19 +Contact: linux-iio@vger.kernel.org +Description: + The number of increments. This defines the number of frequency + points in the frequency sweep. + +What:/sys/bus/iio/devices/iio:deviceX/out_voltage0_settling_cycles +Date: March 2019 +KernelVersion: Kernel 4.19 +Contact: linux-iio@vger.kernel.org +Description: + Number of settling time cycles. This sets the delay between a + start frequency sweep/increment frequency /repeat frequency to + be proportional to the excitation signal frequency times the + number of settling time cycles. From patchwork Sun Mar 10 17:47:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2C241390 for ; Sun, 10 Mar 2019 17:47:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACD9C28C79 for ; Sun, 10 Mar 2019 17:47:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A060F28F78; Sun, 10 Mar 2019 17:47:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 3B18E28C79 for ; Sun, 10 Mar 2019 17:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbfCJRrI (ORCPT ); Sun, 10 Mar 2019 13:47:08 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:38825 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfCJRrI (ORCPT ); Sun, 10 Mar 2019 13:47:08 -0400 Received: by mail-qk1-f195.google.com with SMTP id z3so1436522qkf.5; Sun, 10 Mar 2019 10:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=biGbN1qZKcjEQifkIF3WDWR9XJQqnSG1Zf6I9cTOXp0=; b=tnKrfpKLESda8h7QeJDNIhF0qktGsiutkzE9u6NzPr3A7gskNc8g2w2NNkUjOEDTOV BySVbbzm2/jRNsb4niOLHDFxi1Vd7hZqRkqEQqNZcqrK+0PKlNlyagvXkv5iytcg0enF 9ZCq6shSrGm+DruBJspx+aHSOq31HavuwaU94pTctGjjVlEVEIrKEEm4Pt4XwZgJ260r AvUfmf0VXTBx7kobZJQoCC3yC09ZUFozKyUCPCUTAn27BkgzAdjDtIXndcRbFAH2rt3d b45HxoYAMzKhncl5u64aFvv0K33q8Riv07pHLXmq/xkpTftkBuYT78tRxz0pjzKTZgz2 iCFQ== 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:mime-version :content-disposition:user-agent; bh=biGbN1qZKcjEQifkIF3WDWR9XJQqnSG1Zf6I9cTOXp0=; b=cl2rHQGmOHG/1jeNX3oKECqx1LK2gz8h9sZZluN8Sr2qMqjnrfwNJrdRRWzrGzdm+l cJoalucoSFGlsy2LLnQIyMAF+8iDo9VVwGhvBEgEXvYFTeJGrA+rV+/FMVcPwNw3t2fF OOSyLz+nN8LBJVA8xtd151a1IgGOvXrwR1aPWJhAvPPqIUaMcS9THRqpIFbYgDhu1y3f uBO5XLb1fNlaSldBMcqb6XMPfRy9EJ/RanrAHHiC0lTLK7Onl7LJn1XN4/8Ak5yaIfGz MJK8cj4juVmQpRHrw1rXp2LP/IgVrTRAmq5v9FkQTlV6BdRM46EoX6SeFKNauVzqBcaT jnmQ== X-Gm-Message-State: APjAAAWb3tulmHtMHkLjAUABXYTzZ4W3YO2HtdK1KvbKTMNKUCwdfIKN 5neKZWQt5bEaMwJnGr4Qz3w= X-Google-Smtp-Source: APXvYqxMXJ0pDgOKHaIH6ga5oK3sYevhKrt4rJYzyYa8CxP5qtZfepDxvyA810NKcuDXUQzVbu7o5A== X-Received: by 2002:a37:4f45:: with SMTP id d66mr21671668qkb.81.1552240026919; Sun, 10 Mar 2019 10:47:06 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id u13sm2285694qtb.2.2019.03.10.10.47.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:47:06 -0700 (PDT) Date: Sun, 10 Mar 2019 14:47:02 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 6/7] staging: iio: ad5933: change attributes' ABI call Message-ID: <20190310174702.fko4xwrw5pclw6kr@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 Change device attributes to use more suitable ABI functions when setting and displaying AC output excitation voltage. It better complies with device hardware since these attributes are used to manage DDS peak-to-peak output voltage. Signed-off-by: Marcelo Schmitt --- drivers/staging/iio/impedance-analyzer/ad5933.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index d75bdfbf93de..314cb71b1b5a 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -443,12 +443,12 @@ static ssize_t ad5933_store(struct device *dev, return ret ? ret : len; } -static IIO_DEVICE_ATTR(out_voltage0_scale, 0644, +static IIO_DEVICE_ATTR(out_altvoltage0_raw, 0644, ad5933_show, ad5933_store, AD5933_OUT_RANGE); -static IIO_DEVICE_ATTR(out_voltage0_scale_available, 0444, +static IIO_DEVICE_ATTR(out_altvoltage0_scale_available, 0444, ad5933_show, NULL, AD5933_OUT_RANGE_AVAIL); @@ -480,8 +480,8 @@ static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 0644, * don't create dedicated sysfs channel attributes for out0 and in0. */ static struct attribute *ad5933_attributes[] = { - &iio_dev_attr_out_voltage0_scale.dev_attr.attr, - &iio_dev_attr_out_voltage0_scale_available.dev_attr.attr, + &iio_dev_attr_out_altvoltage0_raw.dev_attr.attr, + &iio_dev_attr_out_altvoltage0_scale_available.dev_attr.attr, &iio_dev_attr_out_voltage0_freq_start.dev_attr.attr, &iio_dev_attr_out_voltage0_freq_increment.dev_attr.attr, &iio_dev_attr_out_voltage0_freq_points.dev_attr.attr, From patchwork Sun Mar 10 17:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Schmitt X-Patchwork-Id: 10846395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A52B1390 for ; Sun, 10 Mar 2019 17:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62E7F28C79 for ; Sun, 10 Mar 2019 17:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 548EB28F78; Sun, 10 Mar 2019 17:47:35 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 D676128C79 for ; Sun, 10 Mar 2019 17:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfCJRrc (ORCPT ); Sun, 10 Mar 2019 13:47:32 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:40279 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfCJRrc (ORCPT ); Sun, 10 Mar 2019 13:47:32 -0400 Received: by mail-qt1-f195.google.com with SMTP id f11so2646934qti.7; Sun, 10 Mar 2019 10:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=U/9C6nHKxgwE9tjC/XRJk2GGafScXmIfb2Us8bo3FLQ=; b=R8kwSQ+ohpykcCTdyaSQ8ZUXAMWQOahoWeb70ygKzfu7RlZrSh1jVzLAfcLCIA48uk qCzpsaGPGkcrQgAqFboIQegIyDUap4/n6zTpyDIjLrR7c+Vj3r8Yp9ZfO8UrcdmAFl7w UECsehDEb5Lgo4r7MvCnyzLNWRIeRmsBpC/yhcHG8w+/aah4s1pZOFXtJ43CgPx+lJ57 ULhc45HS0BmCwIBT1c91u+N/cuj1anUjT6awVWz2tvkplsRGCt+rJi6NSFhNS4vF82U9 zr/iVrutVxH0jBj5sssNR9bbVNRrT1JCvkw26EtIUo07sR5DTbz8DCAJrdKDbYzfK/0h oUzQ== 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:mime-version :content-disposition:user-agent; bh=U/9C6nHKxgwE9tjC/XRJk2GGafScXmIfb2Us8bo3FLQ=; b=L/G3A2W8nZc/QKYfN0OBosJjNujAE84GNrTEm7N8pBIURZENVJXqRWdX1kELFOziZz IdE0731IYq5hkg9yuvwE11qZeNsmr2US5JaUiX0GSWO765rtQJ2up46gLx8x4j3EqrE8 M96RZCjkkG2y/fa7cjiKUNx3Dfp/eb9l0bdjalIk7f+a6E1brXX3Z+pmUCHR+SwZOJSK pB+K+8LSyhHVG6zcrIMVrxe7sJQsahY3PHzl0F+trghjfGfSQmS/sOpszdMtw4mHYEFE jZ7RDKQOUgMglM++/lr53wEcAm2Evhhp6DUmLln9AaT7NnQcXTP6XOvRg6iIK+DJM7QV nboQ== X-Gm-Message-State: APjAAAVdLHZPxKcDf9I8xLtSTogHVAT0PZYuIKBvaj/gs/qtMZT1gbpB NUjtJPQXqJjldriXnGJAcVw= X-Google-Smtp-Source: APXvYqz2ssKmUA3fQ5uWcgBG1VN/YKT2kOzqiusadfYI7fMK8v78EXn/ZY5C5Xc4hQQ44q/qrfbVmw== X-Received: by 2002:ac8:f4c:: with SMTP id l12mr22915840qtk.225.1552240048433; Sun, 10 Mar 2019 10:47:28 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id h58sm2244455qtb.89.2019.03.10.10.47.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 10:47:28 -0700 (PDT) Date: Sun, 10 Mar 2019 14:47:24 -0300 From: Marcelo Schmitt To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 7/7] staging: iio: ad5933: move out of staging Message-ID: <20190310174724.uezijzibo3bjmjet@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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 Move ad5933 impedance-analyzer driver from staging to mainline. The ad5933 is a high precision impedance converter system solution that combines an on-board frequency generator with an analog-to-digital converter (ADC). This driver was designed to be compatible with both ad5933 and ad5934 chips. Signed-off-by: Marcelo Schmitt --- drivers/iio/impedance-analyzer/Kconfig | 18 + drivers/iio/impedance-analyzer/Makefile | 5 + drivers/iio/impedance-analyzer/ad5933.c | 811 ++++++++++++++++++ .../staging/iio/impedance-analyzer/Kconfig | 18 - .../staging/iio/impedance-analyzer/Makefile | 5 - .../staging/iio/impedance-analyzer/ad5933.c | 811 ------------------ 6 files changed, 834 insertions(+), 834 deletions(-) create mode 100644 drivers/iio/impedance-analyzer/Kconfig create mode 100644 drivers/iio/impedance-analyzer/Makefile create mode 100644 drivers/iio/impedance-analyzer/ad5933.c delete mode 100644 drivers/staging/iio/impedance-analyzer/Kconfig delete mode 100644 drivers/staging/iio/impedance-analyzer/Makefile delete mode 100644 drivers/staging/iio/impedance-analyzer/ad5933.c diff --git a/drivers/iio/impedance-analyzer/Kconfig b/drivers/iio/impedance-analyzer/Kconfig new file mode 100644 index 000000000000..b9a679cdd146 --- /dev/null +++ b/drivers/iio/impedance-analyzer/Kconfig @@ -0,0 +1,18 @@ +# +# Impedance Converter, Network Analyzer drivers +# +menu "Network Analyzer, Impedance Converters" + +config AD5933 + tristate "Analog Devices AD5933, AD5934 driver" + depends on I2C + select IIO_BUFFER + select IIO_KFIFO_BUF + help + Say yes here to build support for Analog Devices Impedance Converter, + Network Analyzer, AD5933/4. + + To compile this driver as a module, choose M here: the + module will be called ad5933. + +endmenu diff --git a/drivers/iio/impedance-analyzer/Makefile b/drivers/iio/impedance-analyzer/Makefile new file mode 100644 index 000000000000..7604d786583e --- /dev/null +++ b/drivers/iio/impedance-analyzer/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Impedance Converter, Network Analyzer drivers +# + +obj-$(CONFIG_AD5933) += ad5933.o diff --git a/drivers/iio/impedance-analyzer/ad5933.c b/drivers/iio/impedance-analyzer/ad5933.c new file mode 100644 index 000000000000..314cb71b1b5a --- /dev/null +++ b/drivers/iio/impedance-analyzer/ad5933.c @@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AD5933 AD5934 Impedance Converter, Network Analyzer + * + * Copyright 2011 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* AD5933/AD5934 Registers */ +#define AD5933_REG_CONTROL_HB 0x80 /* R/W, 1 byte */ +#define AD5933_REG_CONTROL_LB 0x81 /* R/W, 1 byte */ +#define AD5933_REG_FREQ_START 0x82 /* R/W, 3 bytes */ +#define AD5933_REG_FREQ_INC 0x85 /* R/W, 3 bytes */ +#define AD5933_REG_INC_NUM 0x88 /* R/W, 2 bytes, 9 bit */ +#define AD5933_REG_SETTLING_CYCLES 0x8A /* R/W, 2 bytes */ +#define AD5933_REG_STATUS 0x8F /* R, 1 byte */ +#define AD5933_REG_TEMP_DATA 0x92 /* R, 2 bytes*/ +#define AD5933_REG_REAL_DATA 0x94 /* R, 2 bytes*/ +#define AD5933_REG_IMAG_DATA 0x96 /* R, 2 bytes*/ + +/* AD5933_REG_CONTROL_HB Bits */ +#define AD5933_CTRL_INIT_START_FREQ (0x1 << 4) +#define AD5933_CTRL_START_SWEEP (0x2 << 4) +#define AD5933_CTRL_INC_FREQ (0x3 << 4) +#define AD5933_CTRL_REPEAT_FREQ (0x4 << 4) +#define AD5933_CTRL_MEASURE_TEMP (0x9 << 4) +#define AD5933_CTRL_POWER_DOWN (0xA << 4) +#define AD5933_CTRL_STANDBY (0xB << 4) + +#define AD5933_CTRL_RANGE_2000mVpp (0x0 << 1) +#define AD5933_CTRL_RANGE_200mVpp (0x1 << 1) +#define AD5933_CTRL_RANGE_400mVpp (0x2 << 1) +#define AD5933_CTRL_RANGE_1000mVpp (0x3 << 1) +#define AD5933_CTRL_RANGE(x) ((x) << 1) + +#define AD5933_CTRL_PGA_GAIN_1 (0x1 << 0) +#define AD5933_CTRL_PGA_GAIN_5 (0x0 << 0) + +/* AD5933_REG_CONTROL_LB Bits */ +#define AD5933_CTRL_RESET (0x1 << 4) +#define AD5933_CTRL_INT_SYSCLK (0x0 << 3) +#define AD5933_CTRL_EXT_SYSCLK (0x1 << 3) + +/* AD5933_REG_STATUS Bits */ +#define AD5933_STAT_TEMP_VALID (0x1 << 0) +#define AD5933_STAT_DATA_VALID (0x1 << 1) +#define AD5933_STAT_SWEEP_DONE (0x1 << 2) + +/* I2C Block Commands */ +#define AD5933_I2C_BLOCK_WRITE 0xA0 +#define AD5933_I2C_BLOCK_READ 0xA1 +#define AD5933_I2C_ADDR_POINTER 0xB0 + +/* Device Specs */ +#define AD5933_INT_OSC_FREQ_Hz 16776000 +#define AD5933_MAX_OUTPUT_FREQ_Hz 100000 +#define AD5933_MAX_RETRIES 100 + +#define AD5933_OUT_RANGE 1 +#define AD5933_OUT_RANGE_AVAIL 2 +#define AD5933_OUT_SETTLING_CYCLES 3 +#define AD5933_IN_PGA_GAIN 4 +#define AD5933_IN_PGA_GAIN_AVAIL 5 +#define AD5933_FREQ_POINTS 6 + +#define AD5933_POLL_TIME_ms 10 +#define AD5933_INIT_EXCITATION_TIME_ms 100 + +struct ad5933_state { + struct i2c_client *client; + struct regulator *reg; + struct clk *mclk; + struct delayed_work work; + struct mutex lock; /* Protect sensor state */ + unsigned long mclk_hz; + unsigned char ctrl_hb; + unsigned char ctrl_lb; + unsigned int range_avail[4]; + unsigned short vref_mv; + unsigned short settling_cycles; + unsigned short freq_points; + unsigned int freq_start; + unsigned int freq_inc; + unsigned int state; + unsigned int poll_time_jiffies; +}; + +#define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \ + _scan_index, _realbits) { \ + .type = (_type), \ + .extend_name = (_extend_name), \ + .info_mask_separate = (_info_mask_separate), \ + .address = (_address), \ + .scan_index = (_scan_index), \ + .scan_type = { \ + .sign = 's', \ + .realbits = (_realbits), \ + .storagebits = 16, \ + }, \ +} + +static const struct iio_chan_spec ad5933_channels[] = { + AD5933_CHANNEL(IIO_TEMP, NULL, BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), AD5933_REG_TEMP_DATA, -1, 14), + /* Ring Channels */ + AD5933_CHANNEL(IIO_VOLTAGE, "real", 0, AD5933_REG_REAL_DATA, 0, 16), + AD5933_CHANNEL(IIO_VOLTAGE, "imag", 0, AD5933_REG_IMAG_DATA, 1, 16), +}; + +static int ad5933_i2c_write(struct i2c_client *client, u8 reg, u8 len, u8 *data) +{ + int ret; + + while (len--) { + ret = i2c_smbus_write_byte_data(client, reg++, *data++); + if (ret < 0) { + dev_err(&client->dev, "I2C write error\n"); + return ret; + } + } + return 0; +} + +static int ad5933_i2c_read(struct i2c_client *client, u8 reg, u8 len, u8 *data) +{ + int ret; + + while (len--) { + ret = i2c_smbus_read_byte_data(client, reg++); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + *data++ = ret; + } + return 0; +} + +static int ad5933_cmd(struct ad5933_state *st, unsigned char cmd) +{ + unsigned char dat = st->ctrl_hb | cmd; + + return ad5933_i2c_write(st->client, + AD5933_REG_CONTROL_HB, 1, &dat); +} + +static int ad5933_reset(struct ad5933_state *st) +{ + unsigned char dat = st->ctrl_lb | AD5933_CTRL_RESET; + + return ad5933_i2c_write(st->client, + AD5933_REG_CONTROL_LB, 1, &dat); +} + +static int ad5933_wait_busy(struct ad5933_state *st, unsigned char event) +{ + unsigned char val, timeout = AD5933_MAX_RETRIES; + int ret; + + while (timeout--) { + ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &val); + if (ret < 0) + return ret; + if (val & event) + return val; + cpu_relax(); + mdelay(1); + } + + return -EAGAIN; +} + +static int ad5933_set_freq(struct ad5933_state *st, + unsigned int reg, unsigned long freq) +{ + unsigned long long freqreg; + union { + __be32 d32; + u8 d8[4]; + } dat; + + freqreg = (u64)freq * (u64)(1 << 27); + do_div(freqreg, st->mclk_hz / 4); + + switch (reg) { + case AD5933_REG_FREQ_START: + st->freq_start = freq; + break; + case AD5933_REG_FREQ_INC: + st->freq_inc = freq; + break; + default: + return -EINVAL; + } + + dat.d32 = cpu_to_be32(freqreg); + return ad5933_i2c_write(st->client, reg, 3, &dat.d8[1]); +} + +static int ad5933_setup(struct ad5933_state *st) +{ + __be16 dat; + int ret; + + ret = ad5933_reset(st); + if (ret < 0) + return ret; + + ret = ad5933_set_freq(st, AD5933_REG_FREQ_START, 10000); + if (ret < 0) + return ret; + + ret = ad5933_set_freq(st, AD5933_REG_FREQ_INC, 200); + if (ret < 0) + return ret; + + st->settling_cycles = 10; + dat = cpu_to_be16(st->settling_cycles); + + ret = ad5933_i2c_write(st->client, + AD5933_REG_SETTLING_CYCLES, + 2, (u8 *)&dat); + if (ret < 0) + return ret; + + st->freq_points = 100; + dat = cpu_to_be16(st->freq_points); + + return ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, (u8 *)&dat); +} + +static void ad5933_calc_out_ranges(struct ad5933_state *st) +{ + int i; + unsigned int normalized_3v3[4] = {1980, 198, 383, 970}; + + for (i = 0; i < 4; i++) + st->range_avail[i] = normalized_3v3[i] * st->vref_mv / 3300; +} + +/* + * handles: AD5933_REG_FREQ_START and AD5933_REG_FREQ_INC + */ + +static ssize_t ad5933_show_frequency(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad5933_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret; + unsigned long long freqreg; + union { + __be32 d32; + u8 d8[4]; + } dat; + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad5933_i2c_read(st->client, this_attr->address, 3, &dat.d8[1]); + iio_device_release_direct_mode(indio_dev); + if (ret < 0) + return ret; + + freqreg = be32_to_cpu(dat.d32) & 0xFFFFFF; + + freqreg = (u64)freqreg * (u64)(st->mclk_hz / 4); + do_div(freqreg, 1 << 27); + + return sprintf(buf, "%d\n", (int)freqreg); +} + +static ssize_t ad5933_store_frequency(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad5933_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + unsigned long val; + int ret; + + ret = kstrtoul(buf, 10, &val); + if (ret) + return ret; + + if (val > AD5933_MAX_OUTPUT_FREQ_Hz) + return -EINVAL; + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad5933_set_freq(st, this_attr->address, val); + iio_device_release_direct_mode(indio_dev); + + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(out_voltage0_freq_start, 0644, + ad5933_show_frequency, + ad5933_store_frequency, + AD5933_REG_FREQ_START); + +static IIO_DEVICE_ATTR(out_voltage0_freq_increment, 0644, + ad5933_show_frequency, + ad5933_store_frequency, + AD5933_REG_FREQ_INC); + +static ssize_t ad5933_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad5933_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret = 0, len = 0; + + mutex_lock(&st->lock); + switch ((u32)this_attr->address) { + case AD5933_OUT_RANGE: + len = sprintf(buf, "%u\n", + st->range_avail[(st->ctrl_hb >> 1) & 0x3]); + break; + case AD5933_OUT_RANGE_AVAIL: + len = sprintf(buf, "%u %u %u %u\n", st->range_avail[0], + st->range_avail[3], st->range_avail[2], + st->range_avail[1]); + break; + case AD5933_OUT_SETTLING_CYCLES: + len = sprintf(buf, "%d\n", st->settling_cycles); + break; + case AD5933_IN_PGA_GAIN: + len = sprintf(buf, "%s\n", + (st->ctrl_hb & AD5933_CTRL_PGA_GAIN_1) ? + "1" : "0.2"); + break; + case AD5933_IN_PGA_GAIN_AVAIL: + len = sprintf(buf, "1 0.2\n"); + break; + case AD5933_FREQ_POINTS: + len = sprintf(buf, "%d\n", st->freq_points); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&st->lock); + return ret ? ret : len; +} + +static ssize_t ad5933_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad5933_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + u16 val; + int i, ret = 0; + __be16 dat; + + if (this_attr->address != AD5933_IN_PGA_GAIN) { + ret = kstrtou16(buf, 10, &val); + if (ret) + return ret; + } + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + mutex_lock(&st->lock); + switch ((u32)this_attr->address) { + case AD5933_OUT_RANGE: + ret = -EINVAL; + for (i = 0; i < 4; i++) + if (val == st->range_avail[i]) { + st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); + st->ctrl_hb |= AD5933_CTRL_RANGE(i); + ret = ad5933_cmd(st, 0); + break; + } + break; + case AD5933_IN_PGA_GAIN: + if (sysfs_streq(buf, "1")) { + st->ctrl_hb |= AD5933_CTRL_PGA_GAIN_1; + } else if (sysfs_streq(buf, "0.2")) { + st->ctrl_hb &= ~AD5933_CTRL_PGA_GAIN_1; + } else { + ret = -EINVAL; + break; + } + ret = ad5933_cmd(st, 0); + break; + case AD5933_OUT_SETTLING_CYCLES: + val = clamp(val, (u16)0, (u16)0x7FF); + st->settling_cycles = val; + + /* 2x, 4x handling, see datasheet */ + if (val > 1022) + val = (val >> 2) | (3 << 9); + else if (val > 511) + val = (val >> 1) | (1 << 9); + + dat = cpu_to_be16(val); + ret = ad5933_i2c_write(st->client, + AD5933_REG_SETTLING_CYCLES, + 2, (u8 *)&dat); + break; + case AD5933_FREQ_POINTS: + val = clamp(val, (u16)0, (u16)511); + st->freq_points = val; + + dat = cpu_to_be16(val); + ret = ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, + (u8 *)&dat); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&st->lock); + iio_device_release_direct_mode(indio_dev); + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(out_altvoltage0_raw, 0644, + ad5933_show, + ad5933_store, + AD5933_OUT_RANGE); + +static IIO_DEVICE_ATTR(out_altvoltage0_scale_available, 0444, + ad5933_show, + NULL, + AD5933_OUT_RANGE_AVAIL); + +static IIO_DEVICE_ATTR(in_voltage0_scale, 0644, + ad5933_show, + ad5933_store, + AD5933_IN_PGA_GAIN); + +static IIO_DEVICE_ATTR(in_voltage0_scale_available, 0444, + ad5933_show, + NULL, + AD5933_IN_PGA_GAIN_AVAIL); + +static IIO_DEVICE_ATTR(out_voltage0_freq_points, 0644, + ad5933_show, + ad5933_store, + AD5933_FREQ_POINTS); + +static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 0644, + ad5933_show, + ad5933_store, + AD5933_OUT_SETTLING_CYCLES); + +/* + * note: + * ideally we would handle the scale attributes via the iio_info + * (read|write)_raw methods, however this part is a untypical since we + * don't create dedicated sysfs channel attributes for out0 and in0. + */ +static struct attribute *ad5933_attributes[] = { + &iio_dev_attr_out_altvoltage0_raw.dev_attr.attr, + &iio_dev_attr_out_altvoltage0_scale_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_start.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_increment.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_points.dev_attr.attr, + &iio_dev_attr_out_voltage0_settling_cycles.dev_attr.attr, + &iio_dev_attr_in_voltage0_scale.dev_attr.attr, + &iio_dev_attr_in_voltage0_scale_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group ad5933_attribute_group = { + .attrs = ad5933_attributes, +}; + +static int ad5933_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad5933_state *st = iio_priv(indio_dev); + __be16 dat; + int ret; + + switch (m) { + case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad5933_cmd(st, AD5933_CTRL_MEASURE_TEMP); + if (ret < 0) + goto out; + ret = ad5933_wait_busy(st, AD5933_STAT_TEMP_VALID); + if (ret < 0) + goto out; + + ret = ad5933_i2c_read(st->client, + AD5933_REG_TEMP_DATA, + 2, (u8 *)&dat); + if (ret < 0) + goto out; + iio_device_release_direct_mode(indio_dev); + *val = sign_extend32(be16_to_cpu(dat), 13); + + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 1000; + *val2 = 5; + return IIO_VAL_FRACTIONAL_LOG2; + } + + return -EINVAL; +out: + iio_device_release_direct_mode(indio_dev); + return ret; +} + +static const struct iio_info ad5933_info = { + .read_raw = ad5933_read_raw, + .attrs = &ad5933_attribute_group, +}; + +static int ad5933_ring_preenable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + int ret; + + if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) + return -EINVAL; + + ret = ad5933_reset(st); + if (ret < 0) + return ret; + + ret = ad5933_cmd(st, AD5933_CTRL_STANDBY); + if (ret < 0) + return ret; + + ret = ad5933_cmd(st, AD5933_CTRL_INIT_START_FREQ); + if (ret < 0) + return ret; + + st->state = AD5933_CTRL_INIT_START_FREQ; + + return 0; +} + +static int ad5933_ring_postenable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + + /* + * AD5933_CTRL_INIT_START_FREQ: + * High Q complex circuits require a long time to reach steady state. + * To facilitate the measurement of such impedances, this mode allows + * the user full control of the settling time requirement before + * entering start frequency sweep mode where the impedance measurement + * takes place. In this mode the impedance is excited with the + * programmed start frequency (ad5933_ring_preenable), + * but no measurement takes place. + */ + + schedule_delayed_work(&st->work, + msecs_to_jiffies(AD5933_INIT_EXCITATION_TIME_ms)); + return 0; +} + +static int ad5933_ring_postdisable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + + cancel_delayed_work_sync(&st->work); + return ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); +} + +static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { + .preenable = ad5933_ring_preenable, + .postenable = ad5933_ring_postenable, + .postdisable = ad5933_ring_postdisable, +}; + +static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) +{ + struct iio_buffer *buffer; + + buffer = iio_kfifo_allocate(); + if (!buffer) + return -ENOMEM; + + iio_device_attach_buffer(indio_dev, buffer); + + /* Ring buffer functions - here trigger setup related */ + indio_dev->setup_ops = &ad5933_ring_setup_ops; + + return 0; +} + +static void ad5933_work(struct work_struct *work) +{ + struct ad5933_state *st = container_of(work, + struct ad5933_state, work.work); + struct iio_dev *indio_dev = i2c_get_clientdata(st->client); + __be16 buf[2]; + int val[2]; + unsigned char status; + int ret; + + if (st->state == AD5933_CTRL_INIT_START_FREQ) { + /* start sweep */ + ad5933_cmd(st, AD5933_CTRL_START_SWEEP); + st->state = AD5933_CTRL_START_SWEEP; + schedule_delayed_work(&st->work, st->poll_time_jiffies); + return; + } + + ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); + if (ret) + return; + + if (status & AD5933_STAT_DATA_VALID) { + int scan_count = bitmap_weight(indio_dev->active_scan_mask, + indio_dev->masklength); + ret = ad5933_i2c_read(st->client, + test_bit(1, indio_dev->active_scan_mask) ? + AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA, + scan_count * 2, (u8 *)buf); + if (ret) + return; + + if (scan_count == 2) { + val[0] = be16_to_cpu(buf[0]); + val[1] = be16_to_cpu(buf[1]); + } else { + val[0] = be16_to_cpu(buf[0]); + } + iio_push_to_buffers(indio_dev, val); + } else { + /* no data available - try again later */ + schedule_delayed_work(&st->work, st->poll_time_jiffies); + return; + } + + if (status & AD5933_STAT_SWEEP_DONE) { + /* + * last sample received - power down do + * nothing until the ring enable is toggled + */ + ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); + } else { + /* we just received a valid datum, move on to the next */ + ad5933_cmd(st, AD5933_CTRL_INC_FREQ); + schedule_delayed_work(&st->work, st->poll_time_jiffies); + } +} + +static int ad5933_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct ad5933_state *st; + struct iio_dev *indio_dev; + unsigned long ext_clk_hz = 0; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + st->client = client; + + mutex_init(&st->lock); + + st->reg = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + + ret = regulator_enable(st->reg); + if (ret) { + dev_err(&client->dev, "Failed to enable specified VDD supply\n"); + return ret; + } + ret = regulator_get_voltage(st->reg); + + if (ret < 0) + goto error_disable_reg; + + st->vref_mv = ret / 1000; + + st->mclk = devm_clk_get(&client->dev, "mclk"); + if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) { + ret = PTR_ERR(st->mclk); + goto error_disable_reg; + } + + if (!IS_ERR(st->mclk)) { + ret = clk_prepare_enable(st->mclk); + if (ret < 0) + goto error_disable_reg; + ext_clk_hz = clk_get_rate(st->mclk); + } + + if (ext_clk_hz) { + st->mclk_hz = ext_clk_hz; + st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK; + } else { + st->mclk_hz = AD5933_INT_OSC_FREQ_Hz; + st->ctrl_lb = AD5933_CTRL_INT_SYSCLK; + } + + ad5933_calc_out_ranges(st); + INIT_DELAYED_WORK(&st->work, ad5933_work); + st->poll_time_jiffies = msecs_to_jiffies(AD5933_POLL_TIME_ms); + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &ad5933_info; + indio_dev->name = id->name; + indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); + indio_dev->channels = ad5933_channels; + indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); + + ret = ad5933_register_ring_funcs_and_init(indio_dev); + if (ret) + goto error_disable_mclk; + + ret = ad5933_setup(st); + if (ret) + goto error_unreg_ring; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_ring; + + return 0; + +error_unreg_ring: + iio_kfifo_free(indio_dev->buffer); +error_disable_mclk: + clk_disable_unprepare(st->mclk); +error_disable_reg: + regulator_disable(st->reg); + + return ret; +} + +static int ad5933_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad5933_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + iio_kfifo_free(indio_dev->buffer); + regulator_disable(st->reg); + clk_disable_unprepare(st->mclk); + + return 0; +} + +static const struct i2c_device_id ad5933_id[] = { + { "ad5933", 0 }, + { "ad5934", 0 }, + {} +}; + +MODULE_DEVICE_TABLE(i2c, ad5933_id); + +static const struct of_device_id ad5933_of_match[] = { + { .compatible = "adi,ad5933" }, + { .compatible = "adi,ad5934" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, ad5933_of_match); + +static struct i2c_driver ad5933_driver = { + .driver = { + .name = "ad5933", + .of_match_table = ad5933_of_match, + }, + .probe = ad5933_probe, + .remove = ad5933_remove, + .id_table = ad5933_id, +}; +module_i2c_driver(ad5933_driver); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD5933 Impedance Conv. Network Analyzer"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig deleted file mode 100644 index b9a679cdd146..000000000000 --- a/drivers/staging/iio/impedance-analyzer/Kconfig +++ /dev/null @@ -1,18 +0,0 @@ -# -# Impedance Converter, Network Analyzer drivers -# -menu "Network Analyzer, Impedance Converters" - -config AD5933 - tristate "Analog Devices AD5933, AD5934 driver" - depends on I2C - select IIO_BUFFER - select IIO_KFIFO_BUF - help - Say yes here to build support for Analog Devices Impedance Converter, - Network Analyzer, AD5933/4. - - To compile this driver as a module, choose M here: the - module will be called ad5933. - -endmenu diff --git a/drivers/staging/iio/impedance-analyzer/Makefile b/drivers/staging/iio/impedance-analyzer/Makefile deleted file mode 100644 index 7604d786583e..000000000000 --- a/drivers/staging/iio/impedance-analyzer/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# -# Makefile for Impedance Converter, Network Analyzer drivers -# - -obj-$(CONFIG_AD5933) += ad5933.o diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c deleted file mode 100644 index 314cb71b1b5a..000000000000 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ /dev/null @@ -1,811 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * AD5933 AD5934 Impedance Converter, Network Analyzer - * - * Copyright 2011 Analog Devices Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* AD5933/AD5934 Registers */ -#define AD5933_REG_CONTROL_HB 0x80 /* R/W, 1 byte */ -#define AD5933_REG_CONTROL_LB 0x81 /* R/W, 1 byte */ -#define AD5933_REG_FREQ_START 0x82 /* R/W, 3 bytes */ -#define AD5933_REG_FREQ_INC 0x85 /* R/W, 3 bytes */ -#define AD5933_REG_INC_NUM 0x88 /* R/W, 2 bytes, 9 bit */ -#define AD5933_REG_SETTLING_CYCLES 0x8A /* R/W, 2 bytes */ -#define AD5933_REG_STATUS 0x8F /* R, 1 byte */ -#define AD5933_REG_TEMP_DATA 0x92 /* R, 2 bytes*/ -#define AD5933_REG_REAL_DATA 0x94 /* R, 2 bytes*/ -#define AD5933_REG_IMAG_DATA 0x96 /* R, 2 bytes*/ - -/* AD5933_REG_CONTROL_HB Bits */ -#define AD5933_CTRL_INIT_START_FREQ (0x1 << 4) -#define AD5933_CTRL_START_SWEEP (0x2 << 4) -#define AD5933_CTRL_INC_FREQ (0x3 << 4) -#define AD5933_CTRL_REPEAT_FREQ (0x4 << 4) -#define AD5933_CTRL_MEASURE_TEMP (0x9 << 4) -#define AD5933_CTRL_POWER_DOWN (0xA << 4) -#define AD5933_CTRL_STANDBY (0xB << 4) - -#define AD5933_CTRL_RANGE_2000mVpp (0x0 << 1) -#define AD5933_CTRL_RANGE_200mVpp (0x1 << 1) -#define AD5933_CTRL_RANGE_400mVpp (0x2 << 1) -#define AD5933_CTRL_RANGE_1000mVpp (0x3 << 1) -#define AD5933_CTRL_RANGE(x) ((x) << 1) - -#define AD5933_CTRL_PGA_GAIN_1 (0x1 << 0) -#define AD5933_CTRL_PGA_GAIN_5 (0x0 << 0) - -/* AD5933_REG_CONTROL_LB Bits */ -#define AD5933_CTRL_RESET (0x1 << 4) -#define AD5933_CTRL_INT_SYSCLK (0x0 << 3) -#define AD5933_CTRL_EXT_SYSCLK (0x1 << 3) - -/* AD5933_REG_STATUS Bits */ -#define AD5933_STAT_TEMP_VALID (0x1 << 0) -#define AD5933_STAT_DATA_VALID (0x1 << 1) -#define AD5933_STAT_SWEEP_DONE (0x1 << 2) - -/* I2C Block Commands */ -#define AD5933_I2C_BLOCK_WRITE 0xA0 -#define AD5933_I2C_BLOCK_READ 0xA1 -#define AD5933_I2C_ADDR_POINTER 0xB0 - -/* Device Specs */ -#define AD5933_INT_OSC_FREQ_Hz 16776000 -#define AD5933_MAX_OUTPUT_FREQ_Hz 100000 -#define AD5933_MAX_RETRIES 100 - -#define AD5933_OUT_RANGE 1 -#define AD5933_OUT_RANGE_AVAIL 2 -#define AD5933_OUT_SETTLING_CYCLES 3 -#define AD5933_IN_PGA_GAIN 4 -#define AD5933_IN_PGA_GAIN_AVAIL 5 -#define AD5933_FREQ_POINTS 6 - -#define AD5933_POLL_TIME_ms 10 -#define AD5933_INIT_EXCITATION_TIME_ms 100 - -struct ad5933_state { - struct i2c_client *client; - struct regulator *reg; - struct clk *mclk; - struct delayed_work work; - struct mutex lock; /* Protect sensor state */ - unsigned long mclk_hz; - unsigned char ctrl_hb; - unsigned char ctrl_lb; - unsigned int range_avail[4]; - unsigned short vref_mv; - unsigned short settling_cycles; - unsigned short freq_points; - unsigned int freq_start; - unsigned int freq_inc; - unsigned int state; - unsigned int poll_time_jiffies; -}; - -#define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \ - _scan_index, _realbits) { \ - .type = (_type), \ - .extend_name = (_extend_name), \ - .info_mask_separate = (_info_mask_separate), \ - .address = (_address), \ - .scan_index = (_scan_index), \ - .scan_type = { \ - .sign = 's', \ - .realbits = (_realbits), \ - .storagebits = 16, \ - }, \ -} - -static const struct iio_chan_spec ad5933_channels[] = { - AD5933_CHANNEL(IIO_TEMP, NULL, BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE), AD5933_REG_TEMP_DATA, -1, 14), - /* Ring Channels */ - AD5933_CHANNEL(IIO_VOLTAGE, "real", 0, AD5933_REG_REAL_DATA, 0, 16), - AD5933_CHANNEL(IIO_VOLTAGE, "imag", 0, AD5933_REG_IMAG_DATA, 1, 16), -}; - -static int ad5933_i2c_write(struct i2c_client *client, u8 reg, u8 len, u8 *data) -{ - int ret; - - while (len--) { - ret = i2c_smbus_write_byte_data(client, reg++, *data++); - if (ret < 0) { - dev_err(&client->dev, "I2C write error\n"); - return ret; - } - } - return 0; -} - -static int ad5933_i2c_read(struct i2c_client *client, u8 reg, u8 len, u8 *data) -{ - int ret; - - while (len--) { - ret = i2c_smbus_read_byte_data(client, reg++); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - *data++ = ret; - } - return 0; -} - -static int ad5933_cmd(struct ad5933_state *st, unsigned char cmd) -{ - unsigned char dat = st->ctrl_hb | cmd; - - return ad5933_i2c_write(st->client, - AD5933_REG_CONTROL_HB, 1, &dat); -} - -static int ad5933_reset(struct ad5933_state *st) -{ - unsigned char dat = st->ctrl_lb | AD5933_CTRL_RESET; - - return ad5933_i2c_write(st->client, - AD5933_REG_CONTROL_LB, 1, &dat); -} - -static int ad5933_wait_busy(struct ad5933_state *st, unsigned char event) -{ - unsigned char val, timeout = AD5933_MAX_RETRIES; - int ret; - - while (timeout--) { - ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &val); - if (ret < 0) - return ret; - if (val & event) - return val; - cpu_relax(); - mdelay(1); - } - - return -EAGAIN; -} - -static int ad5933_set_freq(struct ad5933_state *st, - unsigned int reg, unsigned long freq) -{ - unsigned long long freqreg; - union { - __be32 d32; - u8 d8[4]; - } dat; - - freqreg = (u64)freq * (u64)(1 << 27); - do_div(freqreg, st->mclk_hz / 4); - - switch (reg) { - case AD5933_REG_FREQ_START: - st->freq_start = freq; - break; - case AD5933_REG_FREQ_INC: - st->freq_inc = freq; - break; - default: - return -EINVAL; - } - - dat.d32 = cpu_to_be32(freqreg); - return ad5933_i2c_write(st->client, reg, 3, &dat.d8[1]); -} - -static int ad5933_setup(struct ad5933_state *st) -{ - __be16 dat; - int ret; - - ret = ad5933_reset(st); - if (ret < 0) - return ret; - - ret = ad5933_set_freq(st, AD5933_REG_FREQ_START, 10000); - if (ret < 0) - return ret; - - ret = ad5933_set_freq(st, AD5933_REG_FREQ_INC, 200); - if (ret < 0) - return ret; - - st->settling_cycles = 10; - dat = cpu_to_be16(st->settling_cycles); - - ret = ad5933_i2c_write(st->client, - AD5933_REG_SETTLING_CYCLES, - 2, (u8 *)&dat); - if (ret < 0) - return ret; - - st->freq_points = 100; - dat = cpu_to_be16(st->freq_points); - - return ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, (u8 *)&dat); -} - -static void ad5933_calc_out_ranges(struct ad5933_state *st) -{ - int i; - unsigned int normalized_3v3[4] = {1980, 198, 383, 970}; - - for (i = 0; i < 4; i++) - st->range_avail[i] = normalized_3v3[i] * st->vref_mv / 3300; -} - -/* - * handles: AD5933_REG_FREQ_START and AD5933_REG_FREQ_INC - */ - -static ssize_t ad5933_show_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad5933_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int ret; - unsigned long long freqreg; - union { - __be32 d32; - u8 d8[4]; - } dat; - - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; - ret = ad5933_i2c_read(st->client, this_attr->address, 3, &dat.d8[1]); - iio_device_release_direct_mode(indio_dev); - if (ret < 0) - return ret; - - freqreg = be32_to_cpu(dat.d32) & 0xFFFFFF; - - freqreg = (u64)freqreg * (u64)(st->mclk_hz / 4); - do_div(freqreg, 1 << 27); - - return sprintf(buf, "%d\n", (int)freqreg); -} - -static ssize_t ad5933_store_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad5933_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - unsigned long val; - int ret; - - ret = kstrtoul(buf, 10, &val); - if (ret) - return ret; - - if (val > AD5933_MAX_OUTPUT_FREQ_Hz) - return -EINVAL; - - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; - ret = ad5933_set_freq(st, this_attr->address, val); - iio_device_release_direct_mode(indio_dev); - - return ret ? ret : len; -} - -static IIO_DEVICE_ATTR(out_voltage0_freq_start, 0644, - ad5933_show_frequency, - ad5933_store_frequency, - AD5933_REG_FREQ_START); - -static IIO_DEVICE_ATTR(out_voltage0_freq_increment, 0644, - ad5933_show_frequency, - ad5933_store_frequency, - AD5933_REG_FREQ_INC); - -static ssize_t ad5933_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad5933_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int ret = 0, len = 0; - - mutex_lock(&st->lock); - switch ((u32)this_attr->address) { - case AD5933_OUT_RANGE: - len = sprintf(buf, "%u\n", - st->range_avail[(st->ctrl_hb >> 1) & 0x3]); - break; - case AD5933_OUT_RANGE_AVAIL: - len = sprintf(buf, "%u %u %u %u\n", st->range_avail[0], - st->range_avail[3], st->range_avail[2], - st->range_avail[1]); - break; - case AD5933_OUT_SETTLING_CYCLES: - len = sprintf(buf, "%d\n", st->settling_cycles); - break; - case AD5933_IN_PGA_GAIN: - len = sprintf(buf, "%s\n", - (st->ctrl_hb & AD5933_CTRL_PGA_GAIN_1) ? - "1" : "0.2"); - break; - case AD5933_IN_PGA_GAIN_AVAIL: - len = sprintf(buf, "1 0.2\n"); - break; - case AD5933_FREQ_POINTS: - len = sprintf(buf, "%d\n", st->freq_points); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&st->lock); - return ret ? ret : len; -} - -static ssize_t ad5933_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad5933_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - u16 val; - int i, ret = 0; - __be16 dat; - - if (this_attr->address != AD5933_IN_PGA_GAIN) { - ret = kstrtou16(buf, 10, &val); - if (ret) - return ret; - } - - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; - mutex_lock(&st->lock); - switch ((u32)this_attr->address) { - case AD5933_OUT_RANGE: - ret = -EINVAL; - for (i = 0; i < 4; i++) - if (val == st->range_avail[i]) { - st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); - st->ctrl_hb |= AD5933_CTRL_RANGE(i); - ret = ad5933_cmd(st, 0); - break; - } - break; - case AD5933_IN_PGA_GAIN: - if (sysfs_streq(buf, "1")) { - st->ctrl_hb |= AD5933_CTRL_PGA_GAIN_1; - } else if (sysfs_streq(buf, "0.2")) { - st->ctrl_hb &= ~AD5933_CTRL_PGA_GAIN_1; - } else { - ret = -EINVAL; - break; - } - ret = ad5933_cmd(st, 0); - break; - case AD5933_OUT_SETTLING_CYCLES: - val = clamp(val, (u16)0, (u16)0x7FF); - st->settling_cycles = val; - - /* 2x, 4x handling, see datasheet */ - if (val > 1022) - val = (val >> 2) | (3 << 9); - else if (val > 511) - val = (val >> 1) | (1 << 9); - - dat = cpu_to_be16(val); - ret = ad5933_i2c_write(st->client, - AD5933_REG_SETTLING_CYCLES, - 2, (u8 *)&dat); - break; - case AD5933_FREQ_POINTS: - val = clamp(val, (u16)0, (u16)511); - st->freq_points = val; - - dat = cpu_to_be16(val); - ret = ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, - (u8 *)&dat); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&st->lock); - iio_device_release_direct_mode(indio_dev); - return ret ? ret : len; -} - -static IIO_DEVICE_ATTR(out_altvoltage0_raw, 0644, - ad5933_show, - ad5933_store, - AD5933_OUT_RANGE); - -static IIO_DEVICE_ATTR(out_altvoltage0_scale_available, 0444, - ad5933_show, - NULL, - AD5933_OUT_RANGE_AVAIL); - -static IIO_DEVICE_ATTR(in_voltage0_scale, 0644, - ad5933_show, - ad5933_store, - AD5933_IN_PGA_GAIN); - -static IIO_DEVICE_ATTR(in_voltage0_scale_available, 0444, - ad5933_show, - NULL, - AD5933_IN_PGA_GAIN_AVAIL); - -static IIO_DEVICE_ATTR(out_voltage0_freq_points, 0644, - ad5933_show, - ad5933_store, - AD5933_FREQ_POINTS); - -static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 0644, - ad5933_show, - ad5933_store, - AD5933_OUT_SETTLING_CYCLES); - -/* - * note: - * ideally we would handle the scale attributes via the iio_info - * (read|write)_raw methods, however this part is a untypical since we - * don't create dedicated sysfs channel attributes for out0 and in0. - */ -static struct attribute *ad5933_attributes[] = { - &iio_dev_attr_out_altvoltage0_raw.dev_attr.attr, - &iio_dev_attr_out_altvoltage0_scale_available.dev_attr.attr, - &iio_dev_attr_out_voltage0_freq_start.dev_attr.attr, - &iio_dev_attr_out_voltage0_freq_increment.dev_attr.attr, - &iio_dev_attr_out_voltage0_freq_points.dev_attr.attr, - &iio_dev_attr_out_voltage0_settling_cycles.dev_attr.attr, - &iio_dev_attr_in_voltage0_scale.dev_attr.attr, - &iio_dev_attr_in_voltage0_scale_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group ad5933_attribute_group = { - .attrs = ad5933_attributes, -}; - -static int ad5933_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - struct ad5933_state *st = iio_priv(indio_dev); - __be16 dat; - int ret; - - switch (m) { - case IIO_CHAN_INFO_RAW: - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; - ret = ad5933_cmd(st, AD5933_CTRL_MEASURE_TEMP); - if (ret < 0) - goto out; - ret = ad5933_wait_busy(st, AD5933_STAT_TEMP_VALID); - if (ret < 0) - goto out; - - ret = ad5933_i2c_read(st->client, - AD5933_REG_TEMP_DATA, - 2, (u8 *)&dat); - if (ret < 0) - goto out; - iio_device_release_direct_mode(indio_dev); - *val = sign_extend32(be16_to_cpu(dat), 13); - - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: - *val = 1000; - *val2 = 5; - return IIO_VAL_FRACTIONAL_LOG2; - } - - return -EINVAL; -out: - iio_device_release_direct_mode(indio_dev); - return ret; -} - -static const struct iio_info ad5933_info = { - .read_raw = ad5933_read_raw, - .attrs = &ad5933_attribute_group, -}; - -static int ad5933_ring_preenable(struct iio_dev *indio_dev) -{ - struct ad5933_state *st = iio_priv(indio_dev); - int ret; - - if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) - return -EINVAL; - - ret = ad5933_reset(st); - if (ret < 0) - return ret; - - ret = ad5933_cmd(st, AD5933_CTRL_STANDBY); - if (ret < 0) - return ret; - - ret = ad5933_cmd(st, AD5933_CTRL_INIT_START_FREQ); - if (ret < 0) - return ret; - - st->state = AD5933_CTRL_INIT_START_FREQ; - - return 0; -} - -static int ad5933_ring_postenable(struct iio_dev *indio_dev) -{ - struct ad5933_state *st = iio_priv(indio_dev); - - /* - * AD5933_CTRL_INIT_START_FREQ: - * High Q complex circuits require a long time to reach steady state. - * To facilitate the measurement of such impedances, this mode allows - * the user full control of the settling time requirement before - * entering start frequency sweep mode where the impedance measurement - * takes place. In this mode the impedance is excited with the - * programmed start frequency (ad5933_ring_preenable), - * but no measurement takes place. - */ - - schedule_delayed_work(&st->work, - msecs_to_jiffies(AD5933_INIT_EXCITATION_TIME_ms)); - return 0; -} - -static int ad5933_ring_postdisable(struct iio_dev *indio_dev) -{ - struct ad5933_state *st = iio_priv(indio_dev); - - cancel_delayed_work_sync(&st->work); - return ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); -} - -static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { - .preenable = ad5933_ring_preenable, - .postenable = ad5933_ring_postenable, - .postdisable = ad5933_ring_postdisable, -}; - -static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - struct iio_buffer *buffer; - - buffer = iio_kfifo_allocate(); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(indio_dev, buffer); - - /* Ring buffer functions - here trigger setup related */ - indio_dev->setup_ops = &ad5933_ring_setup_ops; - - return 0; -} - -static void ad5933_work(struct work_struct *work) -{ - struct ad5933_state *st = container_of(work, - struct ad5933_state, work.work); - struct iio_dev *indio_dev = i2c_get_clientdata(st->client); - __be16 buf[2]; - int val[2]; - unsigned char status; - int ret; - - if (st->state == AD5933_CTRL_INIT_START_FREQ) { - /* start sweep */ - ad5933_cmd(st, AD5933_CTRL_START_SWEEP); - st->state = AD5933_CTRL_START_SWEEP; - schedule_delayed_work(&st->work, st->poll_time_jiffies); - return; - } - - ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); - if (ret) - return; - - if (status & AD5933_STAT_DATA_VALID) { - int scan_count = bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); - ret = ad5933_i2c_read(st->client, - test_bit(1, indio_dev->active_scan_mask) ? - AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA, - scan_count * 2, (u8 *)buf); - if (ret) - return; - - if (scan_count == 2) { - val[0] = be16_to_cpu(buf[0]); - val[1] = be16_to_cpu(buf[1]); - } else { - val[0] = be16_to_cpu(buf[0]); - } - iio_push_to_buffers(indio_dev, val); - } else { - /* no data available - try again later */ - schedule_delayed_work(&st->work, st->poll_time_jiffies); - return; - } - - if (status & AD5933_STAT_SWEEP_DONE) { - /* - * last sample received - power down do - * nothing until the ring enable is toggled - */ - ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); - } else { - /* we just received a valid datum, move on to the next */ - ad5933_cmd(st, AD5933_CTRL_INC_FREQ); - schedule_delayed_work(&st->work, st->poll_time_jiffies); - } -} - -static int ad5933_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct ad5933_state *st; - struct iio_dev *indio_dev; - unsigned long ext_clk_hz = 0; - - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - - st = iio_priv(indio_dev); - i2c_set_clientdata(client, indio_dev); - st->client = client; - - mutex_init(&st->lock); - - st->reg = devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) { - dev_err(&client->dev, "Failed to enable specified VDD supply\n"); - return ret; - } - ret = regulator_get_voltage(st->reg); - - if (ret < 0) - goto error_disable_reg; - - st->vref_mv = ret / 1000; - - st->mclk = devm_clk_get(&client->dev, "mclk"); - if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) { - ret = PTR_ERR(st->mclk); - goto error_disable_reg; - } - - if (!IS_ERR(st->mclk)) { - ret = clk_prepare_enable(st->mclk); - if (ret < 0) - goto error_disable_reg; - ext_clk_hz = clk_get_rate(st->mclk); - } - - if (ext_clk_hz) { - st->mclk_hz = ext_clk_hz; - st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK; - } else { - st->mclk_hz = AD5933_INT_OSC_FREQ_Hz; - st->ctrl_lb = AD5933_CTRL_INT_SYSCLK; - } - - ad5933_calc_out_ranges(st); - INIT_DELAYED_WORK(&st->work, ad5933_work); - st->poll_time_jiffies = msecs_to_jiffies(AD5933_POLL_TIME_ms); - - indio_dev->dev.parent = &client->dev; - indio_dev->info = &ad5933_info; - indio_dev->name = id->name; - indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); - indio_dev->channels = ad5933_channels; - indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); - - ret = ad5933_register_ring_funcs_and_init(indio_dev); - if (ret) - goto error_disable_mclk; - - ret = ad5933_setup(st); - if (ret) - goto error_unreg_ring; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring; - - return 0; - -error_unreg_ring: - iio_kfifo_free(indio_dev->buffer); -error_disable_mclk: - clk_disable_unprepare(st->mclk); -error_disable_reg: - regulator_disable(st->reg); - - return ret; -} - -static int ad5933_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct ad5933_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_kfifo_free(indio_dev->buffer); - regulator_disable(st->reg); - clk_disable_unprepare(st->mclk); - - return 0; -} - -static const struct i2c_device_id ad5933_id[] = { - { "ad5933", 0 }, - { "ad5934", 0 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, ad5933_id); - -static const struct of_device_id ad5933_of_match[] = { - { .compatible = "adi,ad5933" }, - { .compatible = "adi,ad5934" }, - { }, -}; - -MODULE_DEVICE_TABLE(of, ad5933_of_match); - -static struct i2c_driver ad5933_driver = { - .driver = { - .name = "ad5933", - .of_match_table = ad5933_of_match, - }, - .probe = ad5933_probe, - .remove = ad5933_remove, - .id_table = ad5933_id, -}; -module_i2c_driver(ad5933_driver); - -MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("Analog Devices AD5933 Impedance Conv. Network Analyzer"); -MODULE_LICENSE("GPL v2");