diff options
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 108 |
1 files changed, 74 insertions, 34 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index a8dd2f763382..07426c8c255b 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -137,6 +137,48 @@ static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ | |||
137 | static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ | 137 | static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ |
138 | 138 | ||
139 | /* -------------------------------------------------------------------------- | 139 | /* -------------------------------------------------------------------------- |
140 | * Logging/Debugging | ||
141 | * -------------------------------------------------------------------------- */ | ||
142 | |||
143 | /* | ||
144 | * Splitters used by the developers to track the boundary of the EC | ||
145 | * handling processes. | ||
146 | */ | ||
147 | #ifdef DEBUG | ||
148 | #define EC_DBG_SEP " " | ||
149 | #define EC_DBG_DRV "+++++" | ||
150 | #define EC_DBG_STM "=====" | ||
151 | #define EC_DBG_REQ "*****" | ||
152 | #define EC_DBG_EVT "#####" | ||
153 | #else | ||
154 | #define EC_DBG_SEP "" | ||
155 | #define EC_DBG_DRV | ||
156 | #define EC_DBG_STM | ||
157 | #define EC_DBG_REQ | ||
158 | #define EC_DBG_EVT | ||
159 | #endif | ||
160 | |||
161 | #define ec_log_raw(fmt, ...) \ | ||
162 | pr_info(fmt "\n", ##__VA_ARGS__) | ||
163 | #define ec_dbg_raw(fmt, ...) \ | ||
164 | pr_debug(fmt "\n", ##__VA_ARGS__) | ||
165 | #define ec_log(filter, fmt, ...) \ | ||
166 | ec_log_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__) | ||
167 | #define ec_dbg(filter, fmt, ...) \ | ||
168 | ec_dbg_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__) | ||
169 | |||
170 | #define ec_log_drv(fmt, ...) \ | ||
171 | ec_log(EC_DBG_DRV, fmt, ##__VA_ARGS__) | ||
172 | #define ec_dbg_drv(fmt, ...) \ | ||
173 | ec_dbg(EC_DBG_DRV, fmt, ##__VA_ARGS__) | ||
174 | #define ec_dbg_stm(fmt, ...) \ | ||
175 | ec_dbg(EC_DBG_STM, fmt, ##__VA_ARGS__) | ||
176 | #define ec_dbg_req(fmt, ...) \ | ||
177 | ec_dbg(EC_DBG_REQ, fmt, ##__VA_ARGS__) | ||
178 | #define ec_dbg_evt(fmt, ...) \ | ||
179 | ec_dbg(EC_DBG_EVT, fmt, ##__VA_ARGS__) | ||
180 | |||
181 | /* -------------------------------------------------------------------------- | ||
140 | * Device Flags | 182 | * Device Flags |
141 | * -------------------------------------------------------------------------- */ | 183 | * -------------------------------------------------------------------------- */ |
142 | 184 | ||
@@ -159,14 +201,14 @@ static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | |||
159 | { | 201 | { |
160 | u8 x = inb(ec->command_addr); | 202 | u8 x = inb(ec->command_addr); |
161 | 203 | ||
162 | pr_debug("EC_SC(R) = 0x%2.2x " | 204 | ec_dbg_raw("EC_SC(R) = 0x%2.2x " |
163 | "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", | 205 | "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d", |
164 | x, | 206 | x, |
165 | !!(x & ACPI_EC_FLAG_SCI), | 207 | !!(x & ACPI_EC_FLAG_SCI), |
166 | !!(x & ACPI_EC_FLAG_BURST), | 208 | !!(x & ACPI_EC_FLAG_BURST), |
167 | !!(x & ACPI_EC_FLAG_CMD), | 209 | !!(x & ACPI_EC_FLAG_CMD), |
168 | !!(x & ACPI_EC_FLAG_IBF), | 210 | !!(x & ACPI_EC_FLAG_IBF), |
169 | !!(x & ACPI_EC_FLAG_OBF)); | 211 | !!(x & ACPI_EC_FLAG_OBF)); |
170 | return x; | 212 | return x; |
171 | } | 213 | } |
172 | 214 | ||
@@ -175,20 +217,20 @@ static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | |||
175 | u8 x = inb(ec->data_addr); | 217 | u8 x = inb(ec->data_addr); |
176 | 218 | ||
177 | ec->curr->timestamp = jiffies; | 219 | ec->curr->timestamp = jiffies; |
178 | pr_debug("EC_DATA(R) = 0x%2.2x\n", x); | 220 | ec_dbg_raw("EC_DATA(R) = 0x%2.2x", x); |
179 | return x; | 221 | return x; |
180 | } | 222 | } |
181 | 223 | ||
182 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) | 224 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) |
183 | { | 225 | { |
184 | pr_debug("EC_SC(W) = 0x%2.2x\n", command); | 226 | ec_dbg_raw("EC_SC(W) = 0x%2.2x", command); |
185 | outb(command, ec->command_addr); | 227 | outb(command, ec->command_addr); |
186 | ec->curr->timestamp = jiffies; | 228 | ec->curr->timestamp = jiffies; |
187 | } | 229 | } |
188 | 230 | ||
189 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | 231 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) |
190 | { | 232 | { |
191 | pr_debug("EC_DATA(W) = 0x%2.2x\n", data); | 233 | ec_dbg_raw("EC_DATA(W) = 0x%2.2x", data); |
192 | outb(data, ec->data_addr); | 234 | outb(data, ec->data_addr); |
193 | ec->curr->timestamp = jiffies; | 235 | ec->curr->timestamp = jiffies; |
194 | } | 236 | } |
@@ -240,7 +282,7 @@ static inline void acpi_ec_enable_gpe(struct acpi_ec *ec, bool open) | |||
240 | * software need to manually trigger a pseudo GPE event on | 282 | * software need to manually trigger a pseudo GPE event on |
241 | * EN=1 writes. | 283 | * EN=1 writes. |
242 | */ | 284 | */ |
243 | pr_debug("***** Polling quirk *****\n"); | 285 | ec_dbg_raw("Polling quirk"); |
244 | advance_transaction(ec); | 286 | advance_transaction(ec); |
245 | } | 287 | } |
246 | } | 288 | } |
@@ -299,7 +341,7 @@ static void acpi_ec_set_storm(struct acpi_ec *ec, u8 flag) | |||
299 | { | 341 | { |
300 | if (!test_bit(flag, &ec->flags)) { | 342 | if (!test_bit(flag, &ec->flags)) { |
301 | acpi_ec_disable_gpe(ec, false); | 343 | acpi_ec_disable_gpe(ec, false); |
302 | pr_debug("+++++ Polling enabled +++++\n"); | 344 | ec_dbg_drv("Polling enabled"); |
303 | set_bit(flag, &ec->flags); | 345 | set_bit(flag, &ec->flags); |
304 | } | 346 | } |
305 | } | 347 | } |
@@ -309,7 +351,7 @@ static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag) | |||
309 | if (test_bit(flag, &ec->flags)) { | 351 | if (test_bit(flag, &ec->flags)) { |
310 | clear_bit(flag, &ec->flags); | 352 | clear_bit(flag, &ec->flags); |
311 | acpi_ec_enable_gpe(ec, false); | 353 | acpi_ec_enable_gpe(ec, false); |
312 | pr_debug("+++++ Polling disabled +++++\n"); | 354 | ec_dbg_drv("Polling disabled"); |
313 | } | 355 | } |
314 | } | 356 | } |
315 | 357 | ||
@@ -335,7 +377,7 @@ static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec) | |||
335 | static void acpi_ec_submit_query(struct acpi_ec *ec) | 377 | static void acpi_ec_submit_query(struct acpi_ec *ec) |
336 | { | 378 | { |
337 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { | 379 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { |
338 | pr_debug("***** Event started *****\n"); | 380 | ec_dbg_req("Event started"); |
339 | schedule_work(&ec->work); | 381 | schedule_work(&ec->work); |
340 | } | 382 | } |
341 | } | 383 | } |
@@ -344,7 +386,7 @@ static void acpi_ec_complete_query(struct acpi_ec *ec) | |||
344 | { | 386 | { |
345 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { | 387 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { |
346 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 388 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
347 | pr_debug("***** Event stopped *****\n"); | 389 | ec_dbg_req("Event stopped"); |
348 | } | 390 | } |
349 | } | 391 | } |
350 | 392 | ||
@@ -366,8 +408,8 @@ static void advance_transaction(struct acpi_ec *ec) | |||
366 | u8 status; | 408 | u8 status; |
367 | bool wakeup = false; | 409 | bool wakeup = false; |
368 | 410 | ||
369 | pr_debug("===== %s (%d) =====\n", | 411 | ec_dbg_stm("%s (%d)", in_interrupt() ? "IRQ" : "TASK", |
370 | in_interrupt() ? "IRQ" : "TASK", smp_processor_id()); | 412 | smp_processor_id()); |
371 | /* | 413 | /* |
372 | * By always clearing STS before handling all indications, we can | 414 | * By always clearing STS before handling all indications, we can |
373 | * ensure a hardware STS 0->1 change after this clearing can always | 415 | * ensure a hardware STS 0->1 change after this clearing can always |
@@ -390,8 +432,8 @@ static void advance_transaction(struct acpi_ec *ec) | |||
390 | if (t->rlen == t->ri) { | 432 | if (t->rlen == t->ri) { |
391 | t->flags |= ACPI_EC_COMMAND_COMPLETE; | 433 | t->flags |= ACPI_EC_COMMAND_COMPLETE; |
392 | if (t->command == ACPI_EC_COMMAND_QUERY) | 434 | if (t->command == ACPI_EC_COMMAND_QUERY) |
393 | pr_debug("***** Command(%s) hardware completion *****\n", | 435 | ec_dbg_req("Command(%s) hardware completion", |
394 | acpi_ec_cmd_string(t->command)); | 436 | acpi_ec_cmd_string(t->command)); |
395 | wakeup = true; | 437 | wakeup = true; |
396 | } | 438 | } |
397 | } else | 439 | } else |
@@ -410,8 +452,8 @@ static void advance_transaction(struct acpi_ec *ec) | |||
410 | acpi_ec_complete_query(ec); | 452 | acpi_ec_complete_query(ec); |
411 | t->rdata[t->ri++] = 0x00; | 453 | t->rdata[t->ri++] = 0x00; |
412 | t->flags |= ACPI_EC_COMMAND_COMPLETE; | 454 | t->flags |= ACPI_EC_COMMAND_COMPLETE; |
413 | pr_debug("***** Command(%s) software completion *****\n", | 455 | ec_dbg_req("Command(%s) software completion", |
414 | acpi_ec_cmd_string(t->command)); | 456 | acpi_ec_cmd_string(t->command)); |
415 | wakeup = true; | 457 | wakeup = true; |
416 | } else if ((status & ACPI_EC_FLAG_IBF) == 0) { | 458 | } else if ((status & ACPI_EC_FLAG_IBF) == 0) { |
417 | acpi_ec_write_cmd(ec, t->command); | 459 | acpi_ec_write_cmd(ec, t->command); |
@@ -504,16 +546,14 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
504 | } | 546 | } |
505 | /* following two actions should be kept atomic */ | 547 | /* following two actions should be kept atomic */ |
506 | ec->curr = t; | 548 | ec->curr = t; |
507 | pr_debug("***** Command(%s) started *****\n", | 549 | ec_dbg_req("Command(%s) started", acpi_ec_cmd_string(t->command)); |
508 | acpi_ec_cmd_string(t->command)); | ||
509 | start_transaction(ec); | 550 | start_transaction(ec); |
510 | spin_unlock_irqrestore(&ec->lock, tmp); | 551 | spin_unlock_irqrestore(&ec->lock, tmp); |
511 | ret = ec_poll(ec); | 552 | ret = ec_poll(ec); |
512 | spin_lock_irqsave(&ec->lock, tmp); | 553 | spin_lock_irqsave(&ec->lock, tmp); |
513 | if (t->irq_count == ec_storm_threshold) | 554 | if (t->irq_count == ec_storm_threshold) |
514 | acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); | 555 | acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); |
515 | pr_debug("***** Command(%s) stopped *****\n", | 556 | ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command)); |
516 | acpi_ec_cmd_string(t->command)); | ||
517 | ec->curr = NULL; | 557 | ec->curr = NULL; |
518 | /* Disable GPE for command processing (IBF=0/OBF=1) */ | 558 | /* Disable GPE for command processing (IBF=0/OBF=1) */ |
519 | acpi_ec_complete_request(ec); | 559 | acpi_ec_complete_request(ec); |
@@ -676,11 +716,11 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming) | |||
676 | 716 | ||
677 | spin_lock_irqsave(&ec->lock, flags); | 717 | spin_lock_irqsave(&ec->lock, flags); |
678 | if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { | 718 | if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { |
679 | pr_debug("+++++ Starting EC +++++\n"); | 719 | ec_dbg_drv("Starting EC"); |
680 | /* Enable GPE for event processing (SCI_EVT=1) */ | 720 | /* Enable GPE for event processing (SCI_EVT=1) */ |
681 | if (!resuming) | 721 | if (!resuming) |
682 | acpi_ec_submit_request(ec); | 722 | acpi_ec_submit_request(ec); |
683 | pr_debug("EC started\n"); | 723 | ec_log_drv("EC started"); |
684 | } | 724 | } |
685 | spin_unlock_irqrestore(&ec->lock, flags); | 725 | spin_unlock_irqrestore(&ec->lock, flags); |
686 | } | 726 | } |
@@ -702,7 +742,7 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending) | |||
702 | 742 | ||
703 | spin_lock_irqsave(&ec->lock, flags); | 743 | spin_lock_irqsave(&ec->lock, flags); |
704 | if (acpi_ec_started(ec)) { | 744 | if (acpi_ec_started(ec)) { |
705 | pr_debug("+++++ Stopping EC +++++\n"); | 745 | ec_dbg_drv("Stopping EC"); |
706 | set_bit(EC_FLAGS_STOPPED, &ec->flags); | 746 | set_bit(EC_FLAGS_STOPPED, &ec->flags); |
707 | spin_unlock_irqrestore(&ec->lock, flags); | 747 | spin_unlock_irqrestore(&ec->lock, flags); |
708 | wait_event(ec->wait, acpi_ec_stopped(ec)); | 748 | wait_event(ec->wait, acpi_ec_stopped(ec)); |
@@ -712,7 +752,7 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending) | |||
712 | acpi_ec_complete_request(ec); | 752 | acpi_ec_complete_request(ec); |
713 | clear_bit(EC_FLAGS_STARTED, &ec->flags); | 753 | clear_bit(EC_FLAGS_STARTED, &ec->flags); |
714 | clear_bit(EC_FLAGS_STOPPED, &ec->flags); | 754 | clear_bit(EC_FLAGS_STOPPED, &ec->flags); |
715 | pr_debug("EC stopped\n"); | 755 | ec_log_drv("EC stopped"); |
716 | } | 756 | } |
717 | spin_unlock_irqrestore(&ec->lock, flags); | 757 | spin_unlock_irqrestore(&ec->lock, flags); |
718 | } | 758 | } |
@@ -824,12 +864,12 @@ static void acpi_ec_run(void *cxt) | |||
824 | 864 | ||
825 | if (!handler) | 865 | if (!handler) |
826 | return; | 866 | return; |
827 | pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); | 867 | ec_dbg_evt("Query(0x%02x) started", handler->query_bit); |
828 | if (handler->func) | 868 | if (handler->func) |
829 | handler->func(handler->data); | 869 | handler->func(handler->data); |
830 | else if (handler->handle) | 870 | else if (handler->handle) |
831 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); | 871 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); |
832 | pr_debug("##### Query(0x%02x) stopped #####\n", handler->query_bit); | 872 | ec_dbg_evt("Query(0x%02x) stopped", handler->query_bit); |
833 | acpi_ec_put_query_handler(handler); | 873 | acpi_ec_put_query_handler(handler); |
834 | } | 874 | } |
835 | 875 | ||
@@ -861,8 +901,8 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data) | |||
861 | if (value == handler->query_bit) { | 901 | if (value == handler->query_bit) { |
862 | /* have custom handler for this bit */ | 902 | /* have custom handler for this bit */ |
863 | handler = acpi_ec_get_query_handler(handler); | 903 | handler = acpi_ec_get_query_handler(handler); |
864 | pr_debug("##### Query(0x%02x) scheduled #####\n", | 904 | ec_dbg_evt("Query(0x%02x) scheduled", |
865 | handler->query_bit); | 905 | handler->query_bit); |
866 | status = acpi_os_execute((handler->func) ? | 906 | status = acpi_os_execute((handler->func) ? |
867 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, | 907 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, |
868 | acpi_ec_run, handler); | 908 | acpi_ec_run, handler); |