Lines Matching refs:lis3

116 static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg)  in lis3lv02d_read_8()  argument
119 if (lis3->read(lis3, reg, &lo) < 0) in lis3lv02d_read_8()
125 static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg) in lis3lv02d_read_12() argument
129 lis3->read(lis3, reg - 1, &lo); in lis3lv02d_read_12()
130 lis3->read(lis3, reg, &hi); in lis3lv02d_read_12()
136 static s16 lis331dlh_read_data(struct lis3lv02d *lis3, int reg) in lis331dlh_read_data() argument
141 lis3->read(lis3, reg - 1, &lo); in lis331dlh_read_data()
142 lis3->read(lis3, reg, &hi); in lis331dlh_read_data()
145 return (s16) v >> lis3->shift_adj; in lis331dlh_read_data()
172 static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) in lis3lv02d_get_xyz() argument
177 if (lis3->blkread) { in lis3lv02d_get_xyz()
178 if (lis3->whoami == WAI_12B) { in lis3lv02d_get_xyz()
180 lis3->blkread(lis3, OUTX_L, 6, (u8 *)data); in lis3lv02d_get_xyz()
186 lis3->blkread(lis3, OUTX, 5, data); in lis3lv02d_get_xyz()
191 position[0] = lis3->read_data(lis3, OUTX); in lis3lv02d_get_xyz()
192 position[1] = lis3->read_data(lis3, OUTY); in lis3lv02d_get_xyz()
193 position[2] = lis3->read_data(lis3, OUTZ); in lis3lv02d_get_xyz()
197 position[i] = (position[i] * lis3->scale) / LIS3_ACCURACY; in lis3lv02d_get_xyz()
199 *x = lis3lv02d_get_axis(lis3->ac.x, position); in lis3lv02d_get_xyz()
200 *y = lis3lv02d_get_axis(lis3->ac.y, position); in lis3lv02d_get_xyz()
201 *z = lis3lv02d_get_axis(lis3->ac.z, position); in lis3lv02d_get_xyz()
211 static int lis3lv02d_get_odr_index(struct lis3lv02d *lis3) in lis3lv02d_get_odr_index() argument
216 lis3->read(lis3, CTRL_REG1, &ctrl); in lis3lv02d_get_odr_index()
217 ctrl &= lis3->odr_mask; in lis3lv02d_get_odr_index()
218 shift = ffs(lis3->odr_mask) - 1; in lis3lv02d_get_odr_index()
222 static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3) in lis3lv02d_get_pwron_wait() argument
224 int odr_idx = lis3lv02d_get_odr_index(lis3); in lis3lv02d_get_pwron_wait()
225 int div = lis3->odrs[odr_idx]; in lis3lv02d_get_pwron_wait()
233 dev_err(&lis3->pdev->dev, "Error unknown odrs-index: %d\n", odr_idx); in lis3lv02d_get_pwron_wait()
238 msleep(lis3->pwron_delay / div); in lis3lv02d_get_pwron_wait()
242 static int lis3lv02d_set_odr(struct lis3lv02d *lis3, int rate) in lis3lv02d_set_odr() argument
250 lis3->read(lis3, CTRL_REG1, &ctrl); in lis3lv02d_set_odr()
251 ctrl &= ~lis3->odr_mask; in lis3lv02d_set_odr()
252 len = 1 << hweight_long(lis3->odr_mask); /* # of possible values */ in lis3lv02d_set_odr()
253 shift = ffs(lis3->odr_mask) - 1; in lis3lv02d_set_odr()
256 if (lis3->odrs[i] == rate) { in lis3lv02d_set_odr()
257 lis3->write(lis3, CTRL_REG1, in lis3lv02d_set_odr()
264 static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) in lis3lv02d_selftest() argument
273 mutex_lock(&lis3->mutex); in lis3lv02d_selftest()
275 irq_cfg = lis3->irq_cfg; in lis3lv02d_selftest()
276 if (lis3->whoami == WAI_8B) { in lis3lv02d_selftest()
277 lis3->data_ready_count[IRQ_LINE0] = 0; in lis3lv02d_selftest()
278 lis3->data_ready_count[IRQ_LINE1] = 0; in lis3lv02d_selftest()
281 atomic_inc(&lis3->wake_thread); in lis3lv02d_selftest()
282 lis3->irq_cfg = LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY; in lis3lv02d_selftest()
283 lis3->read(lis3, CTRL_REG3, &ctrl_reg_data); in lis3lv02d_selftest()
284 lis3->write(lis3, CTRL_REG3, (ctrl_reg_data & in lis3lv02d_selftest()
289 if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) { in lis3lv02d_selftest()
294 if (lis3->whoami == WAI_12B) in lis3lv02d_selftest()
300 lis3->read(lis3, ctlreg, &reg); in lis3lv02d_selftest()
301 lis3->write(lis3, ctlreg, (reg | selftest)); in lis3lv02d_selftest()
302 ret = lis3lv02d_get_pwron_wait(lis3); in lis3lv02d_selftest()
307 x = lis3->read_data(lis3, OUTX); in lis3lv02d_selftest()
308 y = lis3->read_data(lis3, OUTY); in lis3lv02d_selftest()
309 z = lis3->read_data(lis3, OUTZ); in lis3lv02d_selftest()
312 lis3->write(lis3, ctlreg, reg); in lis3lv02d_selftest()
313 ret = lis3lv02d_get_pwron_wait(lis3); in lis3lv02d_selftest()
317 results[0] = x - lis3->read_data(lis3, OUTX); in lis3lv02d_selftest()
318 results[1] = y - lis3->read_data(lis3, OUTY); in lis3lv02d_selftest()
319 results[2] = z - lis3->read_data(lis3, OUTZ); in lis3lv02d_selftest()
323 if (lis3->whoami == WAI_8B) { in lis3lv02d_selftest()
325 atomic_dec(&lis3->wake_thread); in lis3lv02d_selftest()
326 lis3->write(lis3, CTRL_REG3, ctrl_reg_data); in lis3lv02d_selftest()
327 lis3->irq_cfg = irq_cfg; in lis3lv02d_selftest()
330 lis3->data_ready_count[IRQ_LINE0] < 2) { in lis3lv02d_selftest()
336 lis3->data_ready_count[IRQ_LINE1] < 2) { in lis3lv02d_selftest()
342 if (lis3->pdata) { in lis3lv02d_selftest()
346 if ((results[i] < lis3->pdata->st_min_limits[i]) || in lis3lv02d_selftest()
347 (results[i] > lis3->pdata->st_max_limits[i])) { in lis3lv02d_selftest()
356 mutex_unlock(&lis3->mutex); in lis3lv02d_selftest()
376 static inline void lis3_context_save(struct lis3lv02d *lis3) in lis3_context_save() argument
379 for (i = 0; i < lis3->regs_size; i++) in lis3_context_save()
380 lis3->read(lis3, lis3->regs[i], &lis3->reg_cache[i]); in lis3_context_save()
381 lis3->regs_stored = true; in lis3_context_save()
384 static inline void lis3_context_restore(struct lis3lv02d *lis3) in lis3_context_restore() argument
387 if (lis3->regs_stored) in lis3_context_restore()
388 for (i = 0; i < lis3->regs_size; i++) in lis3_context_restore()
389 lis3->write(lis3, lis3->regs[i], lis3->reg_cache[i]); in lis3_context_restore()
392 void lis3lv02d_poweroff(struct lis3lv02d *lis3) in lis3lv02d_poweroff() argument
394 if (lis3->reg_ctrl) in lis3lv02d_poweroff()
395 lis3_context_save(lis3); in lis3lv02d_poweroff()
397 lis3->write(lis3, CTRL_REG1, 0x00); in lis3lv02d_poweroff()
398 if (lis3->reg_ctrl) in lis3lv02d_poweroff()
399 lis3->reg_ctrl(lis3, LIS3_REG_OFF); in lis3lv02d_poweroff()
403 int lis3lv02d_poweron(struct lis3lv02d *lis3) in lis3lv02d_poweron() argument
408 lis3->init(lis3); in lis3lv02d_poweron()
416 if (lis3->pdata) { in lis3lv02d_poweron()
417 lis3->read(lis3, CTRL_REG2, &reg); in lis3lv02d_poweron()
418 if (lis3->whoami == WAI_12B) in lis3lv02d_poweron()
420 else if (lis3->whoami == WAI_3DLH) in lis3lv02d_poweron()
424 lis3->write(lis3, CTRL_REG2, reg); in lis3lv02d_poweron()
426 if (lis3->whoami == WAI_3DLH) { in lis3lv02d_poweron()
427 lis3->read(lis3, CTRL_REG4, &reg); in lis3lv02d_poweron()
429 lis3->write(lis3, CTRL_REG4, reg); in lis3lv02d_poweron()
433 err = lis3lv02d_get_pwron_wait(lis3); in lis3lv02d_poweron()
437 if (lis3->reg_ctrl) in lis3lv02d_poweron()
438 lis3_context_restore(lis3); in lis3lv02d_poweron()
447 struct lis3lv02d *lis3 = input_get_drvdata(input); in lis3lv02d_joystick_poll() local
450 mutex_lock(&lis3->mutex); in lis3lv02d_joystick_poll()
451 lis3lv02d_get_xyz(lis3, &x, &y, &z); in lis3lv02d_joystick_poll()
456 mutex_unlock(&lis3->mutex); in lis3lv02d_joystick_poll()
461 struct lis3lv02d *lis3 = input_get_drvdata(input); in lis3lv02d_joystick_open() local
463 if (lis3->pm_dev) in lis3lv02d_joystick_open()
464 pm_runtime_get_sync(lis3->pm_dev); in lis3lv02d_joystick_open()
466 if (lis3->pdata && lis3->whoami == WAI_8B && lis3->idev) in lis3lv02d_joystick_open()
467 atomic_set(&lis3->wake_thread, 1); in lis3lv02d_joystick_open()
479 struct lis3lv02d *lis3 = input_get_drvdata(input); in lis3lv02d_joystick_close() local
481 atomic_set(&lis3->wake_thread, 0); in lis3lv02d_joystick_close()
482 if (lis3->pm_dev) in lis3lv02d_joystick_close()
483 pm_runtime_put(lis3->pm_dev); in lis3lv02d_joystick_close()
488 struct lis3lv02d *lis3 = data; in lis302dl_interrupt() local
490 if (!test_bit(0, &lis3->misc_opened)) in lis302dl_interrupt()
498 atomic_inc(&lis3->count); in lis302dl_interrupt()
500 wake_up_interruptible(&lis3->misc_wait); in lis302dl_interrupt()
501 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN); in lis302dl_interrupt()
503 if (atomic_read(&lis3->wake_thread)) in lis302dl_interrupt()
508 static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3) in lis302dl_interrupt_handle_click() argument
510 struct input_dev *dev = lis3->idev; in lis302dl_interrupt_handle_click()
513 mutex_lock(&lis3->mutex); in lis302dl_interrupt_handle_click()
514 lis3->read(lis3, CLICK_SRC, &click_src); in lis302dl_interrupt_handle_click()
517 input_report_key(dev, lis3->mapped_btns[0], 1); in lis302dl_interrupt_handle_click()
518 input_report_key(dev, lis3->mapped_btns[0], 0); in lis302dl_interrupt_handle_click()
522 input_report_key(dev, lis3->mapped_btns[1], 1); in lis302dl_interrupt_handle_click()
523 input_report_key(dev, lis3->mapped_btns[1], 0); in lis302dl_interrupt_handle_click()
527 input_report_key(dev, lis3->mapped_btns[2], 1); in lis302dl_interrupt_handle_click()
528 input_report_key(dev, lis3->mapped_btns[2], 0); in lis302dl_interrupt_handle_click()
531 mutex_unlock(&lis3->mutex); in lis302dl_interrupt_handle_click()
534 static inline void lis302dl_data_ready(struct lis3lv02d *lis3, int index) in lis302dl_data_ready() argument
539 lis3lv02d_get_xyz(lis3, &dummy, &dummy, &dummy); in lis302dl_data_ready()
540 lis3->data_ready_count[index]++; in lis302dl_data_ready()
545 struct lis3lv02d *lis3 = data; in lis302dl_interrupt_thread1_8b() local
546 u8 irq_cfg = lis3->irq_cfg & LIS3_IRQ1_MASK; in lis302dl_interrupt_thread1_8b()
549 lis302dl_interrupt_handle_click(lis3); in lis302dl_interrupt_thread1_8b()
551 lis302dl_data_ready(lis3, IRQ_LINE0); in lis302dl_interrupt_thread1_8b()
553 lis3lv02d_joystick_poll(lis3->idev); in lis302dl_interrupt_thread1_8b()
560 struct lis3lv02d *lis3 = data; in lis302dl_interrupt_thread2_8b() local
561 u8 irq_cfg = lis3->irq_cfg & LIS3_IRQ2_MASK; in lis302dl_interrupt_thread2_8b()
564 lis302dl_interrupt_handle_click(lis3); in lis302dl_interrupt_thread2_8b()
566 lis302dl_data_ready(lis3, IRQ_LINE1); in lis302dl_interrupt_thread2_8b()
568 lis3lv02d_joystick_poll(lis3->idev); in lis302dl_interrupt_thread2_8b()
575 struct lis3lv02d *lis3 = container_of(file->private_data, in lis3lv02d_misc_open() local
578 if (test_and_set_bit(0, &lis3->misc_opened)) in lis3lv02d_misc_open()
581 if (lis3->pm_dev) in lis3lv02d_misc_open()
582 pm_runtime_get_sync(lis3->pm_dev); in lis3lv02d_misc_open()
584 atomic_set(&lis3->count, 0); in lis3lv02d_misc_open()
590 struct lis3lv02d *lis3 = container_of(file->private_data, in lis3lv02d_misc_release() local
593 clear_bit(0, &lis3->misc_opened); /* release the device */ in lis3lv02d_misc_release()
594 if (lis3->pm_dev) in lis3lv02d_misc_release()
595 pm_runtime_put(lis3->pm_dev); in lis3lv02d_misc_release()
602 struct lis3lv02d *lis3 = container_of(file->private_data, in lis3lv02d_misc_read() local
613 add_wait_queue(&lis3->misc_wait, &wait); in lis3lv02d_misc_read()
616 data = atomic_xchg(&lis3->count, 0); in lis3lv02d_misc_read()
646 remove_wait_queue(&lis3->misc_wait, &wait); in lis3lv02d_misc_read()
653 struct lis3lv02d *lis3 = container_of(file->private_data, in lis3lv02d_misc_poll() local
656 poll_wait(file, &lis3->misc_wait, wait); in lis3lv02d_misc_poll()
657 if (atomic_read(&lis3->count)) in lis3lv02d_misc_poll()
664 struct lis3lv02d *lis3 = container_of(file->private_data, in lis3lv02d_misc_fasync() local
667 return fasync_helper(fd, file, on, &lis3->async_queue); in lis3lv02d_misc_fasync()
680 int lis3lv02d_joystick_enable(struct lis3lv02d *lis3) in lis3lv02d_joystick_enable() argument
687 if (lis3->idev) in lis3lv02d_joystick_enable()
698 input_dev->dev.parent = &lis3->pdev->dev; in lis3lv02d_joystick_enable()
703 max_val = (lis3->mdps_max_val * lis3->scale) / LIS3_ACCURACY; in lis3lv02d_joystick_enable()
704 if (lis3->whoami == WAI_12B) { in lis3lv02d_joystick_enable()
711 fuzz = (fuzz * lis3->scale) / LIS3_ACCURACY; in lis3lv02d_joystick_enable()
712 flat = (flat * lis3->scale) / LIS3_ACCURACY; in lis3lv02d_joystick_enable()
718 input_set_drvdata(input_dev, lis3); in lis3lv02d_joystick_enable()
719 lis3->idev = input_dev; in lis3lv02d_joystick_enable()
729 lis3->mapped_btns[0] = lis3lv02d_get_axis(abs(lis3->ac.x), btns); in lis3lv02d_joystick_enable()
730 lis3->mapped_btns[1] = lis3lv02d_get_axis(abs(lis3->ac.y), btns); in lis3lv02d_joystick_enable()
731 lis3->mapped_btns[2] = lis3lv02d_get_axis(abs(lis3->ac.z), btns); in lis3lv02d_joystick_enable()
733 err = input_register_device(lis3->idev); in lis3lv02d_joystick_enable()
741 lis3->idev = NULL; in lis3lv02d_joystick_enable()
747 void lis3lv02d_joystick_disable(struct lis3lv02d *lis3) in lis3lv02d_joystick_disable() argument
749 if (lis3->irq) in lis3lv02d_joystick_disable()
750 free_irq(lis3->irq, lis3); in lis3lv02d_joystick_disable()
751 if (lis3->pdata && lis3->pdata->irq2) in lis3lv02d_joystick_disable()
752 free_irq(lis3->pdata->irq2, lis3); in lis3lv02d_joystick_disable()
754 if (!lis3->idev) in lis3lv02d_joystick_disable()
757 if (lis3->irq) in lis3lv02d_joystick_disable()
758 misc_deregister(&lis3->miscdev); in lis3lv02d_joystick_disable()
759 input_unregister_device(lis3->idev); in lis3lv02d_joystick_disable()
760 lis3->idev = NULL; in lis3lv02d_joystick_disable()
765 static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3) in lis3lv02d_sysfs_poweron() argument
775 if (lis3->pm_dev) { in lis3lv02d_sysfs_poweron()
776 pm_runtime_get_sync(lis3->pm_dev); in lis3lv02d_sysfs_poweron()
777 pm_runtime_put_noidle(lis3->pm_dev); in lis3lv02d_sysfs_poweron()
778 pm_schedule_suspend(lis3->pm_dev, LIS3_SYSFS_POWERDOWN_DELAY); in lis3lv02d_sysfs_poweron()
785 struct lis3lv02d *lis3 = dev_get_drvdata(dev); in lis3lv02d_selftest_show() local
793 lis3lv02d_sysfs_poweron(lis3); in lis3lv02d_selftest_show()
794 switch (lis3lv02d_selftest(lis3, values)) { in lis3lv02d_selftest_show()
813 struct lis3lv02d *lis3 = dev_get_drvdata(dev); in lis3lv02d_position_show() local
816 lis3lv02d_sysfs_poweron(lis3); in lis3lv02d_position_show()
817 mutex_lock(&lis3->mutex); in lis3lv02d_position_show()
818 lis3lv02d_get_xyz(lis3, &x, &y, &z); in lis3lv02d_position_show()
819 mutex_unlock(&lis3->mutex); in lis3lv02d_position_show()
826 struct lis3lv02d *lis3 = dev_get_drvdata(dev); in lis3lv02d_rate_show() local
829 lis3lv02d_sysfs_poweron(lis3); in lis3lv02d_rate_show()
831 odr_idx = lis3lv02d_get_odr_index(lis3); in lis3lv02d_rate_show()
832 return sprintf(buf, "%d\n", lis3->odrs[odr_idx]); in lis3lv02d_rate_show()
839 struct lis3lv02d *lis3 = dev_get_drvdata(dev); in lis3lv02d_rate_set() local
847 lis3lv02d_sysfs_poweron(lis3); in lis3lv02d_rate_set()
848 if (lis3lv02d_set_odr(lis3, rate)) in lis3lv02d_rate_set()
871 static int lis3lv02d_add_fs(struct lis3lv02d *lis3) in lis3lv02d_add_fs() argument
873 lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); in lis3lv02d_add_fs()
874 if (IS_ERR(lis3->pdev)) in lis3lv02d_add_fs()
875 return PTR_ERR(lis3->pdev); in lis3lv02d_add_fs()
877 platform_set_drvdata(lis3->pdev, lis3); in lis3lv02d_add_fs()
878 return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); in lis3lv02d_add_fs()
881 void lis3lv02d_remove_fs(struct lis3lv02d *lis3) in lis3lv02d_remove_fs() argument
883 sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); in lis3lv02d_remove_fs()
884 platform_device_unregister(lis3->pdev); in lis3lv02d_remove_fs()
885 if (lis3->pm_dev) { in lis3lv02d_remove_fs()
887 pm_runtime_barrier(lis3->pm_dev); in lis3lv02d_remove_fs()
890 if (!pm_runtime_suspended(lis3->pm_dev)) in lis3lv02d_remove_fs()
891 lis3lv02d_poweroff(lis3); in lis3lv02d_remove_fs()
893 pm_runtime_disable(lis3->pm_dev); in lis3lv02d_remove_fs()
894 pm_runtime_set_suspended(lis3->pm_dev); in lis3lv02d_remove_fs()
896 kfree(lis3->reg_cache); in lis3lv02d_remove_fs()
900 static void lis3lv02d_8b_configure(struct lis3lv02d *lis3, in lis3lv02d_8b_configure() argument
907 lis3->write(lis3, CLICK_CFG, p->click_flags); in lis3lv02d_8b_configure()
908 lis3->write(lis3, CLICK_TIMELIMIT, p->click_time_limit); in lis3lv02d_8b_configure()
909 lis3->write(lis3, CLICK_LATENCY, p->click_latency); in lis3lv02d_8b_configure()
910 lis3->write(lis3, CLICK_WINDOW, p->click_window); in lis3lv02d_8b_configure()
911 lis3->write(lis3, CLICK_THSZ, p->click_thresh_z & 0xf); in lis3lv02d_8b_configure()
912 lis3->write(lis3, CLICK_THSY_X, in lis3lv02d_8b_configure()
916 if (lis3->idev) { in lis3lv02d_8b_configure()
917 input_set_capability(lis3->idev, EV_KEY, BTN_X); in lis3lv02d_8b_configure()
918 input_set_capability(lis3->idev, EV_KEY, BTN_Y); in lis3lv02d_8b_configure()
919 input_set_capability(lis3->idev, EV_KEY, BTN_Z); in lis3lv02d_8b_configure()
924 lis3->write(lis3, FF_WU_CFG_1, p->wakeup_flags); in lis3lv02d_8b_configure()
925 lis3->write(lis3, FF_WU_THS_1, p->wakeup_thresh & 0x7f); in lis3lv02d_8b_configure()
927 lis3->write(lis3, FF_WU_DURATION_1, p->duration1 + 1); in lis3lv02d_8b_configure()
932 lis3->write(lis3, FF_WU_CFG_2, p->wakeup_flags2); in lis3lv02d_8b_configure()
933 lis3->write(lis3, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f); in lis3lv02d_8b_configure()
935 lis3->write(lis3, FF_WU_DURATION_2, p->duration2 + 1); in lis3lv02d_8b_configure()
939 lis3->write(lis3, CTRL_REG2, ctrl2); in lis3lv02d_8b_configure()
947 DRIVER_NAME, lis3); in lis3lv02d_8b_configure()
954 int lis3lv02d_init_dt(struct lis3lv02d *lis3) in lis3lv02d_init_dt() argument
957 struct device_node *np = lis3->of_node; in lis3lv02d_init_dt()
961 if (!lis3->of_node) in lis3lv02d_init_dt()
1106 lis3->pdata = pdata; in lis3lv02d_init_dt()
1112 int lis3lv02d_init_dt(struct lis3lv02d *lis3) in lis3lv02d_init_dt() argument
1123 int lis3lv02d_init_device(struct lis3lv02d *lis3) in lis3lv02d_init_device() argument
1129 lis3->whoami = lis3lv02d_read_8(lis3, WHO_AM_I); in lis3lv02d_init_device()
1131 switch (lis3->whoami) { in lis3lv02d_init_device()
1134 lis3->read_data = lis3lv02d_read_12; in lis3lv02d_init_device()
1135 lis3->mdps_max_val = 2048; in lis3lv02d_init_device()
1136 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_12B; in lis3lv02d_init_device()
1137 lis3->odrs = lis3_12_rates; in lis3lv02d_init_device()
1138 lis3->odr_mask = CTRL1_DF0 | CTRL1_DF1; in lis3lv02d_init_device()
1139 lis3->scale = LIS3_SENSITIVITY_12B; in lis3lv02d_init_device()
1140 lis3->regs = lis3_wai12_regs; in lis3lv02d_init_device()
1141 lis3->regs_size = ARRAY_SIZE(lis3_wai12_regs); in lis3lv02d_init_device()
1145 lis3->read_data = lis3lv02d_read_8; in lis3lv02d_init_device()
1146 lis3->mdps_max_val = 128; in lis3lv02d_init_device()
1147 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; in lis3lv02d_init_device()
1148 lis3->odrs = lis3_8_rates; in lis3lv02d_init_device()
1149 lis3->odr_mask = CTRL1_DR; in lis3lv02d_init_device()
1150 lis3->scale = LIS3_SENSITIVITY_8B; in lis3lv02d_init_device()
1151 lis3->regs = lis3_wai8_regs; in lis3lv02d_init_device()
1152 lis3->regs_size = ARRAY_SIZE(lis3_wai8_regs); in lis3lv02d_init_device()
1156 lis3->read_data = lis3lv02d_read_8; in lis3lv02d_init_device()
1157 lis3->mdps_max_val = 128; in lis3lv02d_init_device()
1158 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; in lis3lv02d_init_device()
1159 lis3->odrs = lis3_3dc_rates; in lis3lv02d_init_device()
1160 lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; in lis3lv02d_init_device()
1161 lis3->scale = LIS3_SENSITIVITY_8B; in lis3lv02d_init_device()
1165 lis3->read_data = lis331dlh_read_data; in lis3lv02d_init_device()
1166 lis3->mdps_max_val = 2048; /* 12 bits for 2G */ in lis3lv02d_init_device()
1167 lis3->shift_adj = SHIFT_ADJ_2G; in lis3lv02d_init_device()
1168 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; in lis3lv02d_init_device()
1169 lis3->odrs = lis3_3dlh_rates; in lis3lv02d_init_device()
1170 lis3->odr_mask = CTRL1_DR0 | CTRL1_DR1; in lis3lv02d_init_device()
1171 lis3->scale = LIS3DLH_SENSITIVITY_2G; in lis3lv02d_init_device()
1174 pr_err("unknown sensor type 0x%X\n", lis3->whoami); in lis3lv02d_init_device()
1178 lis3->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs), in lis3lv02d_init_device()
1181 if (lis3->reg_cache == NULL) in lis3lv02d_init_device()
1184 mutex_init(&lis3->mutex); in lis3lv02d_init_device()
1185 atomic_set(&lis3->wake_thread, 0); in lis3lv02d_init_device()
1187 lis3lv02d_add_fs(lis3); in lis3lv02d_init_device()
1188 err = lis3lv02d_poweron(lis3); in lis3lv02d_init_device()
1190 lis3lv02d_remove_fs(lis3); in lis3lv02d_init_device()
1194 if (lis3->pm_dev) { in lis3lv02d_init_device()
1195 pm_runtime_set_active(lis3->pm_dev); in lis3lv02d_init_device()
1196 pm_runtime_enable(lis3->pm_dev); in lis3lv02d_init_device()
1199 if (lis3lv02d_joystick_enable(lis3)) in lis3lv02d_init_device()
1204 if (lis3->pdata) { in lis3lv02d_init_device()
1205 struct lis3lv02d_platform_data *p = lis3->pdata; in lis3lv02d_init_device()
1207 if (lis3->whoami == WAI_8B) in lis3lv02d_init_device()
1208 lis3lv02d_8b_configure(lis3, p); in lis3lv02d_init_device()
1212 lis3->irq_cfg = p->irq_cfg; in lis3lv02d_init_device()
1214 lis3->write(lis3, CTRL_REG3, p->irq_cfg); in lis3lv02d_init_device()
1217 lis3lv02d_set_odr(lis3, p->default_rate); in lis3lv02d_init_device()
1221 if (!lis3->irq) { in lis3lv02d_init_device()
1237 if (lis3->pdata && lis3->whoami == WAI_8B) in lis3lv02d_init_device()
1242 err = request_threaded_irq(lis3->irq, lis302dl_interrupt, in lis3lv02d_init_device()
1246 DRIVER_NAME, lis3); in lis3lv02d_init_device()
1253 lis3->miscdev.minor = MISC_DYNAMIC_MINOR; in lis3lv02d_init_device()
1254 lis3->miscdev.name = "freefall"; in lis3lv02d_init_device()
1255 lis3->miscdev.fops = &lis3lv02d_misc_fops; in lis3lv02d_init_device()
1257 if (misc_register(&lis3->miscdev)) in lis3lv02d_init_device()