ec.c (8c2fcadc933f713d51f46ec4dcd9b12830e0df84) ec.c (9630bdd9b15d2f489c646d8bc04b60e53eb5ec78)
1/*
2 * ec.c - ACPI Embedded Controller Driver (v2.1)
3 *
4 * Copyright (C) 2006-2008 Alexey Starikovskiy <astarikovskiy@suse.de>
5 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
6 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
7 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
8 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>

--- 293 unchanged lines hidden (view full) ---

302 pr_err(PREFIX "input buffer is not empty, "
303 "aborting transaction\n");
304 status = -ETIME;
305 goto end;
306 }
307 pr_debug(PREFIX "transaction start\n");
308 /* disable GPE during transaction if storm is detected */
309 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
1/*
2 * ec.c - ACPI Embedded Controller Driver (v2.1)
3 *
4 * Copyright (C) 2006-2008 Alexey Starikovskiy <astarikovskiy@suse.de>
5 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
6 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
7 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
8 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>

--- 293 unchanged lines hidden (view full) ---

302 pr_err(PREFIX "input buffer is not empty, "
303 "aborting transaction\n");
304 status = -ETIME;
305 goto end;
306 }
307 pr_debug(PREFIX "transaction start\n");
308 /* disable GPE during transaction if storm is detected */
309 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
310 acpi_disable_gpe(NULL, ec->gpe);
310 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
311 }
312
313 status = acpi_ec_transaction_unlocked(ec, t);
314
315 /* check if we received SCI during transaction */
316 ec_check_sci_sync(ec, acpi_ec_read_status(ec));
317 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
318 msleep(1);
319 /* it is safe to enable GPE outside of transaction */
311 }
312
313 status = acpi_ec_transaction_unlocked(ec, t);
314
315 /* check if we received SCI during transaction */
316 ec_check_sci_sync(ec, acpi_ec_read_status(ec));
317 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
318 msleep(1);
319 /* it is safe to enable GPE outside of transaction */
320 acpi_enable_gpe(NULL, ec->gpe);
320 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
321 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
322 pr_info(PREFIX "GPE storm detected, "
323 "transactions will use polling mode\n");
324 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
325 }
326 pr_debug(PREFIX "transaction end\n");
327end:
328 if (ec->global_lock)

--- 454 unchanged lines hidden (view full) ---

783 acpi_status status;
784 if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
785 return 0;
786 status = acpi_install_gpe_handler(NULL, ec->gpe,
787 ACPI_GPE_EDGE_TRIGGERED,
788 &acpi_ec_gpe_handler, ec);
789 if (ACPI_FAILURE(status))
790 return -ENODEV;
321 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
322 pr_info(PREFIX "GPE storm detected, "
323 "transactions will use polling mode\n");
324 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
325 }
326 pr_debug(PREFIX "transaction end\n");
327end:
328 if (ec->global_lock)

--- 454 unchanged lines hidden (view full) ---

783 acpi_status status;
784 if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
785 return 0;
786 status = acpi_install_gpe_handler(NULL, ec->gpe,
787 ACPI_GPE_EDGE_TRIGGERED,
788 &acpi_ec_gpe_handler, ec);
789 if (ACPI_FAILURE(status))
790 return -ENODEV;
791 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
792 acpi_enable_gpe(NULL, ec->gpe);
791
792 acpi_enable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
793 status = acpi_install_address_space_handler(ec->handle,
794 ACPI_ADR_SPACE_EC,
795 &acpi_ec_space_handler,
796 NULL, ec);
797 if (ACPI_FAILURE(status)) {
798 if (status == AE_NOT_FOUND) {
799 /*
800 * Maybe OS fails in evaluating the _REG object.
801 * The AE_NOT_FOUND error will be ignored and OS
802 * continue to initialize EC.
803 */
804 printk(KERN_ERR "Fail in evaluating the _REG object"
805 " of EC device. Broken bios is suspected.\n");
806 } else {
807 acpi_remove_gpe_handler(NULL, ec->gpe,
808 &acpi_ec_gpe_handler);
793 status = acpi_install_address_space_handler(ec->handle,
794 ACPI_ADR_SPACE_EC,
795 &acpi_ec_space_handler,
796 NULL, ec);
797 if (ACPI_FAILURE(status)) {
798 if (status == AE_NOT_FOUND) {
799 /*
800 * Maybe OS fails in evaluating the _REG object.
801 * The AE_NOT_FOUND error will be ignored and OS
802 * continue to initialize EC.
803 */
804 printk(KERN_ERR "Fail in evaluating the _REG object"
805 " of EC device. Broken bios is suspected.\n");
806 } else {
807 acpi_remove_gpe_handler(NULL, ec->gpe,
808 &acpi_ec_gpe_handler);
809 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
809 return -ENODEV;
810 }
811 }
812
813 set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
814 return 0;
815}
816
817static void ec_remove_handlers(struct acpi_ec *ec)
818{
810 return -ENODEV;
811 }
812 }
813
814 set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
815 return 0;
816}
817
818static void ec_remove_handlers(struct acpi_ec *ec)
819{
820 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
819 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
820 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
821 pr_err(PREFIX "failed to remove space handler\n");
822 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
823 &acpi_ec_gpe_handler)))
824 pr_err(PREFIX "failed to remove gpe handler\n");
825 clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
826}

--- 226 unchanged lines hidden (view full) ---

1053 boot_ec = NULL;
1054 return -ENODEV;
1055}
1056
1057static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1058{
1059 struct acpi_ec *ec = acpi_driver_data(device);
1060 /* Stop using GPE */
821 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
822 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
823 pr_err(PREFIX "failed to remove space handler\n");
824 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
825 &acpi_ec_gpe_handler)))
826 pr_err(PREFIX "failed to remove gpe handler\n");
827 clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
828}

--- 226 unchanged lines hidden (view full) ---

1055 boot_ec = NULL;
1056 return -ENODEV;
1057}
1058
1059static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1060{
1061 struct acpi_ec *ec = acpi_driver_data(device);
1062 /* Stop using GPE */
1061 acpi_disable_gpe(NULL, ec->gpe);
1063 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
1062 return 0;
1063}
1064
1065static int acpi_ec_resume(struct acpi_device *device)
1066{
1067 struct acpi_ec *ec = acpi_driver_data(device);
1068 /* Enable use of GPE back */
1064 return 0;
1065}
1066
1067static int acpi_ec_resume(struct acpi_device *device)
1068{
1069 struct acpi_ec *ec = acpi_driver_data(device);
1070 /* Enable use of GPE back */
1069 acpi_enable_gpe(NULL, ec->gpe);
1071 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
1070 return 0;
1071}
1072
1073static struct acpi_driver acpi_ec_driver = {
1074 .name = "ec",
1075 .class = ACPI_EC_CLASS,
1076 .ids = ec_device_ids,
1077 .ops = {

--- 37 unchanged lines hidden ---
1072 return 0;
1073}
1074
1075static struct acpi_driver acpi_ec_driver = {
1076 .name = "ec",
1077 .class = ACPI_EC_CLASS,
1078 .ids = ec_device_ids,
1079 .ops = {

--- 37 unchanged lines hidden ---