ec/compal/ene932: Update to use coreboot EC-mainboard API

This patch implements a simple interface between the EC and mainboard
ASL code. This interface does not rely on the preprocessor, and
prevents name conflicts by scoping the interface methods. As this
interface is documented on the coreboot wiki, an in-tree documentation
is not provided.

Change-Id: If0b09be4f5e17cc444539a30f0186590fa0b72b5
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-on: http://review.coreboot.org/5515
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@gmail.com>
diff --git a/src/ec/compal/ene932/acpi/ec.asl b/src/ec/compal/ene932/acpi/ec.asl
index a042d75..0b7837f 100644
--- a/src/ec/compal/ene932/acpi/ec.asl
+++ b/src/ec/compal/ene932/acpi/ec.asl
@@ -27,7 +27,7 @@
 {
 	Name (_HID, EISAID ("PNP0C09"))
 	Name (_UID, 1)
-	Name (_GPE, EC_SCI)	// GPE for Runtime SCI
+	Name (_GPE, EC_SCI_GPE)	// GPE for Runtime SCI
 
 	OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff)
 	Field (ERAM, ByteAcc, Lock, Preserve)
@@ -272,9 +272,6 @@
 		// Initialize AC power state
 		Store (ADPT, \PWRS)
 
-		// Initialize LID switch state
-		Store (EC_ACPI_LID_SWITCH_OBJECT, \LIDS)
-
 		// Force a read of CPU temperature
 		Store (CTML, Local0)
 	}
@@ -308,6 +305,36 @@
  * Hotkey break Function     46h
  */
 
+	/* Decrease brightness hotkey */
+	Method (_Q11, 0, NotSerialized)
+	{
+		\_SB.MB.BRTD()
+	}
+
+	/* Increase brightness hotkey */
+	Method (_Q12, 0, NotSerialized)
+	{
+		\_SB.MB.BRTU()
+	}
+
+	/* Lid opened */
+	Method (_Q15, 0, NotSerialized)
+	{
+		\_SB.MB.LIDO()
+	}
+
+	/* Lid closed */
+	Method (_Q16, 0, NotSerialized)
+	{
+		\_SB.MB.LIDC()
+	}
+
+	/* Switch display hotkey */
+	Method (_Q1C, 0, NotSerialized)
+	{
+		\_SB.MB.DSPS()
+	}
+
 	// AC Power Connected
 	Method (_Q37, 0, NotSerialized)
 	{
@@ -328,6 +355,12 @@
 		\PNOT ()
 	}
 
+	/* Wireless toggle hotkey */
+	Method (_Q40, 0, NotSerialized)
+	{
+		\_SB.MB.WLTG()
+	}
+
 	// Battery at critical low state
 	Method (_Q22, 0, NotSerialized)
 	{
diff --git a/src/ec/compal/ene932/documentation.txt b/src/ec/compal/ene932/documentation.txt
index eeb801a..a597e4e 100644
--- a/src/ec/compal/ene932/documentation.txt
+++ b/src/ec/compal/ene932/documentation.txt
@@ -1,23 +1,14 @@
 
-Accessing the EC space
-======================
+ASL interface
+=============
 
-The ACPI implementation uses the standard I/O ports 0x62 and 0x66 to access the
-EC functionality. Accesses to these ports must be directed to the LPC bus to
-which the EC is connected.
+This EC implements the standard mainboard-EC coreboot interface.
 
+Deviations from standard interface
+==================================
 
-Interfacing with the ASL files
-==============================
+The following method must be defined in the global namespace:
 
-The mainboard code must define several variables for the ASL files.
-
-* EC_SCI
-  Defines the General Purpose Event (GPE) corresponding to the EC's SCI line.
-* EC_ACPI_LID_SWITCH_OBJECT
-  Defines the APCI object which reads the state of the lid, with 0 = open, and
-  1 = closed. This is usually the bit which reads the GPIO input corresponding
-  to the lid switch.
 * PNOT()
   The mainboard must define a PNOT method to handle power state notifications
   and Notify CPU device objects to re-evaluate their _PPC and _CST tables.
diff --git a/src/mainboard/google/parrot/acpi/ec.asl b/src/mainboard/google/parrot/acpi/ec.asl
index a0ee9d5..ae0090f 100644
--- a/src/mainboard/google/parrot/acpi/ec.asl
+++ b/src/mainboard/google/parrot/acpi/ec.asl
@@ -19,10 +19,7 @@
 
 /* mainboard configuration */
 #include "../ec.h"
-#define EC_SCI 23      // GPIO7 << 16 to GPE bit for Runtime SCI
-
-/* GP15 is defined in the southbridge's ASL */
-#define EC_ACPI_LID_SWITCH_OBJECT	GP15
+#define EC_SCI_GPE 23      // GPIO7 << 16 to GPE bit for Runtime SCI
 
 /* ACPI code for EC functions */
 #include "../../../../ec/compal/ene932/acpi/ec.asl"
diff --git a/src/mainboard/google/parrot/acpi/mainboard.asl b/src/mainboard/google/parrot/acpi/mainboard.asl
index 7b9aef0..4ab9733 100644
--- a/src/mainboard/google/parrot/acpi/mainboard.asl
+++ b/src/mainboard/google/parrot/acpi/mainboard.asl
@@ -68,4 +68,24 @@
 		})
 	}
 
