Lines Matching refs:bdata

130 	struct gpio_button_data *bdata = data;  in gpio_keys_quiesce_key()  local
132 if (!bdata->gpiod) in gpio_keys_quiesce_key()
133 hrtimer_cancel(&bdata->release_timer); in gpio_keys_quiesce_key()
134 else if (bdata->debounce_use_hrtimer) in gpio_keys_quiesce_key()
135 hrtimer_cancel(&bdata->debounce_timer); in gpio_keys_quiesce_key()
137 cancel_delayed_work_sync(&bdata->work); in gpio_keys_quiesce_key()
153 static void gpio_keys_disable_button(struct gpio_button_data *bdata) in gpio_keys_disable_button() argument
155 if (!bdata->disabled) { in gpio_keys_disable_button()
159 disable_irq(bdata->irq); in gpio_keys_disable_button()
160 gpio_keys_quiesce_key(bdata); in gpio_keys_disable_button()
161 bdata->disabled = true; in gpio_keys_disable_button()
175 static void gpio_keys_enable_button(struct gpio_button_data *bdata) in gpio_keys_enable_button() argument
177 if (bdata->disabled) { in gpio_keys_enable_button()
178 enable_irq(bdata->irq); in gpio_keys_enable_button()
179 bdata->disabled = false; in gpio_keys_enable_button()
211 struct gpio_button_data *bdata = &ddata->data[i]; in gpio_keys_attr_show_helper() local
213 if (bdata->button->type != type) in gpio_keys_attr_show_helper()
216 if (only_disabled && !bdata->disabled) in gpio_keys_attr_show_helper()
219 __set_bit(*bdata->code, bits); in gpio_keys_attr_show_helper()
265 struct gpio_button_data *bdata = &ddata->data[i]; in gpio_keys_attr_store_helper() local
267 if (bdata->button->type != type) in gpio_keys_attr_store_helper()
270 if (test_bit(*bdata->code, bits) && in gpio_keys_attr_store_helper()
271 !bdata->button->can_disable) { in gpio_keys_attr_store_helper()
280 struct gpio_button_data *bdata = &ddata->data[i]; in gpio_keys_attr_store_helper() local
282 if (bdata->button->type != type) in gpio_keys_attr_store_helper()
285 if (test_bit(*bdata->code, bits)) in gpio_keys_attr_store_helper()
286 gpio_keys_disable_button(bdata); in gpio_keys_attr_store_helper()
288 gpio_keys_enable_button(bdata); in gpio_keys_attr_store_helper()
366 static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) in gpio_keys_gpio_report_event() argument
368 const struct gpio_keys_button *button = bdata->button; in gpio_keys_gpio_report_event()
369 struct input_dev *input = bdata->input; in gpio_keys_gpio_report_event()
373 state = bdata->debounce_use_hrtimer ? in gpio_keys_gpio_report_event()
374 gpiod_get_value(bdata->gpiod) : in gpio_keys_gpio_report_event()
375 gpiod_get_value_cansleep(bdata->gpiod); in gpio_keys_gpio_report_event()
386 input_event(input, type, *bdata->code, state); in gpio_keys_gpio_report_event()
390 static void gpio_keys_debounce_event(struct gpio_button_data *bdata) in gpio_keys_debounce_event() argument
392 gpio_keys_gpio_report_event(bdata); in gpio_keys_debounce_event()
393 input_sync(bdata->input); in gpio_keys_debounce_event()
395 if (bdata->button->wakeup) in gpio_keys_debounce_event()
396 pm_relax(bdata->input->dev.parent); in gpio_keys_debounce_event()
401 struct gpio_button_data *bdata = in gpio_keys_gpio_work_func() local
404 gpio_keys_debounce_event(bdata); in gpio_keys_gpio_work_func()
409 struct gpio_button_data *bdata = in gpio_keys_debounce_timer() local
412 gpio_keys_debounce_event(bdata); in gpio_keys_debounce_timer()
419 struct gpio_button_data *bdata = dev_id; in gpio_keys_gpio_isr() local
421 BUG_ON(irq != bdata->irq); in gpio_keys_gpio_isr()
423 if (bdata->button->wakeup) { in gpio_keys_gpio_isr()
424 const struct gpio_keys_button *button = bdata->button; in gpio_keys_gpio_isr()
426 pm_stay_awake(bdata->input->dev.parent); in gpio_keys_gpio_isr()
427 if (bdata->suspended && in gpio_keys_gpio_isr()
434 input_report_key(bdata->input, button->code, 1); in gpio_keys_gpio_isr()
438 if (bdata->debounce_use_hrtimer) { in gpio_keys_gpio_isr()
439 hrtimer_start(&bdata->debounce_timer, in gpio_keys_gpio_isr()
440 ms_to_ktime(bdata->software_debounce), in gpio_keys_gpio_isr()
444 &bdata->work, in gpio_keys_gpio_isr()
445 msecs_to_jiffies(bdata->software_debounce)); in gpio_keys_gpio_isr()
453 struct gpio_button_data *bdata = container_of(t, in gpio_keys_irq_timer() local
456 struct input_dev *input = bdata->input; in gpio_keys_irq_timer()
458 if (bdata->key_pressed) { in gpio_keys_irq_timer()
459 input_event(input, EV_KEY, *bdata->code, 0); in gpio_keys_irq_timer()
461 bdata->key_pressed = false; in gpio_keys_irq_timer()
469 struct gpio_button_data *bdata = dev_id; in gpio_keys_irq_isr() local
470 struct input_dev *input = bdata->input; in gpio_keys_irq_isr()
473 BUG_ON(irq != bdata->irq); in gpio_keys_irq_isr()
475 spin_lock_irqsave(&bdata->lock, flags); in gpio_keys_irq_isr()
477 if (!bdata->key_pressed) { in gpio_keys_irq_isr()
478 if (bdata->button->wakeup) in gpio_keys_irq_isr()
479 pm_wakeup_event(bdata->input->dev.parent, 0); in gpio_keys_irq_isr()
481 input_event(input, EV_KEY, *bdata->code, 1); in gpio_keys_irq_isr()
484 if (!bdata->release_delay) { in gpio_keys_irq_isr()
485 input_event(input, EV_KEY, *bdata->code, 0); in gpio_keys_irq_isr()
490 bdata->key_pressed = true; in gpio_keys_irq_isr()
493 if (bdata->release_delay) in gpio_keys_irq_isr()
494 hrtimer_start(&bdata->release_timer, in gpio_keys_irq_isr()
495 ms_to_ktime(bdata->release_delay), in gpio_keys_irq_isr()
498 spin_unlock_irqrestore(&bdata->lock, flags); in gpio_keys_irq_isr()
511 struct gpio_button_data *bdata = &ddata->data[idx]; in gpio_keys_setup_key() local
517 bdata->input = input; in gpio_keys_setup_key()
518 bdata->button = button; in gpio_keys_setup_key()
519 spin_lock_init(&bdata->lock); in gpio_keys_setup_key()
522 bdata->gpiod = devm_fwnode_gpiod_get(dev, child, in gpio_keys_setup_key()
524 if (IS_ERR(bdata->gpiod)) { in gpio_keys_setup_key()
525 error = PTR_ERR(bdata->gpiod); in gpio_keys_setup_key()
531 bdata->gpiod = NULL; in gpio_keys_setup_key()
556 bdata->gpiod = gpio_to_desc(button->gpio); in gpio_keys_setup_key()
557 if (!bdata->gpiod) in gpio_keys_setup_key()
561 if (bdata->gpiod) { in gpio_keys_setup_key()
562 bool active_low = gpiod_is_active_low(bdata->gpiod); in gpio_keys_setup_key()
565 error = gpiod_set_debounce(bdata->gpiod, in gpio_keys_setup_key()
569 bdata->software_debounce = in gpio_keys_setup_key()
577 bdata->debounce_use_hrtimer = in gpio_keys_setup_key()
578 !gpiod_cansleep(bdata->gpiod); in gpio_keys_setup_key()
582 bdata->irq = button->irq; in gpio_keys_setup_key()
584 irq = gpiod_to_irq(bdata->gpiod); in gpio_keys_setup_key()
592 bdata->irq = irq; in gpio_keys_setup_key()
595 INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); in gpio_keys_setup_key()
597 hrtimer_init(&bdata->debounce_timer, in gpio_keys_setup_key()
599 bdata->debounce_timer.function = gpio_keys_debounce_timer; in gpio_keys_setup_key()
606 bdata->wakeup_trigger_type = active_low ? in gpio_keys_setup_key()
610 bdata->wakeup_trigger_type = active_low ? in gpio_keys_setup_key()
627 bdata->irq = button->irq; in gpio_keys_setup_key()
634 bdata->release_delay = button->debounce_interval; in gpio_keys_setup_key()
635 hrtimer_init(&bdata->release_timer, in gpio_keys_setup_key()
637 bdata->release_timer.function = gpio_keys_irq_timer; in gpio_keys_setup_key()
648 bdata->code = &ddata->keymap[idx]; in gpio_keys_setup_key()
649 *bdata->code = button->code; in gpio_keys_setup_key()
650 input_set_capability(input, button->type ?: EV_KEY, *bdata->code); in gpio_keys_setup_key()
656 error = devm_add_action(dev, gpio_keys_quiesce_key, bdata); in gpio_keys_setup_key()
670 error = devm_request_any_context_irq(dev, bdata->irq, isr, irqflags, in gpio_keys_setup_key()
671 desc, bdata); in gpio_keys_setup_key()
674 bdata->irq, error); in gpio_keys_setup_key()
687 struct gpio_button_data *bdata = &ddata->data[i]; in gpio_keys_report_state() local
688 if (bdata->gpiod) in gpio_keys_report_state()
689 gpio_keys_gpio_report_event(bdata); in gpio_keys_report_state()
900 gpio_keys_button_enable_wakeup(struct gpio_button_data *bdata) in gpio_keys_button_enable_wakeup() argument
904 error = enable_irq_wake(bdata->irq); in gpio_keys_button_enable_wakeup()
906 dev_err(bdata->input->dev.parent, in gpio_keys_button_enable_wakeup()
908 bdata->irq, error); in gpio_keys_button_enable_wakeup()
912 if (bdata->wakeup_trigger_type) { in gpio_keys_button_enable_wakeup()
913 error = irq_set_irq_type(bdata->irq, in gpio_keys_button_enable_wakeup()
914 bdata->wakeup_trigger_type); in gpio_keys_button_enable_wakeup()
916 dev_err(bdata->input->dev.parent, in gpio_keys_button_enable_wakeup()
918 bdata->wakeup_trigger_type, bdata->irq, error); in gpio_keys_button_enable_wakeup()
919 disable_irq_wake(bdata->irq); in gpio_keys_button_enable_wakeup()
928 gpio_keys_button_disable_wakeup(struct gpio_button_data *bdata) in gpio_keys_button_disable_wakeup() argument
936 if (bdata->wakeup_trigger_type) { in gpio_keys_button_disable_wakeup()
937 error = irq_set_irq_type(bdata->irq, IRQ_TYPE_EDGE_BOTH); in gpio_keys_button_disable_wakeup()
939 dev_warn(bdata->input->dev.parent, in gpio_keys_button_disable_wakeup()
941 bdata->irq, error); in gpio_keys_button_disable_wakeup()
944 error = disable_irq_wake(bdata->irq); in gpio_keys_button_disable_wakeup()
946 dev_warn(bdata->input->dev.parent, in gpio_keys_button_disable_wakeup()
948 bdata->irq, error); in gpio_keys_button_disable_wakeup()
954 struct gpio_button_data *bdata; in gpio_keys_enable_wakeup() local
959 bdata = &ddata->data[i]; in gpio_keys_enable_wakeup()
960 if (bdata->button->wakeup) { in gpio_keys_enable_wakeup()
961 error = gpio_keys_button_enable_wakeup(bdata); in gpio_keys_enable_wakeup()
965 bdata->suspended = true; in gpio_keys_enable_wakeup()
972 bdata = &ddata->data[i]; in gpio_keys_enable_wakeup()
973 if (bdata->button->wakeup) in gpio_keys_enable_wakeup()
974 gpio_keys_button_disable_wakeup(bdata); in gpio_keys_enable_wakeup()
975 bdata->suspended = false; in gpio_keys_enable_wakeup()
984 struct gpio_button_data *bdata; in gpio_keys_disable_wakeup() local
988 bdata = &ddata->data[i]; in gpio_keys_disable_wakeup()
989 bdata->suspended = false; in gpio_keys_disable_wakeup()
990 if (irqd_is_wakeup_set(irq_get_irq_data(bdata->irq))) in gpio_keys_disable_wakeup()
991 gpio_keys_button_disable_wakeup(bdata); in gpio_keys_disable_wakeup()