aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hid-sensor-hub.h38
-rw-r--r--include/linux/hid-sensor-ids.h9
-rw-r--r--include/linux/iio/buffer.h13
-rw-r--r--include/linux/iio/common/st_sensors.h280
-rw-r--r--include/linux/iio/common/st_sensors_i2c.h20
-rw-r--r--include/linux/iio/common/st_sensors_spi.h20
-rw-r--r--include/linux/iio/consumer.h14
-rw-r--r--include/linux/iio/driver.h9
-rw-r--r--include/linux/iio/gyro/itg3200.h154
-rw-r--r--include/linux/iio/trigger.h5
-rw-r--r--include/linux/pci_ids.h10
-rw-r--r--include/linux/platform_data/invensense_mpu6050.h31
-rw-r--r--include/linux/platform_data/tsl2563.h8
-rw-r--r--include/linux/spi/spi.h44
14 files changed, 630 insertions, 25 deletions
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 0aa5f4c42ae6..ecefb7311dd6 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -157,4 +157,42 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
157*/ 157*/
158int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, 158int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
159 u32 field_index, s32 *value); 159 u32 field_index, s32 *value);
160
161/* hid-sensor-attributes */
162
163/* Common hid sensor iio structure */
164struct hid_sensor_common {
165 struct hid_sensor_hub_device *hsdev;
166 struct platform_device *pdev;
167 unsigned usage_id;
168 bool data_ready;
169 struct hid_sensor_hub_attribute_info poll;
170 struct hid_sensor_hub_attribute_info report_state;
171 struct hid_sensor_hub_attribute_info power_state;
172 struct hid_sensor_hub_attribute_info sensitivity;
173};
174
175/*Convert from hid unit expo to regular exponent*/
176static inline int hid_sensor_convert_exponent(int unit_expo)
177{
178 if (unit_expo < 0x08)
179 return unit_expo;
180 else if (unit_expo <= 0x0f)
181 return -(0x0f-unit_expo+1);
182 else
183 return 0;
184}
185
186int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
187 u32 usage_id,
188 struct hid_sensor_common *st);
189int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
190 int val1, int val2);
191int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
192 int *val1, int *val2);
193int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
194 int val1, int val2);
195int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
196 int *val1, int *val2);
197
160#endif 198#endif
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 55f277372fed..6f24446e7669 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -66,6 +66,15 @@
66#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS 0x200486 66#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS 0x200486
67#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS 0x200487 67#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS 0x200487
68 68
69/* Time (2000a0) */
70#define HID_USAGE_SENSOR_TIME 0x2000a0
71#define HID_USAGE_SENSOR_TIME_YEAR 0x200521
72#define HID_USAGE_SENSOR_TIME_MONTH 0x200522
73#define HID_USAGE_SENSOR_TIME_DAY 0x200523
74#define HID_USAGE_SENSOR_TIME_HOUR 0x200525
75#define HID_USAGE_SENSOR_TIME_MINUTE 0x200526
76#define HID_USAGE_SENSOR_TIME_SECOND 0x200527
77
69/* Units */ 78/* Units */
70#define HID_USAGE_SENSOR_UNITS_NOT_SPECIFIED 0x00 79#define HID_USAGE_SENSOR_UNITS_NOT_SPECIFIED 0x00
71#define HID_USAGE_SENSOR_UNITS_LUX 0x01 80#define HID_USAGE_SENSOR_UNITS_LUX 0x01
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index f3eea18fdf46..2bac0eb8948d 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -103,19 +103,6 @@ int iio_update_buffers(struct iio_dev *indio_dev,
103 **/ 103 **/
104void iio_buffer_init(struct iio_buffer *buffer); 104void iio_buffer_init(struct iio_buffer *buffer);
105 105
106/**
107 * __iio_update_buffer() - update common elements of buffers
108 * @buffer: buffer that is the event source
109 * @bytes_per_datum: size of individual datum including timestamp
110 * @length: number of datums in buffer
111 **/
112static inline void __iio_update_buffer(struct iio_buffer *buffer,
113 int bytes_per_datum, int length)
114{
115 buffer->bytes_per_datum = bytes_per_datum;
116 buffer->length = length;
117}
118
119int iio_scan_mask_query(struct iio_dev *indio_dev, 106int iio_scan_mask_query(struct iio_dev *indio_dev,
120 struct iio_buffer *buffer, int bit); 107 struct iio_buffer *buffer, int bit);
121 108
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
new file mode 100644
index 000000000000..1f86a97ab2e2
--- /dev/null
+++ b/include/linux/iio/common/st_sensors.h
@@ -0,0 +1,280 @@
1/*
2 * STMicroelectronics sensors library driver
3 *
4 * Copyright 2012-2013 STMicroelectronics Inc.
5 *
6 * Denis Ciocca <denis.ciocca@st.com>
7 *
8 * Licensed under the GPL-2.
9 */
10
11#ifndef ST_SENSORS_H
12#define ST_SENSORS_H
13
14#include <linux/i2c.h>
15#include <linux/spi/spi.h>
16#include <linux/irqreturn.h>
17#include <linux/iio/trigger.h>
18
19#define ST_SENSORS_TX_MAX_LENGTH 2
20#define ST_SENSORS_RX_MAX_LENGTH 6
21
22#define ST_SENSORS_ODR_LIST_MAX 10
23#define ST_SENSORS_FULLSCALE_AVL_MAX 10
24
25#define ST_SENSORS_NUMBER_ALL_CHANNELS 4
26#define ST_SENSORS_NUMBER_DATA_CHANNELS 3
27#define ST_SENSORS_ENABLE_ALL_AXIS 0x07
28#define ST_SENSORS_BYTE_FOR_CHANNEL 2
29#define ST_SENSORS_SCAN_X 0
30#define ST_SENSORS_SCAN_Y 1
31#define ST_SENSORS_SCAN_Z 2
32#define ST_SENSORS_DEFAULT_12_REALBITS 12
33#define ST_SENSORS_DEFAULT_16_REALBITS 16
34#define ST_SENSORS_DEFAULT_POWER_ON_VALUE 0x01
35#define ST_SENSORS_DEFAULT_POWER_OFF_VALUE 0x00
36#define ST_SENSORS_DEFAULT_WAI_ADDRESS 0x0f
37#define ST_SENSORS_DEFAULT_AXIS_ADDR 0x20
38#define ST_SENSORS_DEFAULT_AXIS_MASK 0x07
39#define ST_SENSORS_DEFAULT_AXIS_N_BIT 3
40
41#define ST_SENSORS_MAX_NAME 17
42#define ST_SENSORS_MAX_4WAI 7
43
44#define ST_SENSORS_LSM_CHANNELS(device_type, index, mod, endian, bits, addr) \
45{ \
46 .type = device_type, \
47 .modified = 1, \
48 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
49 IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
50 .scan_index = index, \
51 .channel2 = mod, \
52 .address = addr, \
53 .scan_type = { \
54 .sign = 's', \
55 .realbits = bits, \
56 .shift = 16 - bits, \
57 .storagebits = 16, \
58 .endianness = endian, \
59 }, \
60}
61
62#define ST_SENSOR_DEV_ATTR_SAMP_FREQ() \
63 IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, \
64 st_sensors_sysfs_get_sampling_frequency, \
65 st_sensors_sysfs_set_sampling_frequency)
66
67#define ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL() \
68 IIO_DEV_ATTR_SAMP_FREQ_AVAIL( \
69 st_sensors_sysfs_sampling_frequency_avail)
70
71#define ST_SENSORS_DEV_ATTR_SCALE_AVAIL(name) \
72 IIO_DEVICE_ATTR(name, S_IRUGO, \
73 st_sensors_sysfs_scale_avail, NULL , 0);
74
75struct st_sensor_odr_avl {
76 unsigned int hz;
77 u8 value;
78};
79
80struct st_sensor_odr {
81 u8 addr;
82 u8 mask;
83 struct st_sensor_odr_avl odr_avl[ST_SENSORS_ODR_LIST_MAX];
84};
85
86struct st_sensor_power {
87 u8 addr;
88 u8 mask;
89 u8 value_off;
90 u8 value_on;
91};
92
93struct st_sensor_axis {
94 u8 addr;
95 u8 mask;
96};
97
98struct st_sensor_fullscale_avl {
99 unsigned int num;
100 u8 value;
101 unsigned int gain;
102 unsigned int gain2;
103};
104
105struct st_sensor_fullscale {
106 u8 addr;
107 u8 mask;
108 struct st_sensor_fullscale_avl fs_avl[ST_SENSORS_FULLSCALE_AVL_MAX];
109};
110
111/**
112 * struct st_sensor_bdu - ST sensor device block data update
113 * @addr: address of the register.
114 * @mask: mask to write the block data update flag.
115 */
116struct st_sensor_bdu {
117 u8 addr;
118 u8 mask;
119};
120
121/**
122 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
123 * @addr: address of the register.
124 * @mask: mask to write the on/off value.
125 * struct ig1 - represents the Interrupt Generator 1 of sensors.
126 * @en_addr: address of the enable ig1 register.
127 * @en_mask: mask to write the on/off value for enable.
128 */
129struct st_sensor_data_ready_irq {
130 u8 addr;
131 u8 mask;
132 struct {
133 u8 en_addr;
134 u8 en_mask;
135 } ig1;
136};
137
138/**
139 * struct st_sensor_transfer_buffer - ST sensor device I/O buffer
140 * @buf_lock: Mutex to protect rx and tx buffers.
141 * @tx_buf: Buffer used by SPI transfer function to send data to the sensors.
142 * This buffer is used to avoid DMA not-aligned issue.
143 * @rx_buf: Buffer used by SPI transfer to receive data from sensors.
144 * This buffer is used to avoid DMA not-aligned issue.
145 */
146struct st_sensor_transfer_buffer {
147 struct mutex buf_lock;
148 u8 rx_buf[ST_SENSORS_RX_MAX_LENGTH];
149 u8 tx_buf[ST_SENSORS_TX_MAX_LENGTH] ____cacheline_aligned;
150};
151
152/**
153 * struct st_sensor_transfer_function - ST sensor device I/O function
154 * @read_byte: Function used to read one byte.
155 * @write_byte: Function used to write one byte.
156 * @read_multiple_byte: Function used to read multiple byte.
157 */
158struct st_sensor_transfer_function {
159 int (*read_byte) (struct st_sensor_transfer_buffer *tb,
160 struct device *dev, u8 reg_addr, u8 *res_byte);
161 int (*write_byte) (struct st_sensor_transfer_buffer *tb,
162 struct device *dev, u8 reg_addr, u8 data);
163 int (*read_multiple_byte) (struct st_sensor_transfer_buffer *tb,
164 struct device *dev, u8 reg_addr, int len, u8 *data,
165 bool multiread_bit);
166};
167
168/**
169 * struct st_sensors - ST sensors list
170 * @wai: Contents of WhoAmI register.
171 * @sensors_supported: List of supported sensors by struct itself.
172 * @ch: IIO channels for the sensor.
173 * @odr: Output data rate register and ODR list available.
174 * @pw: Power register of the sensor.
175 * @enable_axis: Enable one or more axis of the sensor.
176 * @fs: Full scale register and full scale list available.
177 * @bdu: Block data update register.
178 * @drdy_irq: Data ready register of the sensor.
179 * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read.
180 * @bootime: samples to discard when sensor passing from power-down to power-up.
181 */
182struct st_sensors {
183 u8 wai;
184 char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME];
185 struct iio_chan_spec *ch;
186 struct st_sensor_odr odr;
187 struct st_sensor_power pw;
188 struct st_sensor_axis enable_axis;
189 struct st_sensor_fullscale fs;
190 struct st_sensor_bdu bdu;
191 struct st_sensor_data_ready_irq drdy_irq;
192 bool multi_read_bit;
193 unsigned int bootime;
194};
195
196/**
197 * struct st_sensor_data - ST sensor device status
198 * @dev: Pointer to instance of struct device (I2C or SPI).
199 * @trig: The trigger in use by the core driver.
200 * @sensor: Pointer to the current sensor struct in use.
201 * @current_fullscale: Maximum range of measure by the sensor.
202 * @enabled: Status of the sensor (false->off, true->on).
203 * @multiread_bit: Use or not particular bit for [I2C/SPI] multiread.
204 * @buffer_data: Data used by buffer part.
205 * @odr: Output data rate of the sensor [Hz].
206 * @get_irq_data_ready: Function to get the IRQ used for data ready signal.
207 * @tf: Transfer function structure used by I/O operations.
208 * @tb: Transfer buffers and mutex used by I/O operations.
209 */
210struct st_sensor_data {
211 struct device *dev;
212 struct iio_trigger *trig;
213 struct st_sensors *sensor;
214 struct st_sensor_fullscale_avl *current_fullscale;
215
216 bool enabled;
217 bool multiread_bit;
218
219 char *buffer_data;
220
221 unsigned int odr;
222
223 unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev);
224
225 const struct st_sensor_transfer_function *tf;
226 struct st_sensor_transfer_buffer tb;
227};
228
229#ifdef CONFIG_IIO_BUFFER
230int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
231 const struct iio_trigger_ops *trigger_ops);
232
233void st_sensors_deallocate_trigger(struct iio_dev *indio_dev);
234
235irqreturn_t st_sensors_trigger_handler(int irq, void *p);
236
237int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf);
238#else
239static inline int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
240 const struct iio_trigger_ops *trigger_ops)
241{
242 return 0;
243}
244static inline void st_sensors_deallocate_trigger(struct iio_dev *indio_dev)
245{
246 return;
247}
248#endif
249
250int st_sensors_init_sensor(struct iio_dev *indio_dev);
251
252int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable);
253
254int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable);
255
256int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr);
257
258int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable);
259
260int st_sensors_set_fullscale_by_gain(struct iio_dev *indio_dev, int scale);
261
262int st_sensors_read_info_raw(struct iio_dev *indio_dev,
263 struct iio_chan_spec const *ch, int *val);
264
265int st_sensors_check_device_support(struct iio_dev *indio_dev,
266 int num_sensors_list, const struct st_sensors *sensors);
267
268ssize_t st_sensors_sysfs_get_sampling_frequency(struct device *dev,
269 struct device_attribute *attr, char *buf);
270
271ssize_t st_sensors_sysfs_set_sampling_frequency(struct device *dev,
272 struct device_attribute *attr, const char *buf, size_t size);
273
274ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
275 struct device_attribute *attr, char *buf);
276
277ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
278 struct device_attribute *attr, char *buf);
279
280#endif /* ST_SENSORS_H */
diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
new file mode 100644
index 000000000000..67d845385ae2
--- /dev/null
+++ b/include/linux/iio/common/st_sensors_i2c.h
@@ -0,0 +1,20 @@
1/*
2 * STMicroelectronics sensors i2c library driver
3 *
4 * Copyright 2012-2013 STMicroelectronics Inc.
5 *
6 * Denis Ciocca <denis.ciocca@st.com>
7 *
8 * Licensed under the GPL-2.
9 */
10
11#ifndef ST_SENSORS_I2C_H
12#define ST_SENSORS_I2C_H
13
14#include <linux/i2c.h>
15#include <linux/iio/common/st_sensors.h>
16
17void st_sensors_i2c_configure(struct iio_dev *indio_dev,
18 struct i2c_client *client, struct st_sensor_data *sdata);
19
20#endif /* ST_SENSORS_I2C_H */
diff --git a/include/linux/iio/common/st_sensors_spi.h b/include/linux/iio/common/st_sensors_spi.h
new file mode 100644
index 000000000000..d964a3563dc6
--- /dev/null
+++ b/include/linux/iio/common/st_sensors_spi.h
@@ -0,0 +1,20 @@
1/*
2 * STMicroelectronics sensors spi library driver
3 *
4 * Copyright 2012-2013 STMicroelectronics Inc.
5 *
6 * Denis Ciocca <denis.ciocca@st.com>
7 *
8 * Licensed under the GPL-2.
9 */
10
11#ifndef ST_SENSORS_SPI_H
12#define ST_SENSORS_SPI_H
13
14#include <linux/spi/spi.h>
15#include <linux/iio/common/st_sensors.h>
16
17void st_sensors_spi_configure(struct iio_dev *indio_dev,
18 struct spi_device *spi, struct st_sensor_data *sdata);
19
20#endif /* ST_SENSORS_SPI_H */
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 16c35ac045bd..833926c91aa8 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -15,6 +15,7 @@
15 15
16struct iio_dev; 16struct iio_dev;
17struct iio_chan_spec; 17struct iio_chan_spec;
18struct device;
18 19
19/** 20/**
20 * struct iio_channel - everything needed for a consumer to use a channel 21 * struct iio_channel - everything needed for a consumer to use a channel
@@ -30,14 +31,15 @@ struct iio_channel {
30 31
31/** 32/**
32 * iio_channel_get() - get description of all that is needed to access channel. 33 * iio_channel_get() - get description of all that is needed to access channel.
33 * @name: Unique name of the device as provided in the iio_map 34 * @dev: Pointer to consumer device. Device name must match
35 * the name of the device as provided in the iio_map
34 * with which the desired provider to consumer mapping 36 * with which the desired provider to consumer mapping
35 * was registered. 37 * was registered.
36 * @consumer_channel: Unique name to identify the channel on the consumer 38 * @consumer_channel: Unique name to identify the channel on the consumer
37 * side. This typically describes the channels use within 39 * side. This typically describes the channels use within
38 * the consumer. E.g. 'battery_voltage' 40 * the consumer. E.g. 'battery_voltage'
39 */ 41 */
40struct iio_channel *iio_channel_get(const char *name, 42struct iio_channel *iio_channel_get(struct device *dev,
41 const char *consumer_channel); 43 const char *consumer_channel);
42 44
43/** 45/**
@@ -48,14 +50,14 @@ void iio_channel_release(struct iio_channel *chan);
48 50
49/** 51/**
50 * iio_channel_get_all() - get all channels associated with a client 52 * iio_channel_get_all() - get all channels associated with a client
51 * @name: name of consumer device. 53 * @dev: Pointer to consumer device.
52 * 54 *
53 * Returns an array of iio_channel structures terminated with one with 55 * Returns an array of iio_channel structures terminated with one with
54 * null iio_dev pointer. 56 * null iio_dev pointer.
55 * This function is used by fairly generic consumers to get all the 57 * This function is used by fairly generic consumers to get all the
56 * channels registered as having this consumer. 58 * channels registered as having this consumer.
57 */ 59 */
58struct iio_channel *iio_channel_get_all(const char *name); 60struct iio_channel *iio_channel_get_all(struct device *dev);
59 61
60/** 62/**
61 * iio_channel_release_all() - reverse iio_channel_get_all 63 * iio_channel_release_all() - reverse iio_channel_get_all
@@ -66,7 +68,7 @@ void iio_channel_release_all(struct iio_channel *chan);
66struct iio_cb_buffer; 68struct iio_cb_buffer;
67/** 69/**
68 * iio_channel_get_all_cb() - register callback for triggered capture 70 * iio_channel_get_all_cb() - register callback for triggered capture
69 * @name: Name of client device. 71 * @dev: Pointer to client device.
70 * @cb: Callback function. 72 * @cb: Callback function.
71 * @private: Private data passed to callback. 73 * @private: Private data passed to callback.
72 * 74 *
@@ -74,7 +76,7 @@ struct iio_cb_buffer;
74 * So if the channels requested come from different devices this will 76 * So if the channels requested come from different devices this will
75 * fail. 77 * fail.
76 */ 78 */
77struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, 79struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
78 int (*cb)(u8 *data, 80 int (*cb)(u8 *data,
79 void *private), 81 void *private),
80 void *private); 82 void *private);
diff --git a/include/linux/iio/driver.h b/include/linux/iio/driver.h
index a4f8b2e05af5..7dfb10ee2669 100644
--- a/include/linux/iio/driver.h
+++ b/include/linux/iio/driver.h
@@ -22,13 +22,10 @@ int iio_map_array_register(struct iio_dev *indio_dev,
22 struct iio_map *map); 22 struct iio_map *map);
23 23
24/** 24/**
25 * iio_map_array_unregister() - tell the core to remove consumer mappings 25 * iio_map_array_unregister() - tell the core to remove consumer mappings for
26 * the given provider device
26 * @indio_dev: provider device 27 * @indio_dev: provider device
27 * @map: array of mappings to remove. Note these must have same memory
28 * addresses as those originally added not just equal parameter
29 * values.
30 */ 28 */
31int iio_map_array_unregister(struct iio_dev *indio_dev, 29int iio_map_array_unregister(struct iio_dev *indio_dev);
32 struct iio_map *map);
33 30
34#endif 31#endif
diff --git a/include/linux/iio/gyro/itg3200.h b/include/linux/iio/gyro/itg3200.h
new file mode 100644
index 000000000000..c53f16914b77
--- /dev/null
+++ b/include/linux/iio/gyro/itg3200.h
@@ -0,0 +1,154 @@
1/*
2 * itg3200.h -- support InvenSense ITG3200
3 * Digital 3-Axis Gyroscope driver
4 *
5 * Copyright (c) 2011 Christian Strobel <christian.strobel@iis.fraunhofer.de>
6 * Copyright (c) 2011 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
7 * Copyright (c) 2012 Thorsten Nowak <thorsten.nowak@iis.fraunhofer.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef I2C_ITG3200_H_
15#define I2C_ITG3200_H_
16
17#include <linux/iio/iio.h>
18
19/* Register with I2C address (34h) */
20#define ITG3200_REG_ADDRESS 0x00
21
22/* Sample rate divider
23 * Range: 0 to 255
24 * Default value: 0x00 */
25#define ITG3200_REG_SAMPLE_RATE_DIV 0x15
26
27/* Digital low pass filter settings */
28#define ITG3200_REG_DLPF 0x16
29/* DLPF full scale range */
30#define ITG3200_DLPF_FS_SEL_2000 0x18
31/* Bandwidth (Hz) and internal sample rate
32 * (kHz) of DLPF */
33#define ITG3200_DLPF_256_8 0x00
34#define ITG3200_DLPF_188_1 0x01
35#define ITG3200_DLPF_98_1 0x02
36#define ITG3200_DLPF_42_1 0x03
37#define ITG3200_DLPF_20_1 0x04
38#define ITG3200_DLPF_10_1 0x05
39#define ITG3200_DLPF_5_1 0x06
40
41#define ITG3200_DLPF_CFG_MASK 0x07
42
43/* Configuration for interrupt operations */
44#define ITG3200_REG_IRQ_CONFIG 0x17
45/* Logic level */
46#define ITG3200_IRQ_ACTIVE_LOW 0x80
47#define ITG3200_IRQ_ACTIVE_HIGH 0x00
48/* Drive type */
49#define ITG3200_IRQ_OPEN_DRAIN 0x40
50#define ITG3200_IRQ_PUSH_PULL 0x00
51/* Latch mode */
52#define ITG3200_IRQ_LATCH_UNTIL_CLEARED 0x20
53#define ITG3200_IRQ_LATCH_50US_PULSE 0x00
54/* Latch clear method */
55#define ITG3200_IRQ_LATCH_CLEAR_ANY 0x10
56#define ITG3200_IRQ_LATCH_CLEAR_STATUS 0x00
57/* Enable interrupt when device is ready */
58#define ITG3200_IRQ_DEVICE_RDY_ENABLE 0x04
59/* Enable interrupt when data is available */
60#define ITG3200_IRQ_DATA_RDY_ENABLE 0x01
61
62/* Determine the status of ITG-3200 interrupts */
63#define ITG3200_REG_IRQ_STATUS 0x1A
64/* Status of 'device is ready'-interrupt */
65#define ITG3200_IRQ_DEVICE_RDY_STATUS 0x04
66/* Status of 'data is available'-interrupt */
67#define ITG3200_IRQ_DATA_RDY_STATUS 0x01
68
69/* Sensor registers */
70#define ITG3200_REG_TEMP_OUT_H 0x1B
71#define ITG3200_REG_TEMP_OUT_L 0x1C
72#define ITG3200_REG_GYRO_XOUT_H 0x1D
73#define ITG3200_REG_GYRO_XOUT_L 0x1E
74#define ITG3200_REG_GYRO_YOUT_H 0x1F
75#define ITG3200_REG_GYRO_YOUT_L 0x20
76#define ITG3200_REG_GYRO_ZOUT_H 0x21
77#define ITG3200_REG_GYRO_ZOUT_L 0x22
78
79/* Power management */
80#define ITG3200_REG_POWER_MANAGEMENT 0x3E
81/* Reset device and internal registers to the
82 * power-up-default settings */
83#define ITG3200_RESET 0x80
84/* Enable low power sleep mode */
85#define ITG3200_SLEEP 0x40
86/* Put according gyroscope in standby mode */
87#define ITG3200_STANDBY_GYRO_X 0x20
88#define ITG3200_STANDBY_GYRO_Y 0x10
89#define ITG3200_STANDBY_GYRO_Z 0x08
90/* Determine the device clock source */
91#define ITG3200_CLK_INTERNAL 0x00
92#define ITG3200_CLK_GYRO_X 0x01
93#define ITG3200_CLK_GYRO_Y 0x02
94#define ITG3200_CLK_GYRO_Z 0x03
95#define ITG3200_CLK_EXT_32K 0x04
96#define ITG3200_CLK_EXT_19M 0x05
97
98
99/**
100 * struct itg3200 - device instance specific data
101 * @i2c: actual i2c_client
102 * @trig: data ready trigger from itg3200 pin
103 **/
104struct itg3200 {
105 struct i2c_client *i2c;
106 struct iio_trigger *trig;
107};
108
109enum ITG3200_SCAN_INDEX {
110 ITG3200_SCAN_TEMP,
111 ITG3200_SCAN_GYRO_X,
112 ITG3200_SCAN_GYRO_Y,
113 ITG3200_SCAN_GYRO_Z,
114 ITG3200_SCAN_ELEMENTS,
115};
116
117int itg3200_write_reg_8(struct iio_dev *indio_dev,
118 u8 reg_address, u8 val);
119
120int itg3200_read_reg_8(struct iio_dev *indio_dev,
121 u8 reg_address, u8 *val);
122
123
124#ifdef CONFIG_IIO_BUFFER
125
126void itg3200_remove_trigger(struct iio_dev *indio_dev);
127int itg3200_probe_trigger(struct iio_dev *indio_dev);
128
129int itg3200_buffer_configure(struct iio_dev *indio_dev);
130void itg3200_buffer_unconfigure(struct iio_dev *indio_dev);
131
132#else /* CONFIG_IIO_BUFFER */
133
134static inline void itg3200_remove_trigger(struct iio_dev *indio_dev)
135{
136}
137
138static inline int itg3200_probe_trigger(struct iio_dev *indio_dev)
139{
140 return 0;
141}
142
143static inline int itg3200_buffer_configure(struct iio_dev *indio_dev)
144{
145 return 0;
146}
147
148static inline void itg3200_buffer_unconfigure(struct iio_dev *indio_dev)
149{
150}
151
152#endif /* CONFIG_IIO_RING_BUFFER */
153
154#endif /* ITG3200_H_ */
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 20239da1d0f7..c66e0a96f6e8 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -12,6 +12,7 @@
12#ifndef _IIO_TRIGGER_H_ 12#ifndef _IIO_TRIGGER_H_
13#define _IIO_TRIGGER_H_ 13#define _IIO_TRIGGER_H_
14 14
15#ifdef CONFIG_IIO_TRIGGER
15struct iio_subirq { 16struct iio_subirq {
16 bool enabled; 17 bool enabled;
17}; 18};
@@ -117,4 +118,8 @@ irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
117__printf(1, 2) struct iio_trigger *iio_trigger_alloc(const char *fmt, ...); 118__printf(1, 2) struct iio_trigger *iio_trigger_alloc(const char *fmt, ...);
118void iio_trigger_free(struct iio_trigger *trig); 119void iio_trigger_free(struct iio_trigger *trig);
119 120
121#else
122struct iio_trigger;
123struct iio_trigger_ops;
124#endif
120#endif /* _IIO_TRIGGER_H_ */ 125#endif /* _IIO_TRIGGER_H_ */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 907e7e56fa4b..6938ccfa42d5 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1807,6 +1807,8 @@
1807#define PCI_VENDOR_ID_ESDGMBH 0x12fe 1807#define PCI_VENDOR_ID_ESDGMBH 0x12fe
1808#define PCI_DEVICE_ID_ESDGMBH_CPCIASIO4 0x0111 1808#define PCI_DEVICE_ID_ESDGMBH_CPCIASIO4 0x0111
1809 1809
1810#define PCI_VENDOR_ID_CB 0x1307 /* Measurement Computing */
1811
1810#define PCI_VENDOR_ID_SIIG 0x131f 1812#define PCI_VENDOR_ID_SIIG 0x131f
1811#define PCI_SUBVENDOR_ID_SIIG 0x131f 1813#define PCI_SUBVENDOR_ID_SIIG 0x131f
1812#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 1814#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000
@@ -2013,6 +2015,10 @@
2013#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 2015#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
2014#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 2016#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
2015 2017
2018#define PCI_VENDOR_ID_ADVANTECH 0x13fe
2019
2020#define PCI_VENDOR_ID_MEILHAUS 0x1402
2021
2016#define PCI_VENDOR_ID_LAVA 0x1407 2022#define PCI_VENDOR_ID_LAVA 0x1407
2017#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */ 2023#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */
2018#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */ 2024#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */
@@ -2058,6 +2064,8 @@
2058 2064
2059#define PCI_VENDOR_ID_CHELSIO 0x1425 2065#define PCI_VENDOR_ID_CHELSIO 0x1425
2060 2066
2067#define PCI_VENDOR_ID_ADLINK 0x144a
2068
2061#define PCI_VENDOR_ID_SAMSUNG 0x144d 2069#define PCI_VENDOR_ID_SAMSUNG 0x144d
2062 2070
2063#define PCI_VENDOR_ID_GIGABYTE 0x1458 2071#define PCI_VENDOR_ID_GIGABYTE 0x1458
@@ -2091,6 +2099,8 @@
2091#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 2099#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
2092#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 2100#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150
2093 2101
2102#define PCI_VENDOR_ID_AMPLICON 0x14dc
2103
2094#define PCI_VENDOR_ID_BCM_GVC 0x14a4 2104#define PCI_VENDOR_ID_BCM_GVC 0x14a4
2095#define PCI_VENDOR_ID_BROADCOM 0x14e4 2105#define PCI_VENDOR_ID_BROADCOM 0x14e4
2096#define PCI_DEVICE_ID_TIGON3_5752 0x1600 2106#define PCI_DEVICE_ID_TIGON3_5752 0x1600
diff --git a/include/linux/platform_data/invensense_mpu6050.h b/include/linux/platform_data/invensense_mpu6050.h
new file mode 100644
index 000000000000..ad3aa7b95f35
--- /dev/null
+++ b/include/linux/platform_data/invensense_mpu6050.h
@@ -0,0 +1,31 @@
1/*
2* Copyright (C) 2012 Invensense, Inc.
3*
4* This software is licensed under the terms of the GNU General Public
5* License version 2, as published by the Free Software Foundation, and
6* may be copied, distributed, and modified under those terms.
7*
8* This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*/
13
14#ifndef __INV_MPU6050_PLATFORM_H_
15#define __INV_MPU6050_PLATFORM_H_
16
17/**
18 * struct inv_mpu6050_platform_data - Platform data for the mpu driver
19 * @orientation: Orientation matrix of the chip
20 *
21 * Contains platform specific information on how to configure the MPU6050 to
22 * work on this platform. The orientation matricies are 3x3 rotation matricies
23 * that are applied to the data to rotate from the mounting orientation to the
24 * platform orientation. The values must be one of 0, 1, or -1 and each row and
25 * column should have exactly 1 non-zero value.
26 */
27struct inv_mpu6050_platform_data {
28 __s8 orientation[9];
29};
30
31#endif
diff --git a/include/linux/platform_data/tsl2563.h b/include/linux/platform_data/tsl2563.h
new file mode 100644
index 000000000000..c90d7a09dda7
--- /dev/null
+++ b/include/linux/platform_data/tsl2563.h
@@ -0,0 +1,8 @@
1#ifndef __LINUX_TSL2563_H
2#define __LINUX_TSL2563_H
3
4struct tsl2563_platform_data {
5 int cover_comp_gain;
6};
7
8#endif /* __LINUX_TSL2563_H */
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 30e9c50a5e20..38c2b925923d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -596,6 +596,26 @@ spi_transfer_del(struct spi_transfer *t)
596 list_del(&t->transfer_list); 596 list_del(&t->transfer_list);
597} 597}
598 598
599/**
600 * spi_message_init_with_transfers - Initialize spi_message and append transfers
601 * @m: spi_message to be initialized
602 * @xfers: An array of spi transfers
603 * @num_xfers: Number of items in the xfer array
604 *
605 * This function initializes the given spi_message and adds each spi_transfer in
606 * the given array to the message.
607 */
608static inline void
609spi_message_init_with_transfers(struct spi_message *m,
610struct spi_transfer *xfers, unsigned int num_xfers)
611{
612 unsigned int i;
613
614 spi_message_init(m);
615 for (i = 0; i < num_xfers; ++i)
616 spi_message_add_tail(&xfers[i], m);
617}
618
599/* It's fine to embed message and transaction structures in other data 619/* It's fine to embed message and transaction structures in other data
600 * structures so long as you don't free them while they're in use. 620 * structures so long as you don't free them while they're in use.
601 */ 621 */
@@ -688,6 +708,30 @@ spi_read(struct spi_device *spi, void *buf, size_t len)
688 return spi_sync(spi, &m); 708 return spi_sync(spi, &m);
689} 709}
690 710
711/**
712 * spi_sync_transfer - synchronous SPI data transfer
713 * @spi: device with which data will be exchanged
714 * @xfers: An array of spi_transfers
715 * @num_xfers: Number of items in the xfer array
716 * Context: can sleep
717 *
718 * Does a synchronous SPI data transfer of the given spi_transfer array.
719 *
720 * For more specific semantics see spi_sync().
721 *
722 * It returns zero on success, else a negative error code.
723 */
724static inline int
725spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
726 unsigned int num_xfers)
727{
728 struct spi_message msg;
729
730 spi_message_init_with_transfers(&msg, xfers, num_xfers);
731
732 return spi_sync(spi, &msg);
733}
734
691/* this copies txbuf and rxbuf data; for small transfers only! */ 735/* this copies txbuf and rxbuf data; for small transfers only! */
692extern int spi_write_then_read(struct spi_device *spi, 736extern int spi_write_then_read(struct spi_device *spi,
693 const void *txbuf, unsigned n_tx, 737 const void *txbuf, unsigned n_tx,