+	Device (MB) {
+		/* Lid open */
+		Method (LIDO) { /* Not needed on this board */ }
+		/* Lid closed */
+		Method (LIDC) { /* Not needed on this board */ }
+		/* Increase brightness */
+		Method (BRTU) { /* Not needed on this board */ }
+		/* Decrease brightness */
+		Method (BRTD) { /* Not needed on this board */ }
+		/* Switch display */
+		Method (DSPS) { /* Not needed on this board */ }
+		/* Toggle wireless */
+		Method (WLTG) { /* Not needed on this board */ }
+		/* Return lid state */
+		Method (LIDS)
+		{
+			Return (GP15)
+		}
+	}
+
 }
diff --git a/src/mainboard/hp/pavilion_m6_1035dx/acpi/ec.asl b/src/mainboard/hp/pavilion_m6_1035dx/acpi/ec.asl
index e0d92fa..188515c 100644
--- a/src/mainboard/hp/pavilion_m6_1035dx/acpi/ec.asl
+++ b/src/mainboard/hp/pavilion_m6_1035dx/acpi/ec.asl
@@ -6,9 +6,7 @@
 /*
  * EC bits specific to the mainboard
  */
-#define EC_SCI 3
-/* TODO: We do not yet know how the LID is connected to the platform */
-#define EC_ACPI_LID_SWITCH_OBJECT	Zero
+#define EC_SCI_GPE 3
 
 /* ACPI code for EC functions */
 #include <ec/compal/ene932/acpi/ec.asl>
diff --git a/src/mainboard/hp/pavilion_m6_1035dx/acpi/mainboard.asl b/src/mainboard/hp/pavilion_m6_1035dx/acpi/mainboard.asl
index e30d083..57e2b3c 100644
--- a/src/mainboard/hp/pavilion_m6_1035dx/acpi/mainboard.asl
+++ b/src/mainboard/hp/pavilion_m6_1035dx/acpi/mainboard.asl
@@ -38,7 +38,6 @@
 	/* Variables used by EC */
 	/* TODO: These may belong in global non-volatile storage */
 	Name(PWRS, Zero)
-	Name(LIDS, Zero)
 
 	/* AcpiGpe0Blk */
 	OperationRegion(GP0B, SystemMemory, 0xfed80814, 0x04)
@@ -78,8 +77,24 @@
 		Name(_HID, EisaId("PNP0C0D"))
 		Method(_LID, 0)
 		{
-			Store (GE22, \LIDS)
-			Return (\LIDS)
+			Return (GE22)	/* GE pin 22 */
 		}
 	}
+
+	Device (MB) {
+		/* Lid open */
+		Method (LIDO) { /* Stub */ }
+		/* Lid closed */
+		Method (LIDC) { /* Stub */ }
+		/* Increase brightness */
+		Method (BRTU) { /* Stub */ }
+		/* Decrease brightness */
+		Method (BRTD) { /* Stub */ }
+		/* Switch display */
+		Method (DSPS) { /* Stub */ }
+		/* Toggle wireless */
+		Method (WLTG) { /* Stub */ }
+		/* Return lid state */
+		Method (LIDS) { /* Stub */ }
+	}
 }