diff options
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe15060dcdc..04e90443eff7 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 | } |
@@ -672,7 +682,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) | |||
672 | return single_open(file, acpi_ec_read_info, PDE(inode)->data); | 682 | return single_open(file, acpi_ec_read_info, PDE(inode)->data); |
673 | } | 683 | } |
674 | 684 | ||
675 | static struct file_operations acpi_ec_info_ops = { | 685 | static const struct file_operations acpi_ec_info_ops = { |
676 | .open = acpi_ec_info_open_fs, | 686 | .open = acpi_ec_info_open_fs, |
677 | .read = seq_read, | 687 | .read = seq_read, |
678 | .llseek = seq_lseek, | 688 | .llseek = seq_lseek, |
@@ -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, |
@@ -1069,13 +1083,10 @@ static struct acpi_driver acpi_ec_driver = { | |||
1069 | }, | 1083 | }, |
1070 | }; | 1084 | }; |
1071 | 1085 | ||
1072 | static int __init acpi_ec_init(void) | 1086 | int __init acpi_ec_init(void) |
1073 | { | 1087 | { |
1074 | int result = 0; | 1088 | int result = 0; |
1075 | 1089 | ||
1076 | if (acpi_disabled) | ||
1077 | return 0; | ||
1078 | |||
1079 | acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); | 1090 | acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); |
1080 | if (!acpi_ec_dir) | 1091 | if (!acpi_ec_dir) |
1081 | return -ENODEV; | 1092 | return -ENODEV; |
@@ -1090,8 +1101,6 @@ static int __init acpi_ec_init(void) | |||
1090 | return result; | 1101 | return result; |
1091 | } | 1102 | } |
1092 | 1103 | ||
1093 | subsys_initcall(acpi_ec_init); | ||
1094 | |||
1095 | /* EC driver currently not unloadable */ | 1104 | /* EC driver currently not unloadable */ |
1096 | #if 0 | 1105 | #if 0 |
1097 | static void __exit acpi_ec_exit(void) | 1106 | static void __exit acpi_ec_exit(void) |