lis3 116 drivers/misc/lis3lv02d/lis3lv02d.c static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg) lis3 119 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->read(lis3, reg, &lo) < 0) lis3 125 drivers/misc/lis3lv02d/lis3lv02d.c static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg) lis3 129 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, reg - 1, &lo); lis3 130 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, reg, &hi); lis3 136 drivers/misc/lis3lv02d/lis3lv02d.c static s16 lis331dlh_read_data(struct lis3lv02d *lis3, int reg) lis3 141 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, reg - 1, &lo); lis3 142 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, reg, &hi); lis3 145 drivers/misc/lis3lv02d/lis3lv02d.c return (s16) v >> lis3->shift_adj; lis3 172 drivers/misc/lis3lv02d/lis3lv02d.c static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) lis3 177 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->blkread) { lis3 178 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_12B) { lis3 180 drivers/misc/lis3lv02d/lis3lv02d.c lis3->blkread(lis3, OUTX_L, 6, (u8 *)data); lis3 186 drivers/misc/lis3lv02d/lis3lv02d.c lis3->blkread(lis3, OUTX, 5, data); lis3 191 drivers/misc/lis3lv02d/lis3lv02d.c position[0] = lis3->read_data(lis3, OUTX); lis3 192 drivers/misc/lis3lv02d/lis3lv02d.c position[1] = lis3->read_data(lis3, OUTY); lis3 193 drivers/misc/lis3lv02d/lis3lv02d.c position[2] = lis3->read_data(lis3, OUTZ); lis3 197 drivers/misc/lis3lv02d/lis3lv02d.c position[i] = (position[i] * lis3->scale) / LIS3_ACCURACY; lis3 199 drivers/misc/lis3lv02d/lis3lv02d.c *x = lis3lv02d_get_axis(lis3->ac.x, position); lis3 200 drivers/misc/lis3lv02d/lis3lv02d.c *y = lis3lv02d_get_axis(lis3->ac.y, position); lis3 201 drivers/misc/lis3lv02d/lis3lv02d.c *z = lis3lv02d_get_axis(lis3->ac.z, position); lis3 211 drivers/misc/lis3lv02d/lis3lv02d.c static int lis3lv02d_get_odr(struct lis3lv02d *lis3) lis3 216 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CTRL_REG1, &ctrl); lis3 217 drivers/misc/lis3lv02d/lis3lv02d.c ctrl &= lis3->odr_mask; lis3 218 drivers/misc/lis3lv02d/lis3lv02d.c shift = ffs(lis3->odr_mask) - 1; lis3 219 drivers/misc/lis3lv02d/lis3lv02d.c return lis3->odrs[(ctrl >> shift)]; lis3 222 drivers/misc/lis3lv02d/lis3lv02d.c static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3) lis3 224 drivers/misc/lis3lv02d/lis3lv02d.c int div = lis3lv02d_get_odr(lis3); lis3 230 drivers/misc/lis3lv02d/lis3lv02d.c msleep(lis3->pwron_delay / div); lis3 234 drivers/misc/lis3lv02d/lis3lv02d.c static int lis3lv02d_set_odr(struct lis3lv02d *lis3, int rate) lis3 242 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CTRL_REG1, &ctrl); lis3 243 drivers/misc/lis3lv02d/lis3lv02d.c ctrl &= ~lis3->odr_mask; lis3 244 drivers/misc/lis3lv02d/lis3lv02d.c len = 1 << hweight_long(lis3->odr_mask); /* # of possible values */ lis3 245 drivers/misc/lis3lv02d/lis3lv02d.c shift = ffs(lis3->odr_mask) - 1; lis3 248 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->odrs[i] == rate) { lis3 249 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG1, lis3 256 drivers/misc/lis3lv02d/lis3lv02d.c static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) lis3 265 drivers/misc/lis3lv02d/lis3lv02d.c mutex_lock(&lis3->mutex); lis3 267 drivers/misc/lis3lv02d/lis3lv02d.c irq_cfg = lis3->irq_cfg; lis3 268 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_8B) { lis3 269 drivers/misc/lis3lv02d/lis3lv02d.c lis3->data_ready_count[IRQ_LINE0] = 0; lis3 270 drivers/misc/lis3lv02d/lis3lv02d.c lis3->data_ready_count[IRQ_LINE1] = 0; lis3 273 drivers/misc/lis3lv02d/lis3lv02d.c atomic_inc(&lis3->wake_thread); lis3 274 drivers/misc/lis3lv02d/lis3lv02d.c lis3->irq_cfg = LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY; lis3 275 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CTRL_REG3, &ctrl_reg_data); lis3 276 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG3, (ctrl_reg_data & lis3 281 drivers/misc/lis3lv02d/lis3lv02d.c if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) { lis3 286 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_12B) lis3 292 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, ctlreg, ®); lis3 293 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, ctlreg, (reg | selftest)); lis3 294 drivers/misc/lis3lv02d/lis3lv02d.c ret = lis3lv02d_get_pwron_wait(lis3); lis3 299 drivers/misc/lis3lv02d/lis3lv02d.c x = lis3->read_data(lis3, OUTX); lis3 300 drivers/misc/lis3lv02d/lis3lv02d.c y = lis3->read_data(lis3, OUTY); lis3 301 drivers/misc/lis3lv02d/lis3lv02d.c z = lis3->read_data(lis3, OUTZ); lis3 304 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, ctlreg, reg); lis3 305 drivers/misc/lis3lv02d/lis3lv02d.c ret = lis3lv02d_get_pwron_wait(lis3); lis3 309 drivers/misc/lis3lv02d/lis3lv02d.c results[0] = x - lis3->read_data(lis3, OUTX); lis3 310 drivers/misc/lis3lv02d/lis3lv02d.c results[1] = y - lis3->read_data(lis3, OUTY); lis3 311 drivers/misc/lis3lv02d/lis3lv02d.c results[2] = z - lis3->read_data(lis3, OUTZ); lis3 315 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_8B) { lis3 317 drivers/misc/lis3lv02d/lis3lv02d.c atomic_dec(&lis3->wake_thread); lis3 318 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG3, ctrl_reg_data); lis3 319 drivers/misc/lis3lv02d/lis3lv02d.c lis3->irq_cfg = irq_cfg; lis3 322 drivers/misc/lis3lv02d/lis3lv02d.c lis3->data_ready_count[IRQ_LINE0] < 2) { lis3 328 drivers/misc/lis3lv02d/lis3lv02d.c lis3->data_ready_count[IRQ_LINE1] < 2) { lis3 334 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata) { lis3 338 drivers/misc/lis3lv02d/lis3lv02d.c if ((results[i] < lis3->pdata->st_min_limits[i]) || lis3 339 drivers/misc/lis3lv02d/lis3lv02d.c (results[i] > lis3->pdata->st_max_limits[i])) { lis3 348 drivers/misc/lis3lv02d/lis3lv02d.c mutex_unlock(&lis3->mutex); lis3 368 drivers/misc/lis3lv02d/lis3lv02d.c static inline void lis3_context_save(struct lis3lv02d *lis3) lis3 371 drivers/misc/lis3lv02d/lis3lv02d.c for (i = 0; i < lis3->regs_size; i++) lis3 372 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, lis3->regs[i], &lis3->reg_cache[i]); lis3 373 drivers/misc/lis3lv02d/lis3lv02d.c lis3->regs_stored = true; lis3 376 drivers/misc/lis3lv02d/lis3lv02d.c static inline void lis3_context_restore(struct lis3lv02d *lis3) lis3 379 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->regs_stored) lis3 380 drivers/misc/lis3lv02d/lis3lv02d.c for (i = 0; i < lis3->regs_size; i++) lis3 381 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, lis3->regs[i], lis3->reg_cache[i]); lis3 384 drivers/misc/lis3lv02d/lis3lv02d.c void lis3lv02d_poweroff(struct lis3lv02d *lis3) lis3 386 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->reg_ctrl) lis3 387 drivers/misc/lis3lv02d/lis3lv02d.c lis3_context_save(lis3); lis3 389 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG1, 0x00); lis3 390 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->reg_ctrl) lis3 391 drivers/misc/lis3lv02d/lis3lv02d.c lis3->reg_ctrl(lis3, LIS3_REG_OFF); lis3 395 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_poweron(struct lis3lv02d *lis3) lis3 400 drivers/misc/lis3lv02d/lis3lv02d.c lis3->init(lis3); lis3 408 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata) { lis3 409 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CTRL_REG2, ®); lis3 410 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_12B) lis3 412 drivers/misc/lis3lv02d/lis3lv02d.c else if (lis3->whoami == WAI_3DLH) lis3 416 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG2, reg); lis3 418 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_3DLH) { lis3 419 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CTRL_REG4, ®); lis3 421 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG4, reg); lis3 425 drivers/misc/lis3lv02d/lis3lv02d.c err = lis3lv02d_get_pwron_wait(lis3); lis3 429 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->reg_ctrl) lis3 430 drivers/misc/lis3lv02d/lis3lv02d.c lis3_context_restore(lis3); lis3 439 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = pidev->private; lis3 442 drivers/misc/lis3lv02d/lis3lv02d.c mutex_lock(&lis3->mutex); lis3 443 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_get_xyz(lis3, &x, &y, &z); lis3 448 drivers/misc/lis3lv02d/lis3lv02d.c mutex_unlock(&lis3->mutex); lis3 453 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = pidev->private; lis3 455 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) lis3 456 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_get_sync(lis3->pm_dev); lis3 458 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata && lis3->whoami == WAI_8B && lis3->idev) lis3 459 drivers/misc/lis3lv02d/lis3lv02d.c atomic_set(&lis3->wake_thread, 1); lis3 469 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = pidev->private; lis3 471 drivers/misc/lis3lv02d/lis3lv02d.c atomic_set(&lis3->wake_thread, 0); lis3 472 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) lis3 473 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_put(lis3->pm_dev); lis3 478 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = data; lis3 480 drivers/misc/lis3lv02d/lis3lv02d.c if (!test_bit(0, &lis3->misc_opened)) lis3 488 drivers/misc/lis3lv02d/lis3lv02d.c atomic_inc(&lis3->count); lis3 490 drivers/misc/lis3lv02d/lis3lv02d.c wake_up_interruptible(&lis3->misc_wait); lis3 491 drivers/misc/lis3lv02d/lis3lv02d.c kill_fasync(&lis3->async_queue, SIGIO, POLL_IN); lis3 493 drivers/misc/lis3lv02d/lis3lv02d.c if (atomic_read(&lis3->wake_thread)) lis3 498 drivers/misc/lis3lv02d/lis3lv02d.c static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3) lis3 500 drivers/misc/lis3lv02d/lis3lv02d.c struct input_dev *dev = lis3->idev->input; lis3 503 drivers/misc/lis3lv02d/lis3lv02d.c mutex_lock(&lis3->mutex); lis3 504 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read(lis3, CLICK_SRC, &click_src); lis3 507 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[0], 1); lis3 508 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[0], 0); lis3 512 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[1], 1); lis3 513 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[1], 0); lis3 517 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[2], 1); lis3 518 drivers/misc/lis3lv02d/lis3lv02d.c input_report_key(dev, lis3->mapped_btns[2], 0); lis3 521 drivers/misc/lis3lv02d/lis3lv02d.c mutex_unlock(&lis3->mutex); lis3 524 drivers/misc/lis3lv02d/lis3lv02d.c static inline void lis302dl_data_ready(struct lis3lv02d *lis3, int index) lis3 529 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_get_xyz(lis3, &dummy, &dummy, &dummy); lis3 530 drivers/misc/lis3lv02d/lis3lv02d.c lis3->data_ready_count[index]++; lis3 535 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = data; lis3 536 drivers/misc/lis3lv02d/lis3lv02d.c u8 irq_cfg = lis3->irq_cfg & LIS3_IRQ1_MASK; lis3 539 drivers/misc/lis3lv02d/lis3lv02d.c lis302dl_interrupt_handle_click(lis3); lis3 541 drivers/misc/lis3lv02d/lis3lv02d.c lis302dl_data_ready(lis3, IRQ_LINE0); lis3 543 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_joystick_poll(lis3->idev); lis3 550 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = data; lis3 551 drivers/misc/lis3lv02d/lis3lv02d.c u8 irq_cfg = lis3->irq_cfg & LIS3_IRQ2_MASK; lis3 554 drivers/misc/lis3lv02d/lis3lv02d.c lis302dl_interrupt_handle_click(lis3); lis3 556 drivers/misc/lis3lv02d/lis3lv02d.c lis302dl_data_ready(lis3, IRQ_LINE1); lis3 558 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_joystick_poll(lis3->idev); lis3 565 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = container_of(file->private_data, lis3 568 drivers/misc/lis3lv02d/lis3lv02d.c if (test_and_set_bit(0, &lis3->misc_opened)) lis3 571 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) lis3 572 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_get_sync(lis3->pm_dev); lis3 574 drivers/misc/lis3lv02d/lis3lv02d.c atomic_set(&lis3->count, 0); lis3 580 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = container_of(file->private_data, lis3 583 drivers/misc/lis3lv02d/lis3lv02d.c clear_bit(0, &lis3->misc_opened); /* release the device */ lis3 584 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) lis3 585 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_put(lis3->pm_dev); lis3 592 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = container_of(file->private_data, lis3 603 drivers/misc/lis3lv02d/lis3lv02d.c add_wait_queue(&lis3->misc_wait, &wait); lis3 606 drivers/misc/lis3lv02d/lis3lv02d.c data = atomic_xchg(&lis3->count, 0); lis3 636 drivers/misc/lis3lv02d/lis3lv02d.c remove_wait_queue(&lis3->misc_wait, &wait); lis3 643 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = container_of(file->private_data, lis3 646 drivers/misc/lis3lv02d/lis3lv02d.c poll_wait(file, &lis3->misc_wait, wait); lis3 647 drivers/misc/lis3lv02d/lis3lv02d.c if (atomic_read(&lis3->count)) lis3 654 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = container_of(file->private_data, lis3 657 drivers/misc/lis3lv02d/lis3lv02d.c return fasync_helper(fd, file, on, &lis3->async_queue); lis3 670 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_joystick_enable(struct lis3lv02d *lis3) lis3 677 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->idev) lis3 680 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev = input_allocate_polled_device(); lis3 681 drivers/misc/lis3lv02d/lis3lv02d.c if (!lis3->idev) lis3 684 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->poll = lis3lv02d_joystick_poll; lis3 685 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->open = lis3lv02d_joystick_open; lis3 686 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->close = lis3lv02d_joystick_close; lis3 687 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->poll_interval = MDPS_POLL_INTERVAL; lis3 688 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->poll_interval_min = MDPS_POLL_MIN; lis3 689 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->poll_interval_max = MDPS_POLL_MAX; lis3 690 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev->private = lis3; lis3 691 drivers/misc/lis3lv02d/lis3lv02d.c input_dev = lis3->idev->input; lis3 697 drivers/misc/lis3lv02d/lis3lv02d.c input_dev->dev.parent = &lis3->pdev->dev; lis3 700 drivers/misc/lis3lv02d/lis3lv02d.c max_val = (lis3->mdps_max_val * lis3->scale) / LIS3_ACCURACY; lis3 701 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_12B) { lis3 708 drivers/misc/lis3lv02d/lis3lv02d.c fuzz = (fuzz * lis3->scale) / LIS3_ACCURACY; lis3 709 drivers/misc/lis3lv02d/lis3lv02d.c flat = (flat * lis3->scale) / LIS3_ACCURACY; lis3 715 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mapped_btns[0] = lis3lv02d_get_axis(abs(lis3->ac.x), btns); lis3 716 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mapped_btns[1] = lis3lv02d_get_axis(abs(lis3->ac.y), btns); lis3 717 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mapped_btns[2] = lis3lv02d_get_axis(abs(lis3->ac.z), btns); lis3 719 drivers/misc/lis3lv02d/lis3lv02d.c err = input_register_polled_device(lis3->idev); lis3 721 drivers/misc/lis3lv02d/lis3lv02d.c input_free_polled_device(lis3->idev); lis3 722 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev = NULL; lis3 729 drivers/misc/lis3lv02d/lis3lv02d.c void lis3lv02d_joystick_disable(struct lis3lv02d *lis3) lis3 731 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->irq) lis3 732 drivers/misc/lis3lv02d/lis3lv02d.c free_irq(lis3->irq, lis3); lis3 733 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata && lis3->pdata->irq2) lis3 734 drivers/misc/lis3lv02d/lis3lv02d.c free_irq(lis3->pdata->irq2, lis3); lis3 736 drivers/misc/lis3lv02d/lis3lv02d.c if (!lis3->idev) lis3 739 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->irq) lis3 740 drivers/misc/lis3lv02d/lis3lv02d.c misc_deregister(&lis3->miscdev); lis3 741 drivers/misc/lis3lv02d/lis3lv02d.c input_unregister_polled_device(lis3->idev); lis3 742 drivers/misc/lis3lv02d/lis3lv02d.c input_free_polled_device(lis3->idev); lis3 743 drivers/misc/lis3lv02d/lis3lv02d.c lis3->idev = NULL; lis3 748 drivers/misc/lis3lv02d/lis3lv02d.c static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3) lis3 758 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) { lis3 759 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_get_sync(lis3->pm_dev); lis3 760 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_put_noidle(lis3->pm_dev); lis3 761 drivers/misc/lis3lv02d/lis3lv02d.c pm_schedule_suspend(lis3->pm_dev, LIS3_SYSFS_POWERDOWN_DELAY); lis3 768 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = dev_get_drvdata(dev); lis3 776 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_sysfs_poweron(lis3); lis3 777 drivers/misc/lis3lv02d/lis3lv02d.c switch (lis3lv02d_selftest(lis3, values)) { lis3 796 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = dev_get_drvdata(dev); lis3 799 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_sysfs_poweron(lis3); lis3 800 drivers/misc/lis3lv02d/lis3lv02d.c mutex_lock(&lis3->mutex); lis3 801 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_get_xyz(lis3, &x, &y, &z); lis3 802 drivers/misc/lis3lv02d/lis3lv02d.c mutex_unlock(&lis3->mutex); lis3 809 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = dev_get_drvdata(dev); lis3 811 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_sysfs_poweron(lis3); lis3 812 drivers/misc/lis3lv02d/lis3lv02d.c return sprintf(buf, "%d\n", lis3lv02d_get_odr(lis3)); lis3 819 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d *lis3 = dev_get_drvdata(dev); lis3 827 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_sysfs_poweron(lis3); lis3 828 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3lv02d_set_odr(lis3, rate)) lis3 851 drivers/misc/lis3lv02d/lis3lv02d.c static int lis3lv02d_add_fs(struct lis3lv02d *lis3) lis3 853 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); lis3 854 drivers/misc/lis3lv02d/lis3lv02d.c if (IS_ERR(lis3->pdev)) lis3 855 drivers/misc/lis3lv02d/lis3lv02d.c return PTR_ERR(lis3->pdev); lis3 857 drivers/misc/lis3lv02d/lis3lv02d.c platform_set_drvdata(lis3->pdev, lis3); lis3 858 drivers/misc/lis3lv02d/lis3lv02d.c return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); lis3 861 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_remove_fs(struct lis3lv02d *lis3) lis3 863 drivers/misc/lis3lv02d/lis3lv02d.c sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); lis3 864 drivers/misc/lis3lv02d/lis3lv02d.c platform_device_unregister(lis3->pdev); lis3 865 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) { lis3 867 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_barrier(lis3->pm_dev); lis3 870 drivers/misc/lis3lv02d/lis3lv02d.c if (!pm_runtime_suspended(lis3->pm_dev)) lis3 871 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_poweroff(lis3); lis3 873 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_disable(lis3->pm_dev); lis3 874 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_set_suspended(lis3->pm_dev); lis3 876 drivers/misc/lis3lv02d/lis3lv02d.c kfree(lis3->reg_cache); lis3 881 drivers/misc/lis3lv02d/lis3lv02d.c static void lis3lv02d_8b_configure(struct lis3lv02d *lis3, lis3 888 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_CFG, p->click_flags); lis3 889 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_TIMELIMIT, p->click_time_limit); lis3 890 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_LATENCY, p->click_latency); lis3 891 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_WINDOW, p->click_window); lis3 892 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_THSZ, p->click_thresh_z & 0xf); lis3 893 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CLICK_THSY_X, lis3 897 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->idev) { lis3 898 drivers/misc/lis3lv02d/lis3lv02d.c struct input_dev *input_dev = lis3->idev->input; lis3 906 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_CFG_1, p->wakeup_flags); lis3 907 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_THS_1, p->wakeup_thresh & 0x7f); lis3 909 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_DURATION_1, p->duration1 + 1); lis3 914 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_CFG_2, p->wakeup_flags2); lis3 915 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f); lis3 917 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, FF_WU_DURATION_2, p->duration2 + 1); lis3 921 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG2, ctrl2); lis3 929 drivers/misc/lis3lv02d/lis3lv02d.c DRIVER_NAME, lis3); lis3 936 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_init_dt(struct lis3lv02d *lis3) lis3 939 drivers/misc/lis3lv02d/lis3lv02d.c struct device_node *np = lis3->of_node; lis3 943 drivers/misc/lis3lv02d/lis3lv02d.c if (!lis3->of_node) lis3 1088 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pdata = pdata; lis3 1094 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_init_dt(struct lis3lv02d *lis3) lis3 1105 drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_init_device(struct lis3lv02d *lis3) lis3 1111 drivers/misc/lis3lv02d/lis3lv02d.c lis3->whoami = lis3lv02d_read_8(lis3, WHO_AM_I); lis3 1113 drivers/misc/lis3lv02d/lis3lv02d.c switch (lis3->whoami) { lis3 1116 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read_data = lis3lv02d_read_12; lis3 1117 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mdps_max_val = 2048; lis3 1118 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_12B; lis3 1119 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odrs = lis3_12_rates; lis3 1120 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odr_mask = CTRL1_DF0 | CTRL1_DF1; lis3 1121 drivers/misc/lis3lv02d/lis3lv02d.c lis3->scale = LIS3_SENSITIVITY_12B; lis3 1122 drivers/misc/lis3lv02d/lis3lv02d.c lis3->regs = lis3_wai12_regs; lis3 1123 drivers/misc/lis3lv02d/lis3lv02d.c lis3->regs_size = ARRAY_SIZE(lis3_wai12_regs); lis3 1127 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read_data = lis3lv02d_read_8; lis3 1128 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mdps_max_val = 128; lis3 1129 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; lis3 1130 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odrs = lis3_8_rates; lis3 1131 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odr_mask = CTRL1_DR; lis3 1132 drivers/misc/lis3lv02d/lis3lv02d.c lis3->scale = LIS3_SENSITIVITY_8B; lis3 1133 drivers/misc/lis3lv02d/lis3lv02d.c lis3->regs = lis3_wai8_regs; lis3 1134 drivers/misc/lis3lv02d/lis3lv02d.c lis3->regs_size = ARRAY_SIZE(lis3_wai8_regs); lis3 1138 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read_data = lis3lv02d_read_8; lis3 1139 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mdps_max_val = 128; lis3 1140 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; lis3 1141 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odrs = lis3_3dc_rates; lis3 1142 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; lis3 1143 drivers/misc/lis3lv02d/lis3lv02d.c lis3->scale = LIS3_SENSITIVITY_8B; lis3 1147 drivers/misc/lis3lv02d/lis3lv02d.c lis3->read_data = lis331dlh_read_data; lis3 1148 drivers/misc/lis3lv02d/lis3lv02d.c lis3->mdps_max_val = 2048; /* 12 bits for 2G */ lis3 1149 drivers/misc/lis3lv02d/lis3lv02d.c lis3->shift_adj = SHIFT_ADJ_2G; lis3 1150 drivers/misc/lis3lv02d/lis3lv02d.c lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; lis3 1151 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odrs = lis3_3dlh_rates; lis3 1152 drivers/misc/lis3lv02d/lis3lv02d.c lis3->odr_mask = CTRL1_DR0 | CTRL1_DR1; lis3 1153 drivers/misc/lis3lv02d/lis3lv02d.c lis3->scale = LIS3DLH_SENSITIVITY_2G; lis3 1156 drivers/misc/lis3lv02d/lis3lv02d.c pr_err("unknown sensor type 0x%X\n", lis3->whoami); lis3 1160 drivers/misc/lis3lv02d/lis3lv02d.c lis3->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs), lis3 1163 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->reg_cache == NULL) { lis3 1168 drivers/misc/lis3lv02d/lis3lv02d.c mutex_init(&lis3->mutex); lis3 1169 drivers/misc/lis3lv02d/lis3lv02d.c atomic_set(&lis3->wake_thread, 0); lis3 1171 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_add_fs(lis3); lis3 1172 drivers/misc/lis3lv02d/lis3lv02d.c err = lis3lv02d_poweron(lis3); lis3 1174 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_remove_fs(lis3); lis3 1178 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pm_dev) { lis3 1179 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_set_active(lis3->pm_dev); lis3 1180 drivers/misc/lis3lv02d/lis3lv02d.c pm_runtime_enable(lis3->pm_dev); lis3 1183 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3lv02d_joystick_enable(lis3)) lis3 1188 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata) { lis3 1189 drivers/misc/lis3lv02d/lis3lv02d.c struct lis3lv02d_platform_data *p = lis3->pdata; lis3 1191 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->whoami == WAI_8B) lis3 1192 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_8b_configure(lis3, p); lis3 1196 drivers/misc/lis3lv02d/lis3lv02d.c lis3->irq_cfg = p->irq_cfg; lis3 1198 drivers/misc/lis3lv02d/lis3lv02d.c lis3->write(lis3, CTRL_REG3, p->irq_cfg); lis3 1201 drivers/misc/lis3lv02d/lis3lv02d.c lis3lv02d_set_odr(lis3, p->default_rate); lis3 1205 drivers/misc/lis3lv02d/lis3lv02d.c if (!lis3->irq) { lis3 1221 drivers/misc/lis3lv02d/lis3lv02d.c if (lis3->pdata && lis3->whoami == WAI_8B) lis3 1226 drivers/misc/lis3lv02d/lis3lv02d.c err = request_threaded_irq(lis3->irq, lis302dl_interrupt, lis3 1230 drivers/misc/lis3lv02d/lis3lv02d.c DRIVER_NAME, lis3); lis3 1237 drivers/misc/lis3lv02d/lis3lv02d.c lis3->miscdev.minor = MISC_DYNAMIC_MINOR; lis3 1238 drivers/misc/lis3lv02d/lis3lv02d.c lis3->miscdev.name = "freefall"; lis3 1239 drivers/misc/lis3lv02d/lis3lv02d.c lis3->miscdev.fops = &lis3lv02d_misc_fops; lis3 1241 drivers/misc/lis3lv02d/lis3lv02d.c if (misc_register(&lis3->miscdev)) lis3 263 drivers/misc/lis3lv02d/lis3lv02d.h int (*init) (struct lis3lv02d *lis3); lis3 264 drivers/misc/lis3lv02d/lis3lv02d.h int (*write) (struct lis3lv02d *lis3, int reg, u8 val); lis3 265 drivers/misc/lis3lv02d/lis3lv02d.h int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret); lis3 266 drivers/misc/lis3lv02d/lis3lv02d.h int (*blkread) (struct lis3lv02d *lis3, int reg, int len, u8 *ret); lis3 267 drivers/misc/lis3lv02d/lis3lv02d.h int (*reg_ctrl) (struct lis3lv02d *lis3, bool state); lis3 276 drivers/misc/lis3lv02d/lis3lv02d.h s16 (*read_data) (struct lis3lv02d *lis3, int reg); lis3 310 drivers/misc/lis3lv02d/lis3lv02d.h int lis3lv02d_init_device(struct lis3lv02d *lis3); lis3 311 drivers/misc/lis3lv02d/lis3lv02d.h int lis3lv02d_joystick_enable(struct lis3lv02d *lis3); lis3 312 drivers/misc/lis3lv02d/lis3lv02d.h void lis3lv02d_joystick_disable(struct lis3lv02d *lis3); lis3 313 drivers/misc/lis3lv02d/lis3lv02d.h void lis3lv02d_poweroff(struct lis3lv02d *lis3); lis3 314 drivers/misc/lis3lv02d/lis3lv02d.h int lis3lv02d_poweron(struct lis3lv02d *lis3); lis3 315 drivers/misc/lis3lv02d/lis3lv02d.h int lis3lv02d_remove_fs(struct lis3lv02d *lis3); lis3 316 drivers/misc/lis3lv02d/lis3lv02d.h int lis3lv02d_init_dt(struct lis3lv02d *lis3); lis3 31 drivers/misc/lis3lv02d/lis3lv02d_i2c.c static int lis3_reg_ctrl(struct lis3lv02d *lis3, bool state) lis3 35 drivers/misc/lis3lv02d/lis3lv02d_i2c.c ret = regulator_bulk_disable(ARRAY_SIZE(lis3->regulators), lis3 36 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3->regulators); lis3 38 drivers/misc/lis3lv02d/lis3lv02d_i2c.c ret = regulator_bulk_enable(ARRAY_SIZE(lis3->regulators), lis3 39 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3->regulators); lis3 46 drivers/misc/lis3lv02d/lis3lv02d_i2c.c static inline s32 lis3_i2c_write(struct lis3lv02d *lis3, int reg, u8 value) lis3 48 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct i2c_client *c = lis3->bus_priv; lis3 52 drivers/misc/lis3lv02d/lis3lv02d_i2c.c static inline s32 lis3_i2c_read(struct lis3lv02d *lis3, int reg, u8 *v) lis3 54 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct i2c_client *c = lis3->bus_priv; lis3 59 drivers/misc/lis3lv02d/lis3lv02d_i2c.c static inline s32 lis3_i2c_blockread(struct lis3lv02d *lis3, int reg, int len, lis3 62 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct i2c_client *c = lis3->bus_priv; lis3 67 drivers/misc/lis3lv02d/lis3lv02d_i2c.c static int lis3_i2c_init(struct lis3lv02d *lis3) lis3 72 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3_reg_ctrl(lis3, LIS3_REG_ON); lis3 74 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3->read(lis3, WHO_AM_I, ®); lis3 75 drivers/misc/lis3lv02d/lis3lv02d_i2c.c if (reg != lis3->whoami) lis3 79 drivers/misc/lis3lv02d/lis3lv02d_i2c.c ret = lis3->read(lis3, CTRL_REG1, ®); lis3 83 drivers/misc/lis3lv02d/lis3lv02d_i2c.c if (lis3->whoami == WAI_3DLH) lis3 88 drivers/misc/lis3lv02d/lis3lv02d_i2c.c return lis3->write(lis3, CTRL_REG1, reg); lis3 182 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct lis3lv02d *lis3 = i2c_get_clientdata(client); lis3 188 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3lv02d_joystick_disable(lis3); lis3 191 drivers/misc/lis3lv02d/lis3lv02d_i2c.c regulator_bulk_free(ARRAY_SIZE(lis3->regulators), lis3 200 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct lis3lv02d *lis3 = i2c_get_clientdata(client); lis3 202 drivers/misc/lis3lv02d/lis3lv02d_i2c.c if (!lis3->pdata || !lis3->pdata->wakeup_flags) lis3 203 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3lv02d_poweroff(lis3); lis3 210 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct lis3lv02d *lis3 = i2c_get_clientdata(client); lis3 217 drivers/misc/lis3lv02d/lis3lv02d_i2c.c if (!lis3->pdata || !lis3->pdata->wakeup_flags || lis3 219 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3lv02d_poweron(lis3); lis3 229 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct lis3lv02d *lis3 = i2c_get_clientdata(client); lis3 231 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3lv02d_poweroff(lis3); lis3 238 drivers/misc/lis3lv02d/lis3lv02d_i2c.c struct lis3lv02d *lis3 = i2c_get_clientdata(client); lis3 240 drivers/misc/lis3lv02d/lis3lv02d_i2c.c lis3lv02d_poweron(lis3); lis3 25 drivers/misc/lis3lv02d/lis3lv02d_spi.c static int lis3_spi_read(struct lis3lv02d *lis3, int reg, u8 *v) lis3 27 drivers/misc/lis3lv02d/lis3lv02d_spi.c struct spi_device *spi = lis3->bus_priv; lis3 36 drivers/misc/lis3lv02d/lis3lv02d_spi.c static int lis3_spi_write(struct lis3lv02d *lis3, int reg, u8 val) lis3 39 drivers/misc/lis3lv02d/lis3lv02d_spi.c struct spi_device *spi = lis3->bus_priv; lis3 43 drivers/misc/lis3lv02d/lis3lv02d_spi.c static int lis3_spi_init(struct lis3lv02d *lis3) lis3 49 drivers/misc/lis3lv02d/lis3lv02d_spi.c ret = lis3->read(lis3, CTRL_REG1, ®); lis3 54 drivers/misc/lis3lv02d/lis3lv02d_spi.c return lis3->write(lis3, CTRL_REG1, reg); lis3 101 drivers/misc/lis3lv02d/lis3lv02d_spi.c struct lis3lv02d *lis3 = spi_get_drvdata(spi); lis3 102 drivers/misc/lis3lv02d/lis3lv02d_spi.c lis3lv02d_joystick_disable(lis3); lis3 103 drivers/misc/lis3lv02d/lis3lv02d_spi.c lis3lv02d_poweroff(lis3); lis3 112 drivers/misc/lis3lv02d/lis3lv02d_spi.c struct lis3lv02d *lis3 = spi_get_drvdata(spi); lis3 114 drivers/misc/lis3lv02d/lis3lv02d_spi.c if (!lis3->pdata || !lis3->pdata->wakeup_flags) lis3 123 drivers/misc/lis3lv02d/lis3lv02d_spi.c struct lis3lv02d *lis3 = spi_get_drvdata(spi); lis3 125 drivers/misc/lis3lv02d/lis3lv02d_spi.c if (!lis3->pdata || !lis3->pdata->wakeup_flags) lis3 126 drivers/misc/lis3lv02d/lis3lv02d_spi.c lis3lv02d_poweron(lis3); lis3 88 drivers/platform/x86/hp_accel.c static int lis3lv02d_acpi_init(struct lis3lv02d *lis3) lis3 90 drivers/platform/x86/hp_accel.c struct acpi_device *dev = lis3->bus_priv; lis3 106 drivers/platform/x86/hp_accel.c static int lis3lv02d_acpi_read(struct lis3lv02d *lis3, int reg, u8 *ret) lis3 108 drivers/platform/x86/hp_accel.c struct acpi_device *dev = lis3->bus_priv; lis3 131 drivers/platform/x86/hp_accel.c static int lis3lv02d_acpi_write(struct lis3lv02d *lis3, int reg, u8 val) lis3 133 drivers/platform/x86/hp_accel.c struct acpi_device *dev = lis3->bus_priv;