From patchwork Tue Jun 25 08:11:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 11015021 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 E81D213B4 for ; Tue, 25 Jun 2019 08:12:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC1228A13 for ; Tue, 25 Jun 2019 08:12:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D12E428A1F; Tue, 25 Jun 2019 08:12:21 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 5641328A13 for ; Tue, 25 Jun 2019 08:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728283AbfFYIMU (ORCPT ); Tue, 25 Jun 2019 04:12:20 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:31122 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726543AbfFYIMU (ORCPT ); Tue, 25 Jun 2019 04:12:20 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5P87QuM009883; Tue, 25 Jun 2019 04:11:58 -0400 Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2055.outbound.protection.outlook.com [104.47.38.55]) by mx0b-00128a01.pphosted.com with ESMTP id 2tbc93rjtt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jun 2019 04:11:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=judEWa2ta+8qO2zol744mriEt8xobc9w4g3TRjlCfDI=; b=kVTCfactr0OG1dIKWlFKm8AId3qtHzLIQP++N5iflAkxvTaM0R07IS8oBAA/4kO8EaeFQlZCDAeWrCBR1/EGke5eb9XgycP3z15P0P0SBnHHXtwrm3d5ipmbM656xTgVr74i7si/NAG+kAadoa0JKdn2fn+QxQBCE4G/ogScWTw= Received: from CY1PR03CA0015.namprd03.prod.outlook.com (2603:10b6:600::25) by CY4PR03MB3128.namprd03.prod.outlook.com (2603:10b6:910:53::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Tue, 25 Jun 2019 08:11:55 +0000 Received: from SN1NAM02FT021.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::206) by CY1PR03CA0015.outlook.office365.com (2603:10b6:600::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16 via Frontend Transport; Tue, 25 Jun 2019 08:11:55 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT021.mail.protection.outlook.com (10.152.72.144) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1987.11 via Frontend Transport; Tue, 25 Jun 2019 08:11:54 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x5P8BrH6022647 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 25 Jun 2019 01:11:53 -0700 Received: from mircea-Latitude-E6540.ad.analog.com (10.48.65.115) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 25 Jun 2019 04:11:53 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCHi V4 2/5] iio: adc: ad7124: Add buffered input support Date: Tue, 25 Jun 2019 11:11:25 +0300 Message-ID: <20190625081128.22190-2-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625081128.22190-1-mircea.caprioru@analog.com> References: <20190625081128.22190-1-mircea.caprioru@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(136003)(39860400002)(2980300002)(54534003)(199004)(189003)(446003)(126002)(50466002)(54906003)(8936002)(476003)(26005)(478600001)(356004)(6916009)(2351001)(48376002)(16586007)(6666004)(36756003)(8676002)(5660300002)(44832011)(426003)(246002)(86362001)(486006)(11346002)(70586007)(2616005)(70206006)(47776003)(186003)(50226002)(72206003)(107886003)(316002)(77096007)(7696005)(2906002)(51416003)(106002)(1076003)(76176011)(4326008)(7636002)(305945005)(336012);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB3128;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc673aec-0f4a-44de-a64a-08d6f944c961 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709080)(1401327)(2017052603328);SRVR:CY4PR03MB3128; X-MS-TrafficTypeDiagnostic: CY4PR03MB3128: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-Forefront-PRVS: 0079056367 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: zlBMdYabm3m5G7QtxNc/JeNXHnZWJPlhNtdmsfsznqDXyY0k/tlIU27kPq/i357AvqlRIQxEfT3IEzYr5uXblHIvg1Lynn99Jl+vRyIHl3fdLyYUJnhUpZCDaZ7tYoTz2ZudcSmdbPLYraXT8FRafPyx4wOPzZpc0gbClOqndhJ0IBsukm/9QCXorcSpGbsH86wnzm5EghUHpqIaXoMsSstOBJSNJfg33MtKJup2csiEcL4BiLrIUxd1UVGTDLycAChUjiHtLbyTRMUEYv8cJre/9WU8WlkL6YLzzYmh6FLJC/1FX+Fjrf+KjkM/MLlTvoPgGZzDzTaNZTzY4kal9KhpQ4jt2LEBwXMTZ43uOwWBXeuKmtSzYHdqlAmNnZiI42p44BNjRb/LjqZzqcHwCb+Lo14SNcL9zcOc6IBREK0= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2019 08:11:54.7923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc673aec-0f4a-44de-a64a-08d6f944c961 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3128 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=959 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250067 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 This patch adds the option to enable the buffered mode for positive and negative inputs. Each option can be enabled independently. In buffered mode, the input channel feeds into a high impedance input stage of the buffer amplifier. Therefore, the input can tolerate significant source impedances and is tailored for direct connection to external resistive type sensors such as strain gages or RTDs. Signed-off-by: Mircea Caprioru --- Changelog v2: - nothing changed here Changelog v3: - nothing changed here Changelog v4: - nothing changed here drivers/iio/adc/ad7124.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 810234db9c0d..ab52c5e9ecb1 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -61,6 +61,8 @@ #define AD7124_CONFIG_REF_SEL(x) FIELD_PREP(AD7124_CONFIG_REF_SEL_MSK, x) #define AD7124_CONFIG_PGA_MSK GENMASK(2, 0) #define AD7124_CONFIG_PGA(x) FIELD_PREP(AD7124_CONFIG_PGA_MSK, x) +#define AD7124_CONFIG_IN_BUFF_MSK GENMASK(7, 6) +#define AD7124_CONFIG_IN_BUFF(x) FIELD_PREP(AD7124_CONFIG_IN_BUFF_MSK, x) /* AD7124_FILTER_X */ #define AD7124_FILTER_FS_MSK GENMASK(10, 0) @@ -108,6 +110,8 @@ struct ad7124_chip_info { struct ad7124_channel_config { enum ad7124_ref_sel refsel; bool bipolar; + bool buf_positive; + bool buf_negative; unsigned int ain; unsigned int vref_mv; unsigned int pga_bits; @@ -473,6 +477,11 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, else st->channel_config[channel].refsel = tmp; + st->channel_config[channel].buf_positive = + of_property_read_bool(child, "adi,buffered-positive"); + st->channel_config[channel].buf_negative = + of_property_read_bool(child, "adi,buffered-negative"); + *chan = ad7124_channel_template; chan->address = channel; chan->scan_index = channel; @@ -492,7 +501,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, static int ad7124_setup(struct ad7124_state *st) { unsigned int val, fclk, power_mode; - int i, ret; + int i, ret, tmp; fclk = clk_get_rate(st->mclk); if (!fclk) @@ -525,8 +534,12 @@ static int ad7124_setup(struct ad7124_state *st) if (ret < 0) return ret; + tmp = (st->channel_config[i].buf_positive << 1) + + st->channel_config[i].buf_negative; + val = AD7124_CONFIG_BIPOLAR(st->channel_config[i].bipolar) | - AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel); + AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel) | + AD7124_CONFIG_IN_BUFF(tmp); ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(i), 2, val); if (ret < 0) return ret;