From patchwork Sun Jan 29 15:55:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC5BC61D97 for ; Sun, 29 Jan 2023 15:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234755AbjA2PmP (ORCPT ); Sun, 29 Jan 2023 10:42:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbjA2PmP (ORCPT ); Sun, 29 Jan 2023 10:42:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B14912870; Sun, 29 Jan 2023 07:42:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 065F960DC6; Sun, 29 Jan 2023 15:42:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0564FC4339E; Sun, 29 Jan 2023 15:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006933; bh=48D1qji7MQQv0UQXB018g3Ske4Yx09paEJnj8pvmczs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UVgDkjhesNxbHi12GifWQHb4tmwn6nUWdTWbf52pYERdb97L9+MBEyK1034M3+PYt KWVbEJi4epblX88RRa9FekW49eyiEXhrKU4AhatuaOcOq9owrcbAfYcYeLZ17jkXKu p77RESpPTIogbnyGLHgcSU/GuHdYavYVTXG/YMVgaXtElgjEvlR8nU0lsJ7O8aDfqa xHrGQSerYbzu8jVBoj3GwHol1wxdL9krVcUpbv85uWJD9oqdKy+P4MvKc7LWR/hwcT YgNIqbmHlkPhZ+jZ+OaZQG6AGXK2F2tG7uZJKGuFuhyJ5slhavZy6HANjPt5RDpqr1 Anxt642Mw57Rg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 01/12] staging: iio: accel: adis16203: More conventional header ordering Date: Sun, 29 Jan 2023 15:55:51 +0000 Message-Id: <20230129155602.740743-2-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron A common practice in IIO drivers it to have the headers in alphabetical order with the exception of the more specific IIO headers which come in their own block at the end. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index c0e4c9266b5f..dd02ceb00d40 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -6,14 +6,13 @@ */ #include - -#include -#include - #include #include #include +#include +#include + #define ADIS16203_STARTUP_DELAY 220 /* ms */ /* Flash memory write count */ From patchwork Sun Jan 29 15:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84099C636D0 for ; Sun, 29 Jan 2023 15:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbjA2PmR (ORCPT ); Sun, 29 Jan 2023 10:42:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjA2PmR (ORCPT ); Sun, 29 Jan 2023 10:42:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4858012870; Sun, 29 Jan 2023 07:42:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3DE860DC1; Sun, 29 Jan 2023 15:42:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9C30C4339B; Sun, 29 Jan 2023 15:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006935; bh=7EqEpNgTP+wTWSd+Y/4V+uBfgtR9/+Icmx3ms+nJliM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOe8/uyb9xQme2ljz31bUnmNt3p8S6jjFJyS2SW0tlJIWvYvVxFLlJKnfEtgehwpS OCjoTqivIOWhbdBUbVRLnVn1E/OlxtIizKtMp1lWjAA98Zlyoa4PBPYd+Ybz9GFLJl vq0vEl6H9wy8oHvq3AckqcPy/yad1b+wYyxO0Wzx1UnwLn7ykv+tjUfztaohKzEsoe lzKZVAsTcONqcuQcAa+Y06PUIwYWx45ff+FEF7RlfsfTE1yt0ICwVKbtzHmhs9L7OV ziSNlsfRCha28tiJlNgwhHg8Jaxg2vwNDcR9ro+vneccG50Lb1Zkhp6IezHdEPLDwv d5Ve6FZeH2j7g== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 02/12] staging: iio: accel: adis16203: Drop excessive register comments Date: Sun, 29 Jan 2023 15:55:52 +0000 Message-Id: <20230129155602.740743-3-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron A lot of these comments added very little that was not obvious from the register/field name. In one case the polarity was the opposite of what would be expected so rename that field (currently unused in the driver) Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 71 +-------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index dd02ceb00d40..60117aaf56d4 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -15,111 +15,42 @@ #define ADIS16203_STARTUP_DELAY 220 /* ms */ -/* Flash memory write count */ #define ADIS16203_FLASH_CNT 0x00 - -/* Output, power supply */ #define ADIS16203_SUPPLY_OUT 0x02 - -/* Output, auxiliary ADC input */ #define ADIS16203_AUX_ADC 0x08 - -/* Output, temperature */ #define ADIS16203_TEMP_OUT 0x0A - -/* Output, x-axis inclination */ #define ADIS16203_XINCL_OUT 0x0C - -/* Output, y-axis inclination */ #define ADIS16203_YINCL_OUT 0x0E - -/* Incline null calibration */ #define ADIS16203_INCL_NULL 0x18 - -/* Alarm 1 amplitude threshold */ #define ADIS16203_ALM_MAG1 0x20 - -/* Alarm 2 amplitude threshold */ #define ADIS16203_ALM_MAG2 0x22 - -/* Alarm 1, sample period */ #define ADIS16203_ALM_SMPL1 0x24 - -/* Alarm 2, sample period */ #define ADIS16203_ALM_SMPL2 0x26 - -/* Alarm control */ #define ADIS16203_ALM_CTRL 0x28 - -/* Auxiliary DAC data */ #define ADIS16203_AUX_DAC 0x30 - -/* General-purpose digital input/output control */ #define ADIS16203_GPIO_CTRL 0x32 - -/* Miscellaneous control */ #define ADIS16203_MSC_CTRL 0x34 - -/* Internal sample period (rate) control */ #define ADIS16203_SMPL_PRD 0x36 - -/* Operation, filter configuration */ #define ADIS16203_AVG_CNT 0x38 - -/* Operation, sleep mode control */ #define ADIS16203_SLP_CNT 0x3A - -/* Diagnostics, system status register */ #define ADIS16203_DIAG_STAT 0x3C - -/* Operation, system command register */ #define ADIS16203_GLOB_CMD 0x3E -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Reverses rotation of both inclination outputs */ +#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST_DIS BIT(10) #define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9) - -/* Self-test enable */ #define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ #define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2) - -/* Data-ready polarity: 1 = active high, 0 = active low */ #define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1) - -/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ #define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0) -/* DIAG_STAT */ - -/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16203_DIAG_STAT_ALARM2 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16203_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag */ #define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 - -/* SPI communications failure */ #define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3 - -/* Flash update failure */ #define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2 - -/* Power supply above 3.625 V */ #define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 - -/* Power supply below 2.975 V */ #define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 -/* GLOB_CMD */ - #define ADIS16203_GLOB_CMD_SW_RESET BIT(7) #define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) #define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) From patchwork Sun Jan 29 15:55:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED2E8C05027 for ; Sun, 29 Jan 2023 15:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234979AbjA2PmV (ORCPT ); Sun, 29 Jan 2023 10:42:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbjA2PmU (ORCPT ); Sun, 29 Jan 2023 10:42:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E41D1CF76; Sun, 29 Jan 2023 07:42:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C90060DC7; Sun, 29 Jan 2023 15:42:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3606C433EF; Sun, 29 Jan 2023 15:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006937; bh=LbJlhf7egiClJvLuB5vqS0R+pxqtjvxQgKBOfISnhYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p7l7KoRs7QtwRDEmnAxDZItjbVEfefJ7v7JsyL3H0tzTd2MqmsZYc0ho8sJdo/Kqu jmWq5G6UZWpbV18hTnup2J2HVjJCrvpm+jkaCYHRljoQ35WJAKNWzXdX67i6XfQpcA 3kbFDsnpBcw18b0AK2xl3qxrDe/w4Fayl+wof0O/v+VA+NsX0y3Ov3OAvNj/Isb053 DZilv4odCDDzJkYKbuoXWdz2BHvvfNqboSp0KgE6hRVUqZw/EEgVbXP+Q/upbAkn70 mPZfkJEleqaWQVI0Yz5j9cqp1QPnEaPlYehWSzgmtqCHN7iftu/9piDYYVa/bpBZBY qMKK6D0IHlcNA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 03/12] staging: iio: accel: adis16203: Rename incli channel registers Date: Sun, 29 Jan 2023 15:55:53 +0000 Message-Id: <20230129155602.740743-4-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This device has two such channels that are effectively reading the same thing, just with a 180 degree offset. First rename them (later we will drop one of them as it is easier to apply an offset in software). Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 60117aaf56d4..8e5d1d2ea8e9 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -19,8 +19,8 @@ #define ADIS16203_SUPPLY_OUT 0x02 #define ADIS16203_AUX_ADC 0x08 #define ADIS16203_TEMP_OUT 0x0A -#define ADIS16203_XINCL_OUT 0x0C -#define ADIS16203_YINCL_OUT 0x0E +#define ADIS16203_INCL_OUT 0x0C +#define ADIS16203_INCL_OUT_180 0x0E #define ADIS16203_INCL_NULL 0x18 #define ADIS16203_ALM_MAG1 0x20 #define ADIS16203_ALM_MAG2 0x22 @@ -138,10 +138,10 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec adis16203_channels[] = { ADIS_SUPPLY_CHAN(ADIS16203_SUPPLY_OUT, ADIS16203_SCAN_SUPPLY, 0, 12), ADIS_AUX_ADC_CHAN(ADIS16203_AUX_ADC, ADIS16203_SCAN_AUX_ADC, 0, 12), - ADIS_INCLI_CHAN(X, ADIS16203_XINCL_OUT, ADIS16203_SCAN_INCLI_X, + ADIS_INCLI_CHAN(X, ADIS16203_INCL_OUT, ADIS16203_SCAN_INCLI_X, BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), /* Fixme: Not what it appears to be - see data sheet */ - ADIS_INCLI_CHAN(Y, ADIS16203_YINCL_OUT, ADIS16203_SCAN_INCLI_Y, + ADIS_INCLI_CHAN(Y, ADIS16203_INCL_OUT_180, ADIS16203_SCAN_INCLI_Y, 0, 0, 14), ADIS_TEMP_CHAN(ADIS16203_TEMP_OUT, ADIS16203_SCAN_TEMP, 0, 12), IIO_CHAN_SOFT_TIMESTAMP(5), From patchwork Sun Jan 29 15:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B037BC636D0 for ; Sun, 29 Jan 2023 15:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjA2PmV (ORCPT ); Sun, 29 Jan 2023 10:42:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234942AbjA2PmU (ORCPT ); Sun, 29 Jan 2023 10:42:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC30812870; Sun, 29 Jan 2023 07:42:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 73DBD60C6D; Sun, 29 Jan 2023 15:42:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72C21C433AF; Sun, 29 Jan 2023 15:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006938; bh=SwYXs9I2ta5OOSwgF/OPkPmKgovgrvcG9ebNwU0ipZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=irruQ4HVQU/Se0RhzA6X29YhfBt867rGRmxvhpLt+5pLMZq9JbuTav4mDY4bKFOe3 RjDPQHUgjV5bwwf05mIAg74ZOyVOwy2cqYAzC/THLmflWlDc/Q1V0BG4ZyRIFc4dv4 A0xn7UQXg9Qa6VOKJ+mUeNlOXoDR6wjl6iuHnEwtdsHrnwdcGV+U22PQAPGbQNs1G+ kVkJtDv//LFa6tp0YDvyzyKHtGoIq8KtzAM/zM6QxveibRgl5m+gGSGBewIMW+VVuJ IPJftb8MFKWRgctPo4C4i3+t3syFPPwtGMLt+35YswOY7cxvqMkTAqM9qxDNBDWnvY 3w62w9Pj/mgrA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 04/12] staging: iio: accel: adis16203: Drop the 180 degree offset channel Date: Sun, 29 Jan 2023 15:55:54 +0000 Message-Id: <20230129155602.740743-5-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron There is no standard ABI suitable for this channel, which is blocking the graduation of this driver from staging. It provides no obvious benefit over applying a -180 degree offset in software. So drop the channel. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 8e5d1d2ea8e9..b59a003f3e26 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -59,7 +59,6 @@ enum adis16203_scan { ADIS16203_SCAN_INCLI_X, - ADIS16203_SCAN_INCLI_Y, ADIS16203_SCAN_SUPPLY, ADIS16203_SCAN_AUX_ADC, ADIS16203_SCAN_TEMP, @@ -140,11 +139,8 @@ static const struct iio_chan_spec adis16203_channels[] = { ADIS_AUX_ADC_CHAN(ADIS16203_AUX_ADC, ADIS16203_SCAN_AUX_ADC, 0, 12), ADIS_INCLI_CHAN(X, ADIS16203_INCL_OUT, ADIS16203_SCAN_INCLI_X, BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), - /* Fixme: Not what it appears to be - see data sheet */ - ADIS_INCLI_CHAN(Y, ADIS16203_INCL_OUT_180, ADIS16203_SCAN_INCLI_Y, - 0, 0, 14), ADIS_TEMP_CHAN(ADIS16203_TEMP_OUT, ADIS16203_SCAN_TEMP, 0, 12), - IIO_CHAN_SOFT_TIMESTAMP(5), + IIO_CHAN_SOFT_TIMESTAMP(4), }; static const struct iio_info adis16203_info = { From patchwork Sun Jan 29 15:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BADEC636D4 for ; Sun, 29 Jan 2023 15:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234942AbjA2PmX (ORCPT ); Sun, 29 Jan 2023 10:42:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234924AbjA2PmW (ORCPT ); Sun, 29 Jan 2023 10:42:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1D981A485; Sun, 29 Jan 2023 07:42:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3C32860C6D; Sun, 29 Jan 2023 15:42:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43120C433EF; Sun, 29 Jan 2023 15:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006940; bh=O29dY269yId+Tk5piMwcX/yhYJ65tW/QMiVRDIvTutI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvWcR22Ge8GZ06zQzW1562KQzzZJkOtiXjwj5ETmNKrrbVih8axwobKo444JjEZC5 6Bsk3OTqGAlezrqqDSrtqDbbMJJ8AjfkV2cFD5jYEGB+TGxpz8k8o68ZBChDqFHoBT z2fsqVQv3wLug388qU9hj9i6u42dJJAXvVBA3ZcTnCCdkH0Kjl6fINuHxu64AppO6Z Ex9VOODE3wHdxHkpoB+t3gGv97XZE5zz7g/AkCN05t2h7OBpewx/+8QN/lnQk3sJS/ AdRu4DHhW9eDp85K4s8advd2kjuBpGA8heHyOD6OgFHAs5Tg/1vHp5Y2Nv7LSEGTdC O1VTK2sMUrkhQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 05/12] staging: iio: accel: adis16203: Simplify handling of calibbias Date: Sun, 29 Jan 2023 15:55:55 +0000 Message-Id: <20230129155602.740743-6-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Dropping the indirection on address lookup as there was only one address enables several other minor cleanups. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index b59a003f3e26..67c0340d7097 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -5,6 +5,7 @@ * Copyright 2010 Analog Devices Inc. */ +#include #include #include #include @@ -57,6 +58,8 @@ #define ADIS16203_ERROR_ACTIVE BIT(14) +#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) + enum adis16203_scan { ADIS16203_SCAN_INCLI_X, ADIS16203_SCAN_SUPPLY, @@ -66,10 +69,6 @@ enum adis16203_scan { #define DRIVER_NAME "adis16203" -static const u8 adis16203_addresses[] = { - [ADIS16203_SCAN_INCLI_X] = ADIS16203_INCL_NULL, -}; - static int adis16203_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, @@ -77,10 +76,12 @@ static int adis16203_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *st = iio_priv(indio_dev); - /* currently only one writable parameter which keeps this simple */ - u8 addr = adis16203_addresses[chan->scan_index]; - return adis_write_reg_16(st, addr, val & 0x3FFF); + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; + + return adis_write_reg_16(st, ADIS16203_INCL_NULL, + FIELD_PREP(ADIS16203_INCLI_NULL_MSK, val)); } static int adis16203_read_raw(struct iio_dev *indio_dev, @@ -90,7 +91,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, { struct adis *st = iio_priv(indio_dev); int ret; - u8 addr; + s16 val16; switch (mask) { @@ -123,8 +124,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, *val = 25000 / -470 - 1278; /* 25 C = 1278 */ return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: - addr = adis16203_addresses[chan->scan_index]; - ret = adis_read_reg_16(st, addr, &val16); + ret = adis_read_reg_16(st, ADIS16203_INCL_NULL, &val16); if (ret) return ret; *val = sign_extend32(val16, 13); From patchwork Sun Jan 29 15:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E669CC05027 for ; Sun, 29 Jan 2023 15:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235057AbjA2Pm3 (ORCPT ); Sun, 29 Jan 2023 10:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234767AbjA2Pm2 (ORCPT ); Sun, 29 Jan 2023 10:42:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 279951F90F; Sun, 29 Jan 2023 07:42:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C2670B80D1B; Sun, 29 Jan 2023 15:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14848C4339B; Sun, 29 Jan 2023 15:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006942; bh=KwirpNA3y6XauK8S7usKhZVnThfvTfYC6YOhW8SKf60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExrtN2zHBoKnCWubvkA/Eo/ZqvhyxJz9u21FCCWFrTsUUtZZ2OlnTmtYgtDPZCPtZ ZBbFF/3slKU0Kp+LMERDd7mf8e/4dkx/nHBwaTucjYWJ+iY+YQvu6CiGfJ8Nlsa/RQ 0/Z4jiM6EjLhMtMLQN9r4aq9wDB/ouOEIZ3hv2Ju+SkZ/RgKf/+OlDWqdaG4NEJsFj fceMbjgsLFy/n+tFO6AJ+sLdYZlzHb6ntnY3t82rHP41w+0cC4cCwXCu306kX5z067 ZXHptaYKiurISLGVOqWPm2oR3ZRCFfa0GJPC/9J2vgyZuTePvRlEcr19NI9e+HWv10 787Iv3cN0N8pw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 06/12] staging: iio: accel: adis16203: Drop driver name define Date: Sun, 29 Jan 2023 15:55:56 +0000 Message-Id: <20230129155602.740743-7-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron These defines just make it harder to see what strings are set for which driver structure fields. Much better to just have the string inline. In this case it wasn't even used. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 67c0340d7097..25342717539b 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -67,8 +67,6 @@ enum adis16203_scan { ADIS16203_SCAN_TEMP, }; -#define DRIVER_NAME "adis16203" - static int adis16203_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, @@ -196,7 +194,7 @@ static int adis16203_probe(struct spi_device *spi) /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); - indio_dev->name = spi->dev.driver->name; + indio_dev->name = "adis16203"; indio_dev->channels = adis16203_channels; indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); indio_dev->info = &adis16203_info; From patchwork Sun Jan 29 15:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F947C636CC for ; Sun, 29 Jan 2023 15:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbjA2Pma (ORCPT ); Sun, 29 Jan 2023 10:42:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235091AbjA2Pm3 (ORCPT ); Sun, 29 Jan 2023 10:42:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F329B1CACC; Sun, 29 Jan 2023 07:42:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94D12B80C98; Sun, 29 Jan 2023 15:42:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8D3FC433A8; Sun, 29 Jan 2023 15:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006944; bh=xNFqaSt6sAiqcpyDJBbIK/2JCT49tj09BjUpYSsTMco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B9VyOX4E+PCVSoEm6qiHGvlbtWJvNw0Cd36RVFez4SH7PDpTx3QJdZZMXq/lQLY/g vI3ZZn0PfYahsYmMjS+PNG3+mMIMTtA6uosaUUXl3p91j7xSMSxmTL8uyh5FmIQnFv ++6Xhi8M+B37zbh3RZ8qrViJAovnt8b9kDJ6FTTBHsrGpaQijhShZM8AkPE++DQsvp Sqm4Dl8Qqds47irMeMamodBGtkjYg8OHMjd7JlGntgB9Z3x5iTkY6PXPzzcsq3g6I8 BgSXHHI0CKjTXHz5B+iWaMNbCeiGJN4iAqOiVoLArqtD1Cihu5SKe9XCWhOFToiR2/ pqlW6d4Uymlxw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 07/12] staging: iio: accel: adis16203: Make units explicit in name of delay define Date: Sun, 29 Jan 2023 15:55:57 +0000 Message-Id: <20230129155602.740743-8-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron A postfix of _MS avoids the need for a comment that might bit rot. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 25342717539b..271e560c41c0 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -14,7 +14,7 @@ #include #include -#define ADIS16203_STARTUP_DELAY 220 /* ms */ +#define ADIS16203_STARTUP_DELAY_MS 220 #define ADIS16203_FLASH_CNT 0x00 #define ADIS16203_SUPPLY_OUT 0x02 @@ -156,9 +156,9 @@ static const char * const adis16203_status_error_msgs[] = { }; static const struct adis_timeout adis16203_timeouts = { - .reset_ms = ADIS16203_STARTUP_DELAY, - .sw_reset_ms = ADIS16203_STARTUP_DELAY, - .self_test_ms = ADIS16203_STARTUP_DELAY + .reset_ms = ADIS16203_STARTUP_DELAY_MS, + .sw_reset_ms = ADIS16203_STARTUP_DELAY_MS, + .self_test_ms = ADIS16203_STARTUP_DELAY_MS }; static const struct adis_data adis16203_data = { From patchwork Sun Jan 29 15:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2AC9C636CD for ; Sun, 29 Jan 2023 15:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbjA2Pmd (ORCPT ); Sun, 29 Jan 2023 10:42:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232549AbjA2Pmc (ORCPT ); Sun, 29 Jan 2023 10:42:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9161A4A7; Sun, 29 Jan 2023 07:42:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5FC48B80D12; Sun, 29 Jan 2023 15:42:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A92FAC433EF; Sun, 29 Jan 2023 15:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006946; bh=VnHxjBNrUG6CY7s6ScRwsoldize5YgLyA6igzmAEr7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pdItW5EBz9mJcp4RAwEM+vohZYfsGWZcd3x9X00EeAGAEwlkPt8vunEkSH8WyWRBC tvtGiLBArFh74o7NMpeuC2MyB5qe9+GtRe9U9m11aL1tohMb+PsPIndGM+M24GxHUv OQxdiiL6Iy02bmNRXIOR8Ug9erzFxFul8XmSl8kgR0jVL598n5oHOQ1V4ewmP69Eb0 uUGMUaXndRQvY+sN7ti+rOeNqarwK9EbAECtDwQPgWWwa6/lpkdDgHzg9pHQZQsmMn dxHZgUrTFusY9b/aN4yLggPQSo8FsF2+E8vAj8KvR58fkjuitSi8CJQyxOqZxVHBcU /S/FfjHpzll1A== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 08/12] staging: iio: accel: adis16203: Trivial whitespace cleanup Date: Sun, 29 Jan 2023 15:55:58 +0000 Message-Id: <20230129155602.740743-9-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Identation etc in this driver was inconsistent. Fix that. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 97 +++++++++++++-------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 271e560c41c0..20e9c9eb9436 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -16,49 +16,49 @@ #define ADIS16203_STARTUP_DELAY_MS 220 -#define ADIS16203_FLASH_CNT 0x00 -#define ADIS16203_SUPPLY_OUT 0x02 -#define ADIS16203_AUX_ADC 0x08 -#define ADIS16203_TEMP_OUT 0x0A -#define ADIS16203_INCL_OUT 0x0C -#define ADIS16203_INCL_OUT_180 0x0E -#define ADIS16203_INCL_NULL 0x18 -#define ADIS16203_ALM_MAG1 0x20 -#define ADIS16203_ALM_MAG2 0x22 -#define ADIS16203_ALM_SMPL1 0x24 -#define ADIS16203_ALM_SMPL2 0x26 -#define ADIS16203_ALM_CTRL 0x28 -#define ADIS16203_AUX_DAC 0x30 -#define ADIS16203_GPIO_CTRL 0x32 -#define ADIS16203_MSC_CTRL 0x34 -#define ADIS16203_SMPL_PRD 0x36 -#define ADIS16203_AVG_CNT 0x38 -#define ADIS16203_SLP_CNT 0x3A -#define ADIS16203_DIAG_STAT 0x3C -#define ADIS16203_GLOB_CMD 0x3E - -#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST_DIS BIT(10) -#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9) -#define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8) -#define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2) -#define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1) -#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0) - -#define ADIS16203_DIAG_STAT_ALARM2 BIT(9) -#define ADIS16203_DIAG_STAT_ALARM1 BIT(8) -#define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2 -#define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 -#define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 - -#define ADIS16203_GLOB_CMD_SW_RESET BIT(7) -#define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) -#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) - -#define ADIS16203_ERROR_ACTIVE BIT(14) - -#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) +#define ADIS16203_FLASH_CNT 0x00 +#define ADIS16203_SUPPLY_OUT 0x02 +#define ADIS16203_AUX_ADC 0x08 +#define ADIS16203_TEMP_OUT 0x0A +#define ADIS16203_INCL_OUT 0x0C +#define ADIS16203_INCL_OUT_180 0x0E +#define ADIS16203_INCL_NULL 0x18 +#define ADIS16203_ALM_MAG1 0x20 +#define ADIS16203_ALM_MAG2 0x22 +#define ADIS16203_ALM_SMPL1 0x24 +#define ADIS16203_ALM_SMPL2 0x26 +#define ADIS16203_ALM_CTRL 0x28 +#define ADIS16203_AUX_DAC 0x30 +#define ADIS16203_GPIO_CTRL 0x32 +#define ADIS16203_MSC_CTRL 0x34 +#define ADIS16203_SMPL_PRD 0x36 +#define ADIS16203_AVG_CNT 0x38 +#define ADIS16203_SLP_CNT 0x3A +#define ADIS16203_DIAG_STAT 0x3C +#define ADIS16203_GLOB_CMD 0x3E + +#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST_DIS BIT(10) +#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9) +#define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2) +#define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0) + +#define ADIS16203_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16203_DIAG_STAT_ALARM1 BIT(8) +#define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3 +#define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 + +#define ADIS16203_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) + +#define ADIS16203_ERROR_ACTIVE BIT(14) + +#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) enum adis16203_scan { ADIS16203_SCAN_INCLI_X, @@ -69,9 +69,7 @@ enum adis16203_scan { static int adis16203_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, - int val, - int val2, - long mask) + int val, int val2, long mask) { struct adis *st = iio_priv(indio_dev); @@ -84,18 +82,16 @@ static int adis16203_write_raw(struct iio_dev *indio_dev, static int adis16203_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, - int *val, int *val2, - long mask) + int *val, int *val2, long mask) { struct adis *st = iio_priv(indio_dev); int ret; - s16 val16; switch (mask) { case IIO_CHAN_INFO_RAW: return adis_single_conversion(indio_dev, chan, - ADIS16203_ERROR_ACTIVE, val); + ADIS16203_ERROR_ACTIVE, val); case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_VOLTAGE: @@ -220,7 +216,6 @@ static const struct of_device_id adis16203_of_match[] = { { .compatible = "adi,adis16203" }, { }, }; - MODULE_DEVICE_TABLE(of, adis16203_of_match); static struct spi_driver adis16203_driver = { From patchwork Sun Jan 29 15:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2FF1C05027 for ; Sun, 29 Jan 2023 15:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234670AbjA2Pmc (ORCPT ); Sun, 29 Jan 2023 10:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234460AbjA2Pmb (ORCPT ); Sun, 29 Jan 2023 10:42:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B101E5E1; Sun, 29 Jan 2023 07:42:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7640F60C7B; Sun, 29 Jan 2023 15:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B113C4339B; Sun, 29 Jan 2023 15:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006947; bh=B+qp4Bg0ckQ1EeHpNrnKDGWpfd3LdqaTfOttRJJrPgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw2cpz8cUznyUiTq/isJhbZVtjY6KQzmLO9Wh84cVX6BJFppxCQT4PgPLRnwxsPdm OirxL9UBYIkBhA2aOwOj5Hkc54jV84+15CbjqRFDepZZQbLqM+Y5WkZ2QNyNoxbsK+ o/JRQPFxKD44/01a6ASuVlrMI7Ak0dBqNzmzg3EKg03QtW8c3xy9aiIrfJ+QiBy831 VczPM08lCR72WYWYGzT5fscJr7kYI3sM2pzpJ4aImqLlGfg9miR1IQmobjysWtmjuP 6ZhIp5jmBAWstvPCU85yzFDvS5A7ulaezApa2un3cVbflPJZU5ogAPzi75DPQm6CJ9 SFj02B9o7J3BA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 09/12] staging: iio: accel: adis16203: Drop setting drvdata as nothing gets it Date: Sun, 29 Jan 2023 15:55:59 +0000 Message-Id: <20230129155602.740743-10-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron As commented, it is only useful for .remove() which doesn't exist, so drop setting it and the comment. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 20e9c9eb9436..9915b73454d2 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -187,8 +187,6 @@ static int adis16203_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); indio_dev->name = "adis16203"; indio_dev->channels = adis16203_channels; From patchwork Sun Jan 29 15:56:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0F6CC636CC for ; Sun, 29 Jan 2023 15:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234930AbjA2Pme (ORCPT ); Sun, 29 Jan 2023 10:42:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232549AbjA2Pme (ORCPT ); Sun, 29 Jan 2023 10:42:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4774C1CF56; Sun, 29 Jan 2023 07:42:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F0222B80D14; Sun, 29 Jan 2023 15:42:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B74CC433EF; Sun, 29 Jan 2023 15:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006949; bh=z7t1uWckaiUEht/osE1ffup1zeOOHYuYzMqKoLJ3WvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RhJTIQBQk5BT4QJjN0IIDndC+KTTLr1RgphdmqYvbnk7JRXyYWT+RHKQAzAX9Ez+Y YKuFgmJXff65XMR36kUY2yHqoWeYz1oZb0KfB3ab6F2zwWwOS4JUHcOAzOiE5/+Wm4 RRDII+gVLEKbkSoRokEZWzotJ6KMu7VL5AhlnqtY2KbEgCSmKye/wJEZldM+jxxb5n ZnjQgs1Mmx7v1EVFrlLvA2PL7LjJ9F2q8Z1Yya0vodbvlPeybFdL66h9yXFrnHh4pA 46uuN0W/q/n7QWr7Zeg3Lz2oFQ4c5l1ImGDObMRcmtPNfLMwstZYPYcdb1OtQ/i+oL hg3KVONaiDDfw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 10/12] staging: iio: accel: adis16203: Trivial style cleanup Date: Sun, 29 Jan 2023 15:56:00 +0000 Message-Id: <20230129155602.740743-11-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Drop a training comma after a null terminator and a comment that says nothing beyond the obvious. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 9915b73454d2..1aaf9815aa66 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -182,7 +182,6 @@ static int adis16203_probe(struct spi_device *spi) struct iio_dev *indio_dev; struct adis *st; - /* setup the industrialio driver allocated elements */ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; @@ -212,7 +211,7 @@ static int adis16203_probe(struct spi_device *spi) static const struct of_device_id adis16203_of_match[] = { { .compatible = "adi,adis16203" }, - { }, + { } }; MODULE_DEVICE_TABLE(of, adis16203_of_match); From patchwork Sun Jan 29 15:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B412FC61D97 for ; Sun, 29 Jan 2023 15:42:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbjA2Pmi (ORCPT ); Sun, 29 Jan 2023 10:42:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbjA2Pmi (ORCPT ); Sun, 29 Jan 2023 10:42:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F58F1F93A; Sun, 29 Jan 2023 07:42:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9EC6B80D1B; Sun, 29 Jan 2023 15:42:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BDC0C4339C; Sun, 29 Jan 2023 15:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006951; bh=AiYsY1Pjt06nmkXX9GlrsDATjOE8584u9ZkcrVI9COs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k44MUswAPKW20yXSG+7osdxrDN6A7QZSBrIkhZLiGXLO9kKS1G8/D+md6mu1ltvBS x/i9ElyO28wSGh3/ZJ71zCYC8wgcjTXmnnsmYlbLaHZNSDLA0uuqh7QCk42xUdbbxJ Dc48JN8x1R+mf3MPwRhcdbarSGR3SvHUuSrPx7lTgh9g+x+UBocGfi7Tvpwpe5enLH MnJJY5GKlwMhjZo4ZwYyKWYhzL/kDqWi4LuFyJDTElRGtwJY1v4wvHTvIoCWPUcmxV fyY95+twHZ+FmEchyepRHGeuU9pxL0kHzlg7rDSJxpenYs6g9Q5P81GcM8v90vg+qo 5TSX+rRRIRHgA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 11/12] staging: iio: accel: adis16203: Move out of staging Date: Sun, 29 Jan 2023 15:56:01 +0000 Message-Id: <20230129155602.740743-12-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The main blocker of this driver moving previously was non standard ABI for the 180 degree offset channel. Now support for that channel has been dropped, this simple driver can move out of staging. Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile | 1 + drivers/iio/accel/adis16203.c | 231 ++++++++++++++++++++++++++ drivers/staging/iio/accel/Kconfig | 12 -- drivers/staging/iio/accel/Makefile | 1 - drivers/staging/iio/accel/adis16203.c | 231 -------------------------- 6 files changed, 244 insertions(+), 244 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index b6b45d359f28..88d4b18bd5e8 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -18,6 +18,18 @@ config ADIS16201 To compile this driver as a module, say M here: the module will be called adis16201. +config ADIS16203 + tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer" + depends on SPI + select IIO_ADIS_LIB + select IIO_ADIS_LIB_BUFFER if IIO_BUFFER + help + Say Y here to build support for Analog Devices adis16203 Programmable + 360 Degrees Inclinometer. + + To compile this driver as a module, say M here: the module will be + called adis16203. + config ADIS16209 tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" depends on SPI diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 311ead9c3ef1..b6f0cee52659 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -5,6 +5,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_ADIS16201) += adis16201.o +obj-$(CONFIG_ADIS16203) += adis16203.o obj-$(CONFIG_ADIS16209) += adis16209.o obj-$(CONFIG_ADXL313) += adxl313_core.o obj-$(CONFIG_ADXL313_I2C) += adxl313_i2c.o diff --git a/drivers/iio/accel/adis16203.c b/drivers/iio/accel/adis16203.c new file mode 100644 index 000000000000..1aaf9815aa66 --- /dev/null +++ b/drivers/iio/accel/adis16203.c @@ -0,0 +1,231 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * ADIS16203 Programmable 360 Degrees Inclinometer + * + * Copyright 2010 Analog Devices Inc. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#define ADIS16203_STARTUP_DELAY_MS 220 + +#define ADIS16203_FLASH_CNT 0x00 +#define ADIS16203_SUPPLY_OUT 0x02 +#define ADIS16203_AUX_ADC 0x08 +#define ADIS16203_TEMP_OUT 0x0A +#define ADIS16203_INCL_OUT 0x0C +#define ADIS16203_INCL_OUT_180 0x0E +#define ADIS16203_INCL_NULL 0x18 +#define ADIS16203_ALM_MAG1 0x20 +#define ADIS16203_ALM_MAG2 0x22 +#define ADIS16203_ALM_SMPL1 0x24 +#define ADIS16203_ALM_SMPL2 0x26 +#define ADIS16203_ALM_CTRL 0x28 +#define ADIS16203_AUX_DAC 0x30 +#define ADIS16203_GPIO_CTRL 0x32 +#define ADIS16203_MSC_CTRL 0x34 +#define ADIS16203_SMPL_PRD 0x36 +#define ADIS16203_AVG_CNT 0x38 +#define ADIS16203_SLP_CNT 0x3A +#define ADIS16203_DIAG_STAT 0x3C +#define ADIS16203_GLOB_CMD 0x3E + +#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST_DIS BIT(10) +#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9) +#define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2) +#define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0) + +#define ADIS16203_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16203_DIAG_STAT_ALARM1 BIT(8) +#define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3 +#define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 + +#define ADIS16203_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) + +#define ADIS16203_ERROR_ACTIVE BIT(14) + +#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) + +enum adis16203_scan { + ADIS16203_SCAN_INCLI_X, + ADIS16203_SCAN_SUPPLY, + ADIS16203_SCAN_AUX_ADC, + ADIS16203_SCAN_TEMP, +}; + +static int adis16203_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct adis *st = iio_priv(indio_dev); + + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; + + return adis_write_reg_16(st, ADIS16203_INCL_NULL, + FIELD_PREP(ADIS16203_INCLI_NULL_MSK, val)); +} + +static int adis16203_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct adis *st = iio_priv(indio_dev); + int ret; + s16 val16; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return adis_single_conversion(indio_dev, chan, + ADIS16203_ERROR_ACTIVE, val); + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_VOLTAGE: + if (chan->channel == 0) { + *val = 1; + *val2 = 220000; /* 1.22 mV */ + } else { + *val = 0; + *val2 = 610000; /* 0.61 mV */ + } + return IIO_VAL_INT_PLUS_MICRO; + case IIO_TEMP: + *val = -470; /* -0.47 C */ + *val2 = 0; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_INCLI: + *val = 0; + *val2 = 25000; /* 0.025 degree */ + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_OFFSET: + *val = 25000 / -470 - 1278; /* 25 C = 1278 */ + return IIO_VAL_INT; + case IIO_CHAN_INFO_CALIBBIAS: + ret = adis_read_reg_16(st, ADIS16203_INCL_NULL, &val16); + if (ret) + return ret; + *val = sign_extend32(val16, 13); + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static const struct iio_chan_spec adis16203_channels[] = { + ADIS_SUPPLY_CHAN(ADIS16203_SUPPLY_OUT, ADIS16203_SCAN_SUPPLY, 0, 12), + ADIS_AUX_ADC_CHAN(ADIS16203_AUX_ADC, ADIS16203_SCAN_AUX_ADC, 0, 12), + ADIS_INCLI_CHAN(X, ADIS16203_INCL_OUT, ADIS16203_SCAN_INCLI_X, + BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), + ADIS_TEMP_CHAN(ADIS16203_TEMP_OUT, ADIS16203_SCAN_TEMP, 0, 12), + IIO_CHAN_SOFT_TIMESTAMP(4), +}; + +static const struct iio_info adis16203_info = { + .read_raw = adis16203_read_raw, + .write_raw = adis16203_write_raw, + .update_scan_mode = adis_update_scan_mode, +}; + +static const char * const adis16203_status_error_msgs[] = { + [ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT] = "Self test failure", + [ADIS16203_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", + [ADIS16203_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", + [ADIS16203_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", + [ADIS16203_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", +}; + +static const struct adis_timeout adis16203_timeouts = { + .reset_ms = ADIS16203_STARTUP_DELAY_MS, + .sw_reset_ms = ADIS16203_STARTUP_DELAY_MS, + .self_test_ms = ADIS16203_STARTUP_DELAY_MS +}; + +static const struct adis_data adis16203_data = { + .read_delay = 20, + .msc_ctrl_reg = ADIS16203_MSC_CTRL, + .glob_cmd_reg = ADIS16203_GLOB_CMD, + .diag_stat_reg = ADIS16203_DIAG_STAT, + + .self_test_mask = ADIS16203_MSC_CTRL_SELF_TEST_EN, + .self_test_reg = ADIS16203_MSC_CTRL, + .self_test_no_autoclear = true, + .timeouts = &adis16203_timeouts, + + .status_error_msgs = adis16203_status_error_msgs, + .status_error_mask = BIT(ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT) | + BIT(ADIS16203_DIAG_STAT_SPI_FAIL_BIT) | + BIT(ADIS16203_DIAG_STAT_FLASH_UPT_BIT) | + BIT(ADIS16203_DIAG_STAT_POWER_HIGH_BIT) | + BIT(ADIS16203_DIAG_STAT_POWER_LOW_BIT), +}; + +static int adis16203_probe(struct spi_device *spi) +{ + int ret; + struct iio_dev *indio_dev; + struct adis *st; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); + + indio_dev->name = "adis16203"; + indio_dev->channels = adis16203_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); + indio_dev->info = &adis16203_info; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = adis_init(st, indio_dev, spi, &adis16203_data); + if (ret) + return ret; + + ret = devm_adis_setup_buffer_and_trigger(st, indio_dev, NULL); + if (ret) + return ret; + + /* Get the device into a sane initial state */ + ret = __adis_initial_startup(st); + if (ret) + return ret; + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct of_device_id adis16203_of_match[] = { + { .compatible = "adi,adis16203" }, + { } +}; +MODULE_DEVICE_TABLE(of, adis16203_of_match); + +static struct spi_driver adis16203_driver = { + .driver = { + .name = "adis16203", + .of_match_table = adis16203_of_match, + }, + .probe = adis16203_probe, +}; +module_spi_driver(adis16203_driver); + +MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); +MODULE_DESCRIPTION("Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("spi:adis16203"); +MODULE_IMPORT_NS(IIO_ADISLIB); diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index 3318997a7009..3769af8719f3 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -4,18 +4,6 @@ # menu "Accelerometers" -config ADIS16203 - tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer" - depends on SPI - select IIO_ADIS_LIB - select IIO_ADIS_LIB_BUFFER if IIO_BUFFER - help - Say Y here to build support for Analog Devices adis16203 Programmable - 360 Degrees Inclinometer. - - To compile this driver as a module, say M here: the module will be - called adis16203. - config ADIS16240 tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder" depends on SPI diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile index 094cc9be35bd..b0beec471814 100644 --- a/drivers/staging/iio/accel/Makefile +++ b/drivers/staging/iio/accel/Makefile @@ -3,5 +3,4 @@ # Makefile for industrial I/O accelerometer drivers # -obj-$(CONFIG_ADIS16203) += adis16203.o obj-$(CONFIG_ADIS16240) += adis16240.o diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c deleted file mode 100644 index 1aaf9815aa66..000000000000 --- a/drivers/staging/iio/accel/adis16203.c +++ /dev/null @@ -1,231 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * ADIS16203 Programmable 360 Degrees Inclinometer - * - * Copyright 2010 Analog Devices Inc. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#define ADIS16203_STARTUP_DELAY_MS 220 - -#define ADIS16203_FLASH_CNT 0x00 -#define ADIS16203_SUPPLY_OUT 0x02 -#define ADIS16203_AUX_ADC 0x08 -#define ADIS16203_TEMP_OUT 0x0A -#define ADIS16203_INCL_OUT 0x0C -#define ADIS16203_INCL_OUT_180 0x0E -#define ADIS16203_INCL_NULL 0x18 -#define ADIS16203_ALM_MAG1 0x20 -#define ADIS16203_ALM_MAG2 0x22 -#define ADIS16203_ALM_SMPL1 0x24 -#define ADIS16203_ALM_SMPL2 0x26 -#define ADIS16203_ALM_CTRL 0x28 -#define ADIS16203_AUX_DAC 0x30 -#define ADIS16203_GPIO_CTRL 0x32 -#define ADIS16203_MSC_CTRL 0x34 -#define ADIS16203_SMPL_PRD 0x36 -#define ADIS16203_AVG_CNT 0x38 -#define ADIS16203_SLP_CNT 0x3A -#define ADIS16203_DIAG_STAT 0x3C -#define ADIS16203_GLOB_CMD 0x3E - -#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST_DIS BIT(10) -#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9) -#define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8) -#define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2) -#define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1) -#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0) - -#define ADIS16203_DIAG_STAT_ALARM2 BIT(9) -#define ADIS16203_DIAG_STAT_ALARM1 BIT(8) -#define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2 -#define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 -#define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 - -#define ADIS16203_GLOB_CMD_SW_RESET BIT(7) -#define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) -#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) - -#define ADIS16203_ERROR_ACTIVE BIT(14) - -#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) - -enum adis16203_scan { - ADIS16203_SCAN_INCLI_X, - ADIS16203_SCAN_SUPPLY, - ADIS16203_SCAN_AUX_ADC, - ADIS16203_SCAN_TEMP, -}; - -static int adis16203_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, int val2, long mask) -{ - struct adis *st = iio_priv(indio_dev); - - if (mask != IIO_CHAN_INFO_CALIBBIAS) - return -EINVAL; - - return adis_write_reg_16(st, ADIS16203_INCL_NULL, - FIELD_PREP(ADIS16203_INCLI_NULL_MSK, val)); -} - -static int adis16203_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) -{ - struct adis *st = iio_priv(indio_dev); - int ret; - s16 val16; - - switch (mask) { - case IIO_CHAN_INFO_RAW: - return adis_single_conversion(indio_dev, chan, - ADIS16203_ERROR_ACTIVE, val); - case IIO_CHAN_INFO_SCALE: - switch (chan->type) { - case IIO_VOLTAGE: - if (chan->channel == 0) { - *val = 1; - *val2 = 220000; /* 1.22 mV */ - } else { - *val = 0; - *val2 = 610000; /* 0.61 mV */ - } - return IIO_VAL_INT_PLUS_MICRO; - case IIO_TEMP: - *val = -470; /* -0.47 C */ - *val2 = 0; - return IIO_VAL_INT_PLUS_MICRO; - case IIO_INCLI: - *val = 0; - *val2 = 25000; /* 0.025 degree */ - return IIO_VAL_INT_PLUS_MICRO; - default: - return -EINVAL; - } - case IIO_CHAN_INFO_OFFSET: - *val = 25000 / -470 - 1278; /* 25 C = 1278 */ - return IIO_VAL_INT; - case IIO_CHAN_INFO_CALIBBIAS: - ret = adis_read_reg_16(st, ADIS16203_INCL_NULL, &val16); - if (ret) - return ret; - *val = sign_extend32(val16, 13); - return IIO_VAL_INT; - default: - return -EINVAL; - } -} - -static const struct iio_chan_spec adis16203_channels[] = { - ADIS_SUPPLY_CHAN(ADIS16203_SUPPLY_OUT, ADIS16203_SCAN_SUPPLY, 0, 12), - ADIS_AUX_ADC_CHAN(ADIS16203_AUX_ADC, ADIS16203_SCAN_AUX_ADC, 0, 12), - ADIS_INCLI_CHAN(X, ADIS16203_INCL_OUT, ADIS16203_SCAN_INCLI_X, - BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), - ADIS_TEMP_CHAN(ADIS16203_TEMP_OUT, ADIS16203_SCAN_TEMP, 0, 12), - IIO_CHAN_SOFT_TIMESTAMP(4), -}; - -static const struct iio_info adis16203_info = { - .read_raw = adis16203_read_raw, - .write_raw = adis16203_write_raw, - .update_scan_mode = adis_update_scan_mode, -}; - -static const char * const adis16203_status_error_msgs[] = { - [ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT] = "Self test failure", - [ADIS16203_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", - [ADIS16203_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", - [ADIS16203_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16203_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", -}; - -static const struct adis_timeout adis16203_timeouts = { - .reset_ms = ADIS16203_STARTUP_DELAY_MS, - .sw_reset_ms = ADIS16203_STARTUP_DELAY_MS, - .self_test_ms = ADIS16203_STARTUP_DELAY_MS -}; - -static const struct adis_data adis16203_data = { - .read_delay = 20, - .msc_ctrl_reg = ADIS16203_MSC_CTRL, - .glob_cmd_reg = ADIS16203_GLOB_CMD, - .diag_stat_reg = ADIS16203_DIAG_STAT, - - .self_test_mask = ADIS16203_MSC_CTRL_SELF_TEST_EN, - .self_test_reg = ADIS16203_MSC_CTRL, - .self_test_no_autoclear = true, - .timeouts = &adis16203_timeouts, - - .status_error_msgs = adis16203_status_error_msgs, - .status_error_mask = BIT(ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT) | - BIT(ADIS16203_DIAG_STAT_SPI_FAIL_BIT) | - BIT(ADIS16203_DIAG_STAT_FLASH_UPT_BIT) | - BIT(ADIS16203_DIAG_STAT_POWER_HIGH_BIT) | - BIT(ADIS16203_DIAG_STAT_POWER_LOW_BIT), -}; - -static int adis16203_probe(struct spi_device *spi) -{ - int ret; - struct iio_dev *indio_dev; - struct adis *st; - - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - st = iio_priv(indio_dev); - - indio_dev->name = "adis16203"; - indio_dev->channels = adis16203_channels; - indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); - indio_dev->info = &adis16203_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - ret = adis_init(st, indio_dev, spi, &adis16203_data); - if (ret) - return ret; - - ret = devm_adis_setup_buffer_and_trigger(st, indio_dev, NULL); - if (ret) - return ret; - - /* Get the device into a sane initial state */ - ret = __adis_initial_startup(st); - if (ret) - return ret; - - return devm_iio_device_register(&spi->dev, indio_dev); -} - -static const struct of_device_id adis16203_of_match[] = { - { .compatible = "adi,adis16203" }, - { } -}; -MODULE_DEVICE_TABLE(of, adis16203_of_match); - -static struct spi_driver adis16203_driver = { - .driver = { - .name = "adis16203", - .of_match_table = adis16203_of_match, - }, - .probe = adis16203_probe, -}; -module_spi_driver(adis16203_driver); - -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:adis16203"); -MODULE_IMPORT_NS(IIO_ADISLIB); From patchwork Sun Jan 29 15:56:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13120180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1582BC636CC for ; Sun, 29 Jan 2023 15:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbjA2Pmj (ORCPT ); Sun, 29 Jan 2023 10:42:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234941AbjA2Pmi (ORCPT ); Sun, 29 Jan 2023 10:42:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1281E1E5FF; Sun, 29 Jan 2023 07:42:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 95A67B80D1D; Sun, 29 Jan 2023 15:42:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8677C4339B; Sun, 29 Jan 2023 15:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675006953; bh=qmVa9jZ4Srbg16/5mWKHGWabaBJ05sNxieFRffrNPHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z74NC/g+OS7foeXBmDewrt9cJyC+TKDOQ+L9Vzo0+tPwSZF3d51ThEkUb2zKtfbzZ MucyHHusf93HIPZsQ8KpqABHemTy3aHh1q8K8TT6vGO5DzMA9R4WJW9ndRiJIVULbx tGM8j29g+Gs7LtYx5d04DrTXyXrgiYFtaNI/DeISRlojhBcQG2fnkIw7xa0sLpoiwP Cjvh+XEW+iYiiHpT7cVhUSfYs5Ett1j4SCya6dcL0LyZyB4kWmky/+PRAvCLsNoG/e L7bU0fOYYGUvSd7QwQGlIsQiYU3LyQZjacacsFU32g8+aKR3M+GJxdlgTIZRpS04it jAxJJpDN/+m8Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Subject: [PATCH v2 12/12] dt-bindings: iio: accel: Add ADIS16203 Inclinometer Date: Sun, 29 Jan 2023 15:56:02 +0000 Message-Id: <20230129155602.740743-13-jic23@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129155602.740743-1-jic23@kernel.org> References: <20230129155602.740743-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron There has been a driver in staging for quite a while. Given we are now moving it to the main tree, time to make sure it has binding documentation. Signed-off-by: Jonathan Cameron --- V2: - maxItems/minItems added where needed. - fix interrupt-names to allow multiple entries. --- .../bindings/iio/accel/adi,adis16203.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/accel/adi,adis16203.yaml b/Documentation/devicetree/bindings/iio/accel/adi,adis16203.yaml new file mode 100644 index 000000000000..2248fb4eb2c3 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/adi,adis16203.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/adi,adis16203.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ADIS16203 Programmable 360 degree inclinometer + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: adi,adis16203 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + minItems: 1 + maxItems: 2 + description: + Device has two configurable outputs, both of which may be used + as interrupt sources. + items: + enum: + - dio0 + - dio1 + + reset-gpios: + maxItems: 1 + + vdd-supply: true + +required: + - compatible + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + accelerometer@0 { + compatible = "adi,adis16201"; + reg = <0>; + spi-max-frequency = <2500000>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "dio0"; + }; + }; +... +