Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp333963pxt; Wed, 11 Aug 2021 22:53:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzESHcLTPTGebvmRSI1aIjHORVJhmcQo2UG4e5yS+MjbfHHIScioaDwnikgyozQhv1Yxo3U X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr3394642edd.191.1628747608936; Wed, 11 Aug 2021 22:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628747608; cv=none; d=google.com; s=arc-20160816; b=gmUo8OObNxRxb9jRfBfVpehMa6vzgfeM891h3/TKsgXwmv+4ziCR0ffwsciRrNFDhD h3iuahmo5phvZ8EWq9qus04Y4QUVjDnyLuUy0Hrwz0DRWmLq6RrNHEzQggwx4wpCgMI6 ndOA5bhAJ1uFf3I5kKANM4NZyXxda63T0+hRKE/jBivnNNQ+vuHUTFBwFEusQORMsInd IqcCAMB9yH4EC5b8lLqtWZ/P48UEWy5jxZtRG0KZEbljSBx+2p/1HT1Z7+9C9fDwGGX7 7isvMnAyR/m1/2LeJLiBlg4L8x2/KyPt2iTC94Y8+txPr/oFBwI617DXcHA/w4c9bX5N yerw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=X6qiecSpb2O82FVOe0VyOaGf9cqXgHit9FvXHh6ACQs=; b=iQ65ZuBKA6FCCOUdBIwVt8svOjXRtjnvKCSOWz9fJAeU+NtZNUTssVYj7WpB53iWf6 ZR5aPMJ+J2UXwcHyMKYGaFGvEk3WWLkPXfXwOiHcnyIpHDIKYratXCxbflGrQmPbKSNK I4Szb9CAYT/8Nf/EPZz2PqeQqDgOPONq/8iDb+gZtnswxTCZtAWVysc8fqNC2EFRRiRn /x846es3KjegCvg1DJ+JfTt0lWzVYLqzAxeS2jx+LY/39BTrOUY8RSJOJkJrl2Pi0Iix RS4OiGHqTAsoewuZabnKDMNxiTKJMYIGUcmORUOADnt2A7wlog44Uc01qLxVrV0+8aEO Su8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq24si1344385ejb.538.2021.08.11.22.53.05; Wed, 11 Aug 2021 22:53:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234456AbhHLFtu (ORCPT + 99 others); Thu, 12 Aug 2021 01:49:50 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:46650 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230377AbhHLFts (ORCPT ); Thu, 12 Aug 2021 01:49:48 -0400 X-UUID: 378e15821b38413a87f2b0a0095ee4e5-20210812 X-UUID: 378e15821b38413a87f2b0a0095ee4e5-20210812 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1359506531; Thu, 12 Aug 2021 13:49:19 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 12 Aug 2021 13:49:18 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 12 Aug 2021 13:49:17 +0800 From: Hui Liu To: , , , CC: , , , , , , , , , , , , Subject: [PATCH v1 1/2] iio: mtk-auxadc: add support IIO_CHAN_INFO_RAW case Date: Thu, 12 Aug 2021 13:48:43 +0800 Message-ID: <20210812054844.30575-2-hui.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210812054844.30575-1-hui.liu@mediatek.com> References: <20210812054844.30575-1-hui.liu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support IIO_CHAN_INFO_RAW case. Signed-off-by: Hui Liu --- drivers/iio/adc/mt6577_auxadc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index 79c1dd68b909..e995d43287b2 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -60,7 +60,8 @@ static const struct mtk_auxadc_compatible mt6765_compat = { .type = IIO_VOLTAGE, \ .indexed = 1, \ .channel = (idx), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_PROCESSED), \ } static const struct iio_chan_spec mt6577_auxadc_iio_channels[] = { @@ -181,6 +182,19 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); switch (info) { + case IIO_CHAN_INFO_RAW: + *val = mt6577_auxadc_read(indio_dev, chan); + if (*val < 0) { + dev_notice(indio_dev->dev.parent, + "failed to sample data on channel[%d]\n", + chan->channel); + return *val; + } + if (adc_dev->dev_comp->sample_data_cali) + *val = mt_auxadc_get_cali_data(*val, true); + + return IIO_VAL_INT; + case IIO_CHAN_INFO_PROCESSED: *val = mt6577_auxadc_read(indio_dev, chan); if (*val < 0) { -- 2.18.0