Lines Matching +full:wakeup +full:- +full:event +full:- +full:action

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ec.c - ACPI Embedded Controller Driver (v3)
5 * Copyright (C) 2001-2015 Intel Corporation
43 #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
53 * host should re-check SCI_EVT after the first time the SCI_EVT
56 * at any later time could indicate another event. Normally such
57 * kind of EC firmware has implemented an event queue and will
58 * return 0x00 to indicate "no outstanding event".
61 * event value in the data register (EC_DATA), the target can safely
63 * event is being handled by the host. The host then should check
64 * SCI_EVT right after reading the event response from the data
66 * EVENT: After seeing the event response read from the data register
97 EC_FLAGS_EVENT_HANDLER_INSTALLED, /* Event handler installed */
138 MODULE_PARM_DESC(ec_freeze_events, "Disabling event handling during suspend/resume");
142 MODULE_PARM_DESC(ec_no_wakeup, "Do not wake up from suspend-to-idle");
189 /* --------------------------------------------------------------------------
191 * -------------------------------------------------------------------------- */
231 ec_dbg_raw("%lu: " fmt, ec->reference_count, ## __VA_ARGS__)
233 /* --------------------------------------------------------------------------
235 * -------------------------------------------------------------------------- */
239 return test_bit(EC_FLAGS_STARTED, &ec->flags) && in acpi_ec_started()
240 !test_bit(EC_FLAGS_STOPPED, &ec->flags); in acpi_ec_started()
247 * (boot/resume), OSPMs shouldn't enable the event handling, only in acpi_ec_event_enabled()
250 if (!test_bit(EC_FLAGS_QUERY_ENABLED, &ec->flags)) in acpi_ec_event_enabled()
253 * However, disabling the event handling is experimental for late in acpi_ec_event_enabled()
256 * 1. true: The EC event handling is disabled before entering in acpi_ec_event_enabled()
258 * 2. false: The EC event handling is automatically disabled as in acpi_ec_event_enabled()
264 return test_bit(EC_FLAGS_STARTED, &ec->flags); in acpi_ec_event_enabled()
269 return ec->reference_count == 1; in acpi_ec_flushed()
272 /* --------------------------------------------------------------------------
274 * -------------------------------------------------------------------------- */
278 u8 x = inb(ec->command_addr); in acpi_ec_read_status()
293 u8 x = inb(ec->data_addr); in acpi_ec_read_data()
295 ec->timestamp = jiffies; in acpi_ec_read_data()
303 outb(command, ec->command_addr); in acpi_ec_write_cmd()
304 ec->timestamp = jiffies; in acpi_ec_write_cmd()
310 outb(data, ec->data_addr); in acpi_ec_write_data()
311 ec->timestamp = jiffies; in acpi_ec_write_data()
335 /* --------------------------------------------------------------------------
337 * -------------------------------------------------------------------------- */
343 (void)acpi_get_gpe_status(NULL, ec->gpe, &gpe_status); in acpi_ec_gpe_status_set()
350 acpi_enable_gpe(NULL, ec->gpe); in acpi_ec_enable_gpe()
352 BUG_ON(ec->reference_count < 1); in acpi_ec_enable_gpe()
353 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE); in acpi_ec_enable_gpe()
358 * software need to manually trigger a pseudo GPE event on in acpi_ec_enable_gpe()
369 acpi_disable_gpe(NULL, ec->gpe); in acpi_ec_disable_gpe()
371 BUG_ON(ec->reference_count < 1); in acpi_ec_disable_gpe()
372 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE); in acpi_ec_disable_gpe()
376 /* --------------------------------------------------------------------------
378 * -------------------------------------------------------------------------- */
382 ec->reference_count++; in acpi_ec_submit_request()
383 if (test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags) && in acpi_ec_submit_request()
384 ec->gpe >= 0 && ec->reference_count == 1) in acpi_ec_submit_request()
392 ec->reference_count--; in acpi_ec_complete_request()
393 if (test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags) && in acpi_ec_complete_request()
394 ec->gpe >= 0 && ec->reference_count == 0) in acpi_ec_complete_request()
398 wake_up(&ec->wait); in acpi_ec_complete_request()
403 if (!test_bit(EC_FLAGS_EVENTS_MASKED, &ec->flags)) { in acpi_ec_mask_events()
404 if (ec->gpe >= 0) in acpi_ec_mask_events()
407 disable_irq_nosync(ec->irq); in acpi_ec_mask_events()
410 set_bit(EC_FLAGS_EVENTS_MASKED, &ec->flags); in acpi_ec_mask_events()
416 if (test_bit(EC_FLAGS_EVENTS_MASKED, &ec->flags)) { in acpi_ec_unmask_events()
417 clear_bit(EC_FLAGS_EVENTS_MASKED, &ec->flags); in acpi_ec_unmask_events()
418 if (ec->gpe >= 0) in acpi_ec_unmask_events()
421 enable_irq(ec->irq); in acpi_ec_unmask_events()
428 * acpi_ec_submit_flushable_request() - Increase the reference count unless
433 * This function must be used before taking a new action that should hold
434 * the reference count. If this function returns false, then the action
451 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { in acpi_ec_submit_query()
454 ec->nr_pending_queries++; in acpi_ec_submit_query()
455 queue_work(ec_wq, &ec->work); in acpi_ec_submit_query()
461 if (test_and_clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) in acpi_ec_complete_query()
469 if (!test_and_set_bit(EC_FLAGS_QUERY_ENABLED, &ec->flags)) in __acpi_ec_enable_event()
470 ec_log_drv("event unblocked"); in __acpi_ec_enable_event()
472 * Unconditionally invoke this once after enabling the event in __acpi_ec_enable_event()
480 if (test_and_clear_bit(EC_FLAGS_QUERY_ENABLED, &ec->flags)) in __acpi_ec_disable_event()
481 ec_log_drv("event blocked"); in __acpi_ec_disable_event()
508 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_enable_event()
511 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_enable_event()
521 drain_workqueue(ec_wq); /* flush ec->work */ in __acpi_ec_flush_work()
529 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_disable_event()
531 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_disable_event()
555 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_guard_event()
557 * If firmware SCI_EVT clearing timing is "event", we actually in acpi_ec_guard_event()
559 * evaluating _Qxx, so we need to re-check SCI_EVT after waiting an in acpi_ec_guard_event()
572 !test_bit(EC_FLAGS_QUERY_PENDING, &ec->flags) || in acpi_ec_guard_event()
573 (ec->curr && ec->curr->command == ACPI_EC_COMMAND_QUERY)) in acpi_ec_guard_event()
575 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_guard_event()
584 spin_lock_irqsave(&ec->lock, flags); in ec_transaction_polled()
585 if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_POLL)) in ec_transaction_polled()
587 spin_unlock_irqrestore(&ec->lock, flags); in ec_transaction_polled()
596 spin_lock_irqsave(&ec->lock, flags); in ec_transaction_completed()
597 if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE)) in ec_transaction_completed()
599 spin_unlock_irqrestore(&ec->lock, flags); in ec_transaction_completed()
605 ec->curr->flags |= flag; in ec_transaction_transition()
606 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { in ec_transaction_transition()
615 set_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); in ec_transaction_transition()
621 if (t->irq_count < ec_storm_threshold) in acpi_ec_spurious_interrupt()
622 ++t->irq_count; in acpi_ec_spurious_interrupt()
625 if (t->irq_count == ec_storm_threshold) in acpi_ec_spurious_interrupt()
631 struct transaction *t = ec->curr; in advance_transaction()
632 bool wakeup = false; in advance_transaction() local
638 * Clear GPE_STS upfront to allow subsequent hardware GPE_STS 0->1 in advance_transaction()
649 if (ec->gpe >= 0 && acpi_ec_gpe_status_set(ec)) in advance_transaction()
650 acpi_clear_gpe(NULL, ec->gpe); in advance_transaction()
658 if (!t || !(t->flags & ACPI_EC_COMMAND_POLL)) { in advance_transaction()
660 (!ec->nr_pending_queries || in advance_transaction()
661 test_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags))) { in advance_transaction()
662 clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); in advance_transaction()
669 if (t->flags & ACPI_EC_COMMAND_POLL) { in advance_transaction()
670 if (t->wlen > t->wi) { in advance_transaction()
672 acpi_ec_write_data(ec, t->wdata[t->wi++]); in advance_transaction()
675 } else if (t->rlen > t->ri) { in advance_transaction()
677 t->rdata[t->ri++] = acpi_ec_read_data(ec); in advance_transaction()
678 if (t->rlen == t->ri) { in advance_transaction()
680 wakeup = true; in advance_transaction()
681 if (t->command == ACPI_EC_COMMAND_QUERY) in advance_transaction()
688 } else if (t->wlen == t->wi && !(status & ACPI_EC_FLAG_IBF)) { in advance_transaction()
690 wakeup = true; in advance_transaction()
693 acpi_ec_write_cmd(ec, t->command); in advance_transaction()
701 if (wakeup && interrupt) in advance_transaction()
702 wake_up(&ec->wait); in advance_transaction()
707 ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; in start_transaction()
708 ec->curr->flags = 0; in start_transaction()
713 unsigned long guard = usecs_to_jiffies(ec->polling_guard); in ec_guard()
714 unsigned long timeout = ec->timestamp + guard; in ec_guard()
718 if (ec->busy_polling) { in ec_guard()
730 * for event clearing mode "event" before the in ec_guard()
737 if (wait_event_timeout(ec->wait, in ec_guard()
743 return -ETIME; in ec_guard()
751 while (repeat--) { in ec_poll()
757 spin_lock_irqsave(&ec->lock, flags); in ec_poll()
759 spin_unlock_irqrestore(&ec->lock, flags); in ec_poll()
762 spin_lock_irqsave(&ec->lock, flags); in ec_poll()
764 spin_unlock_irqrestore(&ec->lock, flags); in ec_poll()
766 return -ETIME; in ec_poll()
776 spin_lock_irqsave(&ec->lock, tmp); in acpi_ec_transaction_unlocked()
779 ret = -EINVAL; in acpi_ec_transaction_unlocked()
784 ec->curr = t; in acpi_ec_transaction_unlocked()
785 ec_dbg_req("Command(%s) started", acpi_ec_cmd_string(t->command)); in acpi_ec_transaction_unlocked()
787 spin_unlock_irqrestore(&ec->lock, tmp); in acpi_ec_transaction_unlocked()
791 spin_lock_irqsave(&ec->lock, tmp); in acpi_ec_transaction_unlocked()
792 if (t->irq_count == ec_storm_threshold) in acpi_ec_transaction_unlocked()
794 ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command)); in acpi_ec_transaction_unlocked()
795 ec->curr = NULL; in acpi_ec_transaction_unlocked()
800 spin_unlock_irqrestore(&ec->lock, tmp); in acpi_ec_transaction_unlocked()
809 if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) in acpi_ec_transaction()
810 return -EINVAL; in acpi_ec_transaction()
811 if (t->rdata) in acpi_ec_transaction()
812 memset(t->rdata, 0, t->rlen); in acpi_ec_transaction()
814 mutex_lock(&ec->mutex); in acpi_ec_transaction()
815 if (ec->global_lock) { in acpi_ec_transaction()
818 status = -ENODEV; in acpi_ec_transaction()
825 if (ec->global_lock) in acpi_ec_transaction()
828 mutex_unlock(&ec->mutex); in acpi_ec_transaction()
881 return -ENODEV; in ec_read()
898 return -ENODEV; in ec_write()
915 return -ENODEV; in ec_transaction()
926 return first_ec->handle; in ec_get_handle()
934 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_start()
935 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { in acpi_ec_start()
937 /* Enable GPE for event processing (SCI_EVT=1) */ in acpi_ec_start()
944 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_start()
952 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_stopped()
954 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_stopped()
962 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_stop()
965 set_bit(EC_FLAGS_STOPPED, &ec->flags); in acpi_ec_stop()
966 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_stop()
967 wait_event(ec->wait, acpi_ec_stopped(ec)); in acpi_ec_stop()
968 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_stop()
969 /* Disable GPE for event processing (SCI_EVT=1) */ in acpi_ec_stop()
975 clear_bit(EC_FLAGS_STARTED, &ec->flags); in acpi_ec_stop()
976 clear_bit(EC_FLAGS_STOPPED, &ec->flags); in acpi_ec_stop()
979 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_stop()
986 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_enter_noirq()
987 ec->busy_polling = true; in acpi_ec_enter_noirq()
988 ec->polling_guard = 0; in acpi_ec_enter_noirq()
990 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_enter_noirq()
997 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_leave_noirq()
998 ec->busy_polling = ec_busy_polling; in acpi_ec_leave_noirq()
999 ec->polling_guard = ec_polling_guard; in acpi_ec_leave_noirq()
1001 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_leave_noirq()
1011 mutex_lock(&ec->mutex); in acpi_ec_block_transactions()
1014 mutex_unlock(&ec->mutex); in acpi_ec_block_transactions()
1021 * atomic context during wakeup, so we don't need to acquire the mutex). in acpi_ec_unblock_transactions()
1027 /* --------------------------------------------------------------------------
1028 Event Management
1029 -------------------------------------------------------------------------- */
1035 mutex_lock(&ec->mutex); in acpi_ec_get_query_handler_by_value()
1036 list_for_each_entry(handler, &ec->list, node) { in acpi_ec_get_query_handler_by_value()
1037 if (value == handler->query_bit) { in acpi_ec_get_query_handler_by_value()
1038 kref_get(&handler->kref); in acpi_ec_get_query_handler_by_value()
1039 mutex_unlock(&ec->mutex); in acpi_ec_get_query_handler_by_value()
1043 mutex_unlock(&ec->mutex); in acpi_ec_get_query_handler_by_value()
1057 kref_put(&handler->kref, acpi_ec_query_handler_release); in acpi_ec_put_query_handler()
1068 return -ENOMEM; in acpi_ec_add_query_handler()
1070 handler->query_bit = query_bit; in acpi_ec_add_query_handler()
1071 handler->handle = handle; in acpi_ec_add_query_handler()
1072 handler->func = func; in acpi_ec_add_query_handler()
1073 handler->data = data; in acpi_ec_add_query_handler()
1074 mutex_lock(&ec->mutex); in acpi_ec_add_query_handler()
1075 kref_init(&handler->kref); in acpi_ec_add_query_handler()
1076 list_add(&handler->node, &ec->list); in acpi_ec_add_query_handler()
1077 mutex_unlock(&ec->mutex); in acpi_ec_add_query_handler()
1088 mutex_lock(&ec->mutex); in acpi_ec_remove_query_handlers()
1089 list_for_each_entry_safe(handler, tmp, &ec->list, node) { in acpi_ec_remove_query_handlers()
1090 if (remove_all || query_bit == handler->query_bit) { in acpi_ec_remove_query_handlers()
1091 list_del_init(&handler->node); in acpi_ec_remove_query_handlers()
1092 list_add(&handler->node, &free_list); in acpi_ec_remove_query_handlers()
1095 mutex_unlock(&ec->mutex); in acpi_ec_remove_query_handlers()
1114 INIT_WORK(&q->work, acpi_ec_event_processor); in acpi_ec_create_query()
1115 t = &q->transaction; in acpi_ec_create_query()
1116 t->command = ACPI_EC_COMMAND_QUERY; in acpi_ec_create_query()
1117 t->rdata = pval; in acpi_ec_create_query()
1118 t->rlen = 1; in acpi_ec_create_query()
1125 if (q->handler) in acpi_ec_delete_query()
1126 acpi_ec_put_query_handler(q->handler); in acpi_ec_delete_query()
1134 struct acpi_ec_query_handler *handler = q->handler; in acpi_ec_event_processor()
1136 ec_dbg_evt("Query(0x%02x) started", handler->query_bit); in acpi_ec_event_processor()
1137 if (handler->func) in acpi_ec_event_processor()
1138 handler->func(handler->data); in acpi_ec_event_processor()
1139 else if (handler->handle) in acpi_ec_event_processor()
1140 acpi_evaluate_object(handler->handle, NULL, NULL, NULL); in acpi_ec_event_processor()
1141 ec_dbg_evt("Query(0x%02x) stopped", handler->query_bit); in acpi_ec_event_processor()
1153 return -ENOMEM; in acpi_ec_query()
1160 result = acpi_ec_transaction(ec, &q->transaction); in acpi_ec_query()
1162 result = -ENODATA; in acpi_ec_query()
1166 q->handler = acpi_ec_get_query_handler_by_value(ec, value); in acpi_ec_query()
1167 if (!q->handler) { in acpi_ec_query()
1168 result = -ENODATA; in acpi_ec_query()
1182 if (!queue_work(ec_query_wq, &q->work)) { in acpi_ec_query()
1184 result = -EBUSY; in acpi_ec_query()
1201 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_check_event()
1206 if (!ec->curr) in acpi_ec_check_event()
1208 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_check_event()
1218 ec_dbg_evt("Event started"); in acpi_ec_event_handler()
1220 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_event_handler()
1221 while (ec->nr_pending_queries) { in acpi_ec_event_handler()
1222 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_event_handler()
1224 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_event_handler()
1225 ec->nr_pending_queries--; in acpi_ec_event_handler()
1232 if (!ec->nr_pending_queries) { in acpi_ec_event_handler()
1238 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_event_handler()
1240 ec_dbg_evt("Event stopped"); in acpi_ec_event_handler()
1249 spin_lock_irqsave(&ec->lock, flags); in acpi_ec_handle_interrupt()
1251 spin_unlock_irqrestore(&ec->lock, flags); in acpi_ec_handle_interrupt()
1267 /* --------------------------------------------------------------------------
1269 * -------------------------------------------------------------------------- */
1286 if (ec->busy_polling || bits > 8) in acpi_ec_space_handler()
1294 if (ec->busy_polling || bits > 8) in acpi_ec_space_handler()
1298 case -EINVAL: in acpi_ec_space_handler()
1300 case -ENODEV: in acpi_ec_space_handler()
1302 case -ETIME: in acpi_ec_space_handler()
1309 /* --------------------------------------------------------------------------
1311 * -------------------------------------------------------------------------- */
1331 mutex_init(&ec->mutex); in acpi_ec_alloc()
1332 init_waitqueue_head(&ec->wait); in acpi_ec_alloc()
1333 INIT_LIST_HEAD(&ec->list); in acpi_ec_alloc()
1334 spin_lock_init(&ec->lock); in acpi_ec_alloc()
1335 INIT_WORK(&ec->work, acpi_ec_event_handler); in acpi_ec_alloc()
1336 ec->timestamp = jiffies; in acpi_ec_alloc()
1337 ec->busy_polling = true; in acpi_ec_alloc()
1338 ec->polling_guard = 0; in acpi_ec_alloc()
1339 ec->gpe = -1; in acpi_ec_alloc()
1340 ec->irq = -1; in acpi_ec_alloc()
1369 ec->command_addr = ec->data_addr = 0; in ec_parse_device()
1375 if (ec->data_addr == 0 || ec->command_addr == 0) in ec_parse_device()
1383 ec->gpe = boot_ec->gpe; in ec_parse_device()
1389 ec->gpe = tmp; in ec_parse_device()
1392 * Errors are non-fatal, allowing for ACPI Reduced Hardware in ec_parse_device()
1399 ec->global_lock = tmp; in ec_parse_device()
1400 ec->handle = handle; in ec_parse_device()
1408 status = acpi_install_gpe_raw_handler(NULL, ec->gpe, in install_gpe_event_handler()
1414 if (test_bit(EC_FLAGS_STARTED, &ec->flags) && ec->reference_count >= 1) in install_gpe_event_handler()
1422 return request_irq(ec->irq, acpi_ec_irq_handler, IRQF_SHARED, in install_gpio_irq_event_handler()
1427 * ec_install_handlers - Install service callbacks and register query methods.
1433 * namespace and register them, and install an event (either GPE or GPIO IRQ)
1437 * -ENODEV if the address space handler cannot be installed, which means
1439 * -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred,
1448 if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { in ec_install_handlers()
1450 status = acpi_install_address_space_handler(ec->handle, in ec_install_handlers()
1456 return -ENODEV; in ec_install_handlers()
1458 set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); in ec_install_handlers()
1464 if (ec->gpe < 0) { in ec_install_handlers()
1471 if (irq == -EPROBE_DEFER) in ec_install_handlers()
1472 return -EPROBE_DEFER; in ec_install_handlers()
1474 ec->irq = irq; in ec_install_handlers()
1477 if (!test_bit(EC_FLAGS_QUERY_METHODS_INSTALLED, &ec->flags)) { in ec_install_handlers()
1479 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1, in ec_install_handlers()
1482 set_bit(EC_FLAGS_QUERY_METHODS_INSTALLED, &ec->flags); in ec_install_handlers()
1484 if (!test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags)) { in ec_install_handlers()
1487 if (ec->gpe >= 0) in ec_install_handlers()
1489 else if (ec->irq >= 0) in ec_install_handlers()
1493 set_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags); in ec_install_handlers()
1497 * Failures to install an event handler are not fatal, because in ec_install_handlers()
1509 if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { in ec_remove_handlers()
1510 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, in ec_remove_handlers()
1513 clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); in ec_remove_handlers()
1529 if (test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags)) { in ec_remove_handlers()
1530 if (ec->gpe >= 0 && in ec_remove_handlers()
1531 ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, in ec_remove_handlers()
1535 if (ec->irq >= 0) in ec_remove_handlers()
1536 free_irq(ec->irq, ec); in ec_remove_handlers()
1538 clear_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags); in ec_remove_handlers()
1540 if (test_bit(EC_FLAGS_QUERY_METHODS_INSTALLED, &ec->flags)) { in ec_remove_handlers()
1542 clear_bit(EC_FLAGS_QUERY_METHODS_INSTALLED, &ec->flags); in ec_remove_handlers()
1558 pr_info("EC_CMD/EC_SC=0x%lx, EC_DATA=0x%lx\n", ec->command_addr, in acpi_ec_setup()
1559 ec->data_addr); in acpi_ec_setup()
1561 if (test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags)) { in acpi_ec_setup()
1562 if (ec->gpe >= 0) in acpi_ec_setup()
1563 pr_info("GPE=0x%x\n", ec->gpe); in acpi_ec_setup()
1565 pr_info("IRQ=%d\n", ec->irq); in acpi_ec_setup()
1579 if (boot_ec && (boot_ec->handle == device->handle || in acpi_ec_add()
1588 return -ENOMEM; in acpi_ec_add()
1590 status = ec_parse_device(device->handle, 0, ec, NULL); in acpi_ec_add()
1592 ret = -EINVAL; in acpi_ec_add()
1596 if (boot_ec && ec->command_addr == boot_ec->command_addr && in acpi_ec_add()
1597 ec->data_addr == boot_ec->data_addr && in acpi_ec_add()
1603 * boot_ec->gpe to ec->gpe. in acpi_ec_add()
1605 boot_ec->handle = ec->handle; in acpi_ec_add()
1606 acpi_handle_debug(ec->handle, "duplicated.\n"); in acpi_ec_add()
1617 acpi_handle_info(boot_ec->handle, in acpi_ec_add()
1621 acpi_handle_info(ec->handle, in acpi_ec_add()
1624 device->driver_data = ec; in acpi_ec_add()
1626 ret = !!request_region(ec->data_addr, 1, "EC data"); in acpi_ec_add()
1627 WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr); in acpi_ec_add()
1628 ret = !!request_region(ec->command_addr, 1, "EC cmd"); in acpi_ec_add()
1629 WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); in acpi_ec_add()
1634 acpi_handle_debug(ec->handle, "enumerated.\n"); in acpi_ec_add()
1649 return -EINVAL; in acpi_ec_remove()
1652 release_region(ec->data_addr, 1); in acpi_ec_remove()
1653 release_region(ec->command_addr, 1); in acpi_ec_remove()
1654 device->driver_data = NULL; in acpi_ec_remove()
1667 if (resource->type != ACPI_RESOURCE_TYPE_IO) in ec_parse_io_ports()
1675 if (ec->data_addr == 0) in ec_parse_io_ports()
1676 ec->data_addr = resource->data.io.minimum; in ec_parse_io_ports()
1677 else if (ec->command_addr == 0) in ec_parse_io_ports()
1678 ec->command_addr = resource->data.io.minimum; in ec_parse_io_ports()
1692 * This function is not Windows-compatible as Windows never enumerates the
1720 if (ACPI_FAILURE(status) || !ec->handle) { in acpi_ec_dsdt_probe()
1726 * When the DSDT EC is available, always re-configure boot EC to in acpi_ec_dsdt_probe()
1740 acpi_handle_info(ec->handle, in acpi_ec_dsdt_probe()
1745 * acpi_ec_ecdt_start - Finalize the boot ECDT EC initialization.
1764 if (!boot_ec || boot_ec->handle != ACPI_ROOT_OBJECT) in acpi_ec_ecdt_start()
1773 status = acpi_get_handle(NULL, ecdt_ptr->id, &handle); in acpi_ec_ecdt_start()
1775 boot_ec->handle = handle; in acpi_ec_ecdt_start()
1811 * MSI MS-171F
1847 ec_correct_ecdt, "MSI MS-171F", {
1848 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star"),
1849 DMI_MATCH(DMI_PRODUCT_NAME, "MS-171F"),}, NULL},
1888 ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", {
1890 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"),}, NULL},
1911 if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) { in acpi_ec_ecdt_probe()
1924 ec->command_addr = ecdt_ptr->data.address; in acpi_ec_ecdt_probe()
1925 ec->data_addr = ecdt_ptr->control.address; in acpi_ec_ecdt_probe()
1927 ec->command_addr = ecdt_ptr->control.address; in acpi_ec_ecdt_probe()
1928 ec->data_addr = ecdt_ptr->data.address; in acpi_ec_ecdt_probe()
1936 ec->gpe = ecdt_ptr->gpe; in acpi_ec_ecdt_probe()
1938 ec->handle = ACPI_ROOT_OBJECT; in acpi_ec_ecdt_probe()
1978 if (ec_no_wakeup && test_bit(EC_FLAGS_STARTED, &ec->flags) && in acpi_ec_suspend_noirq()
1979 ec->gpe >= 0 && ec->reference_count >= 1) in acpi_ec_suspend_noirq()
1980 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE); in acpi_ec_suspend_noirq()
1993 if (ec_no_wakeup && test_bit(EC_FLAGS_STARTED, &ec->flags) && in acpi_ec_resume_noirq()
1994 ec->gpe >= 0 && ec->reference_count >= 1) in acpi_ec_resume_noirq()
1995 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE); in acpi_ec_resume_noirq()
2012 acpi_mark_gpe_for_wake(NULL, first_ec->gpe); in acpi_ec_mark_gpe_for_wake()
2016 void acpi_ec_set_gpe_wake_mask(u8 action) in acpi_ec_set_gpe_wake_mask() argument
2019 acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action); in acpi_ec_set_gpe_wake_mask()
2030 * Report wakeup if the status bit is set for any enabled GPE other in acpi_ec_dispatch_gpe()
2033 if (acpi_any_gpe_status_set(first_ec->gpe)) in acpi_ec_dispatch_gpe()
2037 * Dispatch the EC GPE in-band, but do not report wakeup in any case in acpi_ec_dispatch_gpe()
2040 ret = acpi_dispatch_gpe(NULL, first_ec->gpe); in acpi_ec_dispatch_gpe()
2044 /* Flush the event and query workqueues. */ in acpi_ec_dispatch_gpe()
2061 if (!strncmp(val, "status", sizeof("status") - 1)) { in param_set_event_clearing()
2064 } else if (!strncmp(val, "query", sizeof("query") - 1)) { in param_set_event_clearing()
2067 } else if (!strncmp(val, "event", sizeof("event") - 1)) { in param_set_event_clearing()
2069 pr_info("Assuming SCI_EVT clearing on event reads\n"); in param_set_event_clearing()
2071 result = -EINVAL; in param_set_event_clearing()
2084 return sprintf(buffer, "event\n"); in param_get_event_clearing()
2128 return -ENODEV; in acpi_ec_init_workqueues()
2167 * Disable EC wakeup on following systems to prevent periodic in acpi_ec_init()
2168 * wakeup from EC GPE. in acpi_ec_init()
2172 pr_debug("Disabling EC wakeup on suspend-to-idle\n"); in acpi_ec_init()