patch-2.4.22 linux-2.4.22/drivers/acpi/hardware/hwgpe.c
Next file: linux-2.4.22/drivers/acpi/hardware/hwregs.c
Previous file: linux-2.4.22/drivers/acpi/hardware/hwacpi.c
Back to the patch index
Back to the overall index
- Lines: 749
- Date:
2003-08-25 04:44:41.000000000 -0700
- Orig file:
linux-2.4.21/drivers/acpi/hardware/hwgpe.c
- Orig date:
2001-10-24 14:06:22.000000000 -0700
diff -urN linux-2.4.21/drivers/acpi/hardware/hwgpe.c linux-2.4.22/drivers/acpi/hardware/hwgpe.c
@@ -2,42 +2,58 @@
/******************************************************************************
*
* Module Name: hwgpe - Low level GPE enable/disable/clear functions
- * $Revision: 35 $
*
*****************************************************************************/
/*
- * Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
*/
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
#define _COMPONENT ACPI_HARDWARE
- MODULE_NAME ("hwgpe")
+ ACPI_MODULE_NAME ("hwgpe")
/******************************************************************************
*
- * FUNCTION: Acpi_hw_enable_gpe
+ * FUNCTION: acpi_hw_enable_gpe
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -45,43 +61,41 @@
*
******************************************************************************/
-void
+acpi_status
acpi_hw_enable_gpe (
- u32 gpe_number)
+ struct acpi_gpe_event_info *gpe_event_info)
{
- u32 in_byte;
- u32 register_index;
- u32 bit_mask;
-
-
- FUNCTION_ENTRY ();
+ u32 in_byte;
+ acpi_status status;
- /*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
+ ACPI_FUNCTION_ENTRY ();
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
/*
* Read the current value of the register, set the appropriate bit
* to enable the GPE, and write out the new register.
*/
- in_byte = 0;
- acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
- acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
- (in_byte | bit_mask), 8);
+ status = acpi_hw_low_level_read (8, &in_byte,
+ &gpe_event_info->register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ /* Write with the new GPE bit enabled */
+
+ status = acpi_hw_low_level_write (8, (in_byte | gpe_event_info->bit_mask),
+ &gpe_event_info->register_info->enable_address);
+
+ return (status);
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_enable_gpe_for_wakeup
+ * FUNCTION: acpi_hw_enable_gpe_for_wakeup
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -92,36 +106,33 @@
void
acpi_hw_enable_gpe_for_wakeup (
- u32 gpe_number)
+ struct acpi_gpe_event_info *gpe_event_info)
{
- u32 register_index;
- u32 bit_mask;
+ struct acpi_gpe_register_info *gpe_register_info;
- FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY ();
- /*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
+ /* Get the info block for the entire GPE register */
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+ gpe_register_info = gpe_event_info->register_info;
+ if (!gpe_register_info) {
+ return;
+ }
/*
* Set the bit so we will not disable this when sleeping
*/
- acpi_gbl_gpe_registers[register_index].wake_enable |= bit_mask;
+ gpe_register_info->wake_enable |= gpe_event_info->bit_mask;
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_disable_gpe
+ * FUNCTION: acpi_hw_disable_gpe
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -129,45 +140,53 @@
*
******************************************************************************/
-void
+acpi_status
acpi_hw_disable_gpe (
- u32 gpe_number)
+ struct acpi_gpe_event_info *gpe_event_info)
{
- u32 in_byte;
- u32 register_index;
- u32 bit_mask;
+ u32 in_byte;
+ acpi_status status;
+ struct acpi_gpe_register_info *gpe_register_info;
- FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY ();
- /*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
+ /* Get the info block for the entire GPE register */
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+ gpe_register_info = gpe_event_info->register_info;
+ if (!gpe_register_info) {
+ return (AE_BAD_PARAMETER);
+ }
/*
* Read the current value of the register, clear the appropriate bit,
* and write out the new register value to disable the GPE.
*/
- in_byte = 0;
- acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
- acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
- (in_byte & ~bit_mask), 8);
+ status = acpi_hw_low_level_read (8, &in_byte,
+ &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ /* Write the byte with this GPE bit cleared */
+
+ status = acpi_hw_low_level_write (8, (in_byte & ~(gpe_event_info->bit_mask)),
+ &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
- acpi_hw_disable_gpe_for_wakeup(gpe_number);
+ acpi_hw_disable_gpe_for_wakeup (gpe_event_info);
+ return (AE_OK);
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_disable_gpe_for_wakeup
+ * FUNCTION: acpi_hw_disable_gpe_for_wakeup
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -178,36 +197,33 @@
void
acpi_hw_disable_gpe_for_wakeup (
- u32 gpe_number)
+ struct acpi_gpe_event_info *gpe_event_info)
{
- u32 register_index;
- u32 bit_mask;
+ struct acpi_gpe_register_info *gpe_register_info;
- FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY ();
- /*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
+ /* Get the info block for the entire GPE register */
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+ gpe_register_info = gpe_event_info->register_info;
+ if (!gpe_register_info) {
+ return;
+ }
/*
* Clear the bit so we will disable this when sleeping
*/
- acpi_gbl_gpe_registers[register_index].wake_enable &= ~bit_mask;
+ gpe_register_info->wake_enable &= ~(gpe_event_info->bit_mask);
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_clear_gpe
+ * FUNCTION: acpi_hw_clear_gpe
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -215,40 +231,32 @@
*
******************************************************************************/
-void
+acpi_status
acpi_hw_clear_gpe (
- u32 gpe_number)
+ struct acpi_gpe_event_info *gpe_event_info)
{
- u32 register_index;
- u32 bit_mask;
+ acpi_status status;
- FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY ();
/*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
-
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
-
- /*
* Write a one to the appropriate bit in the status register to
* clear this GPE.
*/
- acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, bit_mask, 8);
+ status = acpi_hw_low_level_write (8, gpe_event_info->bit_mask,
+ &gpe_event_info->register_info->status_address);
+
+ return (status);
}
/******************************************************************************
*
- * FUNCTION: Acpi_hw_get_gpe_status
+ * FUNCTION: acpi_hw_get_gpe_status
*
- * PARAMETERS: Gpe_number - The GPE
+ * PARAMETERS: gpe_number - The GPE
*
* RETURN: None
*
@@ -256,127 +264,317 @@
*
******************************************************************************/
-void
+acpi_status
acpi_hw_get_gpe_status (
- u32 gpe_number,
- acpi_event_status *event_status)
+ struct acpi_gpe_event_info *gpe_event_info,
+ acpi_event_status *event_status)
{
- u32 in_byte = 0;
- u32 register_index = 0;
- u32 bit_mask = 0;
+ u32 in_byte;
+ u8 bit_mask;
+ struct acpi_gpe_register_info *gpe_register_info;
+ acpi_status status;
+ acpi_event_status local_event_status = 0;
- FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY ();
if (!event_status) {
- return;
+ return (AE_BAD_PARAMETER);
}
- (*event_status) = 0;
+ /* Get the info block for the entire GPE register */
- /*
- * Translate GPE number to index into global registers array.
- */
- register_index = acpi_gbl_gpe_valid[gpe_number];
+ gpe_register_info = gpe_event_info->register_info;
- /*
- * Figure out the bit offset for this GPE within the target register.
- */
- bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+ /* Get the register bitmask for this GPE */
+
+ bit_mask = gpe_event_info->bit_mask;
+
+ /* GPE Enabled? */
+
+ status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ goto unlock_and_exit;
+ }
- /*
- * Enabled?:
- */
- in_byte = 0;
- acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
if (bit_mask & in_byte) {
- (*event_status) |= ACPI_EVENT_FLAG_ENABLED;
+ local_event_status |= ACPI_EVENT_FLAG_ENABLED;
}
- /*
- * Enabled for wake?:
- */
- if (bit_mask & acpi_gbl_gpe_registers[register_index].wake_enable) {
- (*event_status) |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+ /* GPE Enabled for wake? */
+
+ if (bit_mask & gpe_register_info->wake_enable) {
+ local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+ }
+
+ /* GPE active (set)? */
+
+ status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address);
+ if (ACPI_FAILURE (status)) {
+ goto unlock_and_exit;
}
- /*
- * Set?
- */
- in_byte = 0;
- acpi_os_read_port (acpi_gbl_gpe_registers[register_index].status_addr, &in_byte, 8);
if (bit_mask & in_byte) {
- (*event_status) |= ACPI_EVENT_FLAG_SET;
+ local_event_status |= ACPI_EVENT_FLAG_SET;
}
+
+ /* Set return value */
+
+ (*event_status) = local_event_status;
+
+
+unlock_and_exit:
+ return (status);
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_disable_non_wakeup_gpes
+ * FUNCTION: acpi_hw_disable_gpe_block
*
- * PARAMETERS: None
+ * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
+ * gpe_block - Gpe Block info
*
- * RETURN: None
+ * RETURN: Status
*
- * DESCRIPTION: Disable all non-wakeup GPEs
- * Call with interrupts disabled. The interrupt handler also
- * modifies Acpi_gbl_Gpe_registers[i].Enable, so it should not be
- * given the chance to run until after non-wake GPEs are
- * re-enabled.
+ * DESCRIPTION: Disable all GPEs within a GPE block
*
******************************************************************************/
-void
-acpi_hw_disable_non_wakeup_gpes (
- void)
+acpi_status
+acpi_hw_disable_gpe_block (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block)
{
- u32 i;
+ u32 i;
+ struct acpi_gpe_register_info *gpe_register_info;
+ acpi_status status;
- FUNCTION_ENTRY ();
- for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+ /* Get the register info for the entire GPE block */
+
+ gpe_register_info = gpe_block->register_info;
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < gpe_block->register_count; i++) {
+ status = acpi_hw_low_level_write (8, 0x00,
+ &gpe_block->register_info[i].enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: acpi_hw_clear_gpe_block
+ *
+ * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
+ * gpe_block - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clear all GPEs within a GPE block
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_hw_clear_gpe_block (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block)
+{
+ u32 i;
+ struct acpi_gpe_register_info *gpe_register_info;
+ acpi_status status;
+
+
+ /* Get the register info for the entire GPE block */
+
+ gpe_register_info = gpe_block->register_info;
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < gpe_block->register_count; i++) {
+ status = acpi_hw_low_level_write (8, 0xFF,
+ &gpe_block->register_info[i].status_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: acpi_hw_disable_non_wakeup_gpe_block
+ *
+ * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
+ * gpe_block - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_hw_disable_non_wakeup_gpe_block (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block)
+{
+ u32 i;
+ struct acpi_gpe_register_info *gpe_register_info;
+ u32 in_value;
+ acpi_status status;
+
+
+ /* Get the register info for the entire GPE block */
+
+ gpe_register_info = gpe_block->register_info;
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < gpe_block->register_count; i++) {
/*
* Read the enabled status of all GPEs. We
* will be using it to restore all the GPEs later.
*/
- acpi_os_read_port (acpi_gbl_gpe_registers[i].enable_addr,
- &acpi_gbl_gpe_registers[i].enable, 8);
+ status = acpi_hw_low_level_read (8, &in_value,
+ &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ gpe_register_info->enable = (u8) in_value;
/*
- * Disable all GPEs but wakeup GPEs.
+ * Disable all GPEs except wakeup GPEs.
*/
- acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
- acpi_gbl_gpe_registers[i].wake_enable, 8);
+ status = acpi_hw_low_level_write (8, gpe_register_info->wake_enable,
+ &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ gpe_register_info++;
}
+
+ return (AE_OK);
}
+
/******************************************************************************
*
- * FUNCTION: Acpi_hw_enable_non_wakeup_gpes
+ * FUNCTION: acpi_hw_disable_non_wakeup_gpes
*
* PARAMETERS: None
*
* RETURN: None
*
- * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ * DESCRIPTION: Disable all non-wakeup GPEs
+ * Called with interrupts disabled. The interrupt handler also
+ * modifies gpe_register_info->Enable, so it should not be
+ * given the chance to run until after non-wake GPEs are
+ * re-enabled.
*
******************************************************************************/
-void
-acpi_hw_enable_non_wakeup_gpes (
+acpi_status
+acpi_hw_disable_non_wakeup_gpes (
void)
{
- u32 i;
+ acpi_status status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ status = acpi_ev_walk_gpe_list (acpi_hw_disable_non_wakeup_gpe_block);
+
+ return (status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: acpi_hw_enable_non_wakeup_gpe_block
+ *
+ * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
+ * gpe_block - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable a single GPE.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_hw_enable_non_wakeup_gpe_block (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block)
+{
+ u32 i;
+ struct acpi_gpe_register_info *gpe_register_info;
+ acpi_status status;
+
+
+ /* This callback processes one entire GPE block */
- FUNCTION_ENTRY ();
+ /* Get the register info for the entire GPE block */
- for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+ gpe_register_info = gpe_block->register_info;
+
+ /* Examine each GPE register within the block */
+
+ for (i = 0; i < gpe_block->register_count; i++) {
/*
* We previously stored the enabled status of all GPEs.
* Blast them back in.
*/
- acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
- acpi_gbl_gpe_registers[i].enable, 8);
+ status = acpi_hw_low_level_write (8, gpe_register_info->enable,
+ &gpe_register_info->enable_address);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ gpe_register_info++;
}
+
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: acpi_hw_enable_non_wakeup_gpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_hw_enable_non_wakeup_gpes (
+ void)
+{
+ acpi_status status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ status = acpi_ev_walk_gpe_list (acpi_hw_enable_non_wakeup_gpe_block);
+
+ return (status);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)