diff options
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index a06d98374705..d5309fd49458 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | /* Uncomment next line to get verbose printout */ | 29 | /* Uncomment next line to get verbose printout */ |
30 | /* #define DEBUG */ | 30 | /* #define DEBUG */ |
31 | #define pr_fmt(fmt) "ACPI : EC: " fmt | ||
31 | 32 | ||
32 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 34 | #include <linux/module.h> |
@@ -49,9 +50,6 @@ | |||
49 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" | 50 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" |
50 | #define ACPI_EC_FILE_INFO "info" | 51 | #define ACPI_EC_FILE_INFO "info" |
51 | 52 | ||
52 | #undef PREFIX | ||
53 | #define PREFIX "ACPI: EC: " | ||
54 | |||
55 | /* EC status register */ | 53 | /* EC status register */ |
56 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 54 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
57 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 55 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
@@ -131,26 +129,26 @@ static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ | |||
131 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | 129 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) |
132 | { | 130 | { |
133 | u8 x = inb(ec->command_addr); | 131 | u8 x = inb(ec->command_addr); |
134 | pr_debug(PREFIX "---> status = 0x%2.2x\n", x); | 132 | pr_debug("---> status = 0x%2.2x\n", x); |
135 | return x; | 133 | return x; |
136 | } | 134 | } |
137 | 135 | ||
138 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | 136 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) |
139 | { | 137 | { |
140 | u8 x = inb(ec->data_addr); | 138 | u8 x = inb(ec->data_addr); |
141 | pr_debug(PREFIX "---> data = 0x%2.2x\n", x); | 139 | pr_debug("---> data = 0x%2.2x\n", x); |
142 | return x; | 140 | return x; |
143 | } | 141 | } |
144 | 142 | ||
145 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) | 143 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) |
146 | { | 144 | { |
147 | pr_debug(PREFIX "<--- command = 0x%2.2x\n", command); | 145 | pr_debug("<--- command = 0x%2.2x\n", command); |
148 | outb(command, ec->command_addr); | 146 | outb(command, ec->command_addr); |
149 | } | 147 | } |
150 | 148 | ||
151 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | 149 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) |
152 | { | 150 | { |
153 | pr_debug(PREFIX "<--- data = 0x%2.2x\n", data); | 151 | pr_debug("<--- data = 0x%2.2x\n", data); |
154 | outb(data, ec->data_addr); | 152 | outb(data, ec->data_addr); |
155 | } | 153 | } |
156 | 154 | ||
@@ -241,7 +239,7 @@ static int ec_poll(struct acpi_ec *ec) | |||
241 | } | 239 | } |
242 | advance_transaction(ec, acpi_ec_read_status(ec)); | 240 | advance_transaction(ec, acpi_ec_read_status(ec)); |
243 | } while (time_before(jiffies, delay)); | 241 | } while (time_before(jiffies, delay)); |
244 | pr_debug(PREFIX "controller reset, restart transaction\n"); | 242 | pr_debug("controller reset, restart transaction\n"); |
245 | spin_lock_irqsave(&ec->lock, flags); | 243 | spin_lock_irqsave(&ec->lock, flags); |
246 | start_transaction(ec); | 244 | start_transaction(ec); |
247 | spin_unlock_irqrestore(&ec->lock, flags); | 245 | spin_unlock_irqrestore(&ec->lock, flags); |
@@ -309,12 +307,12 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
309 | } | 307 | } |
310 | } | 308 | } |
311 | if (ec_wait_ibf0(ec)) { | 309 | if (ec_wait_ibf0(ec)) { |
312 | pr_err(PREFIX "input buffer is not empty, " | 310 | pr_err("input buffer is not empty, " |
313 | "aborting transaction\n"); | 311 | "aborting transaction\n"); |
314 | status = -ETIME; | 312 | status = -ETIME; |
315 | goto end; | 313 | goto end; |
316 | } | 314 | } |
317 | pr_debug(PREFIX "transaction start (cmd=0x%02x, addr=0x%02x)\n", | 315 | pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", |
318 | t->command, t->wdata ? t->wdata[0] : 0); | 316 | t->command, t->wdata ? t->wdata[0] : 0); |
319 | /* disable GPE during transaction if storm is detected */ | 317 | /* disable GPE during transaction if storm is detected */ |
320 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { | 318 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
@@ -331,12 +329,12 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
331 | /* It is safe to enable the GPE outside of the transaction. */ | 329 | /* It is safe to enable the GPE outside of the transaction. */ |
332 | acpi_enable_gpe(NULL, ec->gpe); | 330 | acpi_enable_gpe(NULL, ec->gpe); |
333 | } else if (t->irq_count > ec_storm_threshold) { | 331 | } else if (t->irq_count > ec_storm_threshold) { |
334 | pr_info(PREFIX "GPE storm detected(%d GPEs), " | 332 | pr_info("GPE storm detected(%d GPEs), " |
335 | "transactions will use polling mode\n", | 333 | "transactions will use polling mode\n", |
336 | t->irq_count); | 334 | t->irq_count); |
337 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); | 335 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); |
338 | } | 336 | } |
339 | pr_debug(PREFIX "transaction end\n"); | 337 | pr_debug("transaction end\n"); |
340 | end: | 338 | end: |
341 | if (ec->global_lock) | 339 | if (ec->global_lock) |
342 | acpi_release_global_lock(glk); | 340 | acpi_release_global_lock(glk); |
@@ -570,12 +568,12 @@ static void acpi_ec_run(void *cxt) | |||
570 | struct acpi_ec_query_handler *handler = cxt; | 568 | struct acpi_ec_query_handler *handler = cxt; |
571 | if (!handler) | 569 | if (!handler) |
572 | return; | 570 | return; |
573 | pr_debug(PREFIX "start query execution\n"); | 571 | pr_debug("start query execution\n"); |
574 | if (handler->func) | 572 | if (handler->func) |
575 | handler->func(handler->data); | 573 | handler->func(handler->data); |
576 | else if (handler->handle) | 574 | else if (handler->handle) |
577 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); | 575 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); |
578 | pr_debug(PREFIX "stop query execution\n"); | 576 | pr_debug("stop query execution\n"); |
579 | kfree(handler); | 577 | kfree(handler); |
580 | } | 578 | } |
581 | 579 | ||
@@ -593,7 +591,8 @@ static int acpi_ec_sync_query(struct acpi_ec *ec) | |||
593 | if (!copy) | 591 | if (!copy) |
594 | return -ENOMEM; | 592 | return -ENOMEM; |
595 | memcpy(copy, handler, sizeof(*copy)); | 593 | memcpy(copy, handler, sizeof(*copy)); |
596 | pr_debug(PREFIX "push query execution (0x%2x) on queue\n", value); | 594 | pr_debug("push query execution (0x%2x) on queue\n", |
595 | value); | ||
597 | return acpi_os_execute((copy->func) ? | 596 | return acpi_os_execute((copy->func) ? |
598 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, | 597 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, |
599 | acpi_ec_run, copy); | 598 | acpi_ec_run, copy); |
@@ -616,7 +615,7 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) | |||
616 | { | 615 | { |
617 | if (state & ACPI_EC_FLAG_SCI) { | 616 | if (state & ACPI_EC_FLAG_SCI) { |
618 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { | 617 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { |
619 | pr_debug(PREFIX "push gpe query to the queue\n"); | 618 | pr_debug("push gpe query to the queue\n"); |
620 | return acpi_os_execute(OSL_NOTIFY_HANDLER, | 619 | return acpi_os_execute(OSL_NOTIFY_HANDLER, |
621 | acpi_ec_gpe_query, ec); | 620 | acpi_ec_gpe_query, ec); |
622 | } | 621 | } |
@@ -630,7 +629,7 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, | |||
630 | struct acpi_ec *ec = data; | 629 | struct acpi_ec *ec = data; |
631 | u8 status = acpi_ec_read_status(ec); | 630 | u8 status = acpi_ec_read_status(ec); |
632 | 631 | ||
633 | pr_debug(PREFIX "~~~> interrupt, status:0x%02x\n", status); | 632 | pr_debug("~~~> interrupt, status:0x%02x\n", status); |
634 | 633 | ||
635 | advance_transaction(ec, status); | 634 | advance_transaction(ec, status); |
636 | if (ec_transaction_done(ec) && | 635 | if (ec_transaction_done(ec) && |
@@ -776,7 +775,7 @@ static int ec_install_handlers(struct acpi_ec *ec) | |||
776 | * The AE_NOT_FOUND error will be ignored and OS | 775 | * The AE_NOT_FOUND error will be ignored and OS |
777 | * continue to initialize EC. | 776 | * continue to initialize EC. |
778 | */ | 777 | */ |
779 | printk(KERN_ERR "Fail in evaluating the _REG object" | 778 | pr_err("Fail in evaluating the _REG object" |
780 | " of EC device. Broken bios is suspected.\n"); | 779 | " of EC device. Broken bios is suspected.\n"); |
781 | } else { | 780 | } else { |
782 | acpi_remove_gpe_handler(NULL, ec->gpe, | 781 | acpi_remove_gpe_handler(NULL, ec->gpe, |
@@ -795,10 +794,10 @@ static void ec_remove_handlers(struct acpi_ec *ec) | |||
795 | acpi_disable_gpe(NULL, ec->gpe); | 794 | acpi_disable_gpe(NULL, ec->gpe); |
796 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, | 795 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, |
797 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) | 796 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) |
798 | pr_err(PREFIX "failed to remove space handler\n"); | 797 | pr_err("failed to remove space handler\n"); |
799 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, | 798 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, |
800 | &acpi_ec_gpe_handler))) | 799 | &acpi_ec_gpe_handler))) |
801 | pr_err(PREFIX "failed to remove gpe handler\n"); | 800 | pr_err("failed to remove gpe handler\n"); |
802 | clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); | 801 | clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); |
803 | } | 802 | } |
804 | 803 | ||
@@ -840,7 +839,7 @@ static int acpi_ec_add(struct acpi_device *device) | |||
840 | ret = !!request_region(ec->command_addr, 1, "EC cmd"); | 839 | ret = !!request_region(ec->command_addr, 1, "EC cmd"); |
841 | WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); | 840 | WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); |
842 | 841 | ||
843 | pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | 842 | pr_info("GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", |
844 | ec->gpe, ec->command_addr, ec->data_addr); | 843 | ec->gpe, ec->command_addr, ec->data_addr); |
845 | 844 | ||
846 | ret = ec_install_handlers(ec); | 845 | ret = ec_install_handlers(ec); |
@@ -931,7 +930,7 @@ static int ec_validate_ecdt(const struct dmi_system_id *id) | |||
931 | /* MSI EC needs special treatment, enable it */ | 930 | /* MSI EC needs special treatment, enable it */ |
932 | static int ec_flag_msi(const struct dmi_system_id *id) | 931 | static int ec_flag_msi(const struct dmi_system_id *id) |
933 | { | 932 | { |
934 | printk(KERN_DEBUG PREFIX "Detected MSI hardware, enabling workarounds.\n"); | 933 | pr_debug("Detected MSI hardware, enabling workarounds.\n"); |
935 | EC_FLAGS_MSI = 1; | 934 | EC_FLAGS_MSI = 1; |
936 | EC_FLAGS_VALIDATE_ECDT = 1; | 935 | EC_FLAGS_VALIDATE_ECDT = 1; |
937 | return 0; | 936 | return 0; |
@@ -1010,7 +1009,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
1010 | status = acpi_get_table(ACPI_SIG_ECDT, 1, | 1009 | status = acpi_get_table(ACPI_SIG_ECDT, 1, |
1011 | (struct acpi_table_header **)&ecdt_ptr); | 1010 | (struct acpi_table_header **)&ecdt_ptr); |
1012 | if (ACPI_SUCCESS(status)) { | 1011 | if (ACPI_SUCCESS(status)) { |
1013 | pr_info(PREFIX "EC description table is found, configuring boot EC\n"); | 1012 | pr_info("EC description table is found, configuring boot EC\n"); |
1014 | boot_ec->command_addr = ecdt_ptr->control.address; | 1013 | boot_ec->command_addr = ecdt_ptr->control.address; |
1015 | boot_ec->data_addr = ecdt_ptr->data.address; | 1014 | boot_ec->data_addr = ecdt_ptr->data.address; |
1016 | boot_ec->gpe = ecdt_ptr->gpe; | 1015 | boot_ec->gpe = ecdt_ptr->gpe; |
@@ -1030,7 +1029,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
1030 | 1029 | ||
1031 | /* This workaround is needed only on some broken machines, | 1030 | /* This workaround is needed only on some broken machines, |
1032 | * which require early EC, but fail to provide ECDT */ | 1031 | * which require early EC, but fail to provide ECDT */ |
1033 | printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n"); | 1032 | pr_debug("Look up EC in DSDT\n"); |
1034 | status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, | 1033 | status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, |
1035 | boot_ec, NULL); | 1034 | boot_ec, NULL); |
1036 | /* Check that acpi_get_devices actually find something */ | 1035 | /* Check that acpi_get_devices actually find something */ |
@@ -1042,7 +1041,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
1042 | saved_ec->data_addr != boot_ec->data_addr || | 1041 | saved_ec->data_addr != boot_ec->data_addr || |
1043 | saved_ec->gpe != boot_ec->gpe || | 1042 | saved_ec->gpe != boot_ec->gpe || |
1044 | saved_ec->handle != boot_ec->handle) | 1043 | saved_ec->handle != boot_ec->handle) |
1045 | pr_info(PREFIX "ASUSTek keeps feeding us with broken " | 1044 | pr_info("ASUSTek keeps feeding us with broken " |
1046 | "ECDT tables, which are very hard to workaround. " | 1045 | "ECDT tables, which are very hard to workaround. " |
1047 | "Trying to use DSDT EC info instead. Please send " | 1046 | "Trying to use DSDT EC info instead. Please send " |
1048 | "output of acpidump to linux-acpi@vger.kernel.org\n"); | 1047 | "output of acpidump to linux-acpi@vger.kernel.org\n"); |