aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/Kconfig7
-rw-r--r--drivers/iio/Makefile7
-rw-r--r--drivers/iio/imu/Kconfig11
-rw-r--r--drivers/iio/imu/Makefile8
-rw-r--r--drivers/iio/imu/adis.c (renamed from drivers/staging/iio/imu/adis.c)3
-rw-r--r--drivers/iio/imu/adis_buffer.c (renamed from drivers/staging/iio/imu/adis_buffer.c)3
-rw-r--r--drivers/iio/imu/adis_trigger.c (renamed from drivers/staging/iio/imu/adis_trigger.c)3
-rw-r--r--drivers/staging/iio/accel/adis16201_core.c2
-rw-r--r--drivers/staging/iio/accel/adis16203_core.c2
-rw-r--r--drivers/staging/iio/accel/adis16204_core.c2
-rw-r--r--drivers/staging/iio/accel/adis16209_core.c2
-rw-r--r--drivers/staging/iio/accel/adis16220.h2
-rw-r--r--drivers/staging/iio/accel/adis16240_core.c2
-rw-r--r--drivers/staging/iio/gyro/adis16260.h2
-rw-r--r--drivers/staging/iio/imu/Kconfig12
-rw-r--r--drivers/staging/iio/imu/Makefile5
-rw-r--r--drivers/staging/iio/imu/adis.h186
17 files changed, 37 insertions, 222 deletions
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 65ae734c607d..b2f963be3993 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -63,11 +63,12 @@ config IIO_CONSUMERS_PER_TRIGGER
63source "drivers/iio/accel/Kconfig" 63source "drivers/iio/accel/Kconfig"
64source "drivers/iio/adc/Kconfig" 64source "drivers/iio/adc/Kconfig"
65source "drivers/iio/amplifiers/Kconfig" 65source "drivers/iio/amplifiers/Kconfig"
66source "drivers/iio/light/Kconfig"
67source "drivers/iio/frequency/Kconfig"
68source "drivers/iio/dac/Kconfig"
69source "drivers/iio/common/Kconfig" 66source "drivers/iio/common/Kconfig"
67source "drivers/iio/dac/Kconfig"
68source "drivers/iio/frequency/Kconfig"
70source "drivers/iio/gyro/Kconfig" 69source "drivers/iio/gyro/Kconfig"
70source "drivers/iio/imu/Kconfig"
71source "drivers/iio/light/Kconfig"
71source "drivers/iio/magnetometer/Kconfig" 72source "drivers/iio/magnetometer/Kconfig"
72 73
73endif # IIO 74endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index 31d76a07ec65..a0e8cdd67e4d 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -14,9 +14,10 @@ obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o
14obj-y += accel/ 14obj-y += accel/
15obj-y += adc/ 15obj-y += adc/
16obj-y += amplifiers/ 16obj-y += amplifiers/
17obj-y += light/
18obj-y += frequency/
19obj-y += dac/
20obj-y += common/ 17obj-y += common/
18obj-y += dac/
21obj-y += gyro/ 19obj-y += gyro/
20obj-y += frequency/
21obj-y += imu/
22obj-y += light/
22obj-y += magnetometer/ 23obj-y += magnetometer/
diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig
new file mode 100644
index 000000000000..c24410c873c7
--- /dev/null
+++ b/drivers/iio/imu/Kconfig
@@ -0,0 +1,11 @@
1config IIO_ADIS_LIB
2 tristate
3 help
4 A set of IO helper functions for the Analog Devices ADIS* device family.
5
6config IIO_ADIS_LIB_BUFFER
7 bool
8 select IIO_TRIGGERED_BUFFER
9 help
10 A set of buffer helper functions for the Analog Devices ADIS* device
11 family.
diff --git a/drivers/iio/imu/Makefile b/drivers/iio/imu/Makefile
new file mode 100644
index 000000000000..97676ab5723d
--- /dev/null
+++ b/drivers/iio/imu/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for Inertial Measurement Units
3#
4
5adis_lib-y += adis.o
6adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_trigger.o
7adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_buffer.o
8obj-$(CONFIG_IIO_ADIS_LIB) += adis_lib.o
diff --git a/drivers/staging/iio/imu/adis.c b/drivers/iio/imu/adis.c
index 0bd21022e4c0..8259b774078f 100644
--- a/drivers/staging/iio/imu/adis.c
+++ b/drivers/iio/imu/adis.c
@@ -20,8 +20,7 @@
20#include <linux/iio/iio.h> 20#include <linux/iio/iio.h>
21#include <linux/iio/sysfs.h> 21#include <linux/iio/sysfs.h>
22#include <linux/iio/buffer.h> 22#include <linux/iio/buffer.h>
23 23#include <linux/iio/imu/adis.h>
24#include "adis.h"
25 24
26#define ADIS_MSC_CTRL_DATA_RDY_EN BIT(2) 25#define ADIS_MSC_CTRL_DATA_RDY_EN BIT(2)
27#define ADIS_MSC_CTRL_DATA_RDY_POL_HIGH BIT(1) 26#define ADIS_MSC_CTRL_DATA_RDY_POL_HIGH BIT(1)
diff --git a/drivers/staging/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index 342758c14d2b..a91b4cbdc73a 100644
--- a/drivers/staging/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -18,8 +18,7 @@
18#include <linux/iio/buffer.h> 18#include <linux/iio/buffer.h>
19#include <linux/iio/trigger_consumer.h> 19#include <linux/iio/trigger_consumer.h>
20#include <linux/iio/triggered_buffer.h> 20#include <linux/iio/triggered_buffer.h>
21 21#include <linux/iio/imu/adis.h>
22#include "adis.h"
23 22
24int adis_update_scan_mode(struct iio_dev *indio_dev, 23int adis_update_scan_mode(struct iio_dev *indio_dev,
25 const unsigned long *scan_mask) 24 const unsigned long *scan_mask)
diff --git a/drivers/staging/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
index 3e89b2e83708..5a24c9cac343 100644
--- a/drivers/staging/iio/imu/adis_trigger.c
+++ b/drivers/iio/imu/adis_trigger.c
@@ -14,8 +14,7 @@
14 14
15#include <linux/iio/iio.h> 15#include <linux/iio/iio.h>
16#include <linux/iio/trigger.h> 16#include <linux/iio/trigger.h>
17 17#include <linux/iio/imu/adis.h>
18#include "adis.h"
19 18
20static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, 19static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig,
21 bool state) 20 bool state)
diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c
index 833dd6b73bc3..ccdc8d23f6a3 100644
--- a/drivers/staging/iio/accel/adis16201_core.c
+++ b/drivers/staging/iio/accel/adis16201_core.c
@@ -18,9 +18,9 @@
18#include <linux/iio/iio.h> 18#include <linux/iio/iio.h>
19#include <linux/iio/sysfs.h> 19#include <linux/iio/sysfs.h>
20#include <linux/iio/buffer.h> 20#include <linux/iio/buffer.h>
21#include <linux/iio/imu/adis.h>
21 22
22#include "adis16201.h" 23#include "adis16201.h"
23#include "../imu/adis.h"
24 24
25static const u8 adis16201_addresses[] = { 25static const u8 adis16201_addresses[] = {
26 [ADIS16201_SCAN_ACC_X] = ADIS16201_XACCL_OFFS, 26 [ADIS16201_SCAN_ACC_X] = ADIS16201_XACCL_OFFS,
diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c
index f631e578fbd1..202985ea3531 100644
--- a/drivers/staging/iio/accel/adis16203_core.c
+++ b/drivers/staging/iio/accel/adis16203_core.c
@@ -18,9 +18,9 @@
18#include <linux/iio/iio.h> 18#include <linux/iio/iio.h>
19#include <linux/iio/sysfs.h> 19#include <linux/iio/sysfs.h>
20#include <linux/iio/buffer.h> 20#include <linux/iio/buffer.h>
21#include <linux/iio/imu/adis.h>
21 22
22#include "adis16203.h" 23#include "adis16203.h"
23#include "../imu/adis.h"
24 24
25#define DRIVER_NAME "adis16203" 25#define DRIVER_NAME "adis16203"
26 26
diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c
index dbec841ce30c..6dafad67cd23 100644
--- a/drivers/staging/iio/accel/adis16204_core.c
+++ b/drivers/staging/iio/accel/adis16204_core.c
@@ -21,9 +21,9 @@
21#include <linux/iio/iio.h> 21#include <linux/iio/iio.h>
22#include <linux/iio/sysfs.h> 22#include <linux/iio/sysfs.h>
23#include <linux/iio/buffer.h> 23#include <linux/iio/buffer.h>
24#include <linux/iio/imu/adis.h>
24 25
25#include "adis16204.h" 26#include "adis16204.h"
26#include "../imu/adis.h"
27 27
28/* Unique to this driver currently */ 28/* Unique to this driver currently */
29 29
diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c
index f9f9d582b32d..d2921c30a8bb 100644
--- a/drivers/staging/iio/accel/adis16209_core.c
+++ b/drivers/staging/iio/accel/adis16209_core.c
@@ -19,9 +19,9 @@
19#include <linux/iio/iio.h> 19#include <linux/iio/iio.h>
20#include <linux/iio/sysfs.h> 20#include <linux/iio/sysfs.h>
21#include <linux/iio/buffer.h> 21#include <linux/iio/buffer.h>
22#include <linux/iio/imu/adis.h>
22 23
23#include "adis16209.h" 24#include "adis16209.h"
24#include "../imu/adis.h"
25 25
26static const u8 adis16209_addresses[8][1] = { 26static const u8 adis16209_addresses[8][1] = {
27 [ADIS16209_SCAN_SUPPLY] = { }, 27 [ADIS16209_SCAN_SUPPLY] = { },
diff --git a/drivers/staging/iio/accel/adis16220.h b/drivers/staging/iio/accel/adis16220.h
index 7cc4d2f3ec28..a894ad7fb26d 100644
--- a/drivers/staging/iio/accel/adis16220.h
+++ b/drivers/staging/iio/accel/adis16220.h
@@ -1,7 +1,7 @@
1#ifndef SPI_ADIS16220_H_ 1#ifndef SPI_ADIS16220_H_
2#define SPI_ADIS16220_H_ 2#define SPI_ADIS16220_H_
3 3
4#include "../imu/adis.h" 4#include <linux/iio/imu/adis.h>
5 5
6#define ADIS16220_STARTUP_DELAY 220 /* ms */ 6#define ADIS16220_STARTUP_DELAY 220 /* ms */
7 7
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c
index 3d1a8a9921ad..d098b49cc18b 100644
--- a/drivers/staging/iio/accel/adis16240_core.c
+++ b/drivers/staging/iio/accel/adis16240_core.c
@@ -22,9 +22,9 @@
22#include <linux/iio/iio.h> 22#include <linux/iio/iio.h>
23#include <linux/iio/sysfs.h> 23#include <linux/iio/sysfs.h>
24#include <linux/iio/buffer.h> 24#include <linux/iio/buffer.h>
25#include <linux/iio/imu/adis.h>
25 26
26#include "adis16240.h" 27#include "adis16240.h"
27#include "../imu/adis.h"
28 28
29static ssize_t adis16240_spi_read_signed(struct device *dev, 29static ssize_t adis16240_spi_read_signed(struct device *dev,
30 struct device_attribute *attr, 30 struct device_attribute *attr,
diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h
index ea5eba205bbf..df3c0b7e954a 100644
--- a/drivers/staging/iio/gyro/adis16260.h
+++ b/drivers/staging/iio/gyro/adis16260.h
@@ -2,7 +2,7 @@
2#define SPI_ADIS16260_H_ 2#define SPI_ADIS16260_H_
3 3
4#include "adis16260_platform_data.h" 4#include "adis16260_platform_data.h"
5#include "../imu/adis.h" 5#include <linux/iio/imu/adis.h>
6 6
7#define ADIS16260_STARTUP_DELAY 220 /* ms */ 7#define ADIS16260_STARTUP_DELAY 220 /* ms */
8 8
diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig
index 2c564edeb172..2c2f47de2630 100644
--- a/drivers/staging/iio/imu/Kconfig
+++ b/drivers/staging/iio/imu/Kconfig
@@ -15,15 +15,3 @@ config ADIS16400
15 (adis16400 series also have magnetometers). 15 (adis16400 series also have magnetometers).
16 16
17endmenu 17endmenu
18
19config IIO_ADIS_LIB
20 tristate
21 help
22 A set of IO helper functions for the Analog Devices ADIS* device family.
23
24config IIO_ADIS_LIB_BUFFER
25 bool
26 select IIO_TRIGGERED_BUFFER
27 help
28 A set of buffer helper functions for the Analog Devices ADIS* device
29 family.
diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile
index 65dafba1e5df..3400a13d1522 100644
--- a/drivers/staging/iio/imu/Makefile
+++ b/drivers/staging/iio/imu/Makefile
@@ -5,8 +5,3 @@
5adis16400-y := adis16400_core.o 5adis16400-y := adis16400_core.o
6adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o adis16400_trigger.o 6adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o adis16400_trigger.o
7obj-$(CONFIG_ADIS16400) += adis16400.o 7obj-$(CONFIG_ADIS16400) += adis16400.o
8
9adis_lib-y += adis.o
10adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_trigger.o
11adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_buffer.o
12obj-$(CONFIG_IIO_ADIS_LIB) += adis_lib.o
diff --git a/drivers/staging/iio/imu/adis.h b/drivers/staging/iio/imu/adis.h
deleted file mode 100644
index 8c3304d44b97..000000000000
--- a/drivers/staging/iio/imu/adis.h
+++ /dev/null
@@ -1,186 +0,0 @@
1/*
2 * Common library for ADIS16XXX devices
3 *
4 * Copyright 2012 Analog Devices Inc.
5 * Author: Lars-Peter Clausen <lars@metafoo.de>
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10#ifndef __IIO_ADIS_H__
11#define __IIO_ADIS_H__
12
13#include <linux/spi/spi.h>
14#include <linux/interrupt.h>
15#include <linux/iio/types.h>
16
17#define ADIS_WRITE_REG(reg) (0x80 | (reg))
18#define ADIS_READ_REG(reg) (reg)
19
20/**
21 * struct adis_data - ADIS chip variant specific data
22 * @read_delay: SPI delay for read operations in us
23 * @write_delay: SPI delay for write operations in us
24 * @glob_cmd_reg: Register address of the GLOB_CMD register
25 * @msc_ctrl_reg: Register address of the MSC_CTRL register
26 * @diag_stat_reg: Register address of the DIAG_STAT register
27 * @status_error_msgs: Array of error messgaes
28 * @status_error_mask:
29 */
30struct adis_data {
31 unsigned int read_delay;
32 unsigned int write_delay;
33
34 unsigned int glob_cmd_reg;
35 unsigned int msc_ctrl_reg;
36 unsigned int diag_stat_reg;
37
38 unsigned int self_test_mask;
39 unsigned int startup_delay;
40
41 const char * const *status_error_msgs;
42 unsigned int status_error_mask;
43};
44
45struct adis {
46 struct spi_device *spi;
47 struct iio_trigger *trig;
48
49 const struct adis_data *data;
50
51 struct mutex txrx_lock;
52 struct spi_message msg;
53 struct spi_transfer *xfer;
54 void *buffer;
55
56 uint8_t tx[8] ____cacheline_aligned;
57 uint8_t rx[4];
58};
59
60int adis_init(struct adis *adis, struct iio_dev *indio_dev,
61 struct spi_device *spi, const struct adis_data *data);
62int adis_reset(struct adis *adis);
63
64int adis_write_reg_8(struct adis *adis, unsigned int reg, uint8_t val);
65int adis_write_reg_16(struct adis *adis, unsigned int reg, uint16_t val);
66int adis_read_reg_16(struct adis *adis, unsigned int reg, uint16_t *val);
67
68int adis_enable_irq(struct adis *adis, bool enable);
69int adis_check_status(struct adis *adis);
70
71int adis_initial_startup(struct adis *adis);
72
73int adis_single_conversion(struct iio_dev *indio_dev,
74 const struct iio_chan_spec *chan, unsigned int error_mask,
75 int *val);
76
77#define ADIS_VOLTAGE_CHAN(addr, si, chan, name, bits) { \
78 .type = IIO_VOLTAGE, \
79 .indexed = 1, \
80 .channel = (chan), \
81 .extend_name = name, \
82 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
83 IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
84 .address = (addr), \
85 .scan_index = (si), \
86 .scan_type = { \
87 .sign = 'u', \
88 .realbits = (bits), \
89 .storagebits = 16, \
90 .endianness = IIO_BE, \
91 }, \
92}
93
94#define ADIS_SUPPLY_CHAN(addr, si, bits) \
95 ADIS_VOLTAGE_CHAN(addr, si, 0, "supply", bits)
96
97#define ADIS_AUX_ADC_CHAN(addr, si, bits) \
98 ADIS_VOLTAGE_CHAN(addr, si, 1, NULL, bits)
99
100#define ADIS_TEMP_CHAN(addr, si, bits) { \
101 .type = IIO_TEMP, \
102 .indexed = 1, \
103 .channel = 0, \
104 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
105 IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
106 IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, \
107 .address = (addr), \
108 .scan_index = (si), \
109 .scan_type = { \
110 .sign = 'u', \
111 .realbits = (bits), \
112 .storagebits = 16, \
113 .endianness = IIO_BE, \
114 }, \
115}
116
117#define ADIS_MOD_CHAN(_type, mod, addr, si, info, bits) { \
118 .type = (_type), \
119 .modified = 1, \
120 .channel2 = IIO_MOD_ ## mod, \
121 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
122 IIO_CHAN_INFO_SCALE_SHARED_BIT | \
123 info, \
124 .address = (addr), \
125 .scan_index = (si), \
126 .scan_type = { \
127 .sign = 's', \
128 .realbits = (bits), \
129 .storagebits = 16, \
130 .endianness = IIO_BE, \
131 }, \
132}
133
134#define ADIS_ACCEL_CHAN(mod, addr, si, info, bits) \
135 ADIS_MOD_CHAN(IIO_ACCEL, mod, addr, si, info, bits)
136
137#define ADIS_GYRO_CHAN(mod, addr, si, info, bits) \
138 ADIS_MOD_CHAN(IIO_ANGL_VEL, mod, addr, si, info, bits)
139
140#define ADIS_INCLI_CHAN(mod, addr, si, info, bits) \
141 ADIS_MOD_CHAN(IIO_INCLI, mod, addr, si, info, bits)
142
143#define ADIS_ROT_CHAN(mod, addr, si, info, bits) \
144 ADIS_MOD_CHAN(IIO_ROT, mod, addr, si, info, bits)
145
146#ifdef CONFIG_IIO_ADIS_LIB_BUFFER
147
148int adis_setup_buffer_and_trigger(struct adis *adis,
149 struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *));
150void adis_cleanup_buffer_and_trigger(struct adis *adis,
151 struct iio_dev *indio_dev);
152
153int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev);
154void adis_remove_trigger(struct adis *adis);
155
156int adis_update_scan_mode(struct iio_dev *indio_dev,
157 const unsigned long *scan_mask);
158
159#else /* CONFIG_IIO_BUFFER */
160
161static inline int adis_setup_buffer_and_trigger(struct adis *adis,
162 struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *))
163{
164 return 0;
165}
166
167static inline void adis_cleanup_buffer_and_trigger(struct adis *adis,
168 struct iio_dev *indio_dev)
169{
170}
171
172static inline int adis_probe_trigger(struct adis *adis,
173 struct iio_dev *indio_dev)
174{
175 return 0;
176}
177
178static inline void adis_remove_trigger(struct adis *adis)
179{
180}
181
182#define adis_update_scan_mode NULL
183
184#endif /* CONFIG_IIO_BUFFER */
185
186#endif