aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 14:52:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 14:52:52 -0400
commit08acd4f8af42affd8cbed81cc1b69fa12ddb213f (patch)
tree988d15db6233b20db6a500cd5f590c6d2041462d /drivers/acpi/ec.c
parentccf2779544eecfcc5447e2028d1029b6d4ff7bb6 (diff)
parent008238b54ac2350babf195084ecedbcf7851a202 (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (179 commits) ACPI: Fix acpi_processor_idle and idle= boot parameters interaction acpi: fix section mismatch warning in pnpacpi intel_menlo: fix build warning ACPI: Cleanup: Remove unneeded, multiple local dummy variables ACPI: video - fix permissions on some proc entries ACPI: video - properly handle errors when registering proc elements ACPI: video - do not store invalid entries in attached_array list ACPI: re-name acpi_pm_ops to acpi_suspend_ops ACER_WMI/ASUS_LAPTOP: fix build bug thinkpad_acpi: fix possible NULL pointer dereference if kstrdup failed ACPI: check a return value correctly in acpi_power_get_context() #if 0 acpi/bay.c:eject_removable_drive() eeepc-laptop: add hwmon fan control eeepc-laptop: add backlight eeepc-laptop: add base driver ACPI: thinkpad-acpi: bump up version to 0.20 ACPI: thinkpad-acpi: fix selects in Kconfig ACPI: thinkpad-acpi: use a private workqueue ACPI: thinkpad-acpi: fluff really minor fix ACPI: thinkpad-acpi: use uppercase for "LED" on user documentation ... Fixed conflicts in drivers/acpi/video.c and drivers/misc/intel_menlow.c manually.
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c240
1 files changed, 124 insertions, 116 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e3f04b272f3f..0924992187e8 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -73,38 +73,14 @@ enum ec_event {
73 73
74#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ 74#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
75#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 75#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
76#define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */
76 77
77enum { 78enum {
78 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ 79 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
79 EC_FLAGS_QUERY_PENDING, /* Query is pending */ 80 EC_FLAGS_QUERY_PENDING, /* Query is pending */
80 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ 81 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
81 EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */ 82 EC_FLAGS_NO_GPE, /* Don't use GPE mode */
82 EC_FLAGS_ADDRESS, /* Address is being written */ 83 EC_FLAGS_RESCHEDULE_POLL /* Re-schedule poll */
83 EC_FLAGS_NO_WDATA_GPE, /* Don't expect WDATA GPE event */
84 EC_FLAGS_WDATA, /* Data is being written */
85 EC_FLAGS_NO_OBF1_GPE, /* Don't expect GPE before read */
86};
87
88static int acpi_ec_remove(struct acpi_device *device, int type);
89static int acpi_ec_start(struct acpi_device *device);
90static int acpi_ec_stop(struct acpi_device *device, int type);
91static int acpi_ec_add(struct acpi_device *device);
92
93static const struct acpi_device_id ec_device_ids[] = {
94 {"PNP0C09", 0},
95 {"", 0},
96};
97
98static struct acpi_driver acpi_ec_driver = {
99 .name = "ec",
100 .class = ACPI_EC_CLASS,
101 .ids = ec_device_ids,
102 .ops = {
103 .add = acpi_ec_add,
104 .remove = acpi_ec_remove,
105 .start = acpi_ec_start,
106 .stop = acpi_ec_stop,
107 },
108}; 84};
109 85
110/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 86/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -129,6 +105,8 @@ static struct acpi_ec {
129 struct mutex lock; 105 struct mutex lock;
130 wait_queue_head_t wait; 106 wait_queue_head_t wait;
131 struct list_head list; 107 struct list_head list;
108 struct delayed_work work;
109 atomic_t irq_count;
132 u8 handlers_installed; 110 u8 handlers_installed;
133} *boot_ec, *first_ec; 111} *boot_ec, *first_ec;
134 112
@@ -177,65 +155,52 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
177 return 0; 155 return 0;
178} 156}
179 157
180static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) 158static void ec_schedule_ec_poll(struct acpi_ec *ec)
181{ 159{
182 int ret = 0; 160 if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags))
161 schedule_delayed_work(&ec->work,
162 msecs_to_jiffies(ACPI_EC_DELAY));
163}
183 164
184 if (unlikely(event == ACPI_EC_EVENT_OBF_1 && 165static void ec_switch_to_poll_mode(struct acpi_ec *ec)
185 test_bit(EC_FLAGS_NO_OBF1_GPE, &ec->flags))) 166{
186 force_poll = 1; 167 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
187 if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) && 168 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
188 test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags))) 169 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
189 force_poll = 1; 170 set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
190 if (unlikely(test_bit(EC_FLAGS_WDATA, &ec->flags) && 171}
191 test_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags))) 172
192 force_poll = 1; 173static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
174{
175 atomic_set(&ec->irq_count, 0);
193 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && 176 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
194 likely(!force_poll)) { 177 likely(!force_poll)) {
195 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), 178 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
196 msecs_to_jiffies(ACPI_EC_DELAY))) 179 msecs_to_jiffies(ACPI_EC_DELAY)))
197 goto end; 180 return 0;
198 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 181 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
199 if (acpi_ec_check_status(ec, event)) { 182 if (acpi_ec_check_status(ec, event)) {
200 if (event == ACPI_EC_EVENT_OBF_1) { 183 /* missing GPEs, switch back to poll mode */
201 /* miss OBF_1 GPE, don't expect it */ 184 if (printk_ratelimit())
202 pr_info(PREFIX "missing OBF confirmation, " 185 pr_info(PREFIX "missing confirmations, "
203 "don't expect it any longer.\n");
204 set_bit(EC_FLAGS_NO_OBF1_GPE, &ec->flags);
205 } else if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) {
206 /* miss address GPE, don't expect it anymore */
207 pr_info(PREFIX "missing address confirmation, "
208 "don't expect it any longer.\n");
209 set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags);
210 } else if (test_bit(EC_FLAGS_WDATA, &ec->flags)) {
211 /* miss write data GPE, don't expect it */
212 pr_info(PREFIX "missing write data confirmation, "
213 "don't expect it any longer.\n");
214 set_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags);
215 } else {
216 /* missing GPEs, switch back to poll mode */
217 if (printk_ratelimit())
218 pr_info(PREFIX "missing confirmations, "
219 "switch off interrupt mode.\n"); 186 "switch off interrupt mode.\n");
220 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 187 ec_switch_to_poll_mode(ec);
221 } 188 ec_schedule_ec_poll(ec);
222 goto end; 189 return 0;
223 } 190 }
224 } else { 191 } else {
225 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); 192 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
226 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 193 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
227 while (time_before(jiffies, delay)) { 194 while (time_before(jiffies, delay)) {
228 if (acpi_ec_check_status(ec, event)) 195 if (acpi_ec_check_status(ec, event))
229 goto end; 196 return 0;
197 udelay(ACPI_EC_UDELAY);
230 } 198 }
231 } 199 }
232 pr_err(PREFIX "acpi_ec_wait timeout," 200 pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n",
233 " status = %d, expect_event = %d\n", 201 acpi_ec_read_status(ec),
234 acpi_ec_read_status(ec), event); 202 (event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\"");
235 ret = -ETIME; 203 return -ETIME;
236 end:
237 clear_bit(EC_FLAGS_ADDRESS, &ec->flags);
238 return ret;
239} 204}
240 205
241static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, 206static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
@@ -245,8 +210,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
245{ 210{
246 int result = 0; 211 int result = 0;
247 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 212 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
248 acpi_ec_write_cmd(ec, command);
249 pr_debug(PREFIX "transaction start\n"); 213 pr_debug(PREFIX "transaction start\n");
214 acpi_ec_write_cmd(ec, command);
250 for (; wdata_len > 0; --wdata_len) { 215 for (; wdata_len > 0; --wdata_len) {
251 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 216 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
252 if (result) { 217 if (result) {
@@ -254,15 +219,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
254 "write_cmd timeout, command = %d\n", command); 219 "write_cmd timeout, command = %d\n", command);
255 goto end; 220 goto end;
256 } 221 }
257 /* mark the address byte written to EC */
258 if (rdata_len + wdata_len > 1)
259 set_bit(EC_FLAGS_ADDRESS, &ec->flags);
260 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 222 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
261 acpi_ec_write_data(ec, *(wdata++)); 223 acpi_ec_write_data(ec, *(wdata++));
262 } 224 }
263 225
264 if (!rdata_len) { 226 if (!rdata_len) {
265 set_bit(EC_FLAGS_WDATA, &ec->flags);
266 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 227 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
267 if (result) { 228 if (result) {
268 pr_err(PREFIX 229 pr_err(PREFIX
@@ -527,47 +488,51 @@ static u32 acpi_ec_gpe_handler(void *data)
527{ 488{
528 acpi_status status = AE_OK; 489 acpi_status status = AE_OK;
529 struct acpi_ec *ec = data; 490 struct acpi_ec *ec = data;
491 u8 state = acpi_ec_read_status(ec);
530 492
531 pr_debug(PREFIX "~~~> interrupt\n"); 493 pr_debug(PREFIX "~~~> interrupt\n");
494 atomic_inc(&ec->irq_count);
495 if (atomic_read(&ec->irq_count) > 5) {
496 pr_err(PREFIX "GPE storm detected, disabling EC GPE\n");
497 ec_switch_to_poll_mode(ec);
498 goto end;
499 }
532 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 500 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
533 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) 501 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
534 wake_up(&ec->wait); 502 wake_up(&ec->wait);
535 503
536 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) { 504 if (state & ACPI_EC_FLAG_SCI) {
537 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) 505 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
538 status = acpi_os_execute(OSL_EC_BURST_HANDLER, 506 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
539 acpi_ec_gpe_query, ec); 507 acpi_ec_gpe_query, ec);
540 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { 508 } else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
509 !test_bit(EC_FLAGS_NO_GPE, &ec->flags) &&
510 in_interrupt()) {
541 /* this is non-query, must be confirmation */ 511 /* this is non-query, must be confirmation */
542 if (printk_ratelimit()) 512 if (printk_ratelimit())
543 pr_info(PREFIX "non-query interrupt received," 513 pr_info(PREFIX "non-query interrupt received,"
544 " switching to interrupt mode\n"); 514 " switching to interrupt mode\n");
545 set_bit(EC_FLAGS_GPE_MODE, &ec->flags); 515 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
516 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
546 } 517 }
547 518end:
519 ec_schedule_ec_poll(ec);
548 return ACPI_SUCCESS(status) ? 520 return ACPI_SUCCESS(status) ?
549 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 521 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
550} 522}
551 523
524static void do_ec_poll(struct work_struct *work)
525{
526 struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work);
527 atomic_set(&ec->irq_count, 0);
528 (void)acpi_ec_gpe_handler(ec);
529}
530
552/* -------------------------------------------------------------------------- 531/* --------------------------------------------------------------------------
553 Address Space Management 532 Address Space Management
554 -------------------------------------------------------------------------- */ 533 -------------------------------------------------------------------------- */
555 534
556static acpi_status 535static acpi_status
557acpi_ec_space_setup(acpi_handle region_handle,
558 u32 function, void *handler_context, void **return_context)
559{
560 /*
561 * The EC object is in the handler context and is needed
562 * when calling the acpi_ec_space_handler.
563 */
564 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
565 handler_context : NULL;
566
567 return AE_OK;
568}
569
570static acpi_status
571acpi_ec_space_handler(u32 function, acpi_physical_address address, 536acpi_ec_space_handler(u32 function, acpi_physical_address address,
572 u32 bits, acpi_integer *value, 537 u32 bits, acpi_integer *value,
573 void *handler_context, void *region_context) 538 void *handler_context, void *region_context)
@@ -704,6 +669,8 @@ static struct acpi_ec *make_acpi_ec(void)
704 mutex_init(&ec->lock); 669 mutex_init(&ec->lock);
705 init_waitqueue_head(&ec->wait); 670 init_waitqueue_head(&ec->wait);
706 INIT_LIST_HEAD(&ec->list); 671 INIT_LIST_HEAD(&ec->list);
672 INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll);
673 atomic_set(&ec->irq_count, 0);
707 return ec; 674 return ec;
708} 675}
709 676
@@ -736,17 +703,21 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
736 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe); 703 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
737 if (ACPI_FAILURE(status)) 704 if (ACPI_FAILURE(status))
738 return status; 705 return status;
739 /* Find and register all query methods */
740 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
741 acpi_ec_register_query_methods, ec, NULL);
742 /* Use the global lock for all EC transactions? */ 706 /* Use the global lock for all EC transactions? */
743 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock); 707 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
744 ec->handle = handle; 708 ec->handle = handle;
745 return AE_CTRL_TERMINATE; 709 return AE_CTRL_TERMINATE;
746} 710}
747 711
712static void ec_poll_stop(struct acpi_ec *ec)
713{
714 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
715 cancel_delayed_work(&ec->work);
716}
717
748static void ec_remove_handlers(struct acpi_ec *ec) 718static void ec_remove_handlers(struct acpi_ec *ec)
749{ 719{
720 ec_poll_stop(ec);
750 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 721 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
751 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 722 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
752 pr_err(PREFIX "failed to remove space handler\n"); 723 pr_err(PREFIX "failed to remove space handler\n");
@@ -766,31 +737,28 @@ static int acpi_ec_add(struct acpi_device *device)
766 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 737 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
767 738
768 /* Check for boot EC */ 739 /* Check for boot EC */
769 if (boot_ec) { 740 if (boot_ec &&
770 if (boot_ec->handle == device->handle) { 741 (boot_ec->handle == device->handle ||
771 /* Pre-loaded EC from DSDT, just move pointer */ 742 boot_ec->handle == ACPI_ROOT_OBJECT)) {
772 ec = boot_ec; 743 ec = boot_ec;
773 boot_ec = NULL; 744 boot_ec = NULL;
774 goto end; 745 } else {
775 } else if (boot_ec->handle == ACPI_ROOT_OBJECT) { 746 ec = make_acpi_ec();
776 /* ECDT-based EC, time to shut it down */ 747 if (!ec)
777 ec_remove_handlers(boot_ec); 748 return -ENOMEM;
778 kfree(boot_ec); 749 if (ec_parse_device(device->handle, 0, ec, NULL) !=
779 first_ec = boot_ec = NULL; 750 AE_CTRL_TERMINATE) {
751 kfree(ec);
752 return -EINVAL;
780 } 753 }
781 } 754 }
782 755
783 ec = make_acpi_ec();
784 if (!ec)
785 return -ENOMEM;
786
787 if (ec_parse_device(device->handle, 0, ec, NULL) !=
788 AE_CTRL_TERMINATE) {
789 kfree(ec);
790 return -EINVAL;
791 }
792 ec->handle = device->handle; 756 ec->handle = device->handle;
793 end: 757
758 /* Find and register all query methods */
759 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1,
760 acpi_ec_register_query_methods, ec, NULL);
761
794 if (!first_ec) 762 if (!first_ec)
795 first_ec = ec; 763 first_ec = ec;
796 acpi_driver_data(device) = ec; 764 acpi_driver_data(device) = ec;
@@ -865,7 +833,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
865 status = acpi_install_address_space_handler(ec->handle, 833 status = acpi_install_address_space_handler(ec->handle,
866 ACPI_ADR_SPACE_EC, 834 ACPI_ADR_SPACE_EC,
867 &acpi_ec_space_handler, 835 &acpi_ec_space_handler,
868 &acpi_ec_space_setup, ec); 836 NULL, ec);
869 if (ACPI_FAILURE(status)) { 837 if (ACPI_FAILURE(status)) {
870 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); 838 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
871 return -ENODEV; 839 return -ENODEV;
@@ -892,6 +860,7 @@ static int acpi_ec_start(struct acpi_device *device)
892 860
893 /* EC is fully operational, allow queries */ 861 /* EC is fully operational, allow queries */
894 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 862 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
863 ec_schedule_ec_poll(ec);
895 return ret; 864 return ret;
896} 865}
897 866
@@ -919,6 +888,11 @@ int __init acpi_boot_ec_enable(void)
919 return -EFAULT; 888 return -EFAULT;
920} 889}
921 890
891static const struct acpi_device_id ec_device_ids[] = {
892 {"PNP0C09", 0},
893 {"", 0},
894};
895
922int __init acpi_ec_ecdt_probe(void) 896int __init acpi_ec_ecdt_probe(void)
923{ 897{
924 int ret; 898 int ret;
@@ -939,6 +913,7 @@ int __init acpi_ec_ecdt_probe(void)
939 boot_ec->data_addr = ecdt_ptr->data.address; 913 boot_ec->data_addr = ecdt_ptr->data.address;
940 boot_ec->gpe = ecdt_ptr->gpe; 914 boot_ec->gpe = ecdt_ptr->gpe;
941 boot_ec->handle = ACPI_ROOT_OBJECT; 915 boot_ec->handle = ACPI_ROOT_OBJECT;
916 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
942 } else { 917 } else {
943 /* This workaround is needed only on some broken machines, 918 /* This workaround is needed only on some broken machines,
944 * which require early EC, but fail to provide ECDT */ 919 * which require early EC, but fail to provide ECDT */
@@ -968,6 +943,39 @@ int __init acpi_ec_ecdt_probe(void)
968 return -ENODEV; 943 return -ENODEV;
969} 944}
970 945
946static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
947{
948 struct acpi_ec *ec = acpi_driver_data(device);
949 /* Stop using GPE */
950 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
951 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
952 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
953 return 0;
954}
955
956static int acpi_ec_resume(struct acpi_device *device)
957{
958 struct acpi_ec *ec = acpi_driver_data(device);
959 /* Enable use of GPE back */
960 clear_bit(EC_FLAGS_NO_GPE, &ec->flags);
961 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
962 return 0;
963}
964
965static struct acpi_driver acpi_ec_driver = {
966 .name = "ec",
967 .class = ACPI_EC_CLASS,
968 .ids = ec_device_ids,
969 .ops = {
970 .add = acpi_ec_add,
971 .remove = acpi_ec_remove,
972 .start = acpi_ec_start,
973 .stop = acpi_ec_stop,
974 .suspend = acpi_ec_suspend,
975 .resume = acpi_ec_resume,
976 },
977};
978
971static int __init acpi_ec_init(void) 979static int __init acpi_ec_init(void)
972{ 980{
973 int result = 0; 981 int result = 0;