2 * lis3lv02d.c - ST LIS3LV02DL accelerometer driver
4 * Copyright (C) 2007-2008 Yan Burman
5 * Copyright (C) 2008 Eric Piel
6 * Copyright (C) 2008-2009 Pavel Machek
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/dmi.h>
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/platform_device.h>
29 #include <linux/interrupt.h>
30 #include <linux/input-polldev.h>
31 #include <linux/delay.h>
32 #include <linux/wait.h>
33 #include <linux/poll.h>
34 #include <linux/freezer.h>
35 #include <linux/uaccess.h>
36 #include <linux/miscdevice.h>
37 #include <asm/atomic.h>
38 #include "lis3lv02d.h"
40 #define DRIVER_NAME "lis3lv02d"
42 /* joystick device poll interval in milliseconds */
43 #define MDPS_POLL_INTERVAL 50
45 * The sensor can also generate interrupts (DRDY) but it's pretty pointless
46 * because they are generated even if the data do not change. So it's better
47 * to keep the interrupt for the free-fall event. The values are updated at
48 * 40Hz (at the lowest frequency), but as it can be pretty time consuming on
49 * some low processor, we poll the sensor only at 20Hz... enough for the
53 #define LIS3_PWRON_DELAY_WAI_12B (5000)
54 #define LIS3_PWRON_DELAY_WAI_8B (3000)
57 * LIS3LV02D spec says 1024 LSBs corresponds 1 G -> 1LSB is 1000/1024 mG
58 * LIS302D spec says: 18 mG / digit
59 * LIS3_ACCURACY is used to increase accuracy of the intermediate
60 * calculation results.
62 #define LIS3_ACCURACY 1024
63 /* Sensitivity values for -2G +2G scale */
64 #define LIS3_SENSITIVITY_12B ((LIS3_ACCURACY * 1000) / 1024)
65 #define LIS3_SENSITIVITY_8B (18 * LIS3_ACCURACY)
67 #define LIS3_DEFAULT_FUZZ 3
68 #define LIS3_DEFAULT_FLAT 3
70 struct lis3lv02d lis3_dev
= {
71 .misc_wait
= __WAIT_QUEUE_HEAD_INITIALIZER(lis3_dev
.misc_wait
),
74 EXPORT_SYMBOL_GPL(lis3_dev
);
76 static s16
lis3lv02d_read_8(struct lis3lv02d
*lis3
, int reg
)
79 if (lis3
->read(lis3
, reg
, &lo
) < 0)
85 static s16
lis3lv02d_read_12(struct lis3lv02d
*lis3
, int reg
)
89 lis3
->read(lis3
, reg
- 1, &lo
);
90 lis3
->read(lis3
, reg
, &hi
);
91 /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */
92 return (s16
)((hi
<< 8) | lo
);
96 * lis3lv02d_get_axis - For the given axis, give the value converted
97 * @axis: 1,2,3 - can also be negative
98 * @hw_values: raw values returned by the hardware
100 * Returns the converted value.
102 static inline int lis3lv02d_get_axis(s8 axis
, int hw_values
[3])
105 return hw_values
[axis
- 1];
107 return -hw_values
[-axis
- 1];
111 * lis3lv02d_get_xyz - Get X, Y and Z axis values from the accelerometer
112 * @lis3: pointer to the device struct
113 * @x: where to store the X axis value
114 * @y: where to store the Y axis value
115 * @z: where to store the Z axis value
117 * Note that 40Hz input device can eat up about 10% CPU at 800MHZ
119 static void lis3lv02d_get_xyz(struct lis3lv02d
*lis3
, int *x
, int *y
, int *z
)
124 position
[0] = lis3
->read_data(lis3
, OUTX
);
125 position
[1] = lis3
->read_data(lis3
, OUTY
);
126 position
[2] = lis3
->read_data(lis3
, OUTZ
);
128 for (i
= 0; i
< 3; i
++)
129 position
[i
] = (position
[i
] * lis3
->scale
) / LIS3_ACCURACY
;
131 *x
= lis3lv02d_get_axis(lis3
->ac
.x
, position
);
132 *y
= lis3lv02d_get_axis(lis3
->ac
.y
, position
);
133 *z
= lis3lv02d_get_axis(lis3
->ac
.z
, position
);
136 /* conversion btw sampling rate and the register values */
137 static int lis3_12_rates
[4] = {40, 160, 640, 2560};
138 static int lis3_8_rates
[2] = {100, 400};
140 /* ODR is Output Data Rate */
141 static int lis3lv02d_get_odr(void)
146 lis3_dev
.read(&lis3_dev
, CTRL_REG1
, &ctrl
);
147 ctrl
&= lis3_dev
.odr_mask
;
148 shift
= ffs(lis3_dev
.odr_mask
) - 1;
149 return lis3_dev
.odrs
[(ctrl
>> shift
)];
152 static int lis3lv02d_set_odr(int rate
)
157 lis3_dev
.read(&lis3_dev
, CTRL_REG1
, &ctrl
);
158 ctrl
&= ~lis3_dev
.odr_mask
;
159 len
= 1 << hweight_long(lis3_dev
.odr_mask
); /* # of possible values */
160 shift
= ffs(lis3_dev
.odr_mask
) - 1;
162 for (i
= 0; i
< len
; i
++)
163 if (lis3_dev
.odrs
[i
] == rate
) {
164 lis3_dev
.write(&lis3_dev
, CTRL_REG1
,
165 ctrl
| (i
<< shift
));
171 static int lis3lv02d_selftest(struct lis3lv02d
*lis3
, s16 results
[3])
178 mutex_lock(&lis3
->mutex
);
179 if (lis3_dev
.whoami
== WAI_12B
)
182 selftest
= CTRL1_STP
;
184 lis3
->read(lis3
, CTRL_REG1
, ®
);
185 lis3
->write(lis3
, CTRL_REG1
, (reg
| selftest
));
186 msleep(lis3
->pwron_delay
/ lis3lv02d_get_odr());
188 /* Read directly to avoid axis remap */
189 x
= lis3
->read_data(lis3
, OUTX
);
190 y
= lis3
->read_data(lis3
, OUTY
);
191 z
= lis3
->read_data(lis3
, OUTZ
);
193 /* back to normal settings */
194 lis3
->write(lis3
, CTRL_REG1
, reg
);
195 msleep(lis3
->pwron_delay
/ lis3lv02d_get_odr());
197 results
[0] = x
- lis3
->read_data(lis3
, OUTX
);
198 results
[1] = y
- lis3
->read_data(lis3
, OUTY
);
199 results
[2] = z
- lis3
->read_data(lis3
, OUTZ
);
204 for (i
= 0; i
< 3; i
++) {
205 /* Check against selftest acceptance limits */
206 if ((results
[i
] < lis3
->pdata
->st_min_limits
[i
]) ||
207 (results
[i
] > lis3
->pdata
->st_max_limits
[i
])) {
216 mutex_unlock(&lis3
->mutex
);
220 void lis3lv02d_poweroff(struct lis3lv02d
*lis3
)
222 /* disable X,Y,Z axis and power down */
223 lis3
->write(lis3
, CTRL_REG1
, 0x00);
225 EXPORT_SYMBOL_GPL(lis3lv02d_poweroff
);
227 void lis3lv02d_poweron(struct lis3lv02d
*lis3
)
233 /* LIS3 power on delay is quite long */
234 msleep(lis3
->pwron_delay
/ lis3lv02d_get_odr());
237 * Common configuration
238 * BDU: (12 bits sensors only) LSB and MSB values are not updated until
239 * both have been read. So the value read will always be correct.
241 if (lis3
->whoami
== WAI_12B
) {
242 lis3
->read(lis3
, CTRL_REG2
, ®
);
244 lis3
->write(lis3
, CTRL_REG2
, reg
);
247 EXPORT_SYMBOL_GPL(lis3lv02d_poweron
);
250 static void lis3lv02d_joystick_poll(struct input_polled_dev
*pidev
)
254 mutex_lock(&lis3_dev
.mutex
);
255 lis3lv02d_get_xyz(&lis3_dev
, &x
, &y
, &z
);
256 input_report_abs(pidev
->input
, ABS_X
, x
);
257 input_report_abs(pidev
->input
, ABS_Y
, y
);
258 input_report_abs(pidev
->input
, ABS_Z
, z
);
259 input_sync(pidev
->input
);
260 mutex_unlock(&lis3_dev
.mutex
);
263 static irqreturn_t
lis302dl_interrupt(int irq
, void *dummy
)
265 if (!test_bit(0, &lis3_dev
.misc_opened
))
269 * Be careful: on some HP laptops the bios force DD when on battery and
270 * the lid is closed. This leads to interrupts as soon as a little move
273 atomic_inc(&lis3_dev
.count
);
275 wake_up_interruptible(&lis3_dev
.misc_wait
);
276 kill_fasync(&lis3_dev
.async_queue
, SIGIO
, POLL_IN
);
278 if (lis3_dev
.whoami
== WAI_8B
&& lis3_dev
.idev
&&
279 lis3_dev
.idev
->input
->users
)
280 return IRQ_WAKE_THREAD
;
284 static void lis302dl_interrupt_handle_click(struct lis3lv02d
*lis3
)
286 struct input_dev
*dev
= lis3
->idev
->input
;
289 mutex_lock(&lis3
->mutex
);
290 lis3
->read(lis3
, CLICK_SRC
, &click_src
);
292 if (click_src
& CLICK_SINGLE_X
) {
293 input_report_key(dev
, lis3
->mapped_btns
[0], 1);
294 input_report_key(dev
, lis3
->mapped_btns
[0], 0);
297 if (click_src
& CLICK_SINGLE_Y
) {
298 input_report_key(dev
, lis3
->mapped_btns
[1], 1);
299 input_report_key(dev
, lis3
->mapped_btns
[1], 0);
302 if (click_src
& CLICK_SINGLE_Z
) {
303 input_report_key(dev
, lis3
->mapped_btns
[2], 1);
304 input_report_key(dev
, lis3
->mapped_btns
[2], 0);
307 mutex_unlock(&lis3
->mutex
);
310 static void lis302dl_interrupt_handle_ff_wu(struct lis3lv02d
*lis3
)
315 lis3
->read(lis3
, FF_WU_SRC_1
, &wu1_src
);
316 lis3
->read(lis3
, FF_WU_SRC_2
, &wu2_src
);
318 wu1_src
= wu1_src
& FF_WU_SRC_IA
? wu1_src
: 0;
319 wu2_src
= wu2_src
& FF_WU_SRC_IA
? wu2_src
: 0;
321 /* joystick poll is internally protected by the lis3->mutex. */
322 if (wu1_src
|| wu2_src
)
323 lis3lv02d_joystick_poll(lis3_dev
.idev
);
326 static irqreturn_t
lis302dl_interrupt_thread1_8b(int irq
, void *data
)
329 struct lis3lv02d
*lis3
= data
;
331 if ((lis3
->pdata
->irq_cfg
& LIS3_IRQ1_MASK
) == LIS3_IRQ1_CLICK
)
332 lis302dl_interrupt_handle_click(lis3
);
334 lis302dl_interrupt_handle_ff_wu(lis3
);
339 static irqreturn_t
lis302dl_interrupt_thread2_8b(int irq
, void *data
)
342 struct lis3lv02d
*lis3
= data
;
344 if ((lis3
->pdata
->irq_cfg
& LIS3_IRQ2_MASK
) == LIS3_IRQ2_CLICK
)
345 lis302dl_interrupt_handle_click(lis3
);
347 lis302dl_interrupt_handle_ff_wu(lis3
);
352 static int lis3lv02d_misc_open(struct inode
*inode
, struct file
*file
)
354 if (test_and_set_bit(0, &lis3_dev
.misc_opened
))
355 return -EBUSY
; /* already open */
357 atomic_set(&lis3_dev
.count
, 0);
361 static int lis3lv02d_misc_release(struct inode
*inode
, struct file
*file
)
363 fasync_helper(-1, file
, 0, &lis3_dev
.async_queue
);
364 clear_bit(0, &lis3_dev
.misc_opened
); /* release the device */
368 static ssize_t
lis3lv02d_misc_read(struct file
*file
, char __user
*buf
,
369 size_t count
, loff_t
*pos
)
371 DECLARE_WAITQUEUE(wait
, current
);
373 unsigned char byte_data
;
379 add_wait_queue(&lis3_dev
.misc_wait
, &wait
);
381 set_current_state(TASK_INTERRUPTIBLE
);
382 data
= atomic_xchg(&lis3_dev
.count
, 0);
386 if (file
->f_flags
& O_NONBLOCK
) {
391 if (signal_pending(current
)) {
392 retval
= -ERESTARTSYS
;
404 /* make sure we are not going into copy_to_user() with
405 * TASK_INTERRUPTIBLE state */
406 set_current_state(TASK_RUNNING
);
407 if (copy_to_user(buf
, &byte_data
, sizeof(byte_data
)))
411 __set_current_state(TASK_RUNNING
);
412 remove_wait_queue(&lis3_dev
.misc_wait
, &wait
);
417 static unsigned int lis3lv02d_misc_poll(struct file
*file
, poll_table
*wait
)
419 poll_wait(file
, &lis3_dev
.misc_wait
, wait
);
420 if (atomic_read(&lis3_dev
.count
))
421 return POLLIN
| POLLRDNORM
;
425 static int lis3lv02d_misc_fasync(int fd
, struct file
*file
, int on
)
427 return fasync_helper(fd
, file
, on
, &lis3_dev
.async_queue
);
430 static const struct file_operations lis3lv02d_misc_fops
= {
431 .owner
= THIS_MODULE
,
433 .read
= lis3lv02d_misc_read
,
434 .open
= lis3lv02d_misc_open
,
435 .release
= lis3lv02d_misc_release
,
436 .poll
= lis3lv02d_misc_poll
,
437 .fasync
= lis3lv02d_misc_fasync
,
440 static struct miscdevice lis3lv02d_misc_device
= {
441 .minor
= MISC_DYNAMIC_MINOR
,
443 .fops
= &lis3lv02d_misc_fops
,
446 int lis3lv02d_joystick_enable(void)
448 struct input_dev
*input_dev
;
450 int max_val
, fuzz
, flat
;
451 int btns
[] = {BTN_X
, BTN_Y
, BTN_Z
};
456 lis3_dev
.idev
= input_allocate_polled_device();
460 lis3_dev
.idev
->poll
= lis3lv02d_joystick_poll
;
461 lis3_dev
.idev
->poll_interval
= MDPS_POLL_INTERVAL
;
462 input_dev
= lis3_dev
.idev
->input
;
464 input_dev
->name
= "ST LIS3LV02DL Accelerometer";
465 input_dev
->phys
= DRIVER_NAME
"/input0";
466 input_dev
->id
.bustype
= BUS_HOST
;
467 input_dev
->id
.vendor
= 0;
468 input_dev
->dev
.parent
= &lis3_dev
.pdev
->dev
;
470 set_bit(EV_ABS
, input_dev
->evbit
);
471 max_val
= (lis3_dev
.mdps_max_val
* lis3_dev
.scale
) / LIS3_ACCURACY
;
472 fuzz
= (LIS3_DEFAULT_FUZZ
* lis3_dev
.scale
) / LIS3_ACCURACY
;
473 flat
= (LIS3_DEFAULT_FLAT
* lis3_dev
.scale
) / LIS3_ACCURACY
;
474 input_set_abs_params(input_dev
, ABS_X
, -max_val
, max_val
, fuzz
, flat
);
475 input_set_abs_params(input_dev
, ABS_Y
, -max_val
, max_val
, fuzz
, flat
);
476 input_set_abs_params(input_dev
, ABS_Z
, -max_val
, max_val
, fuzz
, flat
);
478 lis3_dev
.mapped_btns
[0] = lis3lv02d_get_axis(abs(lis3_dev
.ac
.x
), btns
);
479 lis3_dev
.mapped_btns
[1] = lis3lv02d_get_axis(abs(lis3_dev
.ac
.y
), btns
);
480 lis3_dev
.mapped_btns
[2] = lis3lv02d_get_axis(abs(lis3_dev
.ac
.z
), btns
);
482 err
= input_register_polled_device(lis3_dev
.idev
);
484 input_free_polled_device(lis3_dev
.idev
);
485 lis3_dev
.idev
= NULL
;
490 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable
);
492 void lis3lv02d_joystick_disable(void)
495 free_irq(lis3_dev
.irq
, &lis3_dev
);
496 if (lis3_dev
.pdata
&& lis3_dev
.pdata
->irq2
)
497 free_irq(lis3_dev
.pdata
->irq2
, &lis3_dev
);
503 misc_deregister(&lis3lv02d_misc_device
);
504 input_unregister_polled_device(lis3_dev
.idev
);
505 input_free_polled_device(lis3_dev
.idev
);
506 lis3_dev
.idev
= NULL
;
508 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable
);
511 static ssize_t
lis3lv02d_selftest_show(struct device
*dev
,
512 struct device_attribute
*attr
, char *buf
)
517 result
= lis3lv02d_selftest(&lis3_dev
, values
);
518 return sprintf(buf
, "%s %d %d %d\n", result
== 0 ? "OK" : "FAIL",
519 values
[0], values
[1], values
[2]);
522 static ssize_t
lis3lv02d_position_show(struct device
*dev
,
523 struct device_attribute
*attr
, char *buf
)
527 mutex_lock(&lis3_dev
.mutex
);
528 lis3lv02d_get_xyz(&lis3_dev
, &x
, &y
, &z
);
529 mutex_unlock(&lis3_dev
.mutex
);
530 return sprintf(buf
, "(%d,%d,%d)\n", x
, y
, z
);
533 static ssize_t
lis3lv02d_rate_show(struct device
*dev
,
534 struct device_attribute
*attr
, char *buf
)
536 return sprintf(buf
, "%d\n", lis3lv02d_get_odr());
539 static ssize_t
lis3lv02d_rate_set(struct device
*dev
,
540 struct device_attribute
*attr
, const char *buf
,
545 if (strict_strtoul(buf
, 0, &rate
))
548 if (lis3lv02d_set_odr(rate
))
554 static DEVICE_ATTR(selftest
, S_IRUSR
, lis3lv02d_selftest_show
, NULL
);
555 static DEVICE_ATTR(position
, S_IRUGO
, lis3lv02d_position_show
, NULL
);
556 static DEVICE_ATTR(rate
, S_IRUGO
| S_IWUSR
, lis3lv02d_rate_show
,
559 static struct attribute
*lis3lv02d_attributes
[] = {
560 &dev_attr_selftest
.attr
,
561 &dev_attr_position
.attr
,
566 static struct attribute_group lis3lv02d_attribute_group
= {
567 .attrs
= lis3lv02d_attributes
571 static int lis3lv02d_add_fs(struct lis3lv02d
*lis3
)
573 lis3
->pdev
= platform_device_register_simple(DRIVER_NAME
, -1, NULL
, 0);
574 if (IS_ERR(lis3
->pdev
))
575 return PTR_ERR(lis3
->pdev
);
577 return sysfs_create_group(&lis3
->pdev
->dev
.kobj
, &lis3lv02d_attribute_group
);
580 int lis3lv02d_remove_fs(struct lis3lv02d
*lis3
)
582 sysfs_remove_group(&lis3
->pdev
->dev
.kobj
, &lis3lv02d_attribute_group
);
583 platform_device_unregister(lis3
->pdev
);
586 EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs
);
588 static void lis3lv02d_8b_configure(struct lis3lv02d
*dev
,
589 struct lis3lv02d_platform_data
*p
)
592 int ctrl2
= p
->hipass_ctrl
;
594 if (p
->click_flags
) {
595 dev
->write(dev
, CLICK_CFG
, p
->click_flags
);
596 dev
->write(dev
, CLICK_TIMELIMIT
, p
->click_time_limit
);
597 dev
->write(dev
, CLICK_LATENCY
, p
->click_latency
);
598 dev
->write(dev
, CLICK_WINDOW
, p
->click_window
);
599 dev
->write(dev
, CLICK_THSZ
, p
->click_thresh_z
& 0xf);
600 dev
->write(dev
, CLICK_THSY_X
,
601 (p
->click_thresh_x
& 0xf) |
602 (p
->click_thresh_y
<< 4));
605 struct input_dev
*input_dev
= lis3_dev
.idev
->input
;
606 input_set_capability(input_dev
, EV_KEY
, BTN_X
);
607 input_set_capability(input_dev
, EV_KEY
, BTN_Y
);
608 input_set_capability(input_dev
, EV_KEY
, BTN_Z
);
612 if (p
->wakeup_flags
) {
613 dev
->write(dev
, FF_WU_CFG_1
, p
->wakeup_flags
);
614 dev
->write(dev
, FF_WU_THS_1
, p
->wakeup_thresh
& 0x7f);
615 /* default to 2.5ms for now */
616 dev
->write(dev
, FF_WU_DURATION_1
, 1);
617 ctrl2
^= HP_FF_WU1
; /* Xor to keep compatible with old pdata*/
620 if (p
->wakeup_flags2
) {
621 dev
->write(dev
, FF_WU_CFG_2
, p
->wakeup_flags2
);
622 dev
->write(dev
, FF_WU_THS_2
, p
->wakeup_thresh2
& 0x7f);
623 /* default to 2.5ms for now */
624 dev
->write(dev
, FF_WU_DURATION_2
, 1);
625 ctrl2
^= HP_FF_WU2
; /* Xor to keep compatible with old pdata*/
627 /* Configure hipass filters */
628 dev
->write(dev
, CTRL_REG2
, ctrl2
);
631 err
= request_threaded_irq(p
->irq2
,
633 lis302dl_interrupt_thread2_8b
,
634 IRQF_TRIGGER_RISING
|
636 DRIVER_NAME
, &lis3_dev
);
638 printk(KERN_ERR DRIVER_NAME
639 "No second IRQ. Limited functionality\n");
644 * Initialise the accelerometer and the various subsystems.
645 * Should be rather independent of the bus system.
647 int lis3lv02d_init_device(struct lis3lv02d
*dev
)
650 irq_handler_t thread_fn
;
652 dev
->whoami
= lis3lv02d_read_8(dev
, WHO_AM_I
);
654 switch (dev
->whoami
) {
656 printk(KERN_INFO DRIVER_NAME
": 12 bits sensor found\n");
657 dev
->read_data
= lis3lv02d_read_12
;
658 dev
->mdps_max_val
= 2048;
659 dev
->pwron_delay
= LIS3_PWRON_DELAY_WAI_12B
;
660 dev
->odrs
= lis3_12_rates
;
661 dev
->odr_mask
= CTRL1_DF0
| CTRL1_DF1
;
662 dev
->scale
= LIS3_SENSITIVITY_12B
;
665 printk(KERN_INFO DRIVER_NAME
": 8 bits sensor found\n");
666 dev
->read_data
= lis3lv02d_read_8
;
667 dev
->mdps_max_val
= 128;
668 dev
->pwron_delay
= LIS3_PWRON_DELAY_WAI_8B
;
669 dev
->odrs
= lis3_8_rates
;
670 dev
->odr_mask
= CTRL1_DR
;
671 dev
->scale
= LIS3_SENSITIVITY_8B
;
674 printk(KERN_ERR DRIVER_NAME
675 ": unknown sensor type 0x%X\n", dev
->whoami
);
679 mutex_init(&dev
->mutex
);
681 lis3lv02d_add_fs(dev
);
682 lis3lv02d_poweron(dev
);
684 if (lis3lv02d_joystick_enable())
685 printk(KERN_ERR DRIVER_NAME
": joystick initialization failed\n");
687 /* passing in platform specific data is purely optional and only
688 * used by the SPI transport layer at the moment */
690 struct lis3lv02d_platform_data
*p
= dev
->pdata
;
692 if (dev
->whoami
== WAI_8B
)
693 lis3lv02d_8b_configure(dev
, p
);
696 dev
->write(dev
, CTRL_REG3
, p
->irq_cfg
);
699 /* bail if we did not get an IRQ from the bus layer */
701 printk(KERN_ERR DRIVER_NAME
702 ": No IRQ. Disabling /dev/freefall\n");
707 * The sensor can generate interrupts for free-fall and direction
708 * detection (distinguishable with FF_WU_SRC and DD_SRC) but to keep
709 * the things simple and _fast_ we activate it only for free-fall, so
710 * no need to read register (very slow with ACPI). For the same reason,
711 * we forbid shared interrupts.
713 * IRQF_TRIGGER_RISING seems pointless on HP laptops because the
714 * io-apic is not configurable (and generates a warning) but I keep it
715 * in case of support for other hardware.
717 if (dev
->whoami
== WAI_8B
)
718 thread_fn
= lis302dl_interrupt_thread1_8b
;
722 err
= request_threaded_irq(dev
->irq
, lis302dl_interrupt
,
724 IRQF_TRIGGER_RISING
| IRQF_ONESHOT
,
725 DRIVER_NAME
, &lis3_dev
);
728 printk(KERN_ERR DRIVER_NAME
"Cannot get IRQ\n");
732 if (misc_register(&lis3lv02d_misc_device
))
733 printk(KERN_ERR DRIVER_NAME
": misc_register failed\n");
737 EXPORT_SYMBOL_GPL(lis3lv02d_init_device
);
739 MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver");
740 MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
741 MODULE_LICENSE("GPL");