patch-2.4.10 linux/drivers/acpi/hardware/hwacpi.c

Next file: linux/drivers/acpi/hardware/hwgpe.c
Previous file: linux/drivers/acpi/executer/exxface.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/hardware/hwacpi.c linux/drivers/acpi/hardware/hwacpi.c
@@ -2,7 +2,7 @@
 /******************************************************************************
  *
  * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
- *              $Revision: 40 $
+ *              $Revision: 45 $
  *
  *****************************************************************************/
 
@@ -45,46 +45,42 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_hw_initialize (
 	void)
 {
-	ACPI_STATUS             status = AE_OK;
+	acpi_status             status = AE_OK;
 	u32                     index;
 
 
+	FUNCTION_TRACE ("Hw_initialize");
+
+
 	/* We must have the ACPI tables by the time we get here */
 
 	if (!acpi_gbl_FADT) {
 		acpi_gbl_restore_acpi_chipset = FALSE;
 
-		return (AE_NO_ACPI_TABLES);
-	}
-
-	/* Must support *some* mode! */
-/*
-	if (!(System_flags & SYS_MODES_MASK))
-	{
-		Restore_acpi_chipset = FALSE;
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT!\n"));
 
-		return (AE_ERROR);
+		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-*/
-
+	/* Identify current ACPI/legacy mode   */
 
 	switch (acpi_gbl_system_flags & SYS_MODES_MASK) {
-		/* Identify current ACPI/legacy mode   */
-
 	case (SYS_MODE_ACPI):
 
 		acpi_gbl_original_mode = SYS_MODE_ACPI;
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports ACPI mode only.\n"));
 		break;
 
 
 	case (SYS_MODE_LEGACY):
 
 		acpi_gbl_original_mode = SYS_MODE_LEGACY;
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n"));
 		break;
 
 
@@ -97,6 +93,12 @@
 			acpi_gbl_original_mode = SYS_MODE_LEGACY;
 		}
 
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"System supports both ACPI and LEGACY modes.\n"));
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"System is currently in %s mode.\n",
+			(acpi_gbl_original_mode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY"));
 		break;
 	}
 
@@ -118,23 +120,22 @@
 		 * coded here. If this changes in the spec, this code will need to
 		 * be modified. The PM1b_evt_blk behaves as expected.
 		 */
-
-		acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN);
+		acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read (
+				   ACPI_MTX_LOCK, PM1_EN);
 
 
 		/*
 		 * The GPEs behave similarly, except that the length of the register
 		 * block is not fixed, so the buffer must be allocated with malloc
 		 */
-
 		if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) &&
 			acpi_gbl_FADT->gpe0blk_len) {
 			/* GPE0 specified in FADT  */
 
-			acpi_gbl_gpe0enable_register_save =
-				acpi_ut_allocate (DIV_2 (acpi_gbl_FADT->gpe0blk_len));
+			acpi_gbl_gpe0enable_register_save = ACPI_MEM_ALLOCATE (
+					   DIV_2 (acpi_gbl_FADT->gpe0blk_len));
 			if (!acpi_gbl_gpe0enable_register_save) {
-				return (AE_NO_MEMORY);
+				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
 
 			/* Save state of GPE0 enable bits */
@@ -153,10 +154,10 @@
 			acpi_gbl_FADT->gpe1_blk_len) {
 			/* GPE1 defined */
 
-			acpi_gbl_gpe1_enable_register_save =
-				acpi_ut_allocate (DIV_2 (acpi_gbl_FADT->gpe1_blk_len));
+			acpi_gbl_gpe1_enable_register_save = ACPI_MEM_ALLOCATE (
+					   DIV_2 (acpi_gbl_FADT->gpe1_blk_len));
 			if (!acpi_gbl_gpe1_enable_register_save) {
-				return (AE_NO_MEMORY);
+				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
 
 			/* save state of GPE1 enable bits */
@@ -172,7 +173,7 @@
 		}
 	}
 
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 
@@ -189,18 +190,22 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_hw_set_mode (
 	u32                     mode)
 {
 
-	ACPI_STATUS             status = AE_NO_HARDWARE_RESPONSE;
+	acpi_status             status = AE_NO_HARDWARE_RESPONSE;
+
+
+	FUNCTION_TRACE ("Hw_set_mode");
 
 
 	if (mode == SYS_MODE_ACPI) {
 		/* BIOS should have disabled ALL fixed and GP events */
 
-		acpi_os_out8 (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_enable);
+		acpi_os_write_port (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_enable, 8);
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
 	}
 
 	else if (mode == SYS_MODE_LEGACY) {
@@ -208,15 +213,21 @@
 		 * BIOS should clear all fixed status bits and restore fixed event
 		 * enable bits to default
 		 */
-
-		acpi_os_out8 (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_disable);
+		acpi_os_write_port (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_disable, 8);
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+				 "Attempting to enable Legacy (non-ACPI) mode\n"));
 	}
 
+	/* Give the platform some time to react */
+
+	acpi_os_stall (5000);
+
 	if (acpi_hw_get_mode () == mode) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", mode));
 		status = AE_OK;
 	}
 
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 
@@ -237,15 +248,18 @@
 acpi_hw_get_mode (void)
 {
 
+	FUNCTION_TRACE ("Hw_get_mode");
+
 
 	if (acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) {
-		return (SYS_MODE_ACPI);
+		return_VALUE (SYS_MODE_ACPI);
 	}
 	else {
-		return (SYS_MODE_LEGACY);
+		return_VALUE (SYS_MODE_LEGACY);
 	}
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_get_mode_capabilities
@@ -263,6 +277,8 @@
 acpi_hw_get_mode_capabilities (void)
 {
 
+	FUNCTION_TRACE ("Hw_get_mode_capabilities");
+
 
 	if (!(acpi_gbl_system_flags & SYS_MODES_MASK)) {
 		if (acpi_hw_get_mode () == SYS_MODE_LEGACY) {
@@ -272,7 +288,6 @@
 			 * tables.  Therefore since we're in SYS_MODE_LEGACY, the system
 			 * must support both modes
 			 */
-
 			acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY);
 		}
 
@@ -299,7 +314,7 @@
 		}
 	}
 
-	return (acpi_gbl_system_flags & SYS_MODES_MASK);
+	return_VALUE (acpi_gbl_system_flags & SYS_MODES_MASK);
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)