aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
authorMárton Németh <nm127@freemail.hu>2007-11-20 19:23:26 -0500
committerLen Brown <len.brown@intel.com>2007-11-20 20:04:39 -0500
commit3ebe08a749a0971a5407818169dc16212ef562f9 (patch)
treeb3f887f0623902fdf7e0b1d1a1ec396a71cecd05 /drivers/acpi/ec.c
parent0af2f653c504d302d83d3a648c0408882ff62d4c (diff)
ACPI: EC: use printk_ratelimit(), add some DEBUG mode messages
Sometimes it is usefull to see raw protocol dump. Uncomment '#define DEBUG' at the beginning of file to make EC really verbose. Signed-off-by: Márton Németh <nm127@freemail.hu> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 06b78e5e33a1..d5a5958d4b20 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -47,6 +47,9 @@
47#undef PREFIX 47#undef PREFIX
48#define PREFIX "ACPI: EC: " 48#define PREFIX "ACPI: EC: "
49 49
50/* Uncomment next line to get verbose print outs*/
51/* #define DEBUG */
52
50/* EC status register */ 53/* EC status register */
51#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 54#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 55#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
@@ -131,21 +134,27 @@ static struct acpi_ec {
131 134
132static inline u8 acpi_ec_read_status(struct acpi_ec *ec) 135static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
133{ 136{
134 return inb(ec->command_addr); 137 u8 x = inb(ec->command_addr);
138 pr_debug(PREFIX "---> status = 0x%2x\n", x);
139 return x;
135} 140}
136 141
137static inline u8 acpi_ec_read_data(struct acpi_ec *ec) 142static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
138{ 143{
144 u8 x = inb(ec->data_addr);
145 pr_debug(PREFIX "---> data = 0x%2x\n", x);
139 return inb(ec->data_addr); 146 return inb(ec->data_addr);
140} 147}
141 148
142static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 149static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
143{ 150{
151 pr_debug(PREFIX "<--- command = 0x%2x\n", command);
144 outb(command, ec->command_addr); 152 outb(command, ec->command_addr);
145} 153}
146 154
147static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 155static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
148{ 156{
157 pr_debug(PREFIX "<--- data = 0x%2x\n", data);
149 outb(data, ec->data_addr); 158 outb(data, ec->data_addr);
150} 159}
151 160
@@ -175,13 +184,14 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
175 if (acpi_ec_check_status(ec, event)) { 184 if (acpi_ec_check_status(ec, event)) {
176 if (event == ACPI_EC_EVENT_OBF_1) { 185 if (event == ACPI_EC_EVENT_OBF_1) {
177 /* miss OBF = 1 GPE, don't expect it anymore */ 186 /* miss OBF = 1 GPE, don't expect it anymore */
178 printk(KERN_INFO PREFIX "missing OBF_1 confirmation," 187 pr_info(PREFIX "missing OBF_1 confirmation,"
179 "switching to degraded mode.\n"); 188 "switching to degraded mode.\n");
180 set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); 189 set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags);
181 } else { 190 } else {
182 /* missing GPEs, switch back to poll mode */ 191 /* missing GPEs, switch back to poll mode */
183 printk(KERN_INFO PREFIX "missing IBF_1 confirmations," 192 if (printk_ratelimit())
184 "switch off interrupt mode.\n"); 193 pr_info(PREFIX "missing IBF_1 confirmations,"
194 "switch off interrupt mode.\n");
185 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 195 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
186 } 196 }
187 return 0; 197 return 0;
@@ -194,7 +204,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
194 return 0; 204 return 0;
195 } 205 }
196 } 206 }
197 printk(KERN_ERR PREFIX "acpi_ec_wait timeout," 207 pr_err(PREFIX "acpi_ec_wait timeout,"
198 " status = %d, expect_event = %d\n", 208 " status = %d, expect_event = %d\n",
199 acpi_ec_read_status(ec), event); 209 acpi_ec_read_status(ec), event);
200 return -ETIME; 210 return -ETIME;
@@ -208,11 +218,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
208 int result = 0; 218 int result = 0;
209 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 219 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
210 acpi_ec_write_cmd(ec, command); 220 acpi_ec_write_cmd(ec, command);
211 221 pr_debug(PREFIX "transaction start\n");
212 for (; wdata_len > 0; --wdata_len) { 222 for (; wdata_len > 0; --wdata_len) {
213 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 223 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
214 if (result) { 224 if (result) {
215 printk(KERN_ERR PREFIX 225 pr_err(PREFIX
216 "write_cmd timeout, command = %d\n", command); 226 "write_cmd timeout, command = %d\n", command);
217 goto end; 227 goto end;
218 } 228 }
@@ -223,7 +233,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
223 if (!rdata_len) { 233 if (!rdata_len) {
224 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 234 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
225 if (result) { 235 if (result) {
226 printk(KERN_ERR PREFIX 236 pr_err(PREFIX
227 "finish-write timeout, command = %d\n", command); 237 "finish-write timeout, command = %d\n", command);
228 goto end; 238 goto end;
229 } 239 }
@@ -235,8 +245,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
235 force_poll = 1; 245 force_poll = 1;
236 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); 246 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
237 if (result) { 247 if (result) {
238 printk(KERN_ERR PREFIX "read timeout, command = %d\n", 248 pr_err(PREFIX "read timeout, command = %d\n", command);
239 command);
240 goto end; 249 goto end;
241 } 250 }
242 /* Don't expect GPE after last read */ 251 /* Don't expect GPE after last read */
@@ -245,6 +254,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
245 *(rdata++) = acpi_ec_read_data(ec); 254 *(rdata++) = acpi_ec_read_data(ec);
246 } 255 }
247 end: 256 end:
257 pr_debug(PREFIX "transaction end\n");
248 return result; 258 return result;
249} 259}
250 260
@@ -273,8 +283,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
273 283
274 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); 284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
275 if (status) { 285 if (status) {
276 printk(KERN_ERR PREFIX 286 pr_err(PREFIX "input buffer is not empty, "
277 "input buffer is not empty, aborting transaction\n"); 287 "aborting transaction\n");
278 goto end; 288 goto end;
279 } 289 }
280 290
@@ -488,6 +498,7 @@ static u32 acpi_ec_gpe_handler(void *data)
488 acpi_status status = AE_OK; 498 acpi_status status = AE_OK;
489 struct acpi_ec *ec = data; 499 struct acpi_ec *ec = data;
490 500
501 pr_debug(PREFIX "~~~> interrupt\n");
491 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 502 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
492 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) 503 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
493 wake_up(&ec->wait); 504 wake_up(&ec->wait);
@@ -498,8 +509,9 @@ static u32 acpi_ec_gpe_handler(void *data)
498 acpi_ec_gpe_query, ec); 509 acpi_ec_gpe_query, ec);
499 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { 510 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) {
500 /* this is non-query, must be confirmation */ 511 /* this is non-query, must be confirmation */
501 printk(KERN_INFO PREFIX "non-query interrupt received," 512 if (printk_ratelimit())
502 " switching to interrupt mode\n"); 513 pr_info(PREFIX "non-query interrupt received,"
514 " switching to interrupt mode\n");
503 set_bit(EC_FLAGS_GPE_MODE, &ec->flags); 515 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
504 } 516 }
505 517
@@ -701,10 +713,10 @@ static void ec_remove_handlers(struct acpi_ec *ec)
701{ 713{
702 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 714 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
703 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 715 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
704 printk(KERN_ERR PREFIX "failed to remove space handler\n"); 716 pr_err(PREFIX "failed to remove space handler\n");
705 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, 717 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
706 &acpi_ec_gpe_handler))) 718 &acpi_ec_gpe_handler)))
707 printk(KERN_ERR PREFIX "failed to remove gpe handler\n"); 719 pr_err(PREFIX "failed to remove gpe handler\n");
708 ec->handlers_installed = 0; 720 ec->handlers_installed = 0;
709} 721}
710 722
@@ -747,9 +759,9 @@ static int acpi_ec_add(struct acpi_device *device)
747 first_ec = ec; 759 first_ec = ec;
748 acpi_driver_data(device) = ec; 760 acpi_driver_data(device) = ec;
749 acpi_ec_add_fs(device); 761 acpi_ec_add_fs(device);
750 printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", 762 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
751 ec->gpe, ec->command_addr, ec->data_addr); 763 ec->gpe, ec->command_addr, ec->data_addr);
752 printk(KERN_INFO PREFIX "driver started in %s mode\n", 764 pr_info(PREFIX "driver started in %s mode\n",
753 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); 765 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
754 return 0; 766 return 0;
755} 767}
@@ -875,7 +887,7 @@ int __init acpi_ec_ecdt_probe(void)
875 status = acpi_get_table(ACPI_SIG_ECDT, 1, 887 status = acpi_get_table(ACPI_SIG_ECDT, 1,
876 (struct acpi_table_header **)&ecdt_ptr); 888 (struct acpi_table_header **)&ecdt_ptr);
877 if (ACPI_SUCCESS(status)) { 889 if (ACPI_SUCCESS(status)) {
878 printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n"); 890 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
879 boot_ec->command_addr = ecdt_ptr->control.address; 891 boot_ec->command_addr = ecdt_ptr->control.address;
880 boot_ec->data_addr = ecdt_ptr->data.address; 892 boot_ec->data_addr = ecdt_ptr->data.address;
881 boot_ec->gpe = ecdt_ptr->gpe; 893 boot_ec->gpe = ecdt_ptr->gpe;