From patchwork Fri Mar 22 20:44:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10866525 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 36AFD1575 for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E5192A500 for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F6892A6F2; Fri, 22 Mar 2019 20:44:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 F298C2A500 for ; Fri, 22 Mar 2019 20:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727521AbfCVUox (ORCPT ); Fri, 22 Mar 2019 16:44:53 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39757 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfCVUox (ORCPT ); Fri, 22 Mar 2019 16:44:53 -0400 Received: by mail-wr1-f68.google.com with SMTP id j9so3744463wrn.6 for ; Fri, 22 Mar 2019 13:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Y/2Q+ooaHDGUSu1DsdVHCzdJg170F1KJxLYWwtCJ3Gw=; b=JO6+V0+CSP5zPc3BQzG0p8ho6t6/yCVXZ9m428oMo5wQh7eOK/Etr5ax+hjrv7H3L+ lN2sK/Z1bEYR2PQJjBYJotIpDcTVJrT1Rqs/+GL8NRdv++pZ8CwV0T2K2weNNtCpaWm1 KCJpa10pcKbtRaDaOA3+0dbBnrm4mHdPufBo/tKrlW1cb3xYoDpGvK+pXk2bQBtuD5HU wXOwC4T4euf/InZUF49SftyCsBqyj2WU2Z6cytwQ5amkqQpHWYTjPy11mKwXmmV2PACK oQRtvqTbNq+yAYYKH+q5d6UMaamGfs7WT0hNtk1ctDNYWZ7YF2Klligm9lznx54UGG+g plhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y/2Q+ooaHDGUSu1DsdVHCzdJg170F1KJxLYWwtCJ3Gw=; b=UN+1m3QIK8Qbdcp0/4oF8Oz9RwM5Av3imNf+JgHGDdSLxSyxN3+IcgOg402EzLskOf 8wTuroN2xAdpYu9x3k7EBU/irx49BqpzwZUKr+7fwN4grUlZLLYWA53HoWt/8dpsiLgi JbNMMtHLiyKUxwTZXJrOQTW24MnGuJc/Ujw0MMrCnhSHz/WtaCAKOmGBxfo3O4uIZ/wr rmM4dXue9+nnulWX0mvymJNSHAHrjDYD1JazdoffZ0E+b/VWj/mSZfcslixQg6bPKGNS LTuAbf7mLXsfNmJjer+Hvptg8UntJKISCpEE9mf3Anx+JdgDfIyffvNt4DGzQ5IqYA4Z MYxA== X-Gm-Message-State: APjAAAVPQGfY1vW+C6v6FZf6xHcb+HH9HsDvHhv63H3Y7xFKVwMR7g5O gFbLrfPbzR7SQ/CWIzWuIFT12mLr X-Google-Smtp-Source: APXvYqxy/wsNm3gJuc/7e5L5zRmmgqgOKwFksjrc4rYR7utjk+v/Etn4jMidzxfWLsw7NsbSNeCOow== X-Received: by 2002:adf:ebce:: with SMTP id v14mr7513626wrn.69.1553287490189; Fri, 22 Mar 2019 13:44:50 -0700 (PDT) Received: from localhost.localdomain ([188.24.4.251]) by smtp.gmail.com with ESMTPSA id a9sm10436565wmb.30.2019.03.22.13.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 13:44:49 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean Subject: [PATCH 1/5] iio: imu: adis16400: move trigger handler into adis16400_core Date: Fri, 22 Mar 2019 22:44:38 +0200 Message-Id: <20190322204442.4035-1-ardeleanalex@gmail.com> X-Mailer: git-send-email 2.17.1 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 From: Alexandru Ardelean The trigger handler for the ADIS16400 is very different from the generic one in the ADIS library. Keeping it in a separate file won't make much sense once the update_scan_mode function will be made more generic and moved into the ADIS library. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/adis16400.h | 2 -- drivers/iio/imu/adis16400_buffer.c | 41 -------------------------- drivers/iio/imu/adis16400_core.c | 46 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h index 73b189c1c0fb..93b6c0c41fdd 100644 --- a/drivers/iio/imu/adis16400.h +++ b/drivers/iio/imu/adis16400.h @@ -203,12 +203,10 @@ ssize_t adis16400_read_data_from_ring(struct device *dev, int adis16400_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask); -irqreturn_t adis16400_trigger_handler(int irq, void *p); #else /* CONFIG_IIO_BUFFER */ #define adis16400_update_scan_mode NULL -#define adis16400_trigger_handler NULL #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c index e70a5339acb1..268349eb51c7 100644 --- a/drivers/iio/imu/adis16400_buffer.c +++ b/drivers/iio/imu/adis16400_buffer.c @@ -58,44 +58,3 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev, return 0; } - -irqreturn_t adis16400_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct adis16400_state *st = iio_priv(indio_dev); - struct adis *adis = &st->adis; - u32 old_speed_hz = st->adis.spi->max_speed_hz; - void *buffer; - int ret; - - if (!adis->buffer) - return -ENOMEM; - - if (!(st->variant->flags & ADIS16400_NO_BURST) && - st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) { - st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST; - spi_setup(st->adis.spi); - } - - ret = spi_sync(adis->spi, &adis->msg); - if (ret) - dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret); - - if (!(st->variant->flags & ADIS16400_NO_BURST)) { - st->adis.spi->max_speed_hz = old_speed_hz; - spi_setup(st->adis.spi); - } - - if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) - buffer = adis->buffer + sizeof(u16); - else - buffer = adis->buffer; - - iio_push_to_buffers_with_timestamp(indio_dev, buffer, - pf->timestamp); - - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 9b697d35dbef..34d52863377a 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "adis16400.h" @@ -465,6 +466,51 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, } } +#if IS_ENABLED(CONFIG_IIO_BUFFER) +static irqreturn_t adis16400_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct adis16400_state *st = iio_priv(indio_dev); + struct adis *adis = &st->adis; + u32 old_speed_hz = st->adis.spi->max_speed_hz; + void *buffer; + int ret; + + if (!adis->buffer) + return -ENOMEM; + + if (!(st->variant->flags & ADIS16400_NO_BURST) && + st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) { + st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST; + spi_setup(st->adis.spi); + } + + ret = spi_sync(adis->spi, &adis->msg); + if (ret) + dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret); + + if (!(st->variant->flags & ADIS16400_NO_BURST)) { + st->adis.spi->max_speed_hz = old_speed_hz; + spi_setup(st->adis.spi); + } + + if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) + buffer = adis->buffer + sizeof(u16); + else + buffer = adis->buffer; + + iio_push_to_buffers_with_timestamp(indio_dev, buffer, + pf->timestamp); + + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} +#else +#define adis16400_trigger_handler NULL +#endif /* IS_ENABLED(CONFIG_IIO_BUFFER) */ + #define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ From patchwork Fri Mar 22 20:44:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10866527 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 6E74D17EF for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573392A500 for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A1E82A6EA; Fri, 22 Mar 2019 20:44:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 C19832A6DD for ; Fri, 22 Mar 2019 20:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727643AbfCVUoy (ORCPT ); Fri, 22 Mar 2019 16:44:54 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39756 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727482AbfCVUoy (ORCPT ); Fri, 22 Mar 2019 16:44:54 -0400 Received: by mail-wr1-f65.google.com with SMTP id j9so3744507wrn.6 for ; Fri, 22 Mar 2019 13:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j6zqP4MLPtYMqVTQigbCve/GmakRYD7os8ayHkbdFP4=; b=ZFoGfALd3NrTiweEXGLEnfGY+CQ5zaqwHgzEYfIt5BgotC9nmk+s5TPOofuehRoY3Y kED7f/P6jncaqxhTLXSTpoZGBNHHQsWhcJu1k42ioaZzY8DZFZX7evO4XyaGufiJwGqF dXzOw8luc/rFanXML/+xLBX76ULe4XbdrLnnjwFaSbxjYIxyAMdmfem3EGrpogny2Ylx eryeZNYhls4yjXdA+m9HPmtNvzFA0ghHjhMEDWTR52o+9wVchW31doEtChXt6egnOPI6 TTIHB64CJmgCc0lROqi0WHhc0me1ZfwaMpkw1fhYMXxT6X1usFwWqRdAuv6k4moLZwuz JEdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j6zqP4MLPtYMqVTQigbCve/GmakRYD7os8ayHkbdFP4=; b=OCc+hc6aRCda3ptcK4EH+hwCRYmVn07hD0/eyyW1TLtBrC8uBo+dFqkZuoLglSLS1b HLk3JgGLzH5tBZT41O8wj69452p8OkFlz95dMQ0FkJUq6uOfXpZBv7iNRES3M/z8NK6w CjykHFSS3f813sMOG5/o8yEiX0bFtC7HUVZ07HpZ1PjOae4aydAWRZ6bX2qmWbdDVjqI kNGDa3A++xA2gSvxt+smITcorI4w7JlAlK9p0zPc4pO+Eh5E68lze1m9xlaAksDjFy6n t46nRBpjCaiNkyoMe6FE0oqpw9fpCkRLyWzdux5EYOAwEg+lOqTdvZe3ShvnHL8G8rJN HinQ== X-Gm-Message-State: APjAAAXE5/MHAEHz6werkjSXijJE0mxjuWjTSyMNMIpn/4YSpeY0ofOX w+iU89sSa016NPFT1P+KwEoC8G6x X-Google-Smtp-Source: APXvYqzJqbz+M0fQgSHS6w8AhyaDKdWuH/+7EIlrzuXa4awA0LNX6e87R5T/hqqVW9pXwL8M7TE29A== X-Received: by 2002:adf:f786:: with SMTP id q6mr7404992wrp.125.1553287491255; Fri, 22 Mar 2019 13:44:51 -0700 (PDT) Received: from localhost.localdomain ([188.24.4.251]) by smtp.gmail.com with ESMTPSA id a9sm10436565wmb.30.2019.03.22.13.44.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 13:44:50 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean Subject: [PATCH 2/5] iio: imu: adis: generalize burst mode support Date: Fri, 22 Mar 2019 22:44:39 +0200 Message-Id: <20190322204442.4035-2-ardeleanalex@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190322204442.4035-1-ardeleanalex@gmail.com> References: <20190322204442.4035-1-ardeleanalex@gmail.com> 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 From: Alexandru Ardelean Some variants in the ADIS16400 family support burst mode. This mechanism is implemented in the `adis16400_buffer.c` file. Some variants in ADIS16480 are also adding burst mode, which is functionally similar to ADIS16400, but with different parameters. To get there, a `adis_burst` struct is added to parametrize certain bits of the SPI communication to setup: the register that triggers burst-mode, and the extra-data-length that needs be accounted for when building the bust-length buffer. The trigger handler cannot be made generic, since it's very specific to each ADIS164XX family. A future enhancement of this `adis_burst` mode will be the possibility to enable/disable burst-mode. For the ADIS16400 family it's hard-coded to on by default. But for ADIS16480 there will be a need to disable this. When that will be implemented, both ADIS16400 & ADIS16480 will have the burst-mode enable-able/disable-able. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/adis16400_buffer.c | 7 +++---- drivers/iio/imu/adis16400_core.c | 8 ++++++++ include/linux/iio/imu/adis.h | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c index 268349eb51c7..199bd72348eb 100644 --- a/drivers/iio/imu/adis16400_buffer.c +++ b/drivers/iio/imu/adis16400_buffer.c @@ -22,7 +22,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev, unsigned int burst_length; u8 *tx; - if (st->variant->flags & ADIS16400_NO_BURST) + if (!adis->burst || !adis->burst->en) return adis_update_scan_mode(indio_dev, scan_mask); kfree(adis->xfer); @@ -30,8 +30,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev, /* All but the timestamp channel */ burst_length = (indio_dev->num_channels - 1) * sizeof(u16); - if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) - burst_length += sizeof(u16); + burst_length += adis->burst->extra_len; adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL); if (!adis->xfer) @@ -42,7 +41,7 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev, return -ENOMEM; tx = adis->buffer + burst_length; - tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD); + tx[0] = ADIS_READ_REG(adis->burst->reg_cmd); tx[1] = 0; adis->xfer[0].tx_buf = tx; diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 34d52863377a..0d799e983d74 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -146,6 +146,11 @@ enum adis16400_chip_variant { ADIS16448, }; +static struct adis_burst adis16400_burst = { + .en = true, + .reg_cmd = ADIS16400_GLOB_CMD, +}; + static int adis16334_get_freq(struct adis16400_state *st) { int ret; @@ -973,6 +978,9 @@ static int adis16400_probe(struct spi_device *spi) if (!(st->variant->flags & ADIS16400_NO_BURST)) { adis16400_setup_chan_mask(st); indio_dev->available_scan_masks = st->avail_scan_mask; + st->adis.burst = &adis16400_burst; + if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) + st->adis.burst->extra_len = sizeof(u16); } ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h index cb6c3ed13459..26141ee87cfb 100644 --- a/include/linux/iio/imu/adis.h +++ b/include/linux/iio/imu/adis.h @@ -21,6 +21,7 @@ #define ADIS_REG_PAGE_ID 0x00 struct adis; +struct adis_burst; /** * struct adis_data - ADIS chip variant specific data @@ -59,6 +60,7 @@ struct adis { struct iio_trigger *trig; const struct adis_data *data; + struct adis_burst *burst; struct mutex txrx_lock; struct spi_message msg; @@ -234,6 +236,18 @@ int adis_single_conversion(struct iio_dev *indio_dev, #ifdef CONFIG_IIO_ADIS_LIB_BUFFER +/** + * struct adis_burst - ADIS data for burst transfers + * @en burst mode enabled + * @reg_cmd register command that triggers burst + * @extra_len extra length to account in the SPI RX buffer + */ +struct adis_burst { + bool en; + unsigned int reg_cmd; + unsigned int extra_len; +}; + int adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *)); void adis_cleanup_buffer_and_trigger(struct adis *adis, From patchwork Fri Mar 22 20:44:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10866529 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 4E9F9922 for ; Fri, 22 Mar 2019 20:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 347A92A074 for ; Fri, 22 Mar 2019 20:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 292262A6DD; Fri, 22 Mar 2019 20:44: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 765152A500 for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfCVUoz (ORCPT ); Fri, 22 Mar 2019 16:44:55 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38063 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfCVUoy (ORCPT ); Fri, 22 Mar 2019 16:44:54 -0400 Received: by mail-wr1-f66.google.com with SMTP id g12so3740346wrm.5 for ; Fri, 22 Mar 2019 13:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fuwr1AYS3lIem3uvasDIfGATPraH3urfuNIWTQGRiNg=; b=ZThTkJWlhkDXumevyrRHaduLMqXi9ilBPSEFgfOctRD1/upnU/HJOg+j6QLbdD+AKe 0h03dYBk1TVCNiqMLoOucCsnwuQl2gIFY/xPI9Jlqcv87B63lehdQ0XQucJQ4SqRgTJl FFijCxPVYMQIZiDM/zA3cIGl3OJYQFx/gRJmHx+YEsj1y338oLoRAPPFaEAqYz0814Ji 2zZm7ami+QBIfUYm2zCi0JBXNpSGhSRlxyVREOZm74X5R9g2aowCA1E/kgLf+J194Q1q 3Y9ER5r+rKqxTbBfVMZW7jW8T81scS92MAcDLVmQz+PW9UJKEBci0+RtkMfm52nD8xZk 4/Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fuwr1AYS3lIem3uvasDIfGATPraH3urfuNIWTQGRiNg=; b=YOlbeFYX5ejVoah4wgRSjm6UF5jEiu19948ywwntxQlwAzO2n6hfCrJKKVM08Gg2zH KxfMHgENnzdsFF5HGztjJJNCevJQKxZvZgPJ07sw9Va8vdVshP/7p7cStVEnBKIIjczz bUngSgyiD17z7qwLjyXk6tlBaC+PxQwDOGi4JOKYzxjuQi+1iIGEcHyg6tWhI4oz89dr IZtMKEA8RJ6Jk/VkHBDBrZMeIkaTvjzgIvTItqN8Apnc0A5DJjOyq3iJvBAgLoIw5l+B YEaZ1PrTFyyLGl80xUX8w+BUOOk3t5PcQI//ybh+p72/1TfsED4wAv/U1REEF917GwR5 L8xw== X-Gm-Message-State: APjAAAVutfSjPoOSJEAppEJSlZklWW0fcRhAwU54RheZ1qR33Pc6vx/8 8fm3rdlzY5A/2AEKcSlowZPqbmi9 X-Google-Smtp-Source: APXvYqwaC5e1iD5PDM87TB1lZZGz60FQjUjwngWi2w4Vllmz539lKqKMYx0VeeHD6kow2cuk+W8Btw== X-Received: by 2002:adf:e443:: with SMTP id t3mr8184774wrm.257.1553287492312; Fri, 22 Mar 2019 13:44:52 -0700 (PDT) Received: from localhost.localdomain ([188.24.4.251]) by smtp.gmail.com with ESMTPSA id a9sm10436565wmb.30.2019.03.22.13.44.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 13:44:51 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean Subject: [PATCH 3/5] iio: imu: adis16400: move burst logic to ADIS lib Date: Fri, 22 Mar 2019 22:44:40 +0200 Message-Id: <20190322204442.4035-3-ardeleanalex@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190322204442.4035-1-ardeleanalex@gmail.com> References: <20190322204442.4035-1-ardeleanalex@gmail.com> 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 From: Alexandru Ardelean This change has been done separately, so that it's easier to visualize the changed logic in the adis_scan_update() function. Most of the function in this `adis16400_update_scan_mode()` that deals with burst-mode will be re-used in the ADIS16480, but with different parameters. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/Makefile | 1 - drivers/iio/imu/adis16400.h | 16 -------- drivers/iio/imu/adis16400_buffer.c | 59 ------------------------------ drivers/iio/imu/adis16400_core.c | 2 +- drivers/iio/imu/adis_buffer.c | 40 ++++++++++++++++++++ 5 files changed, 41 insertions(+), 77 deletions(-) delete mode 100644 drivers/iio/imu/adis16400_buffer.c diff --git a/drivers/iio/imu/Makefile b/drivers/iio/imu/Makefile index 5fd87701259f..c9f85126fbe1 100644 --- a/drivers/iio/imu/Makefile +++ b/drivers/iio/imu/Makefile @@ -5,7 +5,6 @@ # When adding new entries keep the list in alphabetical order adis16400-y := adis16400_core.o -adis16400-$(CONFIG_IIO_BUFFER) += adis16400_buffer.o obj-$(CONFIG_ADIS16400) += adis16400.o obj-$(CONFIG_ADIS16460) += adis16460.o obj-$(CONFIG_ADIS16480) += adis16480.o diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h index 93b6c0c41fdd..7e2e0dbaa2e1 100644 --- a/drivers/iio/imu/adis16400.h +++ b/drivers/iio/imu/adis16400.h @@ -194,20 +194,4 @@ enum { ADIS16400_SCAN_TIMESTAMP, }; -#ifdef CONFIG_IIO_BUFFER - -ssize_t adis16400_read_data_from_ring(struct device *dev, - struct device_attribute *attr, - char *buf); - - -int adis16400_update_scan_mode(struct iio_dev *indio_dev, - const unsigned long *scan_mask); - -#else /* CONFIG_IIO_BUFFER */ - -#define adis16400_update_scan_mode NULL - -#endif /* CONFIG_IIO_BUFFER */ - #endif /* SPI_ADIS16400_H_ */ diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c deleted file mode 100644 index 199bd72348eb..000000000000 --- a/drivers/iio/imu/adis16400_buffer.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "adis16400.h" - -int adis16400_update_scan_mode(struct iio_dev *indio_dev, - const unsigned long *scan_mask) -{ - struct adis16400_state *st = iio_priv(indio_dev); - struct adis *adis = &st->adis; - unsigned int burst_length; - u8 *tx; - - if (!adis->burst || !adis->burst->en) - return adis_update_scan_mode(indio_dev, scan_mask); - - kfree(adis->xfer); - kfree(adis->buffer); - - /* All but the timestamp channel */ - burst_length = (indio_dev->num_channels - 1) * sizeof(u16); - burst_length += adis->burst->extra_len; - - adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL); - if (!adis->xfer) - return -ENOMEM; - - adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL); - if (!adis->buffer) - return -ENOMEM; - - tx = adis->buffer + burst_length; - tx[0] = ADIS_READ_REG(adis->burst->reg_cmd); - tx[1] = 0; - - adis->xfer[0].tx_buf = tx; - adis->xfer[0].bits_per_word = 8; - adis->xfer[0].len = 2; - adis->xfer[1].rx_buf = adis->buffer; - adis->xfer[1].bits_per_word = 8; - adis->xfer[1].len = burst_length; - - spi_message_init(&adis->msg); - spi_message_add_tail(&adis->xfer[0], &adis->msg); - spi_message_add_tail(&adis->xfer[1], &adis->msg); - - return 0; -} diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 0d799e983d74..265c0a46597f 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -887,7 +887,7 @@ static const struct iio_info adis16400_info = { .driver_module = THIS_MODULE, .read_raw = &adis16400_read_raw, .write_raw = &adis16400_write_raw, - .update_scan_mode = adis16400_update_scan_mode, + .update_scan_mode = adis_update_scan_mode, .debugfs_reg_access = adis_debugfs_reg_access, }; diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 36607d52fee0..a2fa6e75b13e 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -20,6 +20,43 @@ #include #include +static int adis_update_scan_mode_burst(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct adis *adis = iio_device_get_drvdata(indio_dev); + unsigned int burst_length; + u8 *tx; + + /* All but the timestamp channel */ + burst_length = (indio_dev->num_channels - 1) * sizeof(u16); + burst_length += adis->burst->extra_len; + + adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL); + if (!adis->xfer) + return -ENOMEM; + + adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL); + if (!adis->buffer) + return -ENOMEM; + + tx = adis->buffer + burst_length; + tx[0] = ADIS_READ_REG(adis->burst->reg_cmd); + tx[1] = 0; + + adis->xfer[0].tx_buf = tx; + adis->xfer[0].bits_per_word = 8; + adis->xfer[0].len = 2; + adis->xfer[1].rx_buf = adis->buffer; + adis->xfer[1].bits_per_word = 8; + adis->xfer[1].len = burst_length; + + spi_message_init(&adis->msg); + spi_message_add_tail(&adis->xfer[0], &adis->msg); + spi_message_add_tail(&adis->xfer[1], &adis->msg); + + return 0; +} + int adis_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask) { @@ -32,6 +69,9 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, kfree(adis->xfer); kfree(adis->buffer); + if (adis->burst && adis->burst->en) + return adis_update_scan_mode_burst(indio_dev, scan_mask); + scan_count = indio_dev->scan_bytes / 2; adis->xfer = kcalloc(scan_count + 1, sizeof(*adis->xfer), GFP_KERNEL); From patchwork Fri Mar 22 20:44:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10866531 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 9C5E617EF for ; Fri, 22 Mar 2019 20:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79E4D2A500 for ; Fri, 22 Mar 2019 20:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 665C22A6F2; Fri, 22 Mar 2019 20:44: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 D52E82A50D for ; Fri, 22 Mar 2019 20:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbfCVUoz (ORCPT ); Fri, 22 Mar 2019 16:44:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52516 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727633AbfCVUoz (ORCPT ); Fri, 22 Mar 2019 16:44:55 -0400 Received: by mail-wm1-f65.google.com with SMTP id a184so3397252wma.2 for ; Fri, 22 Mar 2019 13:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dGwFLD8KFkvXmQH2c7u6bv9W3nTucVU6GeNsRsfqjT4=; b=a3eHeEYIExUwl0sxRCoH/fuEJkpF6kJeLovfZ4vh+RtVZTUvXR5P9ZyNe1gBS6nB5l Ynx/7/xH8IBt6wWhGRLlfapcYHB72di9EESSNKZlTKSGf8zaPWhK5V5XGCLOXgc7OLyE 75fdkxyosr/Z6A0F0nFEXgNPM3D3+bNVc2faN0Gl/cMNkDMYI/R+3vUhGfXlHMDhSovW W42WGAQHTKJp+inmKsDtKQLPH9XtQKYZUQGXnu9RW4WABZLrAonzp6rC2omjkAl122jM bm/O6uca9khgrK7rcUvfDougW1zTtYYuqYICBAO+OAnIF3r8/8lanC4TckBs/DeIKILL 4kYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dGwFLD8KFkvXmQH2c7u6bv9W3nTucVU6GeNsRsfqjT4=; b=kp3X7QOZ0drLcmpXWzj6Civ8ByjGIIZW3pk/epPE04enUt9GGyc4W0dTL19kkFBGBa Ge6WffXSlLUAXd9ssMsPElptlrh1TTzYGFx/BsoD06zAh31zYjKNIPuoK6sktDDLM+JQ wH4RNVWkEu0YZ9kU+KdpNQY2fhbYyggonCQywaQE3kHFXd3A/K+OiWTCJeVaKdZ1puRl nhVqhjFKmUUVrhrAjO6qxmncnyecJb/JP7942bKh82elOWNqAcY0+YLnaY+BuF30smKD xLMKSR0cLSqDtB4CQKByWWEJaq98Gitf5s026Kp6O2jXTpZqe/FpGdcw0HDazsrWMQQT JyfA== X-Gm-Message-State: APjAAAVEBJL+PDodpuc5D9lWWoojamnA7ajjj1Wc8ZH/MfgMmcSIQ3+7 doxwC5hM3SPiLZ0WKbbm7A88K30X X-Google-Smtp-Source: APXvYqwRCfc9pfTcXf82vImXne35pHe+jLHkShQt17LBZ67ZZg9EAalbEpt6eRTidpldhH0PG4cHLw== X-Received: by 2002:a1c:f718:: with SMTP id v24mr4435015wmh.1.1553287493252; Fri, 22 Mar 2019 13:44:53 -0700 (PDT) Received: from localhost.localdomain ([188.24.4.251]) by smtp.gmail.com with ESMTPSA id a9sm10436565wmb.30.2019.03.22.13.44.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 13:44:52 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean Subject: [PATCH 4/5] iio: imu: adis16400: rename adis16400_core.c -> adi16400.c Date: Fri, 22 Mar 2019 22:44:41 +0200 Message-Id: <20190322204442.4035-4-ardeleanalex@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190322204442.4035-1-ardeleanalex@gmail.com> References: <20190322204442.4035-1-ardeleanalex@gmail.com> 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 From: Alexandru Ardelean This change does a simple 1-to-1 rename of the adis16400_core.c file. Now that the `adis16400_buffer.c` file was removed, everything can be moved into a single driver file. But first, this rename. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/Makefile | 1 - drivers/iio/imu/{adis16400_core.c => adis16400.c} | 0 2 files changed, 1 deletion(-) rename drivers/iio/imu/{adis16400_core.c => adis16400.c} (100%) diff --git a/drivers/iio/imu/Makefile b/drivers/iio/imu/Makefile index c9f85126fbe1..4a6958865504 100644 --- a/drivers/iio/imu/Makefile +++ b/drivers/iio/imu/Makefile @@ -4,7 +4,6 @@ # # When adding new entries keep the list in alphabetical order -adis16400-y := adis16400_core.o obj-$(CONFIG_ADIS16400) += adis16400.o obj-$(CONFIG_ADIS16460) += adis16460.o obj-$(CONFIG_ADIS16480) += adis16480.o diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400.c similarity index 100% rename from drivers/iio/imu/adis16400_core.c rename to drivers/iio/imu/adis16400.c From patchwork Fri Mar 22 20:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10866533 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 14AEA1575 for ; Fri, 22 Mar 2019 20:45:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE2432A074 for ; Fri, 22 Mar 2019 20:44:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F742A6E5; Fri, 22 Mar 2019 20:44: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 A38AB2A074 for ; Fri, 22 Mar 2019 20:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727644AbfCVUo6 (ORCPT ); Fri, 22 Mar 2019 16:44:58 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38869 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727633AbfCVUo6 (ORCPT ); Fri, 22 Mar 2019 16:44:58 -0400 Received: by mail-wm1-f67.google.com with SMTP id a188so3392730wmf.3 for ; Fri, 22 Mar 2019 13:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pl2j3w7uK2uBRlbuwdelFf5Y60Ogei0VihtknpX2drs=; b=lc1fZuYTYj33qhr0IkW/ilCIN1ax0ouIxZApJMWDsBuHShLNyy1M2XhJqkqe2GC0Ip M9Bw6ABMAGDI816HXwyDVmhrEibo9NTHQ/wY87GkhHgSVNAbDh5YepMQEw5BB1Ns4gRd JuKYzbIgrNcvZKtBn5JIkg0dGRMiKAlZqLAYzp5vEz2KdQ/XY/Wb0bSYVVY5dZFg5Qt1 bAHzgiO4YlblsJo6niDDoIMyOTgxx8SGxybjaVaspymD71QlWZh7TF0d7T9ZQPwuU75i /SXWoHGIWcLcxtwNMZM3YhwlbCuq5+zH0MmS+WdLOTGH1I8SIj0mbEW5mTIO6fX9PdHf Bl9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pl2j3w7uK2uBRlbuwdelFf5Y60Ogei0VihtknpX2drs=; b=tApOTl6jp5Z3foXhBOjiUyUwHueyCigFkdUNdoQDyKEgKNUKxjIkQOl/ZuFKGgYGoB AQUm46Evn7AxF9nAiWaAUgleRSkmubOey7jtMoK3HFCloogmIALSkKNdNqxpZwmZ2ScK +4UBnd2TAWRDqZnPiQ/ueZeKw83EOGuGIelk2g1aMxFwPWr6pk4KN14b0dUsCLOI6Oim lcFlLHO/XtXk1TuYEwL16b/QcK/tgIjbm3Px9E93X50NWgTZzJRUJlE2g/ToYZ+c0xju WnQdAX/eMaD2WfM98rw6G3Cn+Brk/rLMBcIV8BsGM859+s0WB/lFZam9fQcC9w5O51xm 3yyA== X-Gm-Message-State: APjAAAX0zOcBcG/mfwY1TAzgVT1hVcBXFgdJGWbimHfXHv+6sDyUtfge z8n1xGhjWl5z9X+K1FeDptBzqXrC X-Google-Smtp-Source: APXvYqy11fBtGup9eAhY1YcVmbgSg5wxcBLfM09g59pQ8LGjgYUPCZH58HstvNgXeMhkW+4fJupkng== X-Received: by 2002:a1c:c907:: with SMTP id f7mr4197218wmb.39.1553287494378; Fri, 22 Mar 2019 13:44:54 -0700 (PDT) Received: from localhost.localdomain ([188.24.4.251]) by smtp.gmail.com with ESMTPSA id a9sm10436565wmb.30.2019.03.22.13.44.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 13:44:53 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean Subject: [PATCH 5/5] iio: imu: adis16400: move adis16400.h into adis16400.c Date: Fri, 22 Mar 2019 22:44:42 +0200 Message-Id: <20190322204442.4035-5-ardeleanalex@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190322204442.4035-1-ardeleanalex@gmail.com> References: <20190322204442.4035-1-ardeleanalex@gmail.com> 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 From: Alexandru Ardelean Final part of the re-organization. Move the `adis16400.h` into `adis16400.c` since it no longer needs to be shared among other files. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/adis16400.c | 176 +++++++++++++++++++++++++++++++- drivers/iio/imu/adis16400.h | 197 ------------------------------------ 2 files changed, 175 insertions(+), 198 deletions(-) delete mode 100644 drivers/iio/imu/adis16400.h diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index 265c0a46597f..aef9c4d5edb8 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -32,8 +32,182 @@ #include #include #include +#include + +#define ADIS16400_STARTUP_DELAY 290 /* ms */ +#define ADIS16400_MTEST_DELAY 90 /* ms */ + +#define ADIS16400_FLASH_CNT 0x00 /* Flash memory write count */ +#define ADIS16400_SUPPLY_OUT 0x02 /* Power supply measurement */ +#define ADIS16400_XGYRO_OUT 0x04 /* X-axis gyroscope output */ +#define ADIS16400_YGYRO_OUT 0x06 /* Y-axis gyroscope output */ +#define ADIS16400_ZGYRO_OUT 0x08 /* Z-axis gyroscope output */ +#define ADIS16400_XACCL_OUT 0x0A /* X-axis accelerometer output */ +#define ADIS16400_YACCL_OUT 0x0C /* Y-axis accelerometer output */ +#define ADIS16400_ZACCL_OUT 0x0E /* Z-axis accelerometer output */ +#define ADIS16400_XMAGN_OUT 0x10 /* X-axis magnetometer measurement */ +#define ADIS16400_YMAGN_OUT 0x12 /* Y-axis magnetometer measurement */ +#define ADIS16400_ZMAGN_OUT 0x14 /* Z-axis magnetometer measurement */ +#define ADIS16400_TEMP_OUT 0x16 /* Temperature output */ +#define ADIS16400_AUX_ADC 0x18 /* Auxiliary ADC measurement */ + +#define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */ +#define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */ +#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */ + +#define ADIS16300_PITCH_OUT 0x12 /* X axis inclinometer output measurement */ +#define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */ +#define ADIS16300_AUX_ADC 0x16 /* Auxiliary ADC measurement */ + +#define ADIS16448_BARO_OUT 0x16 /* Barometric pressure output */ +#define ADIS16448_TEMP_OUT 0x18 /* Temperature output */ + +/* Calibration parameters */ +#define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */ +#define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */ +#define ADIS16400_ZGYRO_OFF 0x1E /* Z-axis gyroscope bias offset factor */ +#define ADIS16400_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */ +#define ADIS16400_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */ +#define ADIS16400_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */ +#define ADIS16400_XMAGN_HIF 0x26 /* X-axis magnetometer, hard-iron factor */ +#define ADIS16400_YMAGN_HIF 0x28 /* Y-axis magnetometer, hard-iron factor */ +#define ADIS16400_ZMAGN_HIF 0x2A /* Z-axis magnetometer, hard-iron factor */ +#define ADIS16400_XMAGN_SIF 0x2C /* X-axis magnetometer, soft-iron factor */ +#define ADIS16400_YMAGN_SIF 0x2E /* Y-axis magnetometer, soft-iron factor */ +#define ADIS16400_ZMAGN_SIF 0x30 /* Z-axis magnetometer, soft-iron factor */ + +#define ADIS16400_GPIO_CTRL 0x32 /* Auxiliary digital input/output control */ +#define ADIS16400_MSC_CTRL 0x34 /* Miscellaneous control */ +#define ADIS16400_SMPL_PRD 0x36 /* Internal sample period (rate) control */ +#define ADIS16400_SENS_AVG 0x38 /* Dynamic range and digital filter control */ +#define ADIS16400_SLP_CNT 0x3A /* Sleep mode control */ +#define ADIS16400_DIAG_STAT 0x3C /* System status */ + +/* Alarm functions */ +#define ADIS16400_GLOB_CMD 0x3E /* System command */ +#define ADIS16400_ALM_MAG1 0x40 /* Alarm 1 amplitude threshold */ +#define ADIS16400_ALM_MAG2 0x42 /* Alarm 2 amplitude threshold */ +#define ADIS16400_ALM_SMPL1 0x44 /* Alarm 1 sample size */ +#define ADIS16400_ALM_SMPL2 0x46 /* Alarm 2 sample size */ +#define ADIS16400_ALM_CTRL 0x48 /* Alarm control */ +#define ADIS16400_AUX_DAC 0x4A /* Auxiliary DAC data */ + +#define ADIS16334_LOT_ID1 0x52 /* Lot identification code 1 */ +#define ADIS16334_LOT_ID2 0x54 /* Lot identification code 2 */ +#define ADIS16400_PRODUCT_ID 0x56 /* Product identifier */ +#define ADIS16334_SERIAL_NUMBER 0x58 /* Serial number, lot specific */ + +#define ADIS16400_ERROR_ACTIVE (1<<14) +#define ADIS16400_NEW_DATA (1<<14) + +/* MSC_CTRL */ +#define ADIS16400_MSC_CTRL_MEM_TEST (1<<11) +#define ADIS16400_MSC_CTRL_INT_SELF_TEST (1<<10) +#define ADIS16400_MSC_CTRL_NEG_SELF_TEST (1<<9) +#define ADIS16400_MSC_CTRL_POS_SELF_TEST (1<<8) +#define ADIS16400_MSC_CTRL_GYRO_BIAS (1<<7) +#define ADIS16400_MSC_CTRL_ACCL_ALIGN (1<<6) +#define ADIS16400_MSC_CTRL_DATA_RDY_EN (1<<2) +#define ADIS16400_MSC_CTRL_DATA_RDY_POL_HIGH (1<<1) +#define ADIS16400_MSC_CTRL_DATA_RDY_DIO2 (1<<0) + +/* SMPL_PRD */ +#define ADIS16400_SMPL_PRD_TIME_BASE (1<<7) +#define ADIS16400_SMPL_PRD_DIV_MASK 0x7F + +/* DIAG_STAT */ +#define ADIS16400_DIAG_STAT_ZACCL_FAIL 15 +#define ADIS16400_DIAG_STAT_YACCL_FAIL 14 +#define ADIS16400_DIAG_STAT_XACCL_FAIL 13 +#define ADIS16400_DIAG_STAT_XGYRO_FAIL 12 +#define ADIS16400_DIAG_STAT_YGYRO_FAIL 11 +#define ADIS16400_DIAG_STAT_ZGYRO_FAIL 10 +#define ADIS16400_DIAG_STAT_ALARM2 9 +#define ADIS16400_DIAG_STAT_ALARM1 8 +#define ADIS16400_DIAG_STAT_FLASH_CHK 6 +#define ADIS16400_DIAG_STAT_SELF_TEST 5 +#define ADIS16400_DIAG_STAT_OVERFLOW 4 +#define ADIS16400_DIAG_STAT_SPI_FAIL 3 +#define ADIS16400_DIAG_STAT_FLASH_UPT 2 +#define ADIS16400_DIAG_STAT_POWER_HIGH 1 +#define ADIS16400_DIAG_STAT_POWER_LOW 0 + +/* GLOB_CMD */ +#define ADIS16400_GLOB_CMD_SW_RESET (1<<7) +#define ADIS16400_GLOB_CMD_P_AUTO_NULL (1<<4) +#define ADIS16400_GLOB_CMD_FLASH_UPD (1<<3) +#define ADIS16400_GLOB_CMD_DAC_LATCH (1<<2) +#define ADIS16400_GLOB_CMD_FAC_CALIB (1<<1) +#define ADIS16400_GLOB_CMD_AUTO_NULL (1<<0) + +/* SLP_CNT */ +#define ADIS16400_SLP_CNT_POWER_OFF (1<<8) + +#define ADIS16334_RATE_DIV_SHIFT 8 +#define ADIS16334_RATE_INT_CLK BIT(0) + +#define ADIS16400_SPI_SLOW (u32)(300 * 1000) +#define ADIS16400_SPI_BURST (u32)(1000 * 1000) +#define ADIS16400_SPI_FAST (u32)(2000 * 1000) + +#define ADIS16400_HAS_PROD_ID BIT(0) +#define ADIS16400_NO_BURST BIT(1) +#define ADIS16400_HAS_SLOW_MODE BIT(2) +#define ADIS16400_HAS_SERIAL_NUMBER BIT(3) +#define ADIS16400_BURST_DIAG_STAT BIT(4) + +struct adis16400_state; + +struct adis16400_chip_info { + const struct iio_chan_spec *channels; + const int num_channels; + const long flags; + unsigned int gyro_scale_micro; + unsigned int accel_scale_micro; + int temp_scale_nano; + int temp_offset; + int (*set_freq)(struct adis16400_state *st, unsigned int freq); + int (*get_freq)(struct adis16400_state *st); +}; + +/** + * struct adis16400_state - device instance specific data + * @variant: chip variant info + * @filt_int: integer part of requested filter frequency + * @adis: adis device + **/ +struct adis16400_state { + struct adis16400_chip_info *variant; + int filt_int; + + struct adis adis; + unsigned long avail_scan_mask[2]; +}; -#include "adis16400.h" +/* At the moment triggers are only used for ring buffer + * filling. This may change! + */ + +enum { + ADIS16400_SCAN_SUPPLY, + ADIS16400_SCAN_GYRO_X, + ADIS16400_SCAN_GYRO_Y, + ADIS16400_SCAN_GYRO_Z, + ADIS16400_SCAN_ACC_X, + ADIS16400_SCAN_ACC_Y, + ADIS16400_SCAN_ACC_Z, + ADIS16400_SCAN_MAGN_X, + ADIS16400_SCAN_MAGN_Y, + ADIS16400_SCAN_MAGN_Z, + ADIS16400_SCAN_BARO, + ADIS16350_SCAN_TEMP_X, + ADIS16350_SCAN_TEMP_Y, + ADIS16350_SCAN_TEMP_Z, + ADIS16300_SCAN_INCLI_X, + ADIS16300_SCAN_INCLI_Y, + ADIS16400_SCAN_ADC, + ADIS16400_SCAN_TIMESTAMP, +}; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h deleted file mode 100644 index 7e2e0dbaa2e1..000000000000 --- a/drivers/iio/imu/adis16400.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * adis16400.h support Analog Devices ADIS16400 - * 3d 18g accelerometers, - * 3d gyroscopes, - * 3d 2.5gauss magnetometers via SPI - * - * Copyright (c) 2009 Manuel Stahl - * Copyright (c) 2007 Jonathan Cameron - * - * Loosely based upon lis3l02dq.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef SPI_ADIS16400_H_ -#define SPI_ADIS16400_H_ - -#include - -#define ADIS16400_STARTUP_DELAY 290 /* ms */ -#define ADIS16400_MTEST_DELAY 90 /* ms */ - -#define ADIS16400_FLASH_CNT 0x00 /* Flash memory write count */ -#define ADIS16400_SUPPLY_OUT 0x02 /* Power supply measurement */ -#define ADIS16400_XGYRO_OUT 0x04 /* X-axis gyroscope output */ -#define ADIS16400_YGYRO_OUT 0x06 /* Y-axis gyroscope output */ -#define ADIS16400_ZGYRO_OUT 0x08 /* Z-axis gyroscope output */ -#define ADIS16400_XACCL_OUT 0x0A /* X-axis accelerometer output */ -#define ADIS16400_YACCL_OUT 0x0C /* Y-axis accelerometer output */ -#define ADIS16400_ZACCL_OUT 0x0E /* Z-axis accelerometer output */ -#define ADIS16400_XMAGN_OUT 0x10 /* X-axis magnetometer measurement */ -#define ADIS16400_YMAGN_OUT 0x12 /* Y-axis magnetometer measurement */ -#define ADIS16400_ZMAGN_OUT 0x14 /* Z-axis magnetometer measurement */ -#define ADIS16400_TEMP_OUT 0x16 /* Temperature output */ -#define ADIS16400_AUX_ADC 0x18 /* Auxiliary ADC measurement */ - -#define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */ -#define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */ -#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */ - -#define ADIS16300_PITCH_OUT 0x12 /* X axis inclinometer output measurement */ -#define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */ -#define ADIS16300_AUX_ADC 0x16 /* Auxiliary ADC measurement */ - -#define ADIS16448_BARO_OUT 0x16 /* Barometric pressure output */ -#define ADIS16448_TEMP_OUT 0x18 /* Temperature output */ - -/* Calibration parameters */ -#define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */ -#define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */ -#define ADIS16400_ZGYRO_OFF 0x1E /* Z-axis gyroscope bias offset factor */ -#define ADIS16400_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */ -#define ADIS16400_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */ -#define ADIS16400_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */ -#define ADIS16400_XMAGN_HIF 0x26 /* X-axis magnetometer, hard-iron factor */ -#define ADIS16400_YMAGN_HIF 0x28 /* Y-axis magnetometer, hard-iron factor */ -#define ADIS16400_ZMAGN_HIF 0x2A /* Z-axis magnetometer, hard-iron factor */ -#define ADIS16400_XMAGN_SIF 0x2C /* X-axis magnetometer, soft-iron factor */ -#define ADIS16400_YMAGN_SIF 0x2E /* Y-axis magnetometer, soft-iron factor */ -#define ADIS16400_ZMAGN_SIF 0x30 /* Z-axis magnetometer, soft-iron factor */ - -#define ADIS16400_GPIO_CTRL 0x32 /* Auxiliary digital input/output control */ -#define ADIS16400_MSC_CTRL 0x34 /* Miscellaneous control */ -#define ADIS16400_SMPL_PRD 0x36 /* Internal sample period (rate) control */ -#define ADIS16400_SENS_AVG 0x38 /* Dynamic range and digital filter control */ -#define ADIS16400_SLP_CNT 0x3A /* Sleep mode control */ -#define ADIS16400_DIAG_STAT 0x3C /* System status */ - -/* Alarm functions */ -#define ADIS16400_GLOB_CMD 0x3E /* System command */ -#define ADIS16400_ALM_MAG1 0x40 /* Alarm 1 amplitude threshold */ -#define ADIS16400_ALM_MAG2 0x42 /* Alarm 2 amplitude threshold */ -#define ADIS16400_ALM_SMPL1 0x44 /* Alarm 1 sample size */ -#define ADIS16400_ALM_SMPL2 0x46 /* Alarm 2 sample size */ -#define ADIS16400_ALM_CTRL 0x48 /* Alarm control */ -#define ADIS16400_AUX_DAC 0x4A /* Auxiliary DAC data */ - -#define ADIS16334_LOT_ID1 0x52 /* Lot identification code 1 */ -#define ADIS16334_LOT_ID2 0x54 /* Lot identification code 2 */ -#define ADIS16400_PRODUCT_ID 0x56 /* Product identifier */ -#define ADIS16334_SERIAL_NUMBER 0x58 /* Serial number, lot specific */ - -#define ADIS16400_ERROR_ACTIVE (1<<14) -#define ADIS16400_NEW_DATA (1<<14) - -/* MSC_CTRL */ -#define ADIS16400_MSC_CTRL_MEM_TEST (1<<11) -#define ADIS16400_MSC_CTRL_INT_SELF_TEST (1<<10) -#define ADIS16400_MSC_CTRL_NEG_SELF_TEST (1<<9) -#define ADIS16400_MSC_CTRL_POS_SELF_TEST (1<<8) -#define ADIS16400_MSC_CTRL_GYRO_BIAS (1<<7) -#define ADIS16400_MSC_CTRL_ACCL_ALIGN (1<<6) -#define ADIS16400_MSC_CTRL_DATA_RDY_EN (1<<2) -#define ADIS16400_MSC_CTRL_DATA_RDY_POL_HIGH (1<<1) -#define ADIS16400_MSC_CTRL_DATA_RDY_DIO2 (1<<0) - -/* SMPL_PRD */ -#define ADIS16400_SMPL_PRD_TIME_BASE (1<<7) -#define ADIS16400_SMPL_PRD_DIV_MASK 0x7F - -/* DIAG_STAT */ -#define ADIS16400_DIAG_STAT_ZACCL_FAIL 15 -#define ADIS16400_DIAG_STAT_YACCL_FAIL 14 -#define ADIS16400_DIAG_STAT_XACCL_FAIL 13 -#define ADIS16400_DIAG_STAT_XGYRO_FAIL 12 -#define ADIS16400_DIAG_STAT_YGYRO_FAIL 11 -#define ADIS16400_DIAG_STAT_ZGYRO_FAIL 10 -#define ADIS16400_DIAG_STAT_ALARM2 9 -#define ADIS16400_DIAG_STAT_ALARM1 8 -#define ADIS16400_DIAG_STAT_FLASH_CHK 6 -#define ADIS16400_DIAG_STAT_SELF_TEST 5 -#define ADIS16400_DIAG_STAT_OVERFLOW 4 -#define ADIS16400_DIAG_STAT_SPI_FAIL 3 -#define ADIS16400_DIAG_STAT_FLASH_UPT 2 -#define ADIS16400_DIAG_STAT_POWER_HIGH 1 -#define ADIS16400_DIAG_STAT_POWER_LOW 0 - -/* GLOB_CMD */ -#define ADIS16400_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16400_GLOB_CMD_P_AUTO_NULL (1<<4) -#define ADIS16400_GLOB_CMD_FLASH_UPD (1<<3) -#define ADIS16400_GLOB_CMD_DAC_LATCH (1<<2) -#define ADIS16400_GLOB_CMD_FAC_CALIB (1<<1) -#define ADIS16400_GLOB_CMD_AUTO_NULL (1<<0) - -/* SLP_CNT */ -#define ADIS16400_SLP_CNT_POWER_OFF (1<<8) - -#define ADIS16334_RATE_DIV_SHIFT 8 -#define ADIS16334_RATE_INT_CLK BIT(0) - -#define ADIS16400_SPI_SLOW (u32)(300 * 1000) -#define ADIS16400_SPI_BURST (u32)(1000 * 1000) -#define ADIS16400_SPI_FAST (u32)(2000 * 1000) - -#define ADIS16400_HAS_PROD_ID BIT(0) -#define ADIS16400_NO_BURST BIT(1) -#define ADIS16400_HAS_SLOW_MODE BIT(2) -#define ADIS16400_HAS_SERIAL_NUMBER BIT(3) -#define ADIS16400_BURST_DIAG_STAT BIT(4) - -struct adis16400_state; - -struct adis16400_chip_info { - const struct iio_chan_spec *channels; - const int num_channels; - const long flags; - unsigned int gyro_scale_micro; - unsigned int accel_scale_micro; - int temp_scale_nano; - int temp_offset; - int (*set_freq)(struct adis16400_state *st, unsigned int freq); - int (*get_freq)(struct adis16400_state *st); -}; - -/** - * struct adis16400_state - device instance specific data - * @variant: chip variant info - * @filt_int: integer part of requested filter frequency - * @adis: adis device - **/ -struct adis16400_state { - struct adis16400_chip_info *variant; - int filt_int; - - struct adis adis; - unsigned long avail_scan_mask[2]; -}; - -/* At the moment triggers are only used for ring buffer - * filling. This may change! - */ - -enum { - ADIS16400_SCAN_SUPPLY, - ADIS16400_SCAN_GYRO_X, - ADIS16400_SCAN_GYRO_Y, - ADIS16400_SCAN_GYRO_Z, - ADIS16400_SCAN_ACC_X, - ADIS16400_SCAN_ACC_Y, - ADIS16400_SCAN_ACC_Z, - ADIS16400_SCAN_MAGN_X, - ADIS16400_SCAN_MAGN_Y, - ADIS16400_SCAN_MAGN_Z, - ADIS16400_SCAN_BARO, - ADIS16350_SCAN_TEMP_X, - ADIS16350_SCAN_TEMP_Y, - ADIS16350_SCAN_TEMP_Z, - ADIS16300_SCAN_INCLI_X, - ADIS16300_SCAN_INCLI_Y, - ADIS16400_SCAN_ADC, - ADIS16400_SCAN_TIMESTAMP, -}; - -#endif /* SPI_ADIS16400_H_ */