staging: iio: squash chrdev handler remains into users.
[deliverable/linux.git] / drivers / staging / iio / gyro / adis16260_core.c
1 /*
2 * ADIS16260/ADIS16265 Programmable Digital Gyroscope Sensor Driver
3 *
4 * Copyright 2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9 #include <linux/interrupt.h>
10 #include <linux/irq.h>
11 #include <linux/gpio.h>
12 #include <linux/delay.h>
13 #include <linux/mutex.h>
14 #include <linux/device.h>
15 #include <linux/kernel.h>
16 #include <linux/spi/spi.h>
17 #include <linux/slab.h>
18 #include <linux/sysfs.h>
19 #include <linux/list.h>
20 #include <linux/module.h>
21
22 #include "../iio.h"
23 #include "../sysfs.h"
24 #include "../ring_generic.h"
25
26 #include "adis16260.h"
27
28 #define DRIVER_NAME "adis16260"
29
30 static int adis16260_check_status(struct iio_dev *indio_dev);
31
32 /**
33 * adis16260_spi_write_reg_8() - write single byte to a register
34 * @indio_dev: iio_dev for the device
35 * @reg_address: the address of the register to be written
36 * @val: the value to write
37 **/
38 static int adis16260_spi_write_reg_8(struct iio_dev *indio_dev,
39 u8 reg_address,
40 u8 val)
41 {
42 int ret;
43 struct adis16260_state *st = iio_priv(indio_dev);
44
45 mutex_lock(&st->buf_lock);
46 st->tx[0] = ADIS16260_WRITE_REG(reg_address);
47 st->tx[1] = val;
48
49 ret = spi_write(st->us, st->tx, 2);
50 mutex_unlock(&st->buf_lock);
51
52 return ret;
53 }
54
55 /**
56 * adis16260_spi_write_reg_16() - write 2 bytes to a pair of registers
57 * @indio_dev: iio_dev for the device
58 * @reg_address: the address of the lower of the two registers. Second register
59 * is assumed to have address one greater.
60 * @val: value to be written
61 **/
62 static int adis16260_spi_write_reg_16(struct iio_dev *indio_dev,
63 u8 lower_reg_address,
64 u16 value)
65 {
66 int ret;
67 struct spi_message msg;
68 struct adis16260_state *st = iio_priv(indio_dev);
69 struct spi_transfer xfers[] = {
70 {
71 .tx_buf = st->tx,
72 .bits_per_word = 8,
73 .len = 2,
74 .cs_change = 1,
75 .delay_usecs = 20,
76 }, {
77 .tx_buf = st->tx + 2,
78 .bits_per_word = 8,
79 .len = 2,
80 .delay_usecs = 20,
81 },
82 };
83
84 mutex_lock(&st->buf_lock);
85 st->tx[0] = ADIS16260_WRITE_REG(lower_reg_address);
86 st->tx[1] = value & 0xFF;
87 st->tx[2] = ADIS16260_WRITE_REG(lower_reg_address + 1);
88 st->tx[3] = (value >> 8) & 0xFF;
89
90 spi_message_init(&msg);
91 spi_message_add_tail(&xfers[0], &msg);
92 spi_message_add_tail(&xfers[1], &msg);
93 ret = spi_sync(st->us, &msg);
94 mutex_unlock(&st->buf_lock);
95
96 return ret;
97 }
98
99 /**
100 * adis16260_spi_read_reg_16() - read 2 bytes from a 16-bit register
101 * @indio_dev: iio_dev for the device
102 * @reg_address: the address of the lower of the two registers. Second register
103 * is assumed to have address one greater.
104 * @val: somewhere to pass back the value read
105 **/
106 static int adis16260_spi_read_reg_16(struct iio_dev *indio_dev,
107 u8 lower_reg_address,
108 u16 *val)
109 {
110 struct spi_message msg;
111 struct adis16260_state *st = iio_priv(indio_dev);
112 int ret;
113 struct spi_transfer xfers[] = {
114 {
115 .tx_buf = st->tx,
116 .bits_per_word = 8,
117 .len = 2,
118 .cs_change = 1,
119 .delay_usecs = 30,
120 }, {
121 .rx_buf = st->rx,
122 .bits_per_word = 8,
123 .len = 2,
124 .delay_usecs = 30,
125 },
126 };
127
128 mutex_lock(&st->buf_lock);
129 st->tx[0] = ADIS16260_READ_REG(lower_reg_address);
130 st->tx[1] = 0;
131
132 spi_message_init(&msg);
133 spi_message_add_tail(&xfers[0], &msg);
134 spi_message_add_tail(&xfers[1], &msg);
135 ret = spi_sync(st->us, &msg);
136 if (ret) {
137 dev_err(&st->us->dev,
138 "problem when reading 16 bit register 0x%02X",
139 lower_reg_address);
140 goto error_ret;
141 }
142 *val = (st->rx[0] << 8) | st->rx[1];
143
144 error_ret:
145 mutex_unlock(&st->buf_lock);
146 return ret;
147 }
148
149 static ssize_t adis16260_read_frequency_available(struct device *dev,
150 struct device_attribute *attr,
151 char *buf)
152 {
153 struct iio_dev *indio_dev = dev_get_drvdata(dev);
154 struct adis16260_state *st = iio_priv(indio_dev);
155 if (spi_get_device_id(st->us)->driver_data)
156 return sprintf(buf, "%s\n", "0.129 ~ 256");
157 else
158 return sprintf(buf, "%s\n", "256 2048");
159 }
160
161 static ssize_t adis16260_read_frequency(struct device *dev,
162 struct device_attribute *attr,
163 char *buf)
164 {
165 struct iio_dev *indio_dev = dev_get_drvdata(dev);
166 struct adis16260_state *st = iio_priv(indio_dev);
167 int ret, len = 0;
168 u16 t;
169 int sps;
170 ret = adis16260_spi_read_reg_16(indio_dev,
171 ADIS16260_SMPL_PRD,
172 &t);
173 if (ret)
174 return ret;
175
176 if (spi_get_device_id(st->us)->driver_data) /* If an adis16251 */
177 sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 8 : 256;
178 else
179 sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 66 : 2048;
180 sps /= (t & ADIS16260_SMPL_PRD_DIV_MASK) + 1;
181 len = sprintf(buf, "%d SPS\n", sps);
182 return len;
183 }
184
185 static ssize_t adis16260_write_frequency(struct device *dev,
186 struct device_attribute *attr,
187 const char *buf,
188 size_t len)
189 {
190 struct iio_dev *indio_dev = dev_get_drvdata(dev);
191 struct adis16260_state *st = iio_priv(indio_dev);
192 long val;
193 int ret;
194 u8 t;
195
196 ret = strict_strtol(buf, 10, &val);
197 if (ret)
198 return ret;
199
200 mutex_lock(&indio_dev->mlock);
201 if (spi_get_device_id(st->us)) {
202 t = (256 / val);
203 if (t > 0)
204 t--;
205 t &= ADIS16260_SMPL_PRD_DIV_MASK;
206 } else {
207 t = (2048 / val);
208 if (t > 0)
209 t--;
210 t &= ADIS16260_SMPL_PRD_DIV_MASK;
211 }
212 if ((t & ADIS16260_SMPL_PRD_DIV_MASK) >= 0x0A)
213 st->us->max_speed_hz = ADIS16260_SPI_SLOW;
214 else
215 st->us->max_speed_hz = ADIS16260_SPI_FAST;
216 ret = adis16260_spi_write_reg_8(indio_dev,
217 ADIS16260_SMPL_PRD,
218 t);
219
220 mutex_unlock(&indio_dev->mlock);
221
222 return ret ? ret : len;
223 }
224
225 static int adis16260_reset(struct iio_dev *indio_dev)
226 {
227 int ret;
228 ret = adis16260_spi_write_reg_8(indio_dev,
229 ADIS16260_GLOB_CMD,
230 ADIS16260_GLOB_CMD_SW_RESET);
231 if (ret)
232 dev_err(&indio_dev->dev, "problem resetting device");
233
234 return ret;
235 }
236
237 static ssize_t adis16260_write_reset(struct device *dev,
238 struct device_attribute *attr,
239 const char *buf, size_t len)
240 {
241 struct iio_dev *indio_dev = dev_get_drvdata(dev);
242 if (len < 1)
243 return -EINVAL;
244 switch (buf[0]) {
245 case '1':
246 case 'y':
247 case 'Y':
248 return adis16260_reset(indio_dev);
249 }
250 return -EINVAL;
251 }
252
253 int adis16260_set_irq(struct iio_dev *indio_dev, bool enable)
254 {
255 int ret;
256 u16 msc;
257 ret = adis16260_spi_read_reg_16(indio_dev, ADIS16260_MSC_CTRL, &msc);
258 if (ret)
259 goto error_ret;
260
261 msc |= ADIS16260_MSC_CTRL_DATA_RDY_POL_HIGH;
262 if (enable)
263 msc |= ADIS16260_MSC_CTRL_DATA_RDY_EN;
264 else
265 msc &= ~ADIS16260_MSC_CTRL_DATA_RDY_EN;
266
267 ret = adis16260_spi_write_reg_16(indio_dev, ADIS16260_MSC_CTRL, msc);
268 if (ret)
269 goto error_ret;
270
271 error_ret:
272 return ret;
273 }
274
275 /* Power down the device */
276 static int adis16260_stop_device(struct iio_dev *indio_dev)
277 {
278 int ret;
279 u16 val = ADIS16260_SLP_CNT_POWER_OFF;
280
281 ret = adis16260_spi_write_reg_16(indio_dev, ADIS16260_SLP_CNT, val);
282 if (ret)
283 dev_err(&indio_dev->dev, "problem with turning device off: SLP_CNT");
284
285 return ret;
286 }
287
288 static int adis16260_self_test(struct iio_dev *indio_dev)
289 {
290 int ret;
291 ret = adis16260_spi_write_reg_16(indio_dev,
292 ADIS16260_MSC_CTRL,
293 ADIS16260_MSC_CTRL_MEM_TEST);
294 if (ret) {
295 dev_err(&indio_dev->dev, "problem starting self test");
296 goto err_ret;
297 }
298
299 adis16260_check_status(indio_dev);
300
301 err_ret:
302 return ret;
303 }
304
305 static int adis16260_check_status(struct iio_dev *indio_dev)
306 {
307 u16 status;
308 int ret;
309 struct device *dev = &indio_dev->dev;
310
311 ret = adis16260_spi_read_reg_16(indio_dev,
312 ADIS16260_DIAG_STAT,
313 &status);
314
315 if (ret < 0) {
316 dev_err(dev, "Reading status failed\n");
317 goto error_ret;
318 }
319 ret = status & 0x7F;
320 if (status & ADIS16260_DIAG_STAT_FLASH_CHK)
321 dev_err(dev, "Flash checksum error\n");
322 if (status & ADIS16260_DIAG_STAT_SELF_TEST)
323 dev_err(dev, "Self test error\n");
324 if (status & ADIS16260_DIAG_STAT_OVERFLOW)
325 dev_err(dev, "Sensor overrange\n");
326 if (status & ADIS16260_DIAG_STAT_SPI_FAIL)
327 dev_err(dev, "SPI failure\n");
328 if (status & ADIS16260_DIAG_STAT_FLASH_UPT)
329 dev_err(dev, "Flash update failed\n");
330 if (status & ADIS16260_DIAG_STAT_POWER_HIGH)
331 dev_err(dev, "Power supply above 5.25V\n");
332 if (status & ADIS16260_DIAG_STAT_POWER_LOW)
333 dev_err(dev, "Power supply below 4.75V\n");
334
335 error_ret:
336 return ret;
337 }
338
339 static int adis16260_initial_setup(struct iio_dev *indio_dev)
340 {
341 int ret;
342 struct device *dev = &indio_dev->dev;
343
344 /* Disable IRQ */
345 ret = adis16260_set_irq(indio_dev, false);
346 if (ret) {
347 dev_err(dev, "disable irq failed");
348 goto err_ret;
349 }
350
351 /* Do self test */
352 ret = adis16260_self_test(indio_dev);
353 if (ret) {
354 dev_err(dev, "self test failure");
355 goto err_ret;
356 }
357
358 /* Read status register to check the result */
359 ret = adis16260_check_status(indio_dev);
360 if (ret) {
361 adis16260_reset(indio_dev);
362 dev_err(dev, "device not playing ball -> reset");
363 msleep(ADIS16260_STARTUP_DELAY);
364 ret = adis16260_check_status(indio_dev);
365 if (ret) {
366 dev_err(dev, "giving up");
367 goto err_ret;
368 }
369 }
370
371 err_ret:
372 return ret;
373 }
374
375 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
376 adis16260_read_frequency,
377 adis16260_write_frequency);
378
379 static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
380
381 static IIO_DEVICE_ATTR(sampling_frequency_available,
382 S_IRUGO, adis16260_read_frequency_available, NULL, 0);
383
384 enum adis16260_channel {
385 gyro,
386 temp,
387 in_supply,
388 in_aux,
389 angle,
390 };
391 #define ADIS16260_GYRO_CHANNEL_SET(axis, mod) \
392 struct iio_chan_spec adis16260_channels_##axis[] = { \
393 IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, mod, \
394 (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | \
395 (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | \
396 (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \
397 gyro, ADIS16260_SCAN_GYRO, \
398 IIO_ST('s', 14, 16, 0), 0), \
399 IIO_CHAN(IIO_ANGL, 1, 0, 0, NULL, 0, mod, \
400 0, \
401 angle, ADIS16260_SCAN_ANGL, \
402 IIO_ST('u', 14, 16, 0), 0), \
403 IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, \
404 (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | \
405 (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \
406 temp, ADIS16260_SCAN_TEMP, \
407 IIO_ST('u', 12, 16, 0), 0), \
408 IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, \
409 (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \
410 in_supply, ADIS16260_SCAN_SUPPLY, \
411 IIO_ST('u', 12, 16, 0), 0), \
412 IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, \
413 (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \
414 in_aux, ADIS16260_SCAN_AUX_ADC, \
415 IIO_ST('u', 12, 16, 0), 0), \
416 IIO_CHAN_SOFT_TIMESTAMP(5) \
417 }
418
419 static const ADIS16260_GYRO_CHANNEL_SET(x, IIO_MOD_X);
420 static const ADIS16260_GYRO_CHANNEL_SET(y, IIO_MOD_Y);
421 static const ADIS16260_GYRO_CHANNEL_SET(z, IIO_MOD_Z);
422
423 static const u8 adis16260_addresses[5][3] = {
424 [gyro] = { ADIS16260_GYRO_OUT,
425 ADIS16260_GYRO_OFF,
426 ADIS16260_GYRO_SCALE },
427 [angle] = { ADIS16260_ANGL_OUT },
428 [in_supply] = { ADIS16260_SUPPLY_OUT },
429 [in_aux] = { ADIS16260_AUX_ADC },
430 [temp] = { ADIS16260_TEMP_OUT },
431 };
432 static int adis16260_read_raw(struct iio_dev *indio_dev,
433 struct iio_chan_spec const *chan,
434 int *val, int *val2,
435 long mask)
436 {
437 struct adis16260_state *st = iio_priv(indio_dev);
438 int ret;
439 int bits;
440 u8 addr;
441 s16 val16;
442
443 switch (mask) {
444 case 0:
445 mutex_lock(&indio_dev->mlock);
446 addr = adis16260_addresses[chan->address][0];
447 ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
448 if (ret) {
449 mutex_unlock(&indio_dev->mlock);
450 return ret;
451 }
452
453 if (val16 & ADIS16260_ERROR_ACTIVE) {
454 ret = adis16260_check_status(indio_dev);
455 if (ret) {
456 mutex_unlock(&indio_dev->mlock);
457 return ret;
458 }
459 }
460 val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
461 if (chan->scan_type.sign == 's')
462 val16 = (s16)(val16 <<
463 (16 - chan->scan_type.realbits)) >>
464 (16 - chan->scan_type.realbits);
465 *val = val16;
466 mutex_unlock(&indio_dev->mlock);
467 return IIO_VAL_INT;
468 case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
469 case (1 << IIO_CHAN_INFO_SCALE_SHARED):
470 switch (chan->type) {
471 case IIO_GYRO:
472 *val = 0;
473 if (spi_get_device_id(st->us)->driver_data)
474 *val2 = 320;
475 else
476 *val2 = 1278;
477 return IIO_VAL_INT_PLUS_MICRO;
478 case IIO_IN:
479 *val = 0;
480 if (chan->channel == 0)
481 *val2 = 18315;
482 else
483 *val2 = 610500;
484 return IIO_VAL_INT_PLUS_MICRO;
485 case IIO_TEMP:
486 *val = 0;
487 *val2 = 145300;
488 return IIO_VAL_INT_PLUS_MICRO;
489 default:
490 return -EINVAL;
491 }
492 break;
493 case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
494 *val = 25;
495 return IIO_VAL_INT;
496 case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
497 switch (chan->type) {
498 case IIO_GYRO:
499 bits = 12;
500 break;
501 default:
502 return -EINVAL;
503 };
504 mutex_lock(&indio_dev->mlock);
505 addr = adis16260_addresses[chan->address][1];
506 ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
507 if (ret) {
508 mutex_unlock(&indio_dev->mlock);
509 return ret;
510 }
511 val16 &= (1 << bits) - 1;
512 val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
513 *val = val16;
514 mutex_unlock(&indio_dev->mlock);
515 return IIO_VAL_INT;
516 case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
517 switch (chan->type) {
518 case IIO_GYRO:
519 bits = 12;
520 break;
521 default:
522 return -EINVAL;
523 };
524 mutex_lock(&indio_dev->mlock);
525 addr = adis16260_addresses[chan->address][2];
526 ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
527 if (ret) {
528 mutex_unlock(&indio_dev->mlock);
529 return ret;
530 }
531 *val = (1 << bits) - 1;
532 mutex_unlock(&indio_dev->mlock);
533 return IIO_VAL_INT;
534 }
535 return -EINVAL;
536 }
537
538 static int adis16260_write_raw(struct iio_dev *indio_dev,
539 struct iio_chan_spec const *chan,
540 int val,
541 int val2,
542 long mask)
543 {
544 int bits = 12;
545 s16 val16;
546 u8 addr;
547 switch (mask) {
548 case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
549 val16 = val & ((1 << bits) - 1);
550 addr = adis16260_addresses[chan->address][1];
551 return adis16260_spi_write_reg_16(indio_dev, addr, val16);
552 case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
553 val16 = val & ((1 << bits) - 1);
554 addr = adis16260_addresses[chan->address][2];
555 return adis16260_spi_write_reg_16(indio_dev, addr, val16);
556 }
557 return -EINVAL;
558 }
559
560 static struct attribute *adis16260_attributes[] = {
561 &iio_dev_attr_sampling_frequency.dev_attr.attr,
562 &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
563 &iio_dev_attr_reset.dev_attr.attr,
564 NULL
565 };
566
567 static const struct attribute_group adis16260_attribute_group = {
568 .attrs = adis16260_attributes,
569 };
570
571 static const struct iio_info adis16260_info = {
572 .attrs = &adis16260_attribute_group,
573 .read_raw = &adis16260_read_raw,
574 .write_raw = &adis16260_write_raw,
575 .driver_module = THIS_MODULE,
576 };
577
578 static int __devinit adis16260_probe(struct spi_device *spi)
579 {
580 int ret, regdone = 0;
581 struct adis16260_platform_data *pd = spi->dev.platform_data;
582 struct adis16260_state *st;
583 struct iio_dev *indio_dev;
584
585 /* setup the industrialio driver allocated elements */
586 indio_dev = iio_allocate_device(sizeof(*st));
587 if (indio_dev == NULL) {
588 ret = -ENOMEM;
589 goto error_ret;
590 }
591 st = iio_priv(indio_dev);
592 if (pd)
593 st->negate = pd->negate;
594 /* this is only used for removal purposes */
595 spi_set_drvdata(spi, st);
596
597 st->us = spi;
598 mutex_init(&st->buf_lock);
599
600 indio_dev->name = spi_get_device_id(st->us)->name;
601 indio_dev->dev.parent = &spi->dev;
602 indio_dev->info = &adis16260_info;
603 indio_dev->num_channels
604 = ARRAY_SIZE(adis16260_channels_x);
605 if (pd && pd->direction)
606 switch (pd->direction) {
607 case 'x':
608 indio_dev->channels = adis16260_channels_x;
609 break;
610 case 'y':
611 indio_dev->channels = adis16260_channels_y;
612 break;
613 case 'z':
614 indio_dev->channels = adis16260_channels_z;
615 break;
616 default:
617 return -EINVAL;
618 }
619 else
620 indio_dev->channels = adis16260_channels_x;
621 indio_dev->num_channels = ARRAY_SIZE(adis16260_channels_x);
622 indio_dev->modes = INDIO_DIRECT_MODE;
623
624 ret = adis16260_configure_ring(indio_dev);
625 if (ret)
626 goto error_free_dev;
627
628 ret = iio_device_register(indio_dev);
629 if (ret)
630 goto error_unreg_ring_funcs;
631 regdone = 1;
632 ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
633 indio_dev->channels,
634 ARRAY_SIZE(adis16260_channels_x));
635 if (ret) {
636 printk(KERN_ERR "failed to initialize the ring\n");
637 goto error_unreg_ring_funcs;
638 }
639
640 if (spi->irq) {
641 ret = adis16260_probe_trigger(indio_dev);
642 if (ret)
643 goto error_uninitialize_ring;
644 }
645
646 /* Get the device into a sane initial state */
647 ret = adis16260_initial_setup(indio_dev);
648 if (ret)
649 goto error_remove_trigger;
650 return 0;
651
652 error_remove_trigger:
653 adis16260_remove_trigger(indio_dev);
654 error_uninitialize_ring:
655 iio_ring_buffer_unregister(indio_dev->ring);
656 error_unreg_ring_funcs:
657 adis16260_unconfigure_ring(indio_dev);
658 error_free_dev:
659 if (regdone)
660 iio_device_unregister(indio_dev);
661 else
662 iio_free_device(indio_dev);
663 error_ret:
664 return ret;
665 }
666
667 static int adis16260_remove(struct spi_device *spi)
668 {
669 int ret;
670 struct iio_dev *indio_dev = spi_get_drvdata(spi);
671
672 ret = adis16260_stop_device(indio_dev);
673 if (ret)
674 goto err_ret;
675
676 flush_scheduled_work();
677
678 adis16260_remove_trigger(indio_dev);
679 iio_ring_buffer_unregister(indio_dev->ring);
680 iio_device_unregister(indio_dev);
681 adis16260_unconfigure_ring(indio_dev);
682
683 err_ret:
684 return ret;
685 }
686
687 /*
688 * These parts do not need to be differentiated until someone adds
689 * support for the on chip filtering.
690 */
691 static const struct spi_device_id adis16260_id[] = {
692 {"adis16260", 0},
693 {"adis16265", 0},
694 {"adis16250", 0},
695 {"adis16255", 0},
696 {"adis16251", 1},
697 {}
698 };
699
700 static struct spi_driver adis16260_driver = {
701 .driver = {
702 .name = "adis16260",
703 .owner = THIS_MODULE,
704 },
705 .probe = adis16260_probe,
706 .remove = __devexit_p(adis16260_remove),
707 .id_table = adis16260_id,
708 };
709
710 static __init int adis16260_init(void)
711 {
712 return spi_register_driver(&adis16260_driver);
713 }
714 module_init(adis16260_init);
715
716 static __exit void adis16260_exit(void)
717 {
718 spi_unregister_driver(&adis16260_driver);
719 }
720 module_exit(adis16260_exit);
721
722 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
723 MODULE_DESCRIPTION("Analog Devices ADIS16260/5 Digital Gyroscope Sensor");
724 MODULE_LICENSE("GPL v2");
This page took 0.134479 seconds and 5 git commands to generate.