From patchwork Wed Aug 14 07:31:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 11093437 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 172861398 for ; Wed, 14 Aug 2019 07:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F095F2879B for ; Wed, 14 Aug 2019 07:32:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4323287A0; Wed, 14 Aug 2019 07:32:25 +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 301F92879B for ; Wed, 14 Aug 2019 07:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbfHNHcY (ORCPT ); Wed, 14 Aug 2019 03:32:24 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:11176 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbfHNHcY (ORCPT ); Wed, 14 Aug 2019 03:32:24 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7E7S255014574; Wed, 14 Aug 2019 03:32:00 -0400 Received: from nam03-dm3-obe.outbound.protection.outlook.com (mail-dm3nam03lp2052.outbound.protection.outlook.com [104.47.41.52]) by mx0a-00128a01.pphosted.com with ESMTP id 2ubx1n2d3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Aug 2019 03:32:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d6xY1oykDCKOtHlJrkrv5nlvtvqHP7FKwF8ND3kVRjhyMaa9GcsnDDiZtgBI1ydWLgpCooF30BpLH3Zu1fuvRxkjzKCZEgCJOPlWcUHI6UuOZ6wePyoYRNqAMo5r3Mf5QFKWUwO7PDteR8Kjkt5RHG5acA/+FHeWB45CqzjwmkV4wutp8SKIZBVB3dQoNl5lXSY7eEAj2aXfjx2bW7owZgFv6m9T/GkbEaVeB4jxTQ9+7Ct/ZbB2Hp0wofM4DAAV5VDhe3CCKkoxppTPAQIgA8FjWdVRIrLCkb+Uq52eycd3OSiXLIk3Rvq0R1Qt8RFdvCnZgjq1R51o+4LlWB2gqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N48GBvZrXP1cgctP0trP+9OJeKy1UzOut2KQ8LS51K8=; b=WP7hUY/b9HKyNsnQ5qawzFpAV0z4UKcwoqhiM8Out8y6aq6YrV2PUClTYxSr+lRZpuPbzaqcm5FZhZvLG/vAb5I5UJspdxEYK1iXA/Asg1qThm6Ntj9C7jsYXql+ZpUoTg92Zi2vN1d/Ba/toCVrUYdACa5RDz66wCVDAkengIpDbdpTrPJ5ePTNb2YUwgvfmsJ3Waz/j+hf/0zjmvOKBo4k0xby01rOK9ZBXyMkhLnWq5QV0p66TMf5IQds31Z/OKzxYAMPrAfcK6vNGs5YMQ7GAyhMABBvqUIZH77BHZW+a7jMpP6j/f893hNfiQGIJTADwSrURggOcc75aoSnCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=metafoo.de smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N48GBvZrXP1cgctP0trP+9OJeKy1UzOut2KQ8LS51K8=; b=5xtEh6pbwaVW5+7x0k4/+UaDqVa+Hg7rDMj61ZDL6RAyVPjOEtgijRLlhSUNPu6EJYUHGZ1mZI52I8GRS4iJYYWkepu1kPsGeYQoVcNKzaPHQ5uMHF/i941F0UsRwNDHgai5G+e6pHfblOYZix21NwdiaLAJdDd0Bjp2YE/dNa8= Received: from DM6PR03CA0006.namprd03.prod.outlook.com (2603:10b6:5:40::19) by BN6PR03MB2932.namprd03.prod.outlook.com (2603:10b6:404:119::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.14; Wed, 14 Aug 2019 07:31:58 +0000 Received: from BL2NAM02FT031.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::201) by DM6PR03CA0006.outlook.office365.com (2603:10b6:5:40::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.14 via Frontend Transport; Wed, 14 Aug 2019 07:31:58 +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 BL2NAM02FT031.mail.protection.outlook.com (10.152.77.173) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2157.15 via Frontend Transport; Wed, 14 Aug 2019 07:31:57 +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 x7E7Vv4o020929 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 14 Aug 2019 00:31:57 -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; Wed, 14 Aug 2019 03:31:56 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCH V3 1/4] staging: iio: adc: ad7192: Add low_pass_3db_filter_frequency Date: Wed, 14 Aug 2019 10:31:47 +0300 Message-ID: <20190814073150.4602-1-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 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)(346002)(376002)(396003)(136003)(39860400002)(2980300002)(54534003)(199004)(189003)(47776003)(246002)(426003)(186003)(107886003)(4326008)(7636002)(14444005)(26005)(305945005)(5660300002)(51416003)(486006)(2616005)(44832011)(126002)(1076003)(476003)(8676002)(336012)(7696005)(50466002)(50226002)(16586007)(316002)(2351001)(70206006)(6916009)(478600001)(8936002)(36756003)(2906002)(86362001)(48376002)(6666004)(356004)(54906003)(70586007)(106002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2932;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: 4f75ad02-22d5-41f2-887d-08d720897d07 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709080)(1401327)(2017052603328);SRVR:BN6PR03MB2932; X-MS-TrafficTypeDiagnostic: BN6PR03MB2932: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 01294F875B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Gb+2Ud757UlDzedj+C5FSjLICksoCclDbx4AhWQvwJc07Ch0fIOSY3Ao+pQUdRFLMD08kTp2+XykW8eQsmTQBn3NB+T/bElO4LgDJsLZmv1BFCq5BtuDOeSW2PgkB/3eDKOSIEescegFlA4hOLEB1XAoTebATXaTybQGPvoW2rGzjrCmyjgeJPk0WSGVDZd2Liwr61Y7Aj7rGzAQkKIjKLKrsfEzlQZtpIX5zZtyzEytiswRji8naB/g4tU9UePFOFMGfLQTZIPmKNCtMQAp76oM8NuSPpMtTmHjdqJ70IqDjqwhT8aSXEGAGVx87V1lMUhHdnCAxxEg4YakfXlTcj+5harnWRlWOZsTioZCyuKNWf4bDAco5OdNZx9eJcxiJTHYDRCOlqUsx5yvj2Clax4HJY3vHaIqM0q0FJexSTY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2019 07:31:57.5407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f75ad02-22d5-41f2-887d-08d720897d07 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: BN6PR03MB2932 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-14_02:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140072 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 By adding this option we are able to remove the sync3 field and dt binding. When setting the required cutoff frequency we also determine the ADC configuration for chop and sync filter. Signed-off-by: Mircea Caprioru --- Changelog V2: - no changes here Changelog V3: - no changes here drivers/staging/iio/adc/ad7192.c | 148 +++++++++++++++++++++++++++---- 1 file changed, 132 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 81ea2639c67c..d58ce08f3693 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -143,6 +143,10 @@ #define AD7192_EXT_FREQ_MHZ_MAX 5120000 #define AD7192_INT_FREQ_MHZ 4915200 +#define AD7192_NO_SYNC_FILTER 1 +#define AD7192_SYNC3_FILTER 3 +#define AD7192_SYNC4_FILTER 4 + /* NOTE: * The AD7190/2/5 features a dual use data out ready DOUT/RDY output. * In order to avoid contentions on the SPI bus, it's therefore necessary @@ -250,7 +254,7 @@ static int ad7192_of_clock_select(struct ad7192_state *st) static int ad7192_setup(struct ad7192_state *st, struct device_node *np) { struct iio_dev *indio_dev = spi_get_drvdata(st->sd.spi); - bool rej60_en, sinc3_en, refin2_en, chop_en; + bool rej60_en, refin2_en; bool buf_en, bipolar, burnout_curr_en; unsigned long long scale_uv; int i, ret, id; @@ -282,24 +286,12 @@ static int ad7192_setup(struct ad7192_state *st, struct device_node *np) if (rej60_en) st->mode |= AD7192_MODE_REJ60; - sinc3_en = of_property_read_bool(np, "adi,sinc3-filter-enable"); - if (sinc3_en) - st->mode |= AD7192_MODE_SINC3; - refin2_en = of_property_read_bool(np, "adi,refin2-pins-enable"); if (refin2_en && st->devid != ID_AD7195) st->conf |= AD7192_CONF_REFSEL; - chop_en = of_property_read_bool(np, "adi,chop-enable"); - if (chop_en) { - st->conf |= AD7192_CONF_CHOP; - if (sinc3_en) - st->f_order = 3; /* SINC 3rd order */ - else - st->f_order = 4; /* SINC 4th order */ - } else { - st->f_order = 1; - } + st->conf &= ~AD7192_CONF_CHOP; + st->f_order = AD7192_NO_SYNC_FILTER; buf_en = of_property_read_bool(np, "adi,buffer-enable"); if (buf_en) @@ -311,7 +303,7 @@ static int ad7192_setup(struct ad7192_state *st, struct device_node *np) burnout_curr_en = of_property_read_bool(np, "adi,burnout-currents-enable"); - if (burnout_curr_en && buf_en && !chop_en) { + if (burnout_curr_en && buf_en) { st->conf |= AD7192_CONF_BURN; } else if (burnout_curr_en) { dev_warn(&st->sd.spi->dev, @@ -409,6 +401,49 @@ static ssize_t ad7192_set(struct device *dev, return ret ? ret : len; } +static void ad7192_get_available_filter_freq(struct ad7192_state *st, + int *freq) +{ + unsigned int fadc; + + /* Formulas for filter at page 25 of the datasheet */ + fadc = DIV_ROUND_CLOSEST(st->fclk, + AD7192_SYNC4_FILTER * AD7192_MODE_RATE(st->mode)); + freq[0] = DIV_ROUND_CLOSEST(fadc * 240, 1024); + + fadc = DIV_ROUND_CLOSEST(st->fclk, + AD7192_SYNC3_FILTER * AD7192_MODE_RATE(st->mode)); + freq[1] = DIV_ROUND_CLOSEST(fadc * 240, 1024); + + fadc = DIV_ROUND_CLOSEST(st->fclk, AD7192_MODE_RATE(st->mode)); + freq[2] = DIV_ROUND_CLOSEST(fadc * 230, 1024); + freq[3] = DIV_ROUND_CLOSEST(fadc * 272, 1024); +} + +static int ad7192_show_filter_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad7192_state *st = iio_priv(indio_dev); + unsigned int freq_avail[4], i; + size_t len = 0; + + ad7192_get_available_filter_freq(st, freq_avail); + + for (i = 0; i < ARRAY_SIZE(freq_avail); i++) + len += scnprintf(buf + len, PAGE_SIZE - len, + "%d.%d ", freq_avail[i] / 1000, + freq_avail[i] % 1000); + + buf[len - 1] = '\n'; + + return len; +} + +static IIO_DEVICE_ATTR(filter_low_pass_3db_frequency_available, + 0444, ad7192_show_filter_avail, NULL, 0); + static IIO_DEVICE_ATTR(bridge_switch_en, 0644, ad7192_show_bridge_switch, ad7192_set, AD7192_REG_GPOCON); @@ -418,6 +453,7 @@ static IIO_DEVICE_ATTR(ac_excitation_en, 0644, AD7192_REG_MODE); static struct attribute *ad7192_attributes[] = { + &iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr, &iio_dev_attr_bridge_switch_en.dev_attr.attr, &iio_dev_attr_ac_excitation_en.dev_attr.attr, NULL @@ -428,6 +464,7 @@ static const struct attribute_group ad7192_attribute_group = { }; static struct attribute *ad7195_attributes[] = { + &iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr, &iio_dev_attr_bridge_switch_en.dev_attr.attr, NULL }; @@ -441,6 +478,74 @@ static unsigned int ad7192_get_temp_scale(bool unipolar) return unipolar ? 2815 * 2 : 2815; } +static int ad7192_set_3db_filter_freq(struct ad7192_state *st, + int val, int val2) +{ + int freq_avail[4], i, ret, idx, freq; + unsigned int diff_new, diff_old; + + diff_old = U32_MAX; + freq = val * 1000 + val2; + + ad7192_get_available_filter_freq(st, freq_avail); + + for (i = 0; i < ARRAY_SIZE(freq_avail); i++) { + diff_new = abs(freq - freq_avail[i]); + if (diff_new < diff_old) { + diff_old = diff_new; + idx = i; + } + } + + switch (idx) { + case 0: + st->f_order = AD7192_SYNC4_FILTER; + st->mode &= ~AD7192_MODE_SINC3; + + st->conf |= AD7192_CONF_CHOP; + break; + case 1: + st->f_order = AD7192_SYNC3_FILTER; + st->mode |= AD7192_MODE_SINC3; + + st->conf |= AD7192_CONF_CHOP; + break; + case 2: + st->f_order = AD7192_NO_SYNC_FILTER; + st->mode &= ~AD7192_MODE_SINC3; + + st->conf &= ~AD7192_CONF_CHOP; + break; + case 3: + st->f_order = AD7192_NO_SYNC_FILTER; + st->mode |= AD7192_MODE_SINC3; + + st->conf &= ~AD7192_CONF_CHOP; + break; + } + + ret = ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); + if (ret < 0) + return ret; + + return ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf); +} + +static int ad7192_get_3db_filter_freq(struct ad7192_state *st) +{ + unsigned int fadc; + + fadc = DIV_ROUND_CLOSEST(st->fclk, + st->f_order * AD7192_MODE_RATE(st->mode)); + + if (st->conf & AD7192_CONF_CHOP) + return DIV_ROUND_CLOSEST(fadc * 240, 1024); + if (st->mode & AD7192_MODE_SINC3) + return DIV_ROUND_CLOSEST(fadc * 272, 1024); + else + return DIV_ROUND_CLOSEST(fadc * 230, 1024); +} + static int ad7192_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, @@ -481,6 +586,10 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, *val = st->fclk / (st->f_order * 1024 * AD7192_MODE_RATE(st->mode)); return IIO_VAL_INT; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + *val = ad7192_get_3db_filter_freq(st); + *val2 = 1000; + return IIO_VAL_FRACTIONAL; } return -EINVAL; @@ -535,6 +644,9 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, st->mode |= AD7192_MODE_RATE(div); ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); break; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + ret = ad7192_set_3db_filter_freq(st, val, val2 / 1000); + break; default: ret = -EINVAL; } @@ -553,6 +665,8 @@ static int ad7192_write_raw_get_fmt(struct iio_dev *indio_dev, return IIO_VAL_INT_PLUS_NANO; case IIO_CHAN_INFO_SAMP_FREQ: return IIO_VAL_INT; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; } @@ -653,6 +767,8 @@ static int ad7192_channels_config(struct iio_dev *indio_dev) for (i = 0; i < indio_dev->num_channels; i++) { *chan = channels[i]; + chan->info_mask_shared_by_all |= + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY); if (chan->type != IIO_TEMP) chan->info_mask_shared_by_type_available |= BIT(IIO_CHAN_INFO_SCALE); From patchwork Wed Aug 14 07:31:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 11093439 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 C98621398 for ; Wed, 14 Aug 2019 07:32:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF95828791 for ; Wed, 14 Aug 2019 07:32:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3DE32879B; Wed, 14 Aug 2019 07:32:31 +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 3A6E228791 for ; Wed, 14 Aug 2019 07:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfHNHc0 (ORCPT ); Wed, 14 Aug 2019 03:32:26 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:12674 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbfHNHc0 (ORCPT ); Wed, 14 Aug 2019 03:32:26 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7E7S256014574; Wed, 14 Aug 2019 03:32:06 -0400 Received: from nam01-by2-obe.outbound.protection.outlook.com (mail-by2nam01lp2054.outbound.protection.outlook.com [104.47.34.54]) by mx0a-00128a01.pphosted.com with ESMTP id 2ubx1n2d43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 14 Aug 2019 03:32:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O3YggN4WxDm1jCJWfHa+MmtyUm7XAkfSVNIN5s364wqiSNxayuQhsBABY+ToO2h758NXN7wV3KX03mUTFz+9nSPqK1vkrqogMUdYW770DDuin2jtFh8ZliUxeyM+ku/8TEbffv4rCBeTgEh7z6GIxJ3z0roE49yGdt4OsKZs8ouxpnsbU59/8yzqIP49cuSSlCAuLuU4mZ2l8rbdfg+hg82BDBvRsb47FT6qM+lTx/3EiuIoNdYCKBtE6SRNb+jbdDCkvKTay1G/md3MGLRR5llxT23BeTwetjAIS2BFD0O99YvAhKbPu8ia93GOT0BdvXsUjhplN9xhILI5GGo5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bpcegcOHfYrjOAagOfoHRl0TxjQEF/Qk0j+ySdkDjB0=; b=OPl8S98EOd39gwYgUFYJsm1Lr1qHvE7DffxPJYwgchng3J+t5Y5gTnDYHhBaObGUFscFcguQp2CU36aDGBefUijgiTuyKdw0DY1TzuXXc+gbLSIV6DuOL/y8dL7+PFv/bhOMSfJHuYY+axc3Pmy/aR1XvM8bOWtgAB6dM6q+q2Vw6MoI1EIRkOFxJh4hYbi3Z7oAwChMpXHjKWdyjIqR8DdKaBAtKNVMJgXkkHAWrlQ1Qup+TCI0xIDlwIUPz3nnmx+LM23GWQlNtKpDYa3981bDW0cQ6v6uk+p00wecWwViQybVNaa5T1+2IPLfwEbOrOEol6odywudPUdAJ4SGVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=metafoo.de smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bpcegcOHfYrjOAagOfoHRl0TxjQEF/Qk0j+ySdkDjB0=; b=3n1Vx5wqIrrK8VyNFNz3NOGzdwNA12oBQu4CzQ+HcujJxkF0q1NwABrtVxz+dZ2NicEmXXZweI/k+ZdL8eNXnoNKbKkbVAVElXGLFP06X/5kRwPXBSfnnSE+YRteAY+fkrDi0QzUOvWZI1bMLxFWx4kfiN5unlOV8hUKDCukj3U= Received: from DM6PR03CA0061.namprd03.prod.outlook.com (2603:10b6:5:100::38) by BL0PR03MB4209.namprd03.prod.outlook.com (2603:10b6:208:61::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.14; Wed, 14 Aug 2019 07:32:04 +0000 Received: from BL2NAM02FT047.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::205) by DM6PR03CA0061.outlook.office365.com (2603:10b6:5:100::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.14 via Frontend Transport; Wed, 14 Aug 2019 07:32:04 +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 BL2NAM02FT047.mail.protection.outlook.com (10.152.77.9) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2157.15 via Frontend Transport; Wed, 14 Aug 2019 07:32:03 +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 x7E7W3HE020945 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 14 Aug 2019 00:32:03 -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; Wed, 14 Aug 2019 03:32:02 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCH V3 2/4] iio: adc: ad_sigma_delta: Export ad_sd_calibrate Date: Wed, 14 Aug 2019 10:31:48 +0300 Message-ID: <20190814073150.4602-2-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814073150.4602-1-mircea.caprioru@analog.com> References: <20190814073150.4602-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)(39860400002)(346002)(376002)(136003)(2980300002)(54534003)(199004)(189003)(86362001)(44832011)(426003)(51416003)(70206006)(26005)(54906003)(50466002)(48376002)(106002)(186003)(70586007)(7696005)(11346002)(2616005)(476003)(126002)(486006)(446003)(356004)(246002)(76176011)(316002)(16586007)(6666004)(7636002)(14444005)(478600001)(305945005)(336012)(5660300002)(8676002)(2906002)(1076003)(47776003)(4326008)(6916009)(36756003)(107886003)(2351001)(8936002)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:BL0PR03MB4209;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: 2176dd29-1243-4ac3-9a99-08d720898091 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709080)(1401327)(2017052603328);SRVR:BL0PR03MB4209; X-MS-TrafficTypeDiagnostic: BL0PR03MB4209: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 01294F875B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: pIhTwo41Ubh/5KaA41AHhScmej/2wFXCaUagD0zXTqJXSzv9AmUhTY8s59I/hADGi5UkKZ1gGMpoPVVIHTO30oTgptgMbfiNVQ+6PQMnpOHO+rLdSiaYylhj7Ffs0AHS+HBrxKPJoso4bXHKOe+8Dy3HsW+AfoVCNTJlBHS5YVR85/m/+QGiNw8d3uCKVWekKaStYDchoNPaJ4L2dyKEMF4MApTxLFNDb/gk8bzfUQbjtJDJgfSzfeDLZta2NCCCgIRN3oaM1l1pDaqhR7IDfXDD7KSU+OBHS5pMjICJcC4ACIPEM8ET1RGa9O9vq4sjqh1tWZRsSJZtETlUwgGwOg/E7xT5InpCvaS9Lk8rxbwr7jVNXw3MBHL6MJZWjlHdTtnY0VlZ3PifODLKyV+6UFVGvQ4/turwxqoiNjbJB+M= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2019 07:32:03.4948 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2176dd29-1243-4ac3-9a99-08d720898091 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: BL0PR03MB4209 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-14_02:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140072 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 exports the ad_sd_calibrate function in order to be able to call it from outside ad_sigma_delta. There are cases where the option to calibrate one channel at a time is necessary (ex. system calibration for zero scale and full scale). Signed-off-by: Mircea Caprioru --- Changelog V2: - no changes here Changelog V3: - no changes here drivers/iio/adc/ad_sigma_delta.c | 3 ++- include/linux/iio/adc/ad_sigma_delta.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 2640b75fb774..8ba90486c787 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -205,7 +205,7 @@ int ad_sd_reset(struct ad_sigma_delta *sigma_delta, } EXPORT_SYMBOL_GPL(ad_sd_reset); -static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, +int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, unsigned int mode, unsigned int channel) { int ret; @@ -242,6 +242,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, return ret; } +EXPORT_SYMBOL_GPL(ad_sd_calibrate); /** * ad_sd_calibrate_all() - Performs channel calibration diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h index 7716fa0c9fce..8a4e25a7080c 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -119,6 +119,8 @@ int ad_sd_reset(struct ad_sigma_delta *sigma_delta, int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, int *val); +int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, + unsigned int mode, unsigned int channel); int ad_sd_calibrate_all(struct ad_sigma_delta *sigma_delta, const struct ad_sd_calib_data *cd, unsigned int n); int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev, From patchwork Wed Aug 14 07:31:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 11093441 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 9D530746 for ; Wed, 14 Aug 2019 07:32:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82ED728791 for ; Wed, 14 Aug 2019 07:32:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7640F28797; Wed, 14 Aug 2019 07:32:39 +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 E8B2928791 for ; Wed, 14 Aug 2019 07:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbfHNHci (ORCPT ); Wed, 14 Aug 2019 03:32:38 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:58394 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbfHNHci (ORCPT ); Wed, 14 Aug 2019 03:32:38 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7E7RwXj010368; Wed, 14 Aug 2019 03:32:16 -0400 Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2059.outbound.protection.outlook.com [104.47.48.59]) by mx0b-00128a01.pphosted.com with ESMTP id 2ucbuvrbwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 14 Aug 2019 03:32:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8qqLQAYYjrRH57TXFqUR8gBdcgwT4sP+MRsSK0jqYQaG5aS/BwGKkK95laHuQOocqYVsHDBxgt5mMVWmYjI1SGPCedG1zhecm4bLgDD6fXUI4aCrsIvexdGSVnN2MJNkJSus+mQcYgQECiKhaB/W+9mQmFCYNVhsqdazuyHo6ba7y7sA6D7Df2eoJW6Wf4FScGTZGMdA6YVr6HhgQqWr60J+hpAE1FLK3G9ZSR40JI8JNc/120EeD0qcVUDeuECt5A4JVmdwSqCtW6bjHSWPDa0LGSKdRjlSNRrWf1IOewBR+Z/+7/t4XqY33tuc2u62HpJRpQJdrKoDdR8FYxijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ErXO7WAdpxp6yer5aS/G/KdoOXzKkjRCRuy5C2SzKMY=; b=Cdi8dP5C9gfMfqwC7pUOE+BHyVmZ6hxFN99VnWteVXMV74HRNhzl0UyVLyeI2kVC40DhUZheRwFpgKAz9XuRJMskF6frhFjh+Q9h8ubQaRzFb82crr0+lF8q8xLTakstf2Lgau3AGdhQKsbBIGxtJt6ZpXyrcBHlllKWKP6a+X5LeyQqELw0IafF07uocX6Tts+d2mFESBeQ0mjwHmsj0o8/gh7C7gIPXMOVXWL2CABmFrFWZhufWQusuhds3SfMF59EXifVeeV8oudozFePocD4jxUUN9Avt/KQKnlF5VCedtLt9gBkD8afMQ/pBB9BUMRz625uzXLsRT7OhyJoDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=metafoo.de smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ErXO7WAdpxp6yer5aS/G/KdoOXzKkjRCRuy5C2SzKMY=; b=iFQuvSQZMC7mkLOCZcdQrTOYMNX/qro/dcn4fZbjrf+Tfwb/zJrlAaWyDW1Rutsr/eALuIjrZJdbkFTLD4Ik7e3XaOU9huOPZ6ufANKxr5L1qcvSo/WFtEdgB+gX2+E/sF2+f+lz9LlVrg/7mf0YvPLcA6Sp+VykJXoNR6UgLXs= Received: from DM3PR03CA0023.namprd03.prod.outlook.com (2603:10b6:0:50::33) by BN6PR03MB3379.namprd03.prod.outlook.com (2603:10b6:405:40::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18; Wed, 14 Aug 2019 07:32:09 +0000 Received: from BL2NAM02FT012.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::201) by DM3PR03CA0023.outlook.office365.com (2603:10b6:0:50::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18 via Frontend Transport; Wed, 14 Aug 2019 07:32:09 +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 BL2NAM02FT012.mail.protection.outlook.com (10.152.77.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2157.15 via Frontend Transport; Wed, 14 Aug 2019 07:32:08 +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 x7E7W89b020968 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 14 Aug 2019 00:32:08 -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; Wed, 14 Aug 2019 03:32:07 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCH V3 3/4] staging: iio: adc: ad7192: Add system calibration support Date: Wed, 14 Aug 2019 10:31:49 +0300 Message-ID: <20190814073150.4602-3-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814073150.4602-1-mircea.caprioru@analog.com> References: <20190814073150.4602-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)(346002)(376002)(39860400002)(136003)(2980300002)(54534003)(189003)(199004)(106002)(7696005)(54906003)(7636002)(50226002)(246002)(70206006)(107886003)(478600001)(305945005)(70586007)(51416003)(76176011)(8936002)(14444005)(48376002)(4326008)(50466002)(86362001)(16586007)(2906002)(8676002)(426003)(446003)(44832011)(486006)(5660300002)(186003)(316002)(36756003)(11346002)(47776003)(356004)(6666004)(126002)(1076003)(476003)(2616005)(6916009)(2351001)(26005)(336012);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB3379;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a4b7c58-ccf9-43d8-5089-08d7208983bb X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(4709080)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:BN6PR03MB3379; X-MS-TrafficTypeDiagnostic: BN6PR03MB3379: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 01294F875B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: szabSO9Lp0irtMRNYbIEodM5ysj7Af6CeiR/OQKxAXLZLMN5Y1hxJeHCJLuiW+0yrp2AfP4UZYID1D+lfu4j/xPiHb8W4v9oY62+Ujym5KWTYlp5MSdJMcur456I5JtajOPBhM5MoQIiLQ8e3m6Yhi2uub1gvHEW1eDphHG2/WUEbgcTqLbtgHnCFBjYE/5yB3+aaAHqElCgEjedhiqfZztLf1eJx7i+/wPvbgxovmi99rZ2KPQhS98Gze+DrxIiXWKd7RJcdyZLe8+9Mpo/jfD2nIfaXQfpSkkBsF9E+RM9IR2gtPkOFfLFJlCTKVKDfXjYD9GwAoOzSD5X2h+Divuh2GzhXex4O6of76f9MH6jwll22GgZYIZBDWRbqnHeIR6S/ZGXlcBGYgsTw3gYgaFRN816wPZFNU94y+TrNLE= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2019 07:32:08.8009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a4b7c58-ccf9-43d8-5089-08d7208983bb 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: BN6PR03MB3379 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-14_02:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140072 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 will add a system calibration attribute for each channel. Using this option the user will have the ability to calibrate each channel for zero scale and full scale. It uses the iio_chan_spec_ext_info and IIO_ENUM to implement the functionality. Signed-off-by: Mircea Caprioru --- Changelog V2: - no changes here Changelog V3: - no changes here drivers/staging/iio/adc/ad7192.c | 55 +++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index d58ce08f3693..731072830f30 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -155,6 +155,11 @@ * The DOUT/RDY output must also be wired to an interrupt capable GPIO. */ +enum { + AD7192_SYSCALIB_ZERO_SCALE, + AD7192_SYSCALIB_FULL_SCALE, +}; + struct ad7192_state { struct regulator *avdd; struct regulator *dvdd; @@ -169,10 +174,56 @@ struct ad7192_state { u8 devid; u8 clock_sel; struct mutex lock; /* protect sensor state */ + u8 syscalib_mode[8]; struct ad_sigma_delta sd; }; +static const char * const ad7192_syscalib_modes[] = { + [AD7192_SYSCALIB_ZERO_SCALE] = "zero_scale", + [AD7192_SYSCALIB_FULL_SCALE] = "full_scale", +}; + +static int ad7192_set_syscalib_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct ad7192_state *st = iio_priv(indio_dev); + int ret; + + st->syscalib_mode[chan->channel] = mode; + + if (mode == AD7192_SYSCALIB_ZERO_SCALE) + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_ZERO, + chan->address); + else + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_FULL, + chan->address); + + return ret; +} + +static int ad7192_get_syscalib_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct ad7192_state *st = iio_priv(indio_dev); + + return st->syscalib_mode[chan->channel]; +} + +static const struct iio_enum ad7192_syscalib_mode_enum = { + .items = ad7192_syscalib_modes, + .num_items = ARRAY_SIZE(ad7192_syscalib_modes), + .set = ad7192_set_syscalib_mode, + .get = ad7192_get_syscalib_mode +}; + +static const struct iio_chan_spec_ext_info ad7192_calibsys_ext_info[] = { + IIO_ENUM("system_calibration", IIO_SEPARATE, &ad7192_syscalib_mode_enum), + IIO_ENUM_AVAILABLE("system_calibration", &ad7192_syscalib_mode_enum), + {} +}; + static struct ad7192_state *ad_sigma_delta_to_ad7192(struct ad_sigma_delta *sd) { return container_of(sd, struct ad7192_state, sd); @@ -769,9 +820,11 @@ static int ad7192_channels_config(struct iio_dev *indio_dev) *chan = channels[i]; chan->info_mask_shared_by_all |= BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY); - if (chan->type != IIO_TEMP) + if (chan->type != IIO_TEMP) { chan->info_mask_shared_by_type_available |= BIT(IIO_CHAN_INFO_SCALE); + chan->ext_info = ad7192_calibsys_ext_info; + } chan++; } From patchwork Wed Aug 14 07:31:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 11093443 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 95F2C746 for ; Wed, 14 Aug 2019 07:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C86528791 for ; Wed, 14 Aug 2019 07:32:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 705E728797; Wed, 14 Aug 2019 07:32: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=-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 D309E28791 for ; Wed, 14 Aug 2019 07:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfHNHco (ORCPT ); Wed, 14 Aug 2019 03:32:44 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:21192 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbfHNHck (ORCPT ); Wed, 14 Aug 2019 03:32:40 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7E7S3vO002516; Wed, 14 Aug 2019 03:32:17 -0400 Received: from nam01-by2-obe.outbound.protection.outlook.com (mail-by2nam01lp2054.outbound.protection.outlook.com [104.47.34.54]) by mx0a-00128a01.pphosted.com with ESMTP id 2uc0whhuyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 14 Aug 2019 03:32:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pwy/Vq8/7N/uVTDKAoHKEOBNQcyTfBoeXwGFf7agRNAwoKWBnC+In9wdbMT4i08AgJ/gRvsgWxCEKdjtENGNvuhFPR8yZTZyvG3JaNu2NTgPvevFvcO5+0Vd/VujVQsfLY8saIKA9ixVisD7ayzIIFNYT0hgpHlU6V0zOwzbYoOcMbgcVwtly5s1M06T4efkoPMI8+MK/5IGg+on1+DKtFLnufucAfNPDvkRIW1hc/E4PfLukYczKxmECU9E9OyYC7loqWqRyIN3wXFmrcmzkJbvXwNDzSmPWklkCNuJTUqFuYa18lGLuvFq+aQK6Qgzt732sUbHsRPfJ7SEk9OZqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZjJRsyTLVcWD1ysn5uSWFQ4C4iknXPZ5EFfS4PtX2xA=; b=lJOp7LRvPckfAfL9LA7lNSy66GaC6OPiOymvTMENsMd3iyISMnS4pglZpB64/qDCCPzAo+0Yt9D9y/ZXX8/4SjLWeKl4GzdkN298kTbETJXwSt5FodZ0CjkHOrtbvDkwiLG44WwYgPA9X7ovmdVVjqyboaTjdnX5n9G/SLiGd574sKK6exSxf1zPQalsn9AxtuOH0GLD/KZlYmOJS4Le83FxYwS1IsHPQVIRFXaZlHFqVq1j5ndrpBTar7T1w/xavCbjf6V0bDO2+3qYc1Yl4HlJESV/sZ5har3LaUu1LdDJLrOEsKJ9i4SduohJmc1Llo7oJ8C9DtGYNsbULLKrDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=metafoo.de smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZjJRsyTLVcWD1ysn5uSWFQ4C4iknXPZ5EFfS4PtX2xA=; b=RvdSP4HIiQmCpLUvqp7kfClrLTBpllizOw3efFVsnBmPDGp32esYqwPPnNL/tmUqfZDGH1whvbHbS6zsujy+50wdq9vwCcOhJ5H4AT2Kxbe0b501uk9BB/W96AWjF6aTXpRreZiLnsqel4N0ND97B6HbLS6X5UZ7cD7KVFcCAXo= Received: from DM6PR03CA0039.namprd03.prod.outlook.com (2603:10b6:5:100::16) by CY4PR03MB2422.namprd03.prod.outlook.com (2603:10b6:903:42::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.13; Wed, 14 Aug 2019 07:32:15 +0000 Received: from SN1NAM02FT019.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::203) by DM6PR03CA0039.outlook.office365.com (2603:10b6:5:100::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.14 via Frontend Transport; Wed, 14 Aug 2019 07:32:15 +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 SN1NAM02FT019.mail.protection.outlook.com (10.152.72.130) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2178.16 via Frontend Transport; Wed, 14 Aug 2019 07:32:14 +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 x7E7WEaQ020983 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 14 Aug 2019 00:32:14 -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; Wed, 14 Aug 2019 03:32:13 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCH V3 4/4] dt-bindings: iio: adc: ad7192: Add binding documentation for AD7192 Date: Wed, 14 Aug 2019 10:31:50 +0300 Message-ID: <20190814073150.4602-4-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814073150.4602-1-mircea.caprioru@analog.com> References: <20190814073150.4602-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)(346002)(136003)(396003)(39860400002)(376002)(2980300002)(199004)(189003)(54534003)(107886003)(44832011)(246002)(426003)(316002)(54906003)(6666004)(305945005)(4326008)(106002)(6916009)(2351001)(1076003)(5660300002)(53376002)(86362001)(7636002)(356004)(2616005)(186003)(7696005)(446003)(76176011)(8676002)(14444005)(47776003)(336012)(70586007)(26005)(6306002)(50466002)(11346002)(476003)(126002)(966005)(486006)(2906002)(8936002)(478600001)(36756003)(50226002)(70206006)(2870700001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB2422;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: 4c5ff6b8-673f-43a1-af3f-08d72089877b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709080)(1401327)(2017052603328);SRVR:CY4PR03MB2422; X-MS-TrafficTypeDiagnostic: CY4PR03MB2422: X-MS-Exchange-PUrlCount: 3 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 01294F875B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: MxtR19j4530kbFzhPbSaD8yEg7pYifvjNs9Ck17Nns346AhyF8a9sV7MZfwMMm6E1cyOgRgAqwWGZh1U0AnBrFRoZLewFnU5J7MHR7kzfCkwK48pnJm3u87qI76lW2YuDRPY83apWn/X5ihvIZBczcV750wJXdgX4MBKN6TQt3hG+mz3OmS3Szb5gDsL6VnN+zxuCA7wXCzriNeOmZav3snJwpb6e6gF7REX+OPcOa7qnS74Pyp3qESC/7CEQH4xHBIGaKthpmRz2gSFPjm/Y3ziBLJD54X3bJo6MajMKXSaOVe7C0IFZDpd67rmG9p07bcdoCCMfF2r7onlcapmRlgQlLCr1WDu/skKKXYPdmQlQskQqx2HTEIxWSJls4/hKtGldOnVaU2qlDdDVEpmKn6Rcfm4dOZMIp7MyfYAhWk= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2019 07:32:14.8119 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c5ff6b8-673f-43a1-af3f-08d72089877b 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: CY4PR03MB2422 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-14_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140072 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 add device tree binding documentation for AD7192 adc in YAML format. Signed-off-by: Mircea Caprioru Reviewed-by: Rob Herring --- Changelog V2: - remove description from spi and interrupt properties - changed the name of the device from ad7192 to adc in the example Changelog V3: - added semicolon at the end of the dt example .../bindings/iio/adc/adi,ad7192.yaml | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7192.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7192.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7192.yaml new file mode 100644 index 000000000000..676ec42e1438 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7192.yaml @@ -0,0 +1,121 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2019 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ad7192.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7192 ADC device driver + +maintainers: + - Michael Hennerich + +description: | + Bindings for the Analog Devices AD7192 ADC device. Datasheet can be + found here: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7192.pdf + +properties: + compatible: + enum: + - adi,ad7190 + - adi,ad7192 + - adi,ad7193 + - adi,ad7195 + + reg: + maxItems: 1 + + spi-cpol: true + + spi-cpha: true + + clocks: + maxItems: 1 + description: phandle to the master clock (mclk) + + clock-names: + items: + - const: mclk + + interrupts: + maxItems: 1 + + dvdd-supply: + description: DVdd voltage supply + items: + - const: dvdd + + avdd-supply: + description: AVdd voltage supply + items: + - const: avdd + + adi,rejection-60-Hz-enable: + description: | + This bit enables a notch at 60 Hz when the first notch of the sinc + filter is at 50 Hz. When REJ60 is set, a filter notch is placed at + 60 Hz when the sinc filter first notch is at 50 Hz. This allows + simultaneous 50 Hz/ 60 Hz rejection. + type: boolean + + adi,refin2-pins-enable: + description: | + External reference applied between the P1/REFIN2(+) and P0/REFIN2(−) pins. + type: boolean + + adi,buffer-enable: + description: | + Enables the buffer on the analog inputs. If cleared, the analog inputs + are unbuffered, lowering the power consumption of the device. If this + bit is set, the analog inputs are buffered, allowing the user to place + source impedances on the front end without contributing gain errors to + the system. + type: boolean + + adi,burnout-currents-enable: + description: | + When this bit is set to 1, the 500 nA current sources in the signal + path are enabled. When BURN = 0, the burnout currents are disabled. + The burnout currents can be enabled only when the buffer is active + and when chop is disabled. + type: boolean + + bipolar: + description: see Documentation/devicetree/bindings/iio/adc/adc.txt + type: boolean + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - dvdd-supply + - avdd-supply + - spi-cpol + - spi-cpha + +examples: + - | + spi0 { + adc@0 { + compatible = "adi,ad7192"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cpol; + spi-cpha; + clocks = <&ad7192_mclk>; + clock-names = "mclk"; + #interrupt-cells = <2>; + interrupts = <25 0x2>; + interrupt-parent = <&gpio>; + dvdd-supply = <&dvdd>; + avdd-supply = <&avdd>; + + adi,refin2-pins-enable; + adi,rejection-60-Hz-enable; + adi,buffer-enable; + adi,burnout-currents-enable; + }; + };