Lines Matching +full:hw +full:- +full:settle +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0
14 * - /sys/bus/adb to list the devices and infos
15 * - more /dev/adb to allow userland to receive the
16 * flow of auto-polling datas from a given device.
17 * - move bus probe to a kernel thread
106 * time adb_unregister returns, we know that the old handler isn't being
117 printk("adb reply (%d)", req->reply_len);
118 for(i = 0; i < req->reply_len; i++)
119 printk(" %x", req->reply[i]);
143 /* Note we reset noMovement to 0 each time we move a device */ in adb_scan_bus()
164 * by HW TechNote 01: in adb_scan_bus()
166 * https://developer.apple.com/technotes/hw/hw_01.html in adb_scan_bus()
188 highFree--; in adb_scan_bus()
267 if (adb_controller->autopoll) in __adb_suspend()
268 adb_controller->autopoll(0); in __adb_suspend()
321 /* xmon may do early-init */ in adb_init()
330 if (!driver->probe()) { in adb_init()
335 if (adb_controller != NULL && adb_controller->init && in adb_init()
336 adb_controller->init()) in adb_init()
361 return -ENXIO; in do_adb_reset_bus()
363 if (adb_controller->autopoll) in do_adb_reset_bus()
364 adb_controller->autopoll(0); in do_adb_reset_bus()
370 /* Let the trackpad settle down */ in do_adb_reset_bus()
380 if (adb_controller->reset_bus) in do_adb_reset_bus()
381 ret = adb_controller->reset_bus(); in do_adb_reset_bus()
386 /* Let the trackpad settle down */ in do_adb_reset_bus()
392 if (adb_controller->autopoll) in do_adb_reset_bus()
393 adb_controller->autopoll(autopoll_devs); in do_adb_reset_bus()
406 if ((adb_controller == NULL)||(adb_controller->poll == NULL)) in adb_poll()
408 adb_controller->poll(); in adb_poll()
414 struct completion *comp = req->arg; in adb_sync_req_done()
428 if ((adb_controller == NULL) || (adb_controller->send_request == NULL)) in adb_request()
429 return -ENXIO; in adb_request()
431 return -EINVAL; in adb_request()
433 req->nbytes = nbytes+1; in adb_request()
434 req->done = done; in adb_request()
435 req->reply_expected = flags & ADBREQ_REPLY; in adb_request()
436 req->data[0] = ADB_PACKET; in adb_request()
439 req->data[i+1] = va_arg(list, int); in adb_request()
445 /* Synchronous requests block using an on-stack completion */ in adb_request()
448 req->done = adb_sync_req_done; in adb_request()
449 req->arg = ∁ in adb_request()
453 rc = adb_controller->send_request(req, 0); in adb_request()
455 if ((flags & ADBREQ_SYNC) && !rc && !req->complete) in adb_request()
476 ids->nids = 0; in adb_register()
489 ids->id[ids->nids++] = i; in adb_register()
493 return ids->nids; in adb_register()
500 int ret = -ENODEV; in adb_unregister()
616 struct adbdev_state *state = (struct adbdev_state *) req->arg; in adb_write_done()
619 if (!req->complete) { in adb_write_done()
620 req->reply_len = 0; in adb_write_done()
621 req->complete = 1; in adb_write_done()
623 spin_lock_irqsave(&state->lock, flags); in adb_write_done()
624 atomic_dec(&state->n_pending); in adb_write_done()
625 if (!state->inuse) { in adb_write_done()
627 if (atomic_read(&state->n_pending) == 0) { in adb_write_done()
628 spin_unlock_irqrestore(&state->lock, flags); in adb_write_done()
633 struct adb_request **ap = &state->completed; in adb_write_done()
635 ap = &(*ap)->next; in adb_write_done()
636 req->next = NULL; in adb_write_done()
638 wake_up_interruptible(&state->wait_queue); in adb_write_done()
640 spin_unlock_irqrestore(&state->lock, flags); in adb_write_done()
646 int ret = -EINVAL; in do_adb_query()
648 switch(req->data[1]) { in do_adb_query()
650 if (req->nbytes < 3) in do_adb_query()
653 req->reply[0] = adb_handler[req->data[2]].original_address; in do_adb_query()
654 req->reply[1] = adb_handler[req->data[2]].handler_id; in do_adb_query()
656 req->complete = 1; in do_adb_query()
657 req->reply_len = 2; in do_adb_query()
672 ret = -ENXIO; in adb_open()
677 ret = -ENOMEM; in adb_open()
680 file->private_data = state; in adb_open()
681 spin_lock_init(&state->lock); in adb_open()
682 atomic_set(&state->n_pending, 0); in adb_open()
683 state->completed = NULL; in adb_open()
684 init_waitqueue_head(&state->wait_queue); in adb_open()
685 state->inuse = 1; in adb_open()
694 struct adbdev_state *state = file->private_data; in adb_release()
699 file->private_data = NULL; in adb_release()
700 spin_lock_irqsave(&state->lock, flags); in adb_release()
701 if (atomic_read(&state->n_pending) == 0 in adb_release()
702 && state->completed == NULL) { in adb_release()
703 spin_unlock_irqrestore(&state->lock, flags); in adb_release()
706 state->inuse = 0; in adb_release()
707 spin_unlock_irqrestore(&state->lock, flags); in adb_release()
718 struct adbdev_state *state = file->private_data; in adb_read()
724 return -EINVAL; in adb_read()
725 if (count > sizeof(req->reply)) in adb_read()
726 count = sizeof(req->reply); in adb_read()
729 spin_lock_irqsave(&state->lock, flags); in adb_read()
730 add_wait_queue(&state->wait_queue, &wait); in adb_read()
734 req = state->completed; in adb_read()
736 state->completed = req->next; in adb_read()
737 else if (atomic_read(&state->n_pending) == 0) in adb_read()
738 ret = -EIO; in adb_read()
742 if (file->f_flags & O_NONBLOCK) { in adb_read()
743 ret = -EAGAIN; in adb_read()
747 ret = -ERESTARTSYS; in adb_read()
750 spin_unlock_irqrestore(&state->lock, flags); in adb_read()
752 spin_lock_irqsave(&state->lock, flags); in adb_read()
756 remove_wait_queue(&state->wait_queue, &wait); in adb_read()
757 spin_unlock_irqrestore(&state->lock, flags); in adb_read()
762 ret = req->reply_len; in adb_read()
765 if (ret > 0 && copy_to_user(buf, req->reply, ret)) in adb_read()
766 ret = -EFAULT; in adb_read()
776 struct adbdev_state *state = file->private_data; in adb_write()
779 if (count < 2 || count > sizeof(req->data)) in adb_write()
780 return -EINVAL; in adb_write()
782 return -ENXIO; in adb_write()
787 return -ENOMEM; in adb_write()
789 req->nbytes = count; in adb_write()
790 req->done = adb_write_done; in adb_write()
791 req->arg = (void *) state; in adb_write()
792 req->complete = 0; in adb_write()
794 ret = -EFAULT; in adb_write()
795 if (copy_from_user(req->data, buf, count)) in adb_write()
798 atomic_inc(&state->n_pending); in adb_write()
804 if (req->data[0] == ADB_QUERY) { in adb_write()
808 ret = -EINVAL; in adb_write()
813 else if ((req->data[0] == ADB_PACKET) && (count > 1) in adb_write()
814 && (req->data[1] == ADB_BUSRESET)) { in adb_write()
817 atomic_dec(&state->n_pending); in adb_write()
822 req->reply_expected = ((req->data[1] & 0xc) == 0xc); in adb_write()
823 if (adb_controller && adb_controller->send_request) in adb_write()
824 ret = adb_controller->send_request(req, 0); in adb_write()
826 ret = -ENXIO; in adb_write()
831 atomic_dec(&state->n_pending); in adb_write()
880 return -ENODEV; in adb_dummy_probe()