diff options
| -rw-r--r-- | drivers/acpi/ec.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index bf88f1803801..03107bce03ed 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
| @@ -67,7 +67,7 @@ enum ec_command { | |||
| 67 | 67 | ||
| 68 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ | 68 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ |
| 69 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 69 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
| 70 | #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ | 70 | #define ACPI_EC_CDELAY 10 /* Wait 10us before polling EC */ |
| 71 | 71 | ||
| 72 | #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts | 72 | #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts |
| 73 | per one transaction */ | 73 | per one transaction */ |
| @@ -236,13 +236,23 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) | |||
| 236 | return 0; | 236 | return 0; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | static void ec_delay(void) | ||
| 240 | { | ||
| 241 | /* EC in MSI notebooks don't tolerate delays other than 550 usec */ | ||
| 242 | if (EC_FLAGS_MSI) | ||
| 243 | udelay(ACPI_EC_DELAY); | ||
| 244 | else | ||
| 245 | /* Use shortest sleep available */ | ||
| 246 | msleep(1); | ||
| 247 | } | ||
| 248 | |||
| 239 | static int ec_poll(struct acpi_ec *ec) | 249 | static int ec_poll(struct acpi_ec *ec) |
| 240 | { | 250 | { |
| 241 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | 251 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
| 242 | udelay(ACPI_EC_UDELAY); | 252 | udelay(ACPI_EC_CDELAY); |
| 243 | while (time_before(jiffies, delay)) { | 253 | while (time_before(jiffies, delay)) { |
| 244 | gpe_transaction(ec, acpi_ec_read_status(ec)); | 254 | gpe_transaction(ec, acpi_ec_read_status(ec)); |
| 245 | udelay(ACPI_EC_UDELAY); | 255 | ec_delay(); |
| 246 | if (ec_transaction_done(ec)) | 256 | if (ec_transaction_done(ec)) |
| 247 | return 0; | 257 | return 0; |
| 248 | } | 258 | } |
| @@ -755,6 +765,10 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
| 755 | unsigned long long tmp = 0; | 765 | unsigned long long tmp = 0; |
| 756 | 766 | ||
| 757 | struct acpi_ec *ec = context; | 767 | struct acpi_ec *ec = context; |
| 768 | |||
| 769 | /* clear addr values, ec_parse_io_ports depend on it */ | ||
| 770 | ec->command_addr = ec->data_addr = 0; | ||
| 771 | |||
| 758 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 772 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
| 759 | ec_parse_io_ports, ec); | 773 | ec_parse_io_ports, ec); |
| 760 | if (ACPI_FAILURE(status)) | 774 | if (ACPI_FAILURE(status)) |
| @@ -804,11 +818,11 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 804 | ec = make_acpi_ec(); | 818 | ec = make_acpi_ec(); |
| 805 | if (!ec) | 819 | if (!ec) |
| 806 | return -ENOMEM; | 820 | return -ENOMEM; |
| 807 | if (ec_parse_device(device->handle, 0, ec, NULL) != | 821 | } |
| 808 | AE_CTRL_TERMINATE) { | 822 | if (ec_parse_device(device->handle, 0, ec, NULL) != |
| 823 | AE_CTRL_TERMINATE) { | ||
| 809 | kfree(ec); | 824 | kfree(ec); |
| 810 | return -EINVAL; | 825 | return -EINVAL; |
| 811 | } | ||
| 812 | } | 826 | } |
| 813 | 827 | ||
| 814 | ec->handle = device->handle; | 828 | ec->handle = device->handle; |
| @@ -986,12 +1000,12 @@ int __init acpi_ec_ecdt_probe(void) | |||
| 986 | boot_ec->handle = ACPI_ROOT_OBJECT; | 1000 | boot_ec->handle = ACPI_ROOT_OBJECT; |
| 987 | acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); | 1001 | acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); |
| 988 | /* Don't trust ECDT, which comes from ASUSTek */ | 1002 | /* Don't trust ECDT, which comes from ASUSTek */ |
| 989 | if (!dmi_name_in_vendors("ASUS")) | 1003 | if (!dmi_name_in_vendors("ASUS") && EC_FLAGS_MSI == 0) |
| 990 | goto install; | 1004 | goto install; |
| 991 | saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 1005 | saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
| 992 | if (!saved_ec) | 1006 | if (!saved_ec) |
| 993 | return -ENOMEM; | 1007 | return -ENOMEM; |
| 994 | memcpy(saved_ec, boot_ec, sizeof(*saved_ec)); | 1008 | memcpy(saved_ec, boot_ec, sizeof(struct acpi_ec)); |
| 995 | /* fall through */ | 1009 | /* fall through */ |
| 996 | } | 1010 | } |
| 997 | /* This workaround is needed only on some broken machines, | 1011 | /* This workaround is needed only on some broken machines, |
