Skip to content

Commit

Permalink
staging: iio: gyro: new driver for ADIS16130 digital output gyros
Browse files Browse the repository at this point in the history
Signed-off-by: Barry Song <barry.song@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Barry Song authored and Greg Kroah-Hartman committed Nov 9, 2010
1 parent 1b2f99e commit 7a83f60
Show file tree
Hide file tree
Showing 4 changed files with 431 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/staging/iio/gyro/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ config ADIS16080
Say yes here to build support for Analog Devices adis16080/100 Yaw Rate
Gyroscope with SPI.

config ADIS16130
tristate "Analog Devices ADIS16130 High Precision Angular Rate Sensor driver"
depends on SPI
help
Say yes here to build support for Analog Devices ADIS16130 High Precision
Angular Rate Sensor driver.

config ADIS16260
tristate "Analog Devices ADIS16260 ADIS16265 Digital Gyroscope Sensor SPI driver"
depends on SPI
Expand Down
3 changes: 3 additions & 0 deletions drivers/staging/iio/gyro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ obj-$(CONFIG_ADIS16060) += adis16060.o
adis16080-y := adis16080_core.o
obj-$(CONFIG_ADIS16080) += adis16080.o

adis16130-y := adis16130_core.o
obj-$(CONFIG_ADIS16130) += adis16130.o

adis16260-y := adis16260_core.o
adis16260-$(CONFIG_IIO_RING_BUFFER) += adis16260_ring.o adis16260_trigger.o
obj-$(CONFIG_ADIS16260) += adis16260.o
Expand Down
108 changes: 108 additions & 0 deletions drivers/staging/iio/gyro/adis16130.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#ifndef SPI_ADIS16130_H_
#define SPI_ADIS16130_H_

#define ADIS16130_CON 0x0
#define ADIS16130_CON_RD (1 << 6)
#define ADIS16130_IOP 0x1
#define ADIS16130_IOP_ALL_RDY (1 << 3) /* 1 = data-ready signal low when unread data on all channels; */
#define ADIS16130_IOP_SYNC (1 << 0) /* 1 = synchronization enabled */
#define ADIS16130_RATEDATA 0x8 /* Gyroscope output, rate of rotation */
#define ADIS16130_TEMPDATA 0xA /* Temperature output */
#define ADIS16130_RATECS 0x28 /* Gyroscope channel setup */
#define ADIS16130_RATECS_EN (1 << 3) /* 1 = channel enable; */
#define ADIS16130_TEMPCS 0x2A /* Temperature channel setup */
#define ADIS16130_TEMPCS_EN (1 << 3)
#define ADIS16130_RATECONV 0x30
#define ADIS16130_TEMPCONV 0x32
#define ADIS16130_MODE 0x38
#define ADIS16130_MODE_24BIT (1 << 1) /* 1 = 24-bit resolution; */

#define ADIS16130_MAX_TX 4
#define ADIS16130_MAX_RX 4

/**
* struct adis16130_state - device instance specific data
* @us: actual spi_device to write data
* @work_trigger_to_ring: bh for triggered event handling
* @inter: used to check if new interrupt has been triggered
* @last_timestamp: passing timestamp from th to bh of interrupt handler
* @indio_dev: industrial I/O device structure
* @trig: data ready trigger registered with iio
* @tx: transmit buffer
* @rx: recieve buffer
* @buf_lock: mutex to protect tx and rx
**/
struct adis16130_state {
struct spi_device *us;
struct work_struct work_trigger_to_ring;
s64 last_timestamp;
struct iio_dev *indio_dev;
struct iio_trigger *trig;
u8 *tx;
u8 *rx;
u32 mode; /* 1: 24bits mode 0:16bits mode */
struct mutex buf_lock;
};

#if defined(CONFIG_IIO_RING_BUFFER) && defined(THIS_HAS_RING_BUFFER_SUPPORT)
/* At the moment triggers are only used for ring buffer
* filling. This may change!
*/

enum adis16130_scan {
ADIS16130_SCAN_GYRO,
ADIS16130_SCAN_TEMP,
};

void adis16130_remove_trigger(struct iio_dev *indio_dev);
int adis16130_probe_trigger(struct iio_dev *indio_dev);

ssize_t adis16130_read_data_from_ring(struct device *dev,
struct device_attribute *attr,
char *buf);


int adis16130_configure_ring(struct iio_dev *indio_dev);
void adis16130_unconfigure_ring(struct iio_dev *indio_dev);

int adis16130_initialize_ring(struct iio_ring_buffer *ring);
void adis16130_uninitialize_ring(struct iio_ring_buffer *ring);
#else /* CONFIG_IIO_RING_BUFFER */

static inline void adis16130_remove_trigger(struct iio_dev *indio_dev)
{
}

static inline int adis16130_probe_trigger(struct iio_dev *indio_dev)
{
return 0;
}

static inline ssize_t
adis16130_read_data_from_ring(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return 0;
}

static int adis16130_configure_ring(struct iio_dev *indio_dev)
{
return 0;
}

static inline void adis16130_unconfigure_ring(struct iio_dev *indio_dev)
{
}

static inline int adis16130_initialize_ring(struct iio_ring_buffer *ring)
{
return 0;
}

static inline void adis16130_uninitialize_ring(struct iio_ring_buffer *ring)
{
}

#endif /* CONFIG_IIO_RING_BUFFER */
#endif /* SPI_ADIS16130_H_ */
Loading

0 comments on commit 7a83f60

Please sign in to comment.