Commit | Line | Data |
---|---|---|
455fbdd3 PM |
1 | /* |
2 | * lis3lv02d.c - ST LIS3LV02DL accelerometer driver | |
3 | * | |
4 | * Copyright (C) 2007-2008 Yan Burman | |
5 | * Copyright (C) 2008 Eric Piel | |
ef2cfc79 | 6 | * Copyright (C) 2008-2009 Pavel Machek |
455fbdd3 PM |
7 | * |
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. | |
12 | * | |
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. | |
17 | * | |
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 | |
21 | */ | |
22 | ||
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> | |
dc6ea97b | 30 | #include <linux/input-polldev.h> |
455fbdd3 PM |
31 | #include <linux/delay.h> |
32 | #include <linux/wait.h> | |
33 | #include <linux/poll.h> | |
34 | #include <linux/freezer.h> | |
455fbdd3 | 35 | #include <linux/uaccess.h> |
ef2cfc79 | 36 | #include <linux/miscdevice.h> |
455fbdd3 PM |
37 | #include <asm/atomic.h> |
38 | #include "lis3lv02d.h" | |
39 | ||
40 | #define DRIVER_NAME "lis3lv02d" | |
455fbdd3 PM |
41 | |
42 | /* joystick device poll interval in milliseconds */ | |
43 | #define MDPS_POLL_INTERVAL 50 | |
44 | /* | |
45 | * The sensor can also generate interrupts (DRDY) but it's pretty pointless | |
46 | * because their 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 | |
50 | * joystick. | |
51 | */ | |
52 | ||
a38da2ed | 53 | struct lis3lv02d lis3_dev = { |
be84cfc5 | 54 | .misc_wait = __WAIT_QUEUE_HEAD_INITIALIZER(lis3_dev.misc_wait), |
ef2cfc79 PM |
55 | }; |
56 | ||
be84cfc5 | 57 | EXPORT_SYMBOL_GPL(lis3_dev); |
455fbdd3 | 58 | |
a38da2ed DM |
59 | static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg) |
60 | { | |
61 | s8 lo; | |
62 | if (lis3->read(lis3, reg, &lo) < 0) | |
63 | return 0; | |
64 | ||
65 | return lo; | |
66 | } | |
67 | ||
68 | static s16 lis3lv02d_read_16(struct lis3lv02d *lis3, int reg) | |
be84cfc5 PM |
69 | { |
70 | u8 lo, hi; | |
71 | ||
a38da2ed DM |
72 | lis3->read(lis3, reg - 1, &lo); |
73 | lis3->read(lis3, reg, &hi); | |
be84cfc5 PM |
74 | /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */ |
75 | return (s16)((hi << 8) | lo); | |
76 | } | |
77 | ||
455fbdd3 PM |
78 | /** |
79 | * lis3lv02d_get_axis - For the given axis, give the value converted | |
80 | * @axis: 1,2,3 - can also be negative | |
81 | * @hw_values: raw values returned by the hardware | |
82 | * | |
83 | * Returns the converted value. | |
84 | */ | |
85 | static inline int lis3lv02d_get_axis(s8 axis, int hw_values[3]) | |
86 | { | |
87 | if (axis > 0) | |
88 | return hw_values[axis - 1]; | |
89 | else | |
90 | return -hw_values[-axis - 1]; | |
91 | } | |
92 | ||
93 | /** | |
94 | * lis3lv02d_get_xyz - Get X, Y and Z axis values from the accelerometer | |
a38da2ed DM |
95 | * @lis3: pointer to the device struct |
96 | * @x: where to store the X axis value | |
97 | * @y: where to store the Y axis value | |
98 | * @z: where to store the Z axis value | |
455fbdd3 PM |
99 | * |
100 | * Note that 40Hz input device can eat up about 10% CPU at 800MHZ | |
101 | */ | |
a38da2ed | 102 | static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) |
455fbdd3 PM |
103 | { |
104 | int position[3]; | |
105 | ||
a002ee89 EP |
106 | position[0] = lis3->read_data(lis3, OUTX); |
107 | position[1] = lis3->read_data(lis3, OUTY); | |
108 | position[2] = lis3->read_data(lis3, OUTZ); | |
455fbdd3 | 109 | |
a002ee89 EP |
110 | *x = lis3lv02d_get_axis(lis3->ac.x, position); |
111 | *y = lis3lv02d_get_axis(lis3->ac.y, position); | |
112 | *z = lis3lv02d_get_axis(lis3->ac.z, position); | |
455fbdd3 PM |
113 | } |
114 | ||
a38da2ed | 115 | void lis3lv02d_poweroff(struct lis3lv02d *lis3) |
455fbdd3 | 116 | { |
a002ee89 EP |
117 | /* disable X,Y,Z axis and power down */ |
118 | lis3->write(lis3, CTRL_REG1, 0x00); | |
455fbdd3 | 119 | } |
cfce41a6 | 120 | EXPORT_SYMBOL_GPL(lis3lv02d_poweroff); |
455fbdd3 | 121 | |
a38da2ed | 122 | void lis3lv02d_poweron(struct lis3lv02d *lis3) |
455fbdd3 | 123 | { |
a002ee89 | 124 | u8 reg; |
455fbdd3 | 125 | |
a002ee89 | 126 | lis3->init(lis3); |
455fbdd3 | 127 | |
a002ee89 EP |
128 | /* |
129 | * Common configuration | |
130 | * BDU: LSB and MSB values are not updated until both have been read. | |
131 | * So the value read will always be correct. | |
132 | */ | |
133 | lis3->read(lis3, CTRL_REG2, ®); | |
134 | reg |= CTRL2_BDU; | |
135 | lis3->write(lis3, CTRL_REG2, reg); | |
455fbdd3 | 136 | } |
a002ee89 EP |
137 | EXPORT_SYMBOL_GPL(lis3lv02d_poweron); |
138 | ||
455fbdd3 | 139 | |
ef2cfc79 PM |
140 | static irqreturn_t lis302dl_interrupt(int irq, void *dummy) |
141 | { | |
142 | /* | |
143 | * Be careful: on some HP laptops the bios force DD when on battery and | |
144 | * the lid is closed. This leads to interrupts as soon as a little move | |
145 | * is done. | |
146 | */ | |
be84cfc5 | 147 | atomic_inc(&lis3_dev.count); |
ef2cfc79 | 148 | |
be84cfc5 PM |
149 | wake_up_interruptible(&lis3_dev.misc_wait); |
150 | kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN); | |
ef2cfc79 PM |
151 | return IRQ_HANDLED; |
152 | } | |
153 | ||
154 | static int lis3lv02d_misc_open(struct inode *inode, struct file *file) | |
155 | { | |
156 | int ret; | |
157 | ||
be84cfc5 | 158 | if (test_and_set_bit(0, &lis3_dev.misc_opened)) |
ef2cfc79 PM |
159 | return -EBUSY; /* already open */ |
160 | ||
be84cfc5 | 161 | atomic_set(&lis3_dev.count, 0); |
ef2cfc79 PM |
162 | |
163 | /* | |
164 | * The sensor can generate interrupts for free-fall and direction | |
165 | * detection (distinguishable with FF_WU_SRC and DD_SRC) but to keep | |
166 | * the things simple and _fast_ we activate it only for free-fall, so | |
167 | * no need to read register (very slow with ACPI). For the same reason, | |
168 | * we forbid shared interrupts. | |
169 | * | |
170 | * IRQF_TRIGGER_RISING seems pointless on HP laptops because the | |
171 | * io-apic is not configurable (and generates a warning) but I keep it | |
172 | * in case of support for other hardware. | |
173 | */ | |
be84cfc5 PM |
174 | ret = request_irq(lis3_dev.irq, lis302dl_interrupt, IRQF_TRIGGER_RISING, |
175 | DRIVER_NAME, &lis3_dev); | |
ef2cfc79 PM |
176 | |
177 | if (ret) { | |
be84cfc5 PM |
178 | clear_bit(0, &lis3_dev.misc_opened); |
179 | printk(KERN_ERR DRIVER_NAME ": IRQ%d allocation failed\n", lis3_dev.irq); | |
ef2cfc79 PM |
180 | return -EBUSY; |
181 | } | |
ef2cfc79 PM |
182 | return 0; |
183 | } | |
184 | ||
185 | static int lis3lv02d_misc_release(struct inode *inode, struct file *file) | |
186 | { | |
be84cfc5 | 187 | fasync_helper(-1, file, 0, &lis3_dev.async_queue); |
be84cfc5 PM |
188 | free_irq(lis3_dev.irq, &lis3_dev); |
189 | clear_bit(0, &lis3_dev.misc_opened); /* release the device */ | |
ef2cfc79 PM |
190 | return 0; |
191 | } | |
192 | ||
193 | static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf, | |
194 | size_t count, loff_t *pos) | |
195 | { | |
196 | DECLARE_WAITQUEUE(wait, current); | |
197 | u32 data; | |
198 | unsigned char byte_data; | |
199 | ssize_t retval = 1; | |
200 | ||
201 | if (count < 1) | |
202 | return -EINVAL; | |
203 | ||
be84cfc5 | 204 | add_wait_queue(&lis3_dev.misc_wait, &wait); |
ef2cfc79 PM |
205 | while (true) { |
206 | set_current_state(TASK_INTERRUPTIBLE); | |
be84cfc5 | 207 | data = atomic_xchg(&lis3_dev.count, 0); |
ef2cfc79 PM |
208 | if (data) |
209 | break; | |
210 | ||
211 | if (file->f_flags & O_NONBLOCK) { | |
212 | retval = -EAGAIN; | |
213 | goto out; | |
214 | } | |
215 | ||
216 | if (signal_pending(current)) { | |
217 | retval = -ERESTARTSYS; | |
218 | goto out; | |
219 | } | |
220 | ||
221 | schedule(); | |
222 | } | |
223 | ||
224 | if (data < 255) | |
225 | byte_data = data; | |
226 | else | |
227 | byte_data = 255; | |
228 | ||
229 | /* make sure we are not going into copy_to_user() with | |
230 | * TASK_INTERRUPTIBLE state */ | |
231 | set_current_state(TASK_RUNNING); | |
232 | if (copy_to_user(buf, &byte_data, sizeof(byte_data))) | |
233 | retval = -EFAULT; | |
234 | ||
235 | out: | |
236 | __set_current_state(TASK_RUNNING); | |
be84cfc5 | 237 | remove_wait_queue(&lis3_dev.misc_wait, &wait); |
ef2cfc79 PM |
238 | |
239 | return retval; | |
240 | } | |
241 | ||
242 | static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait) | |
243 | { | |
be84cfc5 PM |
244 | poll_wait(file, &lis3_dev.misc_wait, wait); |
245 | if (atomic_read(&lis3_dev.count)) | |
ef2cfc79 PM |
246 | return POLLIN | POLLRDNORM; |
247 | return 0; | |
248 | } | |
249 | ||
250 | static int lis3lv02d_misc_fasync(int fd, struct file *file, int on) | |
251 | { | |
be84cfc5 | 252 | return fasync_helper(fd, file, on, &lis3_dev.async_queue); |
ef2cfc79 PM |
253 | } |
254 | ||
255 | static const struct file_operations lis3lv02d_misc_fops = { | |
256 | .owner = THIS_MODULE, | |
257 | .llseek = no_llseek, | |
258 | .read = lis3lv02d_misc_read, | |
259 | .open = lis3lv02d_misc_open, | |
260 | .release = lis3lv02d_misc_release, | |
261 | .poll = lis3lv02d_misc_poll, | |
262 | .fasync = lis3lv02d_misc_fasync, | |
263 | }; | |
264 | ||
265 | static struct miscdevice lis3lv02d_misc_device = { | |
266 | .minor = MISC_DYNAMIC_MINOR, | |
267 | .name = "freefall", | |
268 | .fops = &lis3lv02d_misc_fops, | |
269 | }; | |
270 | ||
dc6ea97b | 271 | static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev) |
455fbdd3 PM |
272 | { |
273 | int x, y, z; | |
274 | ||
dc6ea97b EP |
275 | lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); |
276 | input_report_abs(pidev->input, ABS_X, x - lis3_dev.xcalib); | |
277 | input_report_abs(pidev->input, ABS_Y, y - lis3_dev.ycalib); | |
278 | input_report_abs(pidev->input, ABS_Z, z - lis3_dev.zcalib); | |
455fbdd3 PM |
279 | } |
280 | ||
455fbdd3 | 281 | |
455fbdd3 PM |
282 | static inline void lis3lv02d_calibrate_joystick(void) |
283 | { | |
a38da2ed DM |
284 | lis3lv02d_get_xyz(&lis3_dev, |
285 | &lis3_dev.xcalib, &lis3_dev.ycalib, &lis3_dev.zcalib); | |
455fbdd3 PM |
286 | } |
287 | ||
cfce41a6 | 288 | int lis3lv02d_joystick_enable(void) |
455fbdd3 | 289 | { |
dc6ea97b | 290 | struct input_dev *input_dev; |
455fbdd3 PM |
291 | int err; |
292 | ||
be84cfc5 | 293 | if (lis3_dev.idev) |
455fbdd3 PM |
294 | return -EINVAL; |
295 | ||
dc6ea97b | 296 | lis3_dev.idev = input_allocate_polled_device(); |
be84cfc5 | 297 | if (!lis3_dev.idev) |
455fbdd3 PM |
298 | return -ENOMEM; |
299 | ||
dc6ea97b EP |
300 | lis3_dev.idev->poll = lis3lv02d_joystick_poll; |
301 | lis3_dev.idev->poll_interval = MDPS_POLL_INTERVAL; | |
302 | input_dev = lis3_dev.idev->input; | |
303 | ||
455fbdd3 PM |
304 | lis3lv02d_calibrate_joystick(); |
305 | ||
dc6ea97b EP |
306 | input_dev->name = "ST LIS3LV02DL Accelerometer"; |
307 | input_dev->phys = DRIVER_NAME "/input0"; | |
308 | input_dev->id.bustype = BUS_HOST; | |
309 | input_dev->id.vendor = 0; | |
310 | input_dev->dev.parent = &lis3_dev.pdev->dev; | |
455fbdd3 | 311 | |
dc6ea97b EP |
312 | set_bit(EV_ABS, input_dev->evbit); |
313 | input_set_abs_params(input_dev, ABS_X, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | |
314 | input_set_abs_params(input_dev, ABS_Y, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | |
315 | input_set_abs_params(input_dev, ABS_Z, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | |
455fbdd3 | 316 | |
dc6ea97b | 317 | err = input_register_polled_device(lis3_dev.idev); |
455fbdd3 | 318 | if (err) { |
dc6ea97b | 319 | input_free_polled_device(lis3_dev.idev); |
be84cfc5 | 320 | lis3_dev.idev = NULL; |
455fbdd3 PM |
321 | } |
322 | ||
323 | return err; | |
324 | } | |
cfce41a6 | 325 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable); |
455fbdd3 | 326 | |
cfce41a6 | 327 | void lis3lv02d_joystick_disable(void) |
455fbdd3 | 328 | { |
be84cfc5 | 329 | if (!lis3_dev.idev) |
455fbdd3 PM |
330 | return; |
331 | ||
c2884242 EP |
332 | if (lis3_dev.irq) |
333 | misc_deregister(&lis3lv02d_misc_device); | |
dc6ea97b | 334 | input_unregister_polled_device(lis3_dev.idev); |
be84cfc5 | 335 | lis3_dev.idev = NULL; |
455fbdd3 | 336 | } |
cfce41a6 | 337 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); |
455fbdd3 | 338 | |
455fbdd3 PM |
339 | /* Sysfs stuff */ |
340 | static ssize_t lis3lv02d_position_show(struct device *dev, | |
341 | struct device_attribute *attr, char *buf) | |
342 | { | |
343 | int x, y, z; | |
344 | ||
a38da2ed | 345 | lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); |
455fbdd3 PM |
346 | return sprintf(buf, "(%d,%d,%d)\n", x, y, z); |
347 | } | |
348 | ||
349 | static ssize_t lis3lv02d_calibrate_show(struct device *dev, | |
350 | struct device_attribute *attr, char *buf) | |
351 | { | |
be84cfc5 | 352 | return sprintf(buf, "(%d,%d,%d)\n", lis3_dev.xcalib, lis3_dev.ycalib, lis3_dev.zcalib); |
455fbdd3 PM |
353 | } |
354 | ||
355 | static ssize_t lis3lv02d_calibrate_store(struct device *dev, | |
356 | struct device_attribute *attr, | |
357 | const char *buf, size_t count) | |
358 | { | |
455fbdd3 | 359 | lis3lv02d_calibrate_joystick(); |
455fbdd3 PM |
360 | return count; |
361 | } | |
362 | ||
363 | /* conversion btw sampling rate and the register values */ | |
364 | static int lis3lv02dl_df_val[4] = {40, 160, 640, 2560}; | |
365 | static ssize_t lis3lv02d_rate_show(struct device *dev, | |
366 | struct device_attribute *attr, char *buf) | |
367 | { | |
368 | u8 ctrl; | |
369 | int val; | |
370 | ||
a38da2ed | 371 | lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl); |
455fbdd3 PM |
372 | val = (ctrl & (CTRL1_DF0 | CTRL1_DF1)) >> 4; |
373 | return sprintf(buf, "%d\n", lis3lv02dl_df_val[val]); | |
374 | } | |
375 | ||
376 | static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL); | |
377 | static DEVICE_ATTR(calibrate, S_IRUGO|S_IWUSR, lis3lv02d_calibrate_show, | |
378 | lis3lv02d_calibrate_store); | |
379 | static DEVICE_ATTR(rate, S_IRUGO, lis3lv02d_rate_show, NULL); | |
380 | ||
381 | static struct attribute *lis3lv02d_attributes[] = { | |
382 | &dev_attr_position.attr, | |
383 | &dev_attr_calibrate.attr, | |
384 | &dev_attr_rate.attr, | |
385 | NULL | |
386 | }; | |
387 | ||
388 | static struct attribute_group lis3lv02d_attribute_group = { | |
389 | .attrs = lis3lv02d_attributes | |
390 | }; | |
391 | ||
cfce41a6 | 392 | |
a38da2ed | 393 | static int lis3lv02d_add_fs(struct lis3lv02d *lis3) |
455fbdd3 | 394 | { |
a002ee89 EP |
395 | lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); |
396 | if (IS_ERR(lis3->pdev)) | |
397 | return PTR_ERR(lis3->pdev); | |
455fbdd3 | 398 | |
a002ee89 | 399 | return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); |
455fbdd3 PM |
400 | } |
401 | ||
a002ee89 | 402 | int lis3lv02d_remove_fs(struct lis3lv02d *lis3) |
455fbdd3 | 403 | { |
a002ee89 EP |
404 | sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); |
405 | platform_device_unregister(lis3->pdev); | |
455fbdd3 PM |
406 | return 0; |
407 | } | |
cfce41a6 | 408 | EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); |
455fbdd3 | 409 | |
ab337a63 DM |
410 | /* |
411 | * Initialise the accelerometer and the various subsystems. | |
412 | * Should be rather independant of the bus system. | |
413 | */ | |
a38da2ed | 414 | int lis3lv02d_init_device(struct lis3lv02d *dev) |
ab337a63 | 415 | { |
a38da2ed DM |
416 | dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I); |
417 | ||
418 | switch (dev->whoami) { | |
419 | case LIS_DOUBLE_ID: | |
420 | printk(KERN_INFO DRIVER_NAME ": 2-byte sensor found\n"); | |
421 | dev->read_data = lis3lv02d_read_16; | |
422 | dev->mdps_max_val = 2048; | |
423 | break; | |
424 | case LIS_SINGLE_ID: | |
425 | printk(KERN_INFO DRIVER_NAME ": 1-byte sensor found\n"); | |
426 | dev->read_data = lis3lv02d_read_8; | |
427 | dev->mdps_max_val = 128; | |
428 | break; | |
429 | default: | |
430 | printk(KERN_ERR DRIVER_NAME | |
a002ee89 | 431 | ": unknown sensor type 0x%X\n", dev->whoami); |
a38da2ed DM |
432 | return -EINVAL; |
433 | } | |
434 | ||
a38da2ed | 435 | lis3lv02d_add_fs(dev); |
a002ee89 | 436 | lis3lv02d_poweron(dev); |
ab337a63 DM |
437 | |
438 | if (lis3lv02d_joystick_enable()) | |
439 | printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n"); | |
440 | ||
8f3128e7 DM |
441 | /* passing in platform specific data is purely optional and only |
442 | * used by the SPI transport layer at the moment */ | |
443 | if (dev->pdata) { | |
444 | struct lis3lv02d_platform_data *p = dev->pdata; | |
445 | ||
446 | if (p->click_flags && (dev->whoami == LIS_SINGLE_ID)) { | |
447 | dev->write(dev, CLICK_CFG, p->click_flags); | |
448 | dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); | |
449 | dev->write(dev, CLICK_LATENCY, p->click_latency); | |
450 | dev->write(dev, CLICK_WINDOW, p->click_window); | |
451 | dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf); | |
452 | dev->write(dev, CLICK_THSY_X, | |
453 | (p->click_thresh_x & 0xf) | | |
454 | (p->click_thresh_y << 4)); | |
455 | } | |
456 | ||
8873c334 DM |
457 | if (p->wakeup_flags && (dev->whoami == LIS_SINGLE_ID)) { |
458 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | |
459 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | |
460 | /* default to 2.5ms for now */ | |
461 | dev->write(dev, FF_WU_DURATION_1, 1); | |
462 | /* enable high pass filter for both free-fall units */ | |
463 | dev->write(dev, CTRL_REG2, HP_FF_WU1 | HP_FF_WU2); | |
464 | } | |
465 | ||
8f3128e7 DM |
466 | if (p->irq_cfg) |
467 | dev->write(dev, CTRL_REG3, p->irq_cfg); | |
468 | } | |
469 | ||
a38da2ed | 470 | /* bail if we did not get an IRQ from the bus layer */ |
ab337a63 DM |
471 | if (!dev->irq) { |
472 | printk(KERN_ERR DRIVER_NAME | |
a38da2ed | 473 | ": No IRQ. Disabling /dev/freefall\n"); |
ab337a63 DM |
474 | goto out; |
475 | } | |
476 | ||
ab337a63 DM |
477 | if (misc_register(&lis3lv02d_misc_device)) |
478 | printk(KERN_ERR DRIVER_NAME ": misc_register failed\n"); | |
479 | out: | |
ab337a63 DM |
480 | return 0; |
481 | } | |
482 | EXPORT_SYMBOL_GPL(lis3lv02d_init_device); | |
483 | ||
455fbdd3 | 484 | MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver"); |
ef2cfc79 | 485 | MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek"); |
455fbdd3 PM |
486 | MODULE_LICENSE("GPL"); |
487 |