From patchwork Wed Feb 27 16:14:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831825 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 2E1871399 for ; Wed, 27 Feb 2019 16:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A35928E9D for ; Wed, 27 Feb 2019 16:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CE8028FD7; Wed, 27 Feb 2019 16:15:06 +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 2C686295CF for ; Wed, 27 Feb 2019 16:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729521AbfB0QO5 (ORCPT ); Wed, 27 Feb 2019 11:14:57 -0500 Received: from mail-eopbgr770044.outbound.protection.outlook.com ([40.107.77.44]:11920 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728124AbfB0QO5 (ORCPT ); Wed, 27 Feb 2019 11:14:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lC4qCLSqMp5fYwwWpJSc42mfKLO7Qvye4BVVS39Nqck=; b=NPtdGMVFpnV3UTc1oSRFVxqXCWvMONgQ2ZAUMLF7hWAg5nKtzouR54fBxYmx8SekD5qX6yU7oYaRa2ZaKCea4Hw3tMA69JTcZWTlNd/F+5kOeOWHPoegpub7+wDo5X3BbS+g5gwbsf5U07eYU2TNuD4bTvuOMqY+eEmgB2fzQCs= Received: from BL0PR03CA0001.namprd03.prod.outlook.com (2603:10b6:208:2d::14) by CY4PR03MB3063.namprd03.prod.outlook.com (2603:10b6:910:53::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Wed, 27 Feb 2019 16:14:51 +0000 Received: from SN1NAM02FT005.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::201) by BL0PR03CA0001.outlook.office365.com (2603:10b6:208:2d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.15 via Frontend Transport; Wed, 27 Feb 2019 16:14:50 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT005.mail.protection.outlook.com (10.152.72.117) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:14:50 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGEnhM021533 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:14:49 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:14:49 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Date: Wed, 27 Feb 2019 18:14:22 +0200 Message-ID: <1551284068-4882-2-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(346002)(376002)(396003)(39860400002)(2980300002)(3190300001)(199004)(189003)(53416004)(246002)(5660300002)(50466002)(48376002)(446003)(336012)(77096007)(7636002)(186003)(26005)(8676002)(2906002)(7696005)(76176011)(51416003)(4326008)(305945005)(54906003)(110136005)(106002)(47776003)(478600001)(356004)(72206003)(6666004)(2616005)(476003)(486006)(44832011)(426003)(50226002)(8936002)(11346002)(116002)(106466001)(16586007)(36756003)(316002)(126002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB3063;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07bddd46-256b-481d-9566-08d69cceb35a X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:CY4PR03MB3063; X-MS-TrafficTypeDiagnostic: CY4PR03M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/7xCRhtjtPEQ6djduAr2gMxFGIYg= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:14:50.1144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07bddd46-256b-481d-9566-08d69cceb35a 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3063 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 The FNCTIO_CTRL register provides configuration control for each I/O pin (DIO1, DIO2, DIO3 and DIO4). This patch adds the option to configure each DIOx pin as data ready indicator with positive or negative polarity by reading the 'interrupts' and 'interrupt-names' properties from the devicetree. The 'interrupt-names' property is optional, if it is not specified, then the DIO1 pin is used as default data ready signal. Although the factory default assigns DIO2 as data ready signal, in the versions previous this patch, DIO1 pin was used. We should leave this configuration as is, since some devices might be expecting the interrupt on the wrong physical pin. Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 97 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index a27fe20..98a23ac 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -9,6 +9,8 @@ * */ +#include +#include #include #include #include @@ -107,6 +109,14 @@ #define ADIS16480_FIR_COEF_C(x) ADIS16480_FIR_COEF(0x09, (x)) #define ADIS16480_FIR_COEF_D(x) ADIS16480_FIR_COEF(0x0B, (x)) +/* ADIS16480_REG_FNCTIO_CTRL */ +#define ADIS16480_DRDY_SEL_MSK GENMASK(1, 0) +#define ADIS16480_DRDY_SEL(x) FIELD_PREP(ADIS16480_DRDY_SEL_MSK, x) +#define ADIS16480_DRDY_POL_MSK BIT(2) +#define ADIS16480_DRDY_POL(x) FIELD_PREP(ADIS16480_DRDY_POL_MSK, x) +#define ADIS16480_DRDY_EN_MSK BIT(3) +#define ADIS16480_DRDY_EN(x) FIELD_PREP(ADIS16480_DRDY_EN_MSK, x) + struct adis16480_chip_info { unsigned int num_channels; const struct iio_chan_spec *channels; @@ -116,12 +126,26 @@ struct adis16480_chip_info { unsigned int accel_max_scale; }; +enum adis16480_int_pin { + ADIS16480_PIN_DIO1, + ADIS16480_PIN_DIO2, + ADIS16480_PIN_DIO3, + ADIS16480_PIN_DIO4 +}; + struct adis16480 { const struct adis16480_chip_info *chip_info; struct adis adis; }; +static const char * const adis16480_int_pin_names[4] = { + [ADIS16480_PIN_DIO1] = "DIO1", + [ADIS16480_PIN_DIO2] = "DIO2", + [ADIS16480_PIN_DIO3] = "DIO3", + [ADIS16480_PIN_DIO4] = "DIO4", +}; + #ifdef CONFIG_DEBUG_FS static ssize_t adis16480_show_firmware_revision(struct file *file, @@ -741,8 +765,17 @@ static int adis16480_stop_device(struct iio_dev *indio_dev) static int adis16480_enable_irq(struct adis *adis, bool enable) { - return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, - enable ? BIT(3) : 0); + uint16_t val; + int ret; + + ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val); + if (ret < 0) + return ret; + + val &= ~ADIS16480_DRDY_EN_MSK; + val |= ADIS16480_DRDY_EN(enable); + + return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val); } static int adis16480_initial_setup(struct iio_dev *indio_dev) @@ -826,6 +859,62 @@ static const struct adis_data adis16480_data = { .enable_irq = adis16480_enable_irq, }; +static int adis16480_config_irq_pin(struct device_node *of_node, + struct adis16480 *st) +{ + struct irq_data *desc; + enum adis16480_int_pin pin; + unsigned int irq_type; + uint16_t val; + int i, irq = 0; + + desc = irq_get_irq_data(st->adis.spi->irq); + if (!desc) { + dev_err(&st->adis.spi->dev, "Could not find IRQ %d\n", irq); + return -EINVAL; + } + + /* Disable data ready since the default after reset is on */ + val = ADIS16480_DRDY_EN(0); + + /* + * Get the interrupt from the devicetre by reading the interrupt-names + * property. If it is not specified, use DIO1 pin as default. + * According to the datasheet, the factory default assigns DIO2 as data + * ready signal. However, in the previous versions of the driver, DIO1 + * pin was used. So, we should leave it as is since some devices might + * be expecting the interrupt on the wrong physical pin. + */ + pin = ADIS16480_PIN_DIO1; + for (i = 0; i < ARRAY_SIZE(adis16480_int_pin_names); i++) { + irq = of_irq_get_byname(of_node, adis16480_int_pin_names[i]); + if (irq > 0) { + pin = i; + break; + } + } + + val |= ADIS16480_DRDY_SEL(pin); + + /* + * Get the interrupt line behaviour. The data ready polarity can be + * configured as positive or negative, corresponding to + * IRQF_TRIGGER_RISING or IRQF_TRIGGER_FALLING respectively. + */ + irq_type = irqd_get_trigger_type(desc); + if (irq_type == IRQF_TRIGGER_RISING) { /* Default */ + val |= ADIS16480_DRDY_POL(1); + } else if (irq_type == IRQF_TRIGGER_FALLING) { + val |= ADIS16480_DRDY_POL(0); + } else { + dev_err(&st->adis.spi->dev, + "Invalid interrupt type 0x%x specified\n", irq_type); + return -EINVAL; + } + /* Write the data ready configuration to the FNCTIO_CTRL register */ + return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); +} + static int adis16480_probe(struct spi_device *spi) { const struct spi_device_id *id = spi_get_device_id(spi); @@ -853,6 +942,10 @@ static int adis16480_probe(struct spi_device *spi) if (ret) return ret; + ret = adis16480_config_irq_pin(spi->dev.of_node, st); + if (ret) + return ret; + ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); if (ret) return ret; From patchwork Wed Feb 27 16:14:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831831 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 47B1E13B5 for ; Wed, 27 Feb 2019 16:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 320FA2A355 for ; Wed, 27 Feb 2019 16:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 266562A51F; Wed, 27 Feb 2019 16:15:56 +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 2505E2A355 for ; Wed, 27 Feb 2019 16:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbfB0QPx (ORCPT ); Wed, 27 Feb 2019 11:15:53 -0500 Received: from mail-eopbgr730085.outbound.protection.outlook.com ([40.107.73.85]:13536 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727400AbfB0QPx (ORCPT ); Wed, 27 Feb 2019 11:15:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uNsYpGHAvoCWUbhWjZeoTTbnuSxiGLVE1SeAF2MVw5s=; b=qYTvLZD0TR39ZdhOf5Kv4amOO6WRzGkyfbRx2PCita0U0ABFkN7ro/AwK6sOKdfDAxHoOJ1KLx2ypPaC+ySssdcSPQTrFHik2ClKsqt+Im3vpUD9foIbYBm6LFiIC+XuAy2R2wSOd0+UlNdIMno2AGY3KccUp3s/RhUu345tk34= Received: from BL0PR03CA0005.namprd03.prod.outlook.com (2603:10b6:208:2d::18) by CY4PR03MB3061.namprd03.prod.outlook.com (2603:10b6:910:53::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.18; Wed, 27 Feb 2019 16:15:10 +0000 Received: from SN1NAM02FT014.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::202) by BL0PR03CA0005.outlook.office365.com (2603:10b6:208:2d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.15 via Frontend Transport; Wed, 27 Feb 2019 16:15:10 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT014.mail.protection.outlook.com (10.152.72.106) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:15:09 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGF8HM021591 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:15:08 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:15:08 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table Date: Wed, 27 Feb 2019 18:14:23 +0200 Message-ID: <1551284068-4882-3-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(396003)(136003)(2980300002)(3190300001)(199004)(189003)(50466002)(7636002)(48376002)(305945005)(106466001)(246002)(4326008)(186003)(8676002)(36756003)(77096007)(26005)(53416004)(110136005)(8936002)(76176011)(426003)(11346002)(2616005)(126002)(116002)(476003)(44832011)(72206003)(7696005)(54906003)(478600001)(2906002)(6666004)(356004)(50226002)(47776003)(106002)(486006)(316002)(336012)(446003)(51416003)(16586007)(5660300002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB3061;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 396fac34-9c51-452b-73b1-08d69ccebedd X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:CY4PR03MB3061; X-MS-TrafficTypeDiagnostic: CY4PR03MB3061: X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3061;20:lLis4mLJWvB5Y4OjyGV2ume+oefWe65ILK0VMJHo1bBs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fUEImrBEamyOWFQgiRx0aoGHtMOYjm44WLN4MbSyI8+ylXh2dWJuiNl3cfaEc6FouDFp5kES7bx9ZjfFs07uA+uKI6tbWi5l4zyDXVj/xS0QMAKrYnCUj30Xt/hR7fUz8yUoQ2bQe7hUDuh9XIXcvklm92Hrhx5iw8GXtd/Q1C+HD/1RZZLnrnVHSkV1PaJbzfaPxiAfJCGqBdFaxnub5V4cIm+OGpDzAhNtMD1bGlOvZQVuXJLchHwMGYknsQhfgoU1YrTWCB/p966JaC6ZWMnHQTNqHzTtL+M1/aikHGn/eiQbTo1qHL6ptqbf6gk06XdANcA5Hf4C1TkCnEYMOsRHsbme7TCuZtOWbdJle/UKWR2ZXEWwj0QP1T0AOaiAJ0A3fsqGoqk2fxi11C9ZFNZctyMRJteKW8/Do06s9LbRpgju81qolynguozukwRYo+mR9kb7WzXlRIPi+YvlSQ6PLL6a8DJ5coJJZLekKhc2+cZCMV7c7RMegoa15728h6Z2P0dC7V9SWWe7NuvzkW3SxyorBjZ5qHyW9VnlhdA X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 5xqLf6kkTLta0SrUujAdFVHtxke73qTTROsZeoD1xcHDzPKIJJ3p5hLHvGYKSQ7IodYq0347Yd/kUp7gOs8d7g57v+P5MhR5nTb1Mlfi8vN5kAKVUPjgzR4XAeS3072PgKKzuS2nzkL2YL/uweUTMt12aw8hZ4qysRJCVdTwTpCTmNnVE3cgT74cSuQXLscMPq9En75nDGTb30gpgiejbjTpe2iHQA0hwWjyNSzVycM5cZgfqrLOZvWD8TK9cH1Cfli4GauHtb934P9jXNbmeLlMUpD6YzvHfY2cIznvZO+nIn4mn7NX1GrKcNckwlZ3UQpuPdQG9+NzNNYBlhJ+RzqJdYUN3tMED2946ZEQXj2ZYjQxRwEtjvT6yM2Wiy/+C1DqjCklsqXaZ5b9gWj3b2aslWe7W719XRi3ej3dNr0= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:15:09.4280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 396fac34-9c51-452b-73b1-08d69ccebedd 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3061 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 The driver does not have a struct of_device_id table, but supported devices are registered via Device Trees. This patch adds OF device ID table. Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 98a23ac..150d814 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -991,9 +991,19 @@ static const struct spi_device_id adis16480_ids[] = { }; MODULE_DEVICE_TABLE(spi, adis16480_ids); +static const struct of_device_id adis16480_of_match[] = { + { .compatible = "adi,adis16375" }, + { .compatible = "adi,adis16480" }, + { .compatible = "adi,adis16485" }, + { .compatible = "adi,adis16488" }, + { }, +}; +MODULE_DEVICE_TABLE(of, adis16480_of_match); + static struct spi_driver adis16480_driver = { .driver = { .name = "adis16480", + .of_match_table = adis16480_of_match, }, .id_table = adis16480_ids, .probe = adis16480_probe, From patchwork Wed Feb 27 16:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831829 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 575CC1399 for ; Wed, 27 Feb 2019 16:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43F06299EF for ; Wed, 27 Feb 2019 16:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 377FE2A355; Wed, 27 Feb 2019 16:15: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 EEEEC299EF for ; Wed, 27 Feb 2019 16:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbfB0QPh (ORCPT ); Wed, 27 Feb 2019 11:15:37 -0500 Received: from mail-eopbgr740059.outbound.protection.outlook.com ([40.107.74.59]:42720 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727094AbfB0QPh (ORCPT ); Wed, 27 Feb 2019 11:15:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U7nePwpCOe5OTpx4ZlDJ6WYqqpZCrnjPsnhZC3Vtf7o=; b=WtTmy/ydPrnF2mXXws93ACgKeJY/TrWDIgTOMCqL/EUYTgQ5lzXWMAC4s/+vapbMWzay5ETtpKGGYm+Q/giERYVaBq2wngLqOE06t8++Juyol5W0VHkyIACLe7FrJk9bk/o6GMTpQ6GLHJzXR/eWXbwSBtY2OCgnnwzRNOswFBg= Received: from BN6PR03CA0002.namprd03.prod.outlook.com (2603:10b6:404:23::12) by MWHPR03MB3070.namprd03.prod.outlook.com (2603:10b6:301:3c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.15; Wed, 27 Feb 2019 16:15:25 +0000 Received: from BL2NAM02FT017.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BN6PR03CA0002.outlook.office365.com (2603:10b6:404:23::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1643.16 via Frontend Transport; Wed, 27 Feb 2019 16:15:25 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT017.mail.protection.outlook.com (10.152.77.174) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:15:25 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGFOJP021639 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:15:24 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:15:24 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way Date: Wed, 27 Feb 2019 18:14:24 +0200 Message-ID: <1551284068-4882-4-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(136003)(396003)(39860400002)(2980300002)(3190300001)(199004)(189003)(44832011)(51416003)(76176011)(7696005)(4326008)(16586007)(316002)(110136005)(446003)(47776003)(11346002)(426003)(2616005)(72206003)(336012)(48376002)(50466002)(486006)(54906003)(478600001)(116002)(126002)(50226002)(246002)(186003)(8676002)(8936002)(476003)(53416004)(305945005)(7636002)(26005)(106002)(106466001)(356004)(2906002)(77096007)(36756003)(5660300002)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB3070;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 695c40c1-781b-47cd-ca02-08d69ccec804 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:MWHPR03MB3070; X-MS-TrafficTypeDiagnostic: MWHPR03MB3070: X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3070;20:NPoN0T+Y3c4wzBD7ymGTLMpLtq4900N71tKWuWrQqOWq/+cKsMDfC11ioAMq/KKjhbUBlleAzll/DT6RM0BWHQ5v2PVE3g5Jcb8ByeSlHUQK1Jrv9dWDOMJiWPyKor2wNGscbuifN067Z9gNOhF1sV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CE7K2AGW9cnKIbV7YBDnBBxMz4gtqeQPGxclWsX48SOZO8zzJIJm30NOg/XSzyk1TMws1mD5cNi5OP8MoMobeZOQ5O9jhKJ2c/1B1ZAmpRu15HnN+9s2fh2GLYes0EDBBVMf5rUj7ANbb9suHZQEwN+B/4uq59cCSXsceLJjJjyh/EjKOCv67NmTUXd91Wic8NcvUDJOzkr6FOMJlvu7QYz/vBfk20SVL4DxhmsPjM3VD0zh8V1IULElMtNK4oLrO/EQgNEqCnlQt1s520Oz4QSHV7GIgYrHxNjuT1cDzHwT2+DRXWdwb6hggs6caPceGW5s9VS3LWhETuMSmY+PR7s5G++VHxqf3lLSLc6Z0WYvGgB7Atnw251+c2GACbs//a32XBjk0/AYraTJFYaTNQrEnkahi5yhvptcX5iiDvISkDgsPcmshKyG6lLqFbw/ X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 6T80rrNSanv3j6PLXqfR7NopaOYN++M/Yqtaxg/lLwGLuEoIB730givdF+YWrjc+id+LwH2cxSAN+Nqda6qgesbPlIOqvSihc1sV/ukxxXqI3NCKaTPEFXTzZjRU0hUoerYODlLimGFdGpyXYpI9SmFgtIYMXxpBeSKK0W8D2PeSRN89lsyztMjP4hfqu4zYPMkLqr3zJUHCCX/DRKudX/eZ+d//98iMLAPhJrvhn5D93YkPq/oTS/5Gn2UslWrP0KTTRJ6+yb/TkkiH8UPKSDorogyOwuV1Sysj+UkSX70QEnLx/47kcSy0Oh3WXNYApi3zWWszzX9Kt2clfOJtRFk6eomIuNogm15McDpHNHIe4U9JweA/DVzLbgTqcLRjND6UqRWQCz9T2sFdnUXuplKPpJyqAm0/u8MZJ7OyTtU= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:15:25.1436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 695c40c1-781b-47cd-ca02-08d69ccec804 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3070 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 All supported devices provide internal temperature measurement from -40 C to +85 C, with +25 C representing value 0x00. This patch treats the temperature scale in a generic way, similar to the accelerometer and gyroscope scales. So far, there are no temperature max scale differences between the supported devices. However, devices that will make use of this feature will be added in the future. Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 150d814..5a2864a 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -124,6 +124,7 @@ struct adis16480_chip_info { unsigned int gyro_max_scale; unsigned int accel_max_val; unsigned int accel_max_scale; + unsigned int temp_scale; }; enum adis16480_int_pin { @@ -530,6 +531,7 @@ static int adis16480_read_raw(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, int *val, int *val2, long info) { struct adis16480 *st = iio_priv(indio_dev); + unsigned int temp; switch (info) { case IIO_CHAN_INFO_RAW: @@ -549,8 +551,13 @@ static int adis16480_read_raw(struct iio_dev *indio_dev, *val2 = 100; /* 0.0001 gauss */ return IIO_VAL_INT_PLUS_MICRO; case IIO_TEMP: - *val = 5; - *val2 = 650000; /* 5.65 milli degree Celsius */ + /* + * +85 degrees Celsius = temp_max_scale + * +25 degrees Celsius = 0 + * LSB, 25 degrees Celsius = 60 / temp_max_scale + */ + *val = st->chip_info->temp_scale / 1000; + *val2 = (st->chip_info->temp_scale % 1000) * 1000; return IIO_VAL_INT_PLUS_MICRO; case IIO_PRESSURE: *val = 0; @@ -561,7 +568,8 @@ static int adis16480_read_raw(struct iio_dev *indio_dev, } case IIO_CHAN_INFO_OFFSET: /* Only the temperature channel has a offset */ - *val = 4425; /* 25 degree Celsius = 0x0000 */ + temp = 25 * 1000000LL; /* 25 degree Celsius = 0x0000 */ + *val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale); return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: return adis16480_get_calibbias(indio_dev, chan, val); @@ -717,6 +725,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .gyro_max_scale = 300, .accel_max_val = IIO_M_S_2_TO_G(21973), .accel_max_scale = 18, + .temp_scale = 5650, /* 5.65 milli degree Celsius */ }, [ADIS16480] = { .channels = adis16480_channels, @@ -725,6 +734,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .gyro_max_scale = 450, .accel_max_val = IIO_M_S_2_TO_G(12500), .accel_max_scale = 10, + .temp_scale = 5650, /* 5.65 milli degree Celsius */ }, [ADIS16485] = { .channels = adis16485_channels, @@ -733,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .gyro_max_scale = 450, .accel_max_val = IIO_M_S_2_TO_G(20000), .accel_max_scale = 5, + .temp_scale = 5650, /* 5.65 milli degree Celsius */ }, [ADIS16488] = { .channels = adis16480_channels, @@ -741,6 +752,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .gyro_max_scale = 450, .accel_max_val = IIO_M_S_2_TO_G(22500), .accel_max_scale = 18, + .temp_scale = 5650, /* 5.65 milli degree Celsius */ }, }; From patchwork Wed Feb 27 16:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831833 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 F241813B5 for ; Wed, 27 Feb 2019 16:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3182A355 for ; Wed, 27 Feb 2019 16:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D01672A51F; Wed, 27 Feb 2019 16:15:58 +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 54AD92A355 for ; Wed, 27 Feb 2019 16:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729287AbfB0QP5 (ORCPT ); Wed, 27 Feb 2019 11:15:57 -0500 Received: from mail-eopbgr790050.outbound.protection.outlook.com ([40.107.79.50]:34778 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729943AbfB0QP5 (ORCPT ); Wed, 27 Feb 2019 11:15:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m2RvkOXmqkLVtgdx4+xeS0jEbUbwlbN5q+TBJ3Mj/B4=; b=LW7GBNTXDtFd8sdzmluzqIzEwtyoeUNQT4AuY5wq4tFrj9iXqY4u8QTcq8Oxn2pntVrEIlo/stCyawdNYdVSKuW50aIWPpW8MB1Q8++knnCQfdKfPmACnXF04QaVs2H3/4ZQf75U735XdAYdFWYWbD9hCzNjzUHzHh2Xkvbuq24= Received: from DM6PR03CA0002.namprd03.prod.outlook.com (2603:10b6:5:40::15) by BN6PR03MB3058.namprd03.prod.outlook.com (2603:10b6:405:44::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.14; Wed, 27 Feb 2019 16:15:52 +0000 Received: from CY1NAM02FT055.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::201) by DM6PR03CA0002.outlook.office365.com (2603:10b6:5:40::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.15 via Frontend Transport; Wed, 27 Feb 2019 16:15:52 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by CY1NAM02FT055.mail.protection.outlook.com (10.152.74.80) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:15:51 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGFon7021770 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:15:50 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:15:50 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency in a generic way Date: Wed, 27 Feb 2019 18:14:25 +0200 Message-ID: <1551284068-4882-5-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(346002)(39860400002)(396003)(2980300002)(3190300001)(189003)(199004)(44832011)(486006)(476003)(106002)(53416004)(126002)(2616005)(116002)(106466001)(446003)(11346002)(72206003)(478600001)(7636002)(77096007)(110136005)(54906003)(8676002)(186003)(305945005)(51416003)(26005)(246002)(76176011)(336012)(316002)(50226002)(426003)(50466002)(2906002)(16586007)(7696005)(4326008)(36756003)(5660300002)(47776003)(356004)(8936002)(6666004)(48376002)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB3058;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbef9041-6b85-44de-edfe-08d69cced819 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:BN6PR03MB3058; X-MS-TrafficTypeDiagnostic: BN6PR03MB3058: X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB3058;20:+QKzptwphWA3i9h1aDenizoSzPsfsGV5zHJ8PT3rrlsHwAZB06n0+1fbU4NIZqVxZaruHUS+rGkcwTyb70JDWb5pNeqDR57kS/D1a0lXKCv4qmGfFc4BQGDS5n8ouAgVGVaSTs9IKzvrY7uzVSC5G0fUM/6qdfCzFu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7ltBCk7EmsAZJgcuJGqw81NcZ7G/K9tBK/c/QsImrUH9BG6IOJmzfMJVtqG4Fllnpk3fuHRKyLCC5BwBQOls2bIrmvPCxJtO/5Ge+0lN0zBEreay87/2DhVXuFUL3nPZQdE7ZJmWvoemlH4xSZe6NTQMrpiRPdWoBk1ypufAIahe4kPhnKUygLlrnhWyzf+9iIr3BqPcfVsORdV97ZtlZ6tuaTb3QdmIo9YIs8NY51zVaMExak4P6iSQvG4MpSpdqo4i/TWCA6s8QYc8hfWS65SZLKELLq4pWR+swj17UrrkdbmEo4DGTdHFVd3JfykSUgD/U5cgunZeizVYDVZekrDOn5TlcnD1ItEQEhg9Pj8e1Dw9cOihBAzBkem7+FbDmRfADtRww3SeMq/PiY67pSbXlLXFZNHcNKpqn0edU2C3Aul7M1RuK4Jnduj3HrqmdSoyeZg== X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 8xI9um2IetmckL7zzI3UtlAonMNLv4wz88F/BELH+yE570FaXzmCUoEfu2sgqC4VUmGCgFGE1yxwYGIh64HCpxTBrUIAgqb0paOPBP9xzGQeTVp0cY/XL2sfyUxoOLrQt5ORXPS7NFmYNdcIjnGgmejdFbwNDwCwlUzWBoFzu4h1GC9lJfvjssD3ByhiEgnQVDwEc2X0IesmL6zaHmQSXE7XZaHzNDcDVuZ4k5PQcgvJy0wiZ4FVn+kkuERrJZeDgd3+45TKCfUhmXWo+qH9jNA+DE5djgE4oI015gZW5VIBuQtAtEAEgsO0Jqj5hSoPOcxv7jG/kElQH+whjvhMxcZQE7sGxqEQakhSIWm9YkvlsRtK6DfTFLE2Rx+lSYnDydg8QGUgjKx22hGIMKsGYwWXmKZKjyq17neYT2Ne7eg= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:15:51.5962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbef9041-6b85-44de-edfe-08d69cced819 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB3058 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 The adis1648x devices have an internal clock of 2.46 kSPS. The sampling frequency is calculated by applying a decimation rate which can take the maximum value of 2047. Although all adis1648x devices are similar in this regard, devices that will use this feature will be added in the future. Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 5a2864a..92abc95 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -125,6 +125,8 @@ struct adis16480_chip_info { unsigned int accel_max_val; unsigned int accel_max_scale; unsigned int temp_scale; + unsigned int int_clk; + unsigned int max_dec_rate; }; enum adis16480_int_pin { @@ -299,9 +301,9 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2) if (t <= 0) return -EINVAL; - t = 2460000 / t; - if (t > 2048) - t = 2048; + t = st->chip_info->int_clk / t; + if (t > st->chip_info->max_dec_rate) + t = st->chip_info->max_dec_rate; if (t != 0) t--; @@ -320,7 +322,7 @@ static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2) if (ret < 0) return ret; - freq = 2460000 / (t + 1); + freq = st->chip_info->int_clk / (t + 1); *val = freq / 1000; *val2 = (freq % 1000) * 1000; @@ -726,6 +728,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .accel_max_val = IIO_M_S_2_TO_G(21973), .accel_max_scale = 18, .temp_scale = 5650, /* 5.65 milli degree Celsius */ + .int_clk = 2460000, + .max_dec_rate = 2048, }, [ADIS16480] = { .channels = adis16480_channels, @@ -735,6 +739,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .accel_max_val = IIO_M_S_2_TO_G(12500), .accel_max_scale = 10, .temp_scale = 5650, /* 5.65 milli degree Celsius */ + .int_clk = 2460000, + .max_dec_rate = 2048, }, [ADIS16485] = { .channels = adis16485_channels, @@ -744,6 +750,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .accel_max_val = IIO_M_S_2_TO_G(20000), .accel_max_scale = 5, .temp_scale = 5650, /* 5.65 milli degree Celsius */ + .int_clk = 2460000, + .max_dec_rate = 2048, }, [ADIS16488] = { .channels = adis16480_channels, @@ -753,6 +761,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .accel_max_val = IIO_M_S_2_TO_G(22500), .accel_max_scale = 18, .temp_scale = 5650, /* 5.65 milli degree Celsius */ + .int_clk = 2460000, + .max_dec_rate = 2048, }, }; From patchwork Wed Feb 27 16:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831835 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 0BE191399 for ; Wed, 27 Feb 2019 16:16:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E689B2A3D2 for ; Wed, 27 Feb 2019 16:16:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4C322A825; Wed, 27 Feb 2019 16:16:34 +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 887942A3D2 for ; Wed, 27 Feb 2019 16:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728651AbfB0QQd (ORCPT ); Wed, 27 Feb 2019 11:16:33 -0500 Received: from mail-eopbgr810043.outbound.protection.outlook.com ([40.107.81.43]:7296 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727400AbfB0QQc (ORCPT ); Wed, 27 Feb 2019 11:16:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+qVyqs7R/HnXeTBRRccmCqefK/S6u6iiA8X05YV5mGA=; b=lk8A0yiCqm1eqWvkVj2q4yPfmCkHMNILkmL6sG2zmqArseKT47GeYRdLfgUpB0L8gtzLiu15ve4tUV1Yh2xzkh6o2J6zbMDhsM8qzos3uX/olcijbh59IHJknFAAesweX5YA2bUSYylZcn13c174IORWk+/NFmqCmq+EwLdmaHA= Received: from CY4PR03CA0091.namprd03.prod.outlook.com (2603:10b6:910:4d::32) by BYAPR03MB3751.namprd03.prod.outlook.com (2603:10b6:a03:6f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.18; Wed, 27 Feb 2019 16:16:28 +0000 Received: from BL2NAM02FT005.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::206) by CY4PR03CA0091.outlook.office365.com (2603:10b6:910:4d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.15 via Frontend Transport; Wed, 27 Feb 2019 16:16:28 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT005.mail.protection.outlook.com (10.152.76.252) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:16:27 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGGRQr021935 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:16:27 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:16:26 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq in a generic way Date: Wed, 27 Feb 2019 18:14:26 +0200 Message-ID: <1551284068-4882-6-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(39860400002)(136003)(396003)(2980300002)(3190300001)(199004)(189003)(77096007)(7696005)(5660300002)(76176011)(51416003)(316002)(110136005)(54906003)(16586007)(48376002)(356004)(478600001)(106002)(50466002)(4326008)(50226002)(8936002)(305945005)(7636002)(11346002)(2616005)(26005)(476003)(8676002)(44832011)(246002)(336012)(486006)(106466001)(426003)(72206003)(36756003)(186003)(47776003)(53416004)(2906002)(126002)(116002)(446003)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB3751;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abdf77b2-ed23-460c-8fc6-08d69cceed67 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:BYAPR03MB3751; X-MS-TrafficTypeDiagnostic: BYAPR03MB3751: X-Microsoft-Exchange-Diagnostics: 1;BYAPR03MB3751;20:2PqprMrYbnec2u8Gda9sIxXXP1kBb5+5LGTzO+u76+IViYkjF5Ao6MbulGc/MY23yi25N40ykpWDGcbHjzpiMoMX7V6/JWloNt1Kt/4sjtYvGnIWICnYUeFP0Gmwu2F/dLd3UBfEZba0vQX3OPnBgv+1uLd3fH15aEQWDAUM5NkkQMWeXsoaHkAw/fx9b49/QzunEwezICqECUowmUr1hDozeK9n2D/LKHTJ8R46V2yISqALp11ElEjKLXghri6hf+87e+RBOt4zC0v8ESLlUEEQLRaWMDlH+g6N3rrnxahz083aLru8csaZVwYj37zoip0kHvR2+bWiUwLldsbMiGABFm0WldVbF74Wb4hdPZ3Fa0hJ1ouJMvQ1pmJXzu5vxIkT9CJKs6R0ojSwhAFcwBJXEEgoDUqztE5OnOVdapIQxi3416A/pryZaUyn9wMCQ5L5j7cNaRR9pVLBlzBj1d5dGxJSPV+jOFFQv7U1dUnx0J8BlomzLiycaYKAm24f X-Micro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tXqBsjZCxnTPD4X79hXHUyar6avOLNSmT7qgJzX1gLsYbL1fvFIf+bBTDrfZLTQU4ZLt/lgdKocbY7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Ooe+qzAKbXdl4y4CMPV8/teAiJWSdqoJu2tJIXrw9Blsw88yZN65DXAC3vnAk6f2zbD3yK52vvTBIxeTCs+tB4/Rqjl2J0Hj3/pRQGjCo2vNePdyncLLo8tEVrOBpoendmHoStW9OwuyMQZhu9XpX5fBock80vXCkHeoc/sANyjuSpZ5NmNuREcr7+DkUkTsl8dxrWln31neQwXpez7fCa/CiP4+jJsc1u8nKwt5QsYx7QiHVPpiSVbc8nkh4xYL7CDNg+72/eIfWLJhgbsjgxSYmA5GnJ0n8h7uA5rIrzlxzm9u1bFT9AIhfPwJrAxXT6rhKnkQwDjgmxwbE/z3abWDVuJ9byPF37xYp0fMY/3zqjszb0FOoTdMESx0jtLkh5+CtWBaob3uUKmtbdZmNR+0AVcYXa08Ae8O8EgwALY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:16:27.8676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: abdf77b2-ed23-460c-8fc6-08d69cceed67 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB3751 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 When setting the filter frequency, the driver looks into the adis16480_def_filter_freqs table for the best match. Pass this table to the chip_info struct since future devices will need to use a different table. Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 92abc95..c90375d 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -127,6 +127,7 @@ struct adis16480_chip_info { unsigned int temp_scale; unsigned int int_clk; unsigned int max_dec_rate; + const unsigned int *filter_freqs; }; enum adis16480_int_pin { @@ -483,7 +484,7 @@ static int adis16480_get_filter_freq(struct iio_dev *indio_dev, if (!(val & enable_mask)) *freq = 0; else - *freq = adis16480_def_filter_freqs[(val >> offset) & 0x3]; + *freq = st->chip_info->filter_freqs[(val >> offset) & 0x3]; return IIO_VAL_INT; } @@ -510,10 +511,10 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev, val &= ~enable_mask; } else { best_freq = 0; - best_diff = 310; + best_diff = st->chip_info->filter_freqs[0]; for (i = 0; i < ARRAY_SIZE(adis16480_def_filter_freqs); i++) { - if (adis16480_def_filter_freqs[i] >= freq) { - diff = adis16480_def_filter_freqs[i] - freq; + if (st->chip_info->filter_freqs[i] >= freq) { + diff = st->chip_info->filter_freqs[i] - freq; if (diff < best_diff) { best_diff = diff; best_freq = i; @@ -730,6 +731,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000, .max_dec_rate = 2048, + .filter_freqs = adis16480_def_filter_freqs, }, [ADIS16480] = { .channels = adis16480_channels, @@ -741,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000, .max_dec_rate = 2048, + .filter_freqs = adis16480_def_filter_freqs, }, [ADIS16485] = { .channels = adis16485_channels, @@ -752,6 +755,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000, .max_dec_rate = 2048, + .filter_freqs = adis16480_def_filter_freqs, }, [ADIS16488] = { .channels = adis16480_channels, @@ -763,6 +767,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000, .max_dec_rate = 2048, + .filter_freqs = adis16480_def_filter_freqs, }, }; From patchwork Wed Feb 27 16:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831837 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 887021399 for ; Wed, 27 Feb 2019 16:16:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC432A895 for ; Wed, 27 Feb 2019 16:16:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60B6F2E474; Wed, 27 Feb 2019 16:16:59 +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 3F7B82A895 for ; Wed, 27 Feb 2019 16:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728124AbfB0QQ5 (ORCPT ); Wed, 27 Feb 2019 11:16:57 -0500 Received: from mail-eopbgr730070.outbound.protection.outlook.com ([40.107.73.70]:39526 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727400AbfB0QQ5 (ORCPT ); Wed, 27 Feb 2019 11:16:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EixBkaDR6khW1PYA7c2Ukt0kRKUqps0NiaCAkZSEsdI=; b=NYsx2TguMBtJOcqfG45q0bWQENH8fenFR3huPINoE2Kjskmt7acr8Vi6hmLJCtAP2HBejexDB+NYcTmOaXieDGTFFpNzBe2jc9zrTLru0qN3T9K/rLdNI40+MzA8ntw5Zs/8bJB4OgxyriuV79MmoQltXFYO42Mm9+K1nyhH0Ao= Received: from DM6PR03CA0031.namprd03.prod.outlook.com (2603:10b6:5:40::44) by BN7PR03MB3507.namprd03.prod.outlook.com (2603:10b6:406:c2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Wed, 27 Feb 2019 16:16:53 +0000 Received: from SN1NAM02FT023.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::200) by DM6PR03CA0031.outlook.office365.com (2603:10b6:5:40::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1643.18 via Frontend Transport; Wed, 27 Feb 2019 16:16:53 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT023.mail.protection.outlook.com (10.152.72.156) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:16:52 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGGqeU022089 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:16:52 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:16:51 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Date: Wed, 27 Feb 2019 18:14:27 +0200 Message-ID: <1551284068-4882-7-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(376002)(346002)(39860400002)(2980300002)(3190300001)(189003)(199004)(47776003)(11346002)(2906002)(336012)(8676002)(51416003)(106466001)(50226002)(54906003)(7696005)(50466002)(110136005)(48376002)(356004)(446003)(6666004)(5660300002)(106002)(8936002)(6306002)(16586007)(316002)(426003)(36756003)(72206003)(186003)(305945005)(966005)(26005)(77096007)(478600001)(53416004)(246002)(2616005)(476003)(76176011)(126002)(7636002)(486006)(4326008)(44832011)(116002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR03MB3507;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38cd49f5-bc1c-4432-99d7-08d69ccefc8d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:BN7PR03MB3507; X-MS-TrafficTypeDiagnostic: BN7PR03MB3507: X-MS-Exchange-PUrlCount: 2 X-Microsoft-Exchange-Diagnostics: 1;BN7PR03MB3507;20:9jlPDNFRO22hktd5QGz7SrGXXtK7Fcw67Ly6lArt3HVLfaf6xDOkY1HWUXPN6/r+tWJ2MNMP3RNRYP6asu6bly6sg8iLiJ3XxIG/7UTiJpN5Lfl4vjkuxbR6e/pOibw9ONiLpMdV6HrG9vFuFXw9o/j7OXObfOYqBBzjA7fqRbbVQLBG5c1jYADEss5ZuQvthqECoZhDEy0UVFAy9XDB8rcuRCc6PiCbpsEJWmjxr7x5MfZIA8Z3DNCIosLGLC+wdds8ciCBIoyetHmhkky/FsdP3q0+RLLFcOXCmpKKWiOqmUv96mo4AW4DH7Hjh8gXc/+jcsq0TBYLN686/p1Bfi3O29CPshI+n/NiZ44oP/2gp34ci2C33210QNVhAyMO3XFpOCIgFN0wtyCfGtKLXr7xMgGb3XCr3kJPNwSJr9N8NA2xDQKmuPeyXBmoKh3+SEjMFfKfZHfKp/Ko7wRrOTmU/TRL0UyaTAhF0kWoRNHrEcvdNFWkbXf248MMNG1r X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0961DF5286 X-Microsoft-Exchange-Diagnostics: 1;BN7PR03MB3507;23:Az694zXv/oplg9BvDtLIf7plVzq5ohGSWZ+ZFuP220dAcyA4AsjL3MWuD56zKQluNw+G2iIoIO15JQY/n/Rb/NggZuFOc2g84iBWEGSW8c05djZ9GCxZdGw/ixqa9/e3YJ3d+/Zz6TpmoE4MdFl3fJnpwD+oV/L54KNb3K/l9v6clCcVWI+zHvzGl2jEaR3R3kW5yHGGY17eEz0992mcw0wbobSr5SQue73LdECtFhGD7U2EJVfr2HuPRnjBqfALH4kqGmtqn4STee2q75OXX2b96I2bCYxDY3t/Zv4nCCZUoUf+gk+J41mz+bEmDsSw8cJLF66z8auQNabnkfVvOF2p+7TqkwfQXvir/Jqkd8D9oQZIxOKrnsitE37yXD3VHys8AZo8LGndEXDAzAqe65llAaArcALYcexVGyDUfQSad7MAg8Z/vniGbziFO1XMUGk9F7Foi1C5Q0Gp2p40HvBiikh8/Odbu6saYY7NVhNDjPBhtHoht9niRIVUkrYwZVeufPzFk1FcES46PjR93BXwlSi4ByxMx9hLIftxvtAnB6orP2xet66VnojewW6lLdmsfo/GxXJrGn/WbYdO3l1hp3LrvkGAzansVyG1VMVfnuf1IQghTvNwsCkYF8PG71i5CzxFfgCKiqZ30E20I4Bd275licw623uVtRvphLTP27oBOqf4nUaEsvX4g0fQJJpvY+0FqlXrt6hBPAXGMdaXJGMQljLIFElgN7uiVBEOVFtgI0z0EH3bUzVbqX0Rh0eKsfXjpuPr8vxim/brmnFg0XT5TalzXqnrxJCgwv/aR0w101D+Q2eeY9nRtcxDnoB8sDaLW7PQJrJuOt/W88weA+Asm41RYkK5TmlJW44fzegyaW+P/oF7qbMc65g3QVNjzoO9oGrzIidPlgbvfsArv+ZSPQ62kZ0dl+ncZMPxHqSKLpXGfPAz7KQEtcir60HWM3VH6STjdwVsfF82tosywiiTPnu3wpM2J5yq9dgP41mRVEbK33l3AuhJgcZZrRlXZv06ncV6mgC26y+0nY82Vknb4Ie/Wg4VMkEvdC0nHxYquB31/BNnYpNh4+4VnWXTTNXiEhvhKu3M1DhL4GWj6zPifLiQpkvsrODsYxI= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: mT1Q2er1mIsPNufGZDwkyz3GTklb7Ann++TDRpVSL5ALCIqIOrHWJ5UBt7CwhLwuq1DsXL7IVaexMsBt4ic5uGl19J94j3KquHFIJkwk3Ke2w1+RuCZS0AQEtlmB537Gz88sa1PP0HogqttY+aB72ob5GhDbyCnzkVaT5VxHkNEhHZ9attWOtbtP+pCLeYVk/YXknd629s8goZB75yX9gRZvqb2XCjADEfr8EaU8ZXCINbsTw/2lvkQ+t/3220evUYBLpWpH8RhoaOKBsM1IuPXmFNiW5veQrrAxSCRRAfM2wnqs73mfO4t/IocCzu8Zc6xZo8mjPvwmrCgnbEUZ3V5DiH4Wy0Netv7CbuIs4Msa8rwdiH6hq+IC4nzT7UZYEMX5G4ohQB4CaeYEXndjz6HluEiT8FYTbLnvVaYOous= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:16:52.9024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38cd49f5-bc1c-4432-99d7-08d69ccefc8d 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3507 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 The ADIS16495 and ADIS16497 are inertial systems that include a triaxis gyroscope and a triaxis accelerometer. The serial peripheral interface (SPI) provide a simple interface for data collection and configuration control. The devices are similar to ADIS16475, ADIS16480, ADIS16485 and ADIS16488, the main differences are highlighted below: * The temperature data scale is 0.00565 C/LSB for ADIS16475 and ADIS1648x devices, while for ADIS1649x 0.0125 C/LSB. * ADIS1649x devices support different gyroscope measurement ranges which are dependent on the dash number (-1, -2, -3), see Table 24 in the ADIS16495 datasheet. However, the ADIS16497 gyroscopes have the same scale as ADIS16495. * ADIS16495 devices support the acceleration maximum range of 8g, while ADIS16497 devices go up to 40g. * The internal clock for ADIS1649x devices is 4.25 kSPS. The sampling frequency is calculated by applying a decimation rate which can take a maximum value of 4250. * ADIS1649x devices support different default filter frequencies. Datasheets: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16495.pdf Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16497.pdf Signed-off-by: Stefan Popa --- drivers/iio/imu/adis16480.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index c90375d..28cece3 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -453,6 +453,13 @@ static const unsigned int adis16480_def_filter_freqs[] = { 63, }; +static const unsigned int adis16495_def_filter_freqs[] = { + 300, + 100, + 300, + 100, +}; + static const unsigned int ad16480_filter_data[][2] = { [ADIS16480_SCAN_GYRO_X] = { ADIS16480_REG_FILTER_BNK0, 0 }, [ADIS16480_SCAN_GYRO_Y] = { ADIS16480_REG_FILTER_BNK0, 3 }, @@ -713,6 +720,12 @@ enum adis16480_variant { ADIS16480, ADIS16485, ADIS16488, + ADIS16495_1, + ADIS16495_2, + ADIS16495_3, + ADIS16497_1, + ADIS16497_2, + ADIS16497_3, }; static const struct adis16480_chip_info adis16480_chip_info[] = { @@ -769,6 +782,78 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .max_dec_rate = 2048, .filter_freqs = adis16480_def_filter_freqs, }, + [ADIS16495_1] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(20000), + .gyro_max_scale = 125, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 8, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, + [ADIS16495_2] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(18000), + .gyro_max_scale = 450, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 8, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, + [ADIS16495_3] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(20000), + .gyro_max_scale = 2000, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 8, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, + [ADIS16497_1] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(20000), + .gyro_max_scale = 125, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 40, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, + [ADIS16497_2] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(18000), + .gyro_max_scale = 450, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 40, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, + [ADIS16497_3] = { + .channels = adis16485_channels, + .num_channels = ARRAY_SIZE(adis16485_channels), + .gyro_max_val = IIO_RAD_TO_DEGREE(20000), + .gyro_max_scale = 2000, + .accel_max_val = IIO_M_S_2_TO_G(32000), + .accel_max_scale = 40, + .temp_scale = 12500, /* 12.5 milli degree Celsius */ + .int_clk = 4250000, + .max_dec_rate = 4250, + .filter_freqs = adis16495_def_filter_freqs, + }, }; static const struct iio_info adis16480_info = { @@ -1014,6 +1099,12 @@ static const struct spi_device_id adis16480_ids[] = { { "adis16480", ADIS16480 }, { "adis16485", ADIS16485 }, { "adis16488", ADIS16488 }, + { "adis16495-1", ADIS16495_1 }, + { "adis16495-2", ADIS16495_2 }, + { "adis16495-3", ADIS16495_3 }, + { "adis16497-1", ADIS16497_1 }, + { "adis16497-2", ADIS16497_2 }, + { "adis16497-3", ADIS16497_3 }, { } }; MODULE_DEVICE_TABLE(spi, adis16480_ids); @@ -1023,6 +1114,12 @@ static const struct of_device_id adis16480_of_match[] = { { .compatible = "adi,adis16480" }, { .compatible = "adi,adis16485" }, { .compatible = "adi,adis16488" }, + { .compatible = "adi,adis16495-1" }, + { .compatible = "adi,adis16495-2" }, + { .compatible = "adi,adis16495-3" }, + { .compatible = "adi,adis16497-1" }, + { .compatible = "adi,adis16497-2" }, + { .compatible = "adi,adis16497-3" }, { }, }; MODULE_DEVICE_TABLE(of, adis16480_of_match); From patchwork Wed Feb 27 16:14:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10831839 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 A991A1399 for ; Wed, 27 Feb 2019 16:17:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 955742E431 for ; Wed, 27 Feb 2019 16:17:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86C0F2E50E; Wed, 27 Feb 2019 16:17:32 +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 DF5BF2E431 for ; Wed, 27 Feb 2019 16:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729979AbfB0QRb (ORCPT ); Wed, 27 Feb 2019 11:17:31 -0500 Received: from mail-eopbgr790048.outbound.protection.outlook.com ([40.107.79.48]:15331 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727400AbfB0QRb (ORCPT ); Wed, 27 Feb 2019 11:17:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sbNycr1ODAo4AYJ7qnkI3Sh0dwDMeOkrWah9MlkF1ss=; b=m4aqMHRPARqDjDGp83lDGiMwB0qpL4sZmp9LnXC7KqnBUiCRFdLLlrYiL0taR08lmmWpqitBpiiEFvxdOdRr8u+xqUTYt+FiDKQXclemh/bm6vPYst8wt+kgD6za9/h2ppfh1t5wXgrDhd1QkdtZMCp+EEmLerYt08UuvfjMl5o= Received: from DM6PR03CA0049.namprd03.prod.outlook.com (2603:10b6:5:100::26) by DM5PR03MB3068.namprd03.prod.outlook.com (2603:10b6:4:3c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Wed, 27 Feb 2019 16:17:23 +0000 Received: from SN1NAM02FT005.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::205) by DM6PR03CA0049.outlook.office365.com (2603:10b6:5:100::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1643.18 via Frontend Transport; Wed, 27 Feb 2019 16:17:23 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT005.mail.protection.outlook.com (10.152.72.117) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 27 Feb 2019 16:17:23 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1RGHMn1022187 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2019 08:17:22 -0800 Received: from linux.analog.com (10.50.1.179) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Feb 2019 11:17:21 -0500 From: Stefan Popa To: , CC: Stefan Popa , , , , , , , , Subject: [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU Date: Wed, 27 Feb 2019 18:14:28 +0200 Message-ID: <1551284068-4882-8-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551284068-4882-1-git-send-email-stefan.popa@analog.com> References: <1551284068-4882-1-git-send-email-stefan.popa@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.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(396003)(346002)(39860400002)(136003)(2980300002)(3190300001)(189003)(199004)(53416004)(7696005)(72206003)(51416003)(106466001)(76176011)(54906003)(966005)(6306002)(316002)(478600001)(106002)(2906002)(110136005)(36756003)(16586007)(50466002)(48376002)(186003)(4326008)(8676002)(7636002)(8936002)(246002)(305945005)(6346003)(116002)(446003)(77096007)(476003)(126002)(26005)(11346002)(486006)(44832011)(2616005)(336012)(426003)(5660300002)(50226002)(356004)(47776003)(357404004);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB3068;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 613b1e0b-077f-4253-3767-08d69ccf0e85 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:DM5PR03MB3068; X-MS-TrafficTypeDiagnostic: DM5PR03MB3068: X-MS-Exchange-PUrlCount: 2 X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3068;20:bwp1UJZSa5gFDHkOdSX8D73+aQTxfHmItQDIWee+qtN825UN0jGWFSfKk1Vn9YuryxmsIhnYEDLXIA31njvhWdB+KsLDSm82mztbkIyRFDU/n9GtnBDHO1Slm+RLoJv/y54iLMCZrR4EROxVD/7d0Xu7sTRi77OAy3EvJVzc8z2y4uIMarUX+0X3SpUeX/zBV2VANe3XxI9RLTX1/BimZccrPwZmiOrOS1iO4ebcDKG6vEs1kNaJVagMFBYwmf2sU71R2SMGDbbEizW/MFqOskhp9hdO9u9srgK52ChR7wqvEkCzHId7r7YMVwwiOIjLkmTVGtwF5LMxr6ETcbL0rL/3adIdAmzAPAce73ey/RgurFt3T6ZGu5ZKt/Qwtpy9h598WFFkRV2P0ThYGy4woSl3NfZOfHFOPRBSMBlz0wlMPtQx1nmH0AUAXhQjLsSHpm0XtHfXEKyYqHcek/ldYzrKzrM7zX1OOZnHCPkF28Dh/GY1WwlupMNosgFY4JNW X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0961DF5286 X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3068;23:izWE4AVPc5Ad6H3XN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xtTZSxbBZrh8fVYM5Yw/J5D1B14QurnmIIXJP0nIaYqXw0Gr4gY6cCQB96PJi5H2hc X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: WeI2mtUddfNz9umzQU8TskKHCTSj1+QcsjjR3M6xBoSxNJgttqKIIY6p7AZxc0rKgJ474AMRLqRrZZdYBldgPPmIHpgRnjYwomwnUux70kh0OBw17ua0mXI7hSqf/dmzOmha5yFoDb0fWpRFKS0PfJAm+tBGSDHSMOLVsSd+3a/RWGFU4ukiE2m/tGlcHXTSXZFjtCm/MT9AY8UlBMnQhZAx3kCWUlZJ8jFX07W4NlOqdZFowouR1rEtk2Co1UPly02WM1cHpOO+jjUz2zQoClq/PbJP/t6mf0CIr1ms6Qg1ESygtCIYaYqj5PoS4FoTGiqx7d4wyjc7rDUBiZ/SX7Vh9Lv94NPGzbix5ZZPhYIykTcLlg56zsHZIN0kSSumwq1rgzdvwgfSWvOVpjJugMOT5Dmxk0g4tIAcXu6K430= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2019 16:17:23.0634 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 613b1e0b-077f-4253-3767-08d69ccf0e85 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.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB3068 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 Document support for ADIS16480 Inertial Measurement Unit. Signed-off-by: Stefan Popa Reviewed-by: Rob Herring --- .../devicetree/bindings/iio/imu/adi,adis16480.txt | 49 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt new file mode 100644 index 0000000..39ab016 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt @@ -0,0 +1,49 @@ + +Analog Devices ADIS16480 and similar IMUs + +Required properties for the ADIS16480: + +- compatible: Must be one of + * "adi,adis16375" + * "adi,adis16480" + * "adi,adis16485" + * "adi,adis16488" + * "adi,adis16495-1" + * "adi,adis16495-2" + * "adi,adis16495-3" + * "adi,adis16497-1" + * "adi,adis16497-2" + * "adi,adis16497-3" +- reg: SPI chip select number for the device +- spi-max-frequency: Max SPI frequency to use + see: Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-cpha: See Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-cpol: See Documentation/devicetree/bindings/spi/spi-bus.txt +- interrupts: interrupt mapping for IRQ, accepted values are: + * IRQF_TRIGGER_RISING + * IRQF_TRIGGER_FALLING + +Optional properties: + +- interrupt-names: Data ready line selection. Valid values are: + * DIO1 + * DIO2 + * DIO3 + * DIO4 + If this field is left empty, DIO1 is assigned as default data ready + signal. +- reset-gpios: must be the device tree identifier of the RESET pin. As the line + is active low, it should be marked GPIO_ACTIVE_LOW. + +Example: + + imu@0 { + compatible = "adi,adis16495-1"; + reg = <0>; + spi-max-frequency = <3200000>; + spi-cpol; + spi-cpha; + interrupts = <25 IRQF_TRIGGER_FALLING>; + interrupt-parent = <&gpio>; + interrupt-names = "DIO2"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index e4091ac..beecd1e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -942,6 +942,7 @@ F: drivers/dma/dma-axi-dmac.c ANALOG DEVICES INC IIO DRIVERS M: Lars-Peter Clausen M: Michael Hennerich +M: Stefan Popa W: http://wiki.analog.com/ W: http://ez.analog.com/community/linux-device-drivers S: Supported