Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp227048pxt; Wed, 11 Aug 2021 19:26:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuEuuWlD3PWZLPoUXjKbWvq80eLkEy0kREhbhVq2L26wynpVj8K0ZXd+TVtkOqnBSGx/Pa X-Received: by 2002:a17:906:1cc9:: with SMTP id i9mr1478865ejh.345.1628735185497; Wed, 11 Aug 2021 19:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628735185; cv=none; d=google.com; s=arc-20160816; b=QYQupRzmtWbvzXv+JIS7jWNXGJKyUxehwyht3bGuzBQ1Yb969HGsOK1rhT0JB/UEGJ cBUcrsqdZRCEsno3Zkddib5hin6IB+WIXSwk/Ru5r/Ibop88lyG5mBfASiNxnLd+BzlS 5Aot3ZUYVpT0Z/Z2WBDqBBGwa5TUBJK5MSdI1lqlgdNY/MrVkO0r/DBebEvec0bGVurt mT5vT3RH8FcnimOx1TcpgYshlUHh73kAYnndhBvGNt1i9bQDFTw/UEgNaGDZdGGhmygH SDgtkT2h3SQqP0/KTJd05wmt268bwGW026pU1s+83tFjbjORQDHH8f/N2fiTHn+C09PU ikfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=X6qiecSpb2O82FVOe0VyOaGf9cqXgHit9FvXHh6ACQs=; b=XaslE4JiufESqFjsm4TdStipYV3gVkH5oJkx9lvNQVzSwQax0p8Q+1mZ3mMnjpjYC/ RzaZp9TwVpvI3H1RMx0n/0oRnCN8JphC4uM8q30wSJHAKugLB+S69Qqc1P8M1BYk6orP 4pMCTDi64Ukk0U3w+SNL81FJtpQLeIrNWDCbvrgSLVfN7jgdYcsh80rAiRITDxMYQnne Oe8mnXehgZBydMMZL7a1s9vdwT69rnGpDZGamE4rloWLu4oApuGKpPW2qGfMQ+wzoujR 6aI07somcOttQG5RlSxsbbkPyPFE77q/SXO1i6/Q6uKRlEfv+CE3MbaGx0/udxgpekF9 AE6A== 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 w10si1200605ejv.584.2021.08.11.19.26.01; Wed, 11 Aug 2021 19:26:25 -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 S233536AbhHLCYp (ORCPT + 99 others); Wed, 11 Aug 2021 22:24:45 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:49086 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230035AbhHLCYp (ORCPT ); Wed, 11 Aug 2021 22:24:45 -0400 X-UUID: dff4adfb4c0a4c4e9e72d73158659c83-20210812 X-UUID: dff4adfb4c0a4c4e9e72d73158659c83-20210812 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 751955085; Thu, 12 Aug 2021 10:24:17 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 12 Aug 2021 10:24:16 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 12 Aug 2021 10:24:15 +0800 From: Hui Liu To: , , , CC: , , , , , , , , , , , , Subject: [PATCH 1/2] iio: mtk-auxadc: add support IIO_CHAN_INFO_RAW case Date: Thu, 12 Aug 2021 10:23:41 +0800 Message-ID: <20210812022342.29092-1-hui.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 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