From patchwork Thu Aug 30 15:45:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rossak X-Patchwork-Id: 10582179 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 6AC19920 for ; Thu, 30 Aug 2018 15:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5997F2C0E7 for ; Thu, 30 Aug 2018 15:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BB1A2C0EA; Thu, 30 Aug 2018 15:54:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 CE1392C0E7 for ; Thu, 30 Aug 2018 15:54:44 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=5B0hcDTGM5jsYOJoBJCUpASqSFg9M2g3cJ9JZZM2ZYM=; b=Cr6CPcDAv1JwBypPflb9hgOrw+ vm9u7AVlPDst0obqEFuKtsyerkZ0/hrQ9QJdEioV3LqnY1HNnGtLzUQiwvmkL5EdQaQFk+XECX3TN IJpoA8hbA4I6UvnzfH0Y/d8LqBdt2Zm85Wsl+SffWT8IReukmkYjIfE8+mZBFEQZ67+EtZ3O/M2Df dEetPMujgq+0ZU1h2bvLNRI7uuvI1vDGeiKlx/x52+0kMHJpWQQSrI1dGCC5dV81dadXqJQOU/lNG YveyywY53eiKENcMn7huO7CP148IJzbWf7c3zkRCA6G8bW1C9BwsVqZHuyuVZIUi45OYwo+ZK4ilp rZWUdWJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvPHK-0006Uy-Mf; Thu, 30 Aug 2018 15:54:38 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvP8h-0001ez-GV for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 15:45:46 +0000 Received: by mail-wm0-x241.google.com with SMTP id j192-v6so2528608wmj.1 for ; Thu, 30 Aug 2018 08:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GG6wm40smk2VetGm2lnviKqcGAT7hYe3vQr/oTzaQVI=; b=bmaS1q+BXPmP+DBPMWuqMWjvwRfnyLvqywziuN95cD4E2O2H/937CWvaU7dZGRLfIB TNRg2u02nRjE/1uV1ZWJ3llffiaf+/xJvWhJNkNe1rffeAUhxNF84g5U6aQsjPVj1W/8 SImjeOvtj2Tzv3c8OPFIrUY/VnOon5z6mX4nijxLnSN3qwRqX5ZcmTakFNd/OmrHR6Wz s9eWI6ggYw9pOxvwuATKCl1KZ9jY/ejuGwVwLnvsRxgYJm4Z9UaRD0u1jnwd3HnBSAxw Zu5W1BxReIWEFeXrxzTprw77LxhzdxvJw3yXI+Wtf4/yfprWDsSh8TjI+i25nCXdJaOW Y0lw== 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:in-reply-to :references; bh=GG6wm40smk2VetGm2lnviKqcGAT7hYe3vQr/oTzaQVI=; b=ahb7T1u/hQ7+hFDbijq//M+aPoSJAJYPfVTUrx1hNQgEA0/bZ9Dbp8JVsxSXelDZCH diRAGZtPoRFV3+y0Im2xQ/Gt1naNvl/3L3TLi+ZmkZmmVxn2UM5n+CDVNkQvzIYXBkJj Yh8TA0/deD6Bb+xqXG45oXu+EJZ/M2I8NsTnym6L6Gl3GKr42fIf3ysBkTfTfuXe4ucp wJqmrPJLvrqpgDJgZ+G3q/z9WrLZtSdMjyzH0OtLm05JS+9MlQl+pd0tClIN7h/rsEGd DapShmXV7kzJGs/Lv11kyaOYxALnHMXyw1P7HgSTG+n/t/wcqNjE2Q+0g56LEU8Vd0k0 LuWQ== X-Gm-Message-State: APzg51ANv9Kbtv+deu2HfCArZ04ma8v21I35YAOGUtpB0PnH+EieMc3A 3N9nfWdDFdmQIaVw8HzeXcw= X-Google-Smtp-Source: ANB0VdartHcfUT/nLcBRFFSP0xJuRdhM2ofPyAGtXEWOSTAVOlQdEA31+/7iJBAgj7G7lNw7quj1hw== X-Received: by 2002:a1c:c3c6:: with SMTP id t189-v6mr2114853wmf.59.1535643936145; Thu, 30 Aug 2018 08:45:36 -0700 (PDT) Received: from debian-hp.wlan.uni-ulm.de (eduroam170-020.wlan.uni-ulm.de. [134.60.170.20]) by smtp.gmail.com with ESMTPSA id j20-v6sm1362759wmh.9.2018.08.30.08.45.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 08:45:35 -0700 (PDT) From: Philipp Rossak To: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, linux@armlinux.org.uk, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, eugen.hristev@microchip.com, rdunlap@infradead.org, vilhelm.gray@gmail.com, clabbe.montjoie@gmail.com, quentin.schulz@bootlin.com, geert+renesas@glider.be, lukas@wunner.de, icenowy@aosc.io, arnd@arndb.de, broonie@kernel.org, arnaud.pouliquen@st.com Subject: [PATCH v3 16/30] iio: adc: sun4i-gpadc-iio: rework: readout temp_data Date: Thu, 30 Aug 2018 17:45:04 +0200 Message-Id: <20180830154518.29507-17-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180830154518.29507-1-embed3d@gmail.com> References: <20180830154518.29507-1-embed3d@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_084543_768185_E25BF662 X-CRM114-Status: GOOD ( 16.49 ) 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: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 For adding newer sensor some basic rework of the code is necessary. This commit reworks the code and uses regmap field to read out temp_data. Signed-off-by: Philipp Rossak --- drivers/iio/adc/sun4i-gpadc-iio.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index d48f338af563..c278e165e161 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -63,6 +63,7 @@ struct gpadc_data { int (*ths_suspend)(struct sun4i_gpadc_iio *info); int (*ths_resume)(struct sun4i_gpadc_iio *info); bool support_irq; + u32 temp_data_base; }; static irqreturn_t sun4i_gpadc_data_irq_handler(int irq, void *dev_id); @@ -77,6 +78,7 @@ static const struct gpadc_data sun4i_gpadc_data = { .adc_channel = true, .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, + .temp_data_base = SUN4I_GPADC_TEMP_DATA, }; static const struct gpadc_data sun5i_gpadc_data = { @@ -89,6 +91,7 @@ static const struct gpadc_data sun5i_gpadc_data = { .adc_channel = true, .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, + .temp_data_base = SUN4I_GPADC_TEMP_DATA, }; static const struct gpadc_data sun6i_gpadc_data = { @@ -101,12 +104,14 @@ static const struct gpadc_data sun6i_gpadc_data = { .adc_channel = true, .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, + .temp_data_base = SUN4I_GPADC_TEMP_DATA, }; static const struct gpadc_data sun8i_a33_gpadc_data = { .temp_offset = -1662, .temp_scale = 162, .tp_mode_en = SUN8I_A33_GPADC_CTRL1_CHOP_TEMP_EN, + .temp_data_base = SUN4I_GPADC_TEMP_DATA, }; struct sun4i_gpadc_iio { @@ -271,18 +276,18 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val) { struct sun4i_gpadc_iio *info = iio_priv(indio_dev); - if (!info->data->support_irq) { - pm_runtime_get_sync(indio_dev->dev.parent); + if (info->data->adc_channel) + return sun4i_gpadc_read(indio_dev, 0, val, + SUN4I_GPADC_IRQ_TEMP_DATA); - regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val); + pm_runtime_get_sync(indio_dev->dev.parent); - pm_runtime_mark_last_busy(indio_dev->dev.parent); - pm_runtime_put_autosuspend(indio_dev->dev.parent); + regmap_read(info->regmap, info->data->temp_data_base, val); - return 0; - } + pm_runtime_mark_last_busy(indio_dev->dev.parent); + pm_runtime_put_autosuspend(indio_dev->dev.parent); - return sun4i_gpadc_read(indio_dev, 0, val, SUN4I_GPADC_IRQ_TEMP_DATA); + return 0; } static int sun4i_gpadc_temp_offset(struct iio_dev *indio_dev, int *val)