iio: imu: adis16400: move trigger handler into adis16400_core
PATCH 1/5 iio: imu: adis16400: move trigger handler into adis16400_core
From: Alexandru Ardelean <[email protected]>
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.
--- 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(-)
drivers/iio/imu/adis16400.h +0 -2
@@ -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 */
drivers/iio/imu/adis16400_buffer.c +0 -41
44 lines not on this page · raw message
drivers/iio/imu/adis16400_core.c +46 -0
58 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 2/5 iio: imu: adis: generalize burst mode support
From: Alexandru Ardelean <[email protected]>
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.
--- 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(-)
drivers/iio/imu/adis16400_buffer.c +3 -4
@@ -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;
drivers/iio/imu/adis16400_core.c +8 -0
@@ -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);
include/linux/iio/imu/adis.h +14 -0
@@ -21,6 +21,7 @@#define ADIS_REG_PAGE_ID 0x00struct 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,
Signature · 1 line
2.17.1
Re: [PATCH 2/5] iio: imu: adis: generalize burst mode support
Quoted 12 lines · On Fri, 22 Mar 2019 22:44:39 +0200 Alexandru Ardelean <[email protected]>…
From: Alexandru Ardelean <[email protected]>
Some variants in the ADIS16400 family support burst mode. This mechanism is implemented in the
adis16400_buffer.cfile.Some variants in ADIS16480 are also adding burst mode, which is functionally similar to ADIS16400, but with different parameters. To get there, a
adis_burststruct 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.
Quoted 6 lines
The trigger handler cannot be made generic, since it's very specific to each ADIS164XX family.
A future enhancement of this
adis_burstmode 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.
This sounds interesting. I'll wait to see why you need to disable it :) From what I recall there are definitely advantages to turning it off if you have a disconnected set of channels to read.
Been a long time since I fired one of these up, though I think the one I have still works so I might move it into a more regular test set.
Quoted 5 lines
When that will be implemented, both ADIS16400 & ADIS16480 will have the burst-mode enable-able/disable-able.
Signed-off-by Alexandru Ardelean <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 103 lines
--- 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(-)drivers/iio/imu/adis16400_buffer.c +3
-4@@ -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;drivers/iio/imu/adis16400_core.c +8
-0@@ -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);include/linux/iio/imu/adis.h +14
-0@@ -21,6 +21,7 @@#define ADIS_REG_PAGE_ID 0x00struct 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,
PATCH 3/5 iio: imu: adis16400: move burst logic to ADIS lib
In reply to Alexandru ArdeleanFrom: Alexandru Ardelean <[email protected]>
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.
--- 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
drivers/iio/imu/Makefile +0 -1
@@ -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
drivers/iio/imu/adis16400.h +0 -16
@@ -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_ */
drivers/iio/imu/adis16400_buffer.c deleted +0 -59
59 lines not on this page · raw message
drivers/iio/imu/adis16400_core.c +1 -1
@@ -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, };
drivers/iio/imu/adis_buffer.c +40 -0
@@ -20,6 +20,43 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/imu/adis.h> +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 );
Signature · 1 line
2.17.1
Re: [PATCH 3/5] iio: imu: adis16400: move burst logic to ADIS lib
Quoted 9 lines · On Fri, 22 Mar 2019 22:44:40 +0200 Alexandru Ardelean <[email protected]>…
From: Alexandru Ardelean <[email protected]>
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 <[email protected]>
Bit of fuzz in here when applying. Otherwise all looks fine.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 182 lines
--- 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.cdrivers/iio/imu/Makefile +0
-1@@ -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.odrivers/iio/imu/adis16400.h +0
-16@@ -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_ */ drivers/iio/imu/adis16400_buffer.c deleted +0
-59@@ -1,59 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include <linux/interrupt.h> -#include <linux/mutex.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/bitops.h> -#include <linux/export.h> - -#include <linux/iio/iio.h> -#include <linux/iio/buffer.h> -#include <linux/iio/triggered_buffer.h> -#include <linux/iio/trigger_consumer.h> - -#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 ; -}drivers/iio/imu/adis16400_core.c +1
-1@@ -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, };drivers/iio/imu/adis_buffer.c +40
-0@@ -20,6 +20,43 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/imu/adis.h> +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 );
PATCH 4/5 iio: imu: adis16400: rename adis16400_core.c -> adi16400.c
In reply to Alexandru ArdeleanFrom: Alexandru Ardelean <[email protected]>
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.
---
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%)drivers/iio/imu/Makefile +0 -1
@@ -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
drivers/iio/imu/adis16400.c renamed from drivers/iio/imu/adis16400_core.c +0 -0
Signature · 1 line
2.17.1
Re: [PATCH 4/5] iio: imu: adis16400: rename adis16400_core.c -> adi16400.c
Quoted 8 lines · On Fri, 22 Mar 2019 22:44:41 +0200 Alexandru Ardelean <[email protected]>…
From: Alexandru Ardelean <[email protected]>
This change does a simple 1-to-1 rename of the
adis16400_core.cfile. Now that theadis16400_buffer.cfile was removed, everything can be moved into a single driver file.
But first, this rename.Signed-off-by Alexandru Ardelean <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 22 lines
--- 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%)drivers/iio/imu/Makefile +0
-1@@ -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.odrivers/iio/imu/adis16400.c renamed from drivers/iio/imu/adis16400_core.c +0
-0
PATCH 5/5 iio: imu: adis16400: move adis16400.h into adis16400.c
In reply to Alexandru ArdeleanFrom: Alexandru Ardelean <[email protected]>
Final part of the re-organization. Move the adis16400.h into adis16400.c since it no longer needs to be shared among other files.
--- 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
drivers/iio/imu/adis16400.c +175 -1
@@ -32,8 +32,182 @@#include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> #include <linux/iio/trigger_consumer.h> +#include <linux/iio/imu/adis.h> + +#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
drivers/iio/imu/adis16400.h deleted +0 -197
197 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 5/5] iio: imu: adis16400: move adis16400.h into adis16400.c
Quoted 6 lines · On Fri, 22 Mar 2019 22:44:42 +0200 Alexandru Ardelean <[email protected]>…
From: Alexandru Ardelean <[email protected]>
Final part of the re-organization. Move the
adis16400.hintoadis16400.csince it no longer needs to be shared among other files.Signed-off-by Alexandru Ardelean <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 397 lines
--- 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.hdrivers/iio/imu/adis16400.c +175
-1@@ -32,8 +32,182 @@#include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> #include <linux/iio/trigger_consumer.h> +#include <linux/iio/imu/adis.h> + +#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 drivers/iio/imu/adis16400.h deleted +0
-197@@ -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 <[email protected]> -* Copyright (c) 2007 Jonathan Cameron <[email protected]> -* -* 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 <linux/iio/imu/adis.h> - -#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_ */
Quoted 8 lines · On Fri, 22 Mar 2019 22:44:38 +0200 Alexandru Ardelean <[email protected]>…
From: Alexandru Ardelean <[email protected]>
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_modefunction will be made more generic and moved into the ADIS library.Signed-off-by Alexandru Ardelean <[email protected]>
Seems fine to me.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 136 lines
--- 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(-)drivers/iio/imu/adis16400.h +0
-2@@ -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 */ drivers/iio/imu/adis16400_buffer.c +0
-41@@ -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 ; -}drivers/iio/imu/adis16400_core.c +46
-0@@ -31,6 +31,7 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> +#include <linux/iio/trigger_consumer.h> #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, \