aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
authorAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>2007-03-07 14:28:00 -0500
committerLen Brown <len.brown@intel.com>2007-03-09 23:27:29 -0500
commit01f2246269639f6aa93086719a8dbec26cb68e98 (patch)
treebe782dc4be679a11ada18b9813c4a5877e13bac6 /drivers/acpi/ec.c
parentd033879c9838b960014e861d0eb3bdf11d3b9d9d (diff)
ACPI: EC: Cleanup of EC initialization
Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 187981a3e881..2a172299b24c 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $) 2 * ec.c - ACPI Embedded Controller Driver (v2.0)
3 * 3 *
4 * Copyright (C) 2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
5 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 6 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 7 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 8 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
@@ -94,7 +96,6 @@ static struct acpi_driver acpi_ec_driver = {
94/* External interfaces use first EC only, so remember */ 96/* External interfaces use first EC only, so remember */
95static struct acpi_ec { 97static struct acpi_ec {
96 acpi_handle handle; 98 acpi_handle handle;
97 unsigned long uid;
98 unsigned long gpe; 99 unsigned long gpe;
99 unsigned long command_addr; 100 unsigned long command_addr;
100 unsigned long data_addr; 101 unsigned long data_addr;
@@ -525,13 +526,11 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
525 if (!ec) 526 if (!ec)
526 goto end; 527 goto end;
527 528
528 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe); 529 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
529 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 530 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
530 (u32) ec->command_addr, (u32) ec->data_addr); 531 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
531 seq_printf(seq, "use global lock: %s\n", 532 seq_printf(seq, "use global lock:\t%s\n",
532 ec->global_lock ? "yes" : "no"); 533 ec->global_lock ? "yes" : "no");
533 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
534
535 end: 534 end:
536 return 0; 535 return 0;
537} 536}
@@ -655,15 +654,13 @@ static int acpi_ec_add(struct acpi_device *device)
655 654
656static int acpi_ec_remove(struct acpi_device *device, int type) 655static int acpi_ec_remove(struct acpi_device *device, int type)
657{ 656{
658 struct acpi_ec *ec = NULL; 657 struct acpi_ec *ec;
659 658
660 if (!device) 659 if (!device)
661 return -EINVAL; 660 return -EINVAL;
662 661
663 ec = acpi_driver_data(device); 662 ec = acpi_driver_data(device);
664
665 acpi_ec_remove_fs(device); 663 acpi_ec_remove_fs(device);
666
667 acpi_driver_data(device) = NULL; 664 acpi_driver_data(device) = NULL;
668 if (ec == first_ec) 665 if (ec == first_ec)
669 first_ec = NULL; 666 first_ec = NULL;
@@ -671,7 +668,6 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
671 /* Don't touch boot EC */ 668 /* Don't touch boot EC */
672 if (boot_ec != ec) 669 if (boot_ec != ec)
673 kfree(ec); 670 kfree(ec);
674
675 return 0; 671 return 0;
676} 672}
677 673
@@ -680,22 +676,20 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
680{ 676{
681 struct acpi_ec *ec = context; 677 struct acpi_ec *ec = context;
682 678
683 if (resource->type != ACPI_RESOURCE_TYPE_IO) { 679 if (resource->type != ACPI_RESOURCE_TYPE_IO)
684 return AE_OK; 680 return AE_OK;
685 }
686 681
687 /* 682 /*
688 * The first address region returned is the data port, and 683 * The first address region returned is the data port, and
689 * the second address region returned is the status/command 684 * the second address region returned is the status/command
690 * port. 685 * port.
691 */ 686 */
692 if (ec->data_addr == 0) { 687 if (ec->data_addr == 0)
693 ec->data_addr = resource->data.io.minimum; 688 ec->data_addr = resource->data.io.minimum;
694 } else if (ec->command_addr == 0) { 689 else if (ec->command_addr == 0)
695 ec->command_addr = resource->data.io.minimum; 690 ec->command_addr = resource->data.io.minimum;
696 } else { 691 else
697 return AE_CTRL_TERMINATE; 692 return AE_CTRL_TERMINATE;
698 }
699 693
700 return AE_OK; 694 return AE_OK;
701} 695}
@@ -708,6 +702,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
708 &acpi_ec_gpe_handler, ec); 702 &acpi_ec_gpe_handler, ec);
709 if (ACPI_FAILURE(status)) 703 if (ACPI_FAILURE(status))
710 return -ENODEV; 704 return -ENODEV;
705
711 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 706 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
712 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 707 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
713 708
@@ -825,7 +820,6 @@ int __init acpi_ec_ecdt_probe(void)
825 boot_ec->command_addr = ecdt_ptr->control.address; 820 boot_ec->command_addr = ecdt_ptr->control.address;
826 boot_ec->data_addr = ecdt_ptr->data.address; 821 boot_ec->data_addr = ecdt_ptr->data.address;
827 boot_ec->gpe = ecdt_ptr->gpe; 822 boot_ec->gpe = ecdt_ptr->gpe;
828 boot_ec->uid = ecdt_ptr->uid;
829 boot_ec->handle = ACPI_ROOT_OBJECT; 823 boot_ec->handle = ACPI_ROOT_OBJECT;
830 824
831 ret = ec_install_handlers(boot_ec); 825 ret = ec_install_handlers(boot_ec);