From a5f820feb54a59fcdaf4a67a6381ea1ddb36cc6e Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:48 -0600 Subject: ACPI: call acpi_ec_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_ec_init() directly. Previously, both were subsys_initcalls. acpi_ec_init() must happen after acpi_init(), and it's better to call it explicitly rather than rely on link ordering. Signed-off-by: Bjorn Helgaas CC: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/acpi/ec.c') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe1506..bf88f18 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1069,13 +1069,10 @@ static struct acpi_driver acpi_ec_driver = { }, }; -static int __init acpi_ec_init(void) +int __init acpi_ec_init(void) { int result = 0; - if (acpi_disabled) - return 0; - acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); if (!acpi_ec_dir) return -ENODEV; @@ -1090,8 +1087,6 @@ static int __init acpi_ec_init(void) return result; } -subsys_initcall(acpi_ec_init); - /* EC driver currently not unloadable */ #if 0 static void __exit acpi_ec_exit(void) -- cgit v1.1 From 34ff4dbccccce54c83b1234d39b7ad9e548a75dd Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Wed, 1 Apr 2009 00:25:10 -0400 Subject: ACPI: EC: Separate delays for MSI hardware MSI notebooks require very strict delays, while all others are happy with msleep(). References: http://bugzilla.kernel.org/show_bug.cgi?id=9998 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'drivers/acpi/ec.c') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe1506..ac9dd3b 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -67,7 +67,7 @@ enum ec_command { #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ -#define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ +#define ACPI_EC_CDELAY 10 /* Wait 10us before polling EC */ #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts per one transaction */ @@ -236,13 +236,23 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) return 0; } +static void ec_delay(void) +{ + /* EC in MSI notebooks don't tolerate delays other than 550 usec */ + if (EC_FLAGS_MSI) + udelay(ACPI_EC_DELAY); + else + /* Use shortest sleep available */ + msleep(1); +} + static int ec_poll(struct acpi_ec *ec) { unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); - udelay(ACPI_EC_UDELAY); + udelay(ACPI_EC_CDELAY); while (time_before(jiffies, delay)) { gpe_transaction(ec, acpi_ec_read_status(ec)); - udelay(ACPI_EC_UDELAY); + ec_delay(); if (ec_transaction_done(ec)) return 0; } -- cgit v1.1 From a5032bfdd9c80e0231a6324661e123818eb46ecd Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Wed, 1 Apr 2009 01:33:15 -0400 Subject: ACPI: EC: Always parse EC device If ECDT info is not valid, we have last chance to configure EC driver properly at this point, don't miss it. http://bugzilla.kernel.org/show_bug.cgi?id=12461 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/acpi/ec.c') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe1506..5a2d537 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -755,6 +755,10 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) unsigned long long tmp = 0; struct acpi_ec *ec = context; + + /* clear addr values, ec_parse_io_ports depend on it */ + ec->command_addr = ec->data_addr = 0; + status = acpi_walk_resources(handle, METHOD_NAME__CRS, ec_parse_io_ports, ec); if (ACPI_FAILURE(status)) @@ -804,11 +808,11 @@ static int acpi_ec_add(struct acpi_device *device) ec = make_acpi_ec(); if (!ec) return -ENOMEM; - if (ec_parse_device(device->handle, 0, ec, NULL) != - AE_CTRL_TERMINATE) { + } + if (ec_parse_device(device->handle, 0, ec, NULL) != + AE_CTRL_TERMINATE) { kfree(ec); return -EINVAL; - } } ec->handle = device->handle; @@ -986,12 +990,12 @@ int __init acpi_ec_ecdt_probe(void) boot_ec->handle = ACPI_ROOT_OBJECT; acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); /* Don't trust ECDT, which comes from ASUSTek */ - if (!dmi_name_in_vendors("ASUS")) + if (!dmi_name_in_vendors("ASUS") && EC_FLAGS_MSI == 0) goto install; saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); if (!saved_ec) return -ENOMEM; - memcpy(saved_ec, boot_ec, sizeof(*saved_ec)); + memcpy(saved_ec, boot_ec, sizeof(struct acpi_ec)); /* fall through */ } /* This workaround is needed only on some broken machines, -- cgit v1.1 From 070d8eb1f6b789206486ea6a4a1bb7745d86d314 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 12 Jan 2009 00:07:55 +0100 Subject: ACPI: constify VFTs (1/2) Signed-off-by: Jan Engelhardt Signed-off-by: Len Brown --- drivers/acpi/ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi/ec.c') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe1506..1ec61e5 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -672,7 +672,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_ec_read_info, PDE(inode)->data); } -static struct file_operations acpi_ec_info_ops = { +static const struct file_operations acpi_ec_info_ops = { .open = acpi_ec_info_open_fs, .read = seq_read, .llseek = seq_lseek, -- cgit v1.1 From 5aa63f038f042fd1acd6e720a95df72857db0bc7 Mon Sep 17 00:00:00 2001 From: "Almer S. Tigelaar" Date: Sun, 12 Apr 2009 11:26:29 +0000 Subject: ACPI: EC: Fix ACPI EC resume non-query interrupt message When resuming from standby (on a laptop) I see the following message in my kernel.log: "ACPI: EC: non-query interrupt received, switching to interrupt mode" This apparently prevented sony-laptop to properly restore the brightness level on resume. The cause: In drivers/acpi/ec.c the acpi_ec_suspend function clears the GPE mode bit, but this is not restored in acpi_ec_resume (the function below it). The patch below fixes this by properly restoring the GPE_MODE bit. Tested and confirmed to work. Signed-off-by: Almer S. Tigelaar Signed-off-by: Mattia Dongili Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/acpi/ec.c') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 04e9044..391f331 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1065,6 +1065,7 @@ static int acpi_ec_resume(struct acpi_device *device) struct acpi_ec *ec = acpi_driver_data(device); /* Enable use of GPE back */ clear_bit(EC_FLAGS_NO_GPE, &ec->flags); + set_bit(EC_FLAGS_GPE_MODE, &ec->flags); acpi_enable_gpe(NULL, ec->gpe); return 0; } -- cgit v1.1