[coreboot-gerrit] Change in coreboot[master]: ec/google/wilco: Add ACPI EC event handlers

Duncan Laurie (Code Review) gerrit at coreboot.org
Tue Oct 16 00:54:37 CEST 2018


Duncan Laurie has uploaded this change for review. ( https://review.coreboot.org/29124


Change subject: ec/google/wilco: Add ACPI EC event handlers
......................................................................

ec/google/wilco: Add ACPI EC event handlers

Add methods to handle ACPI EC events at runtime.  Currently only
some common events are handled like lid switch and battery info,
and the event status is printed for debug on other events.

Change-Id: Ic0bd070940c8a2dfa6a251f3464301418bdb69c1
Signed-off-by: Duncan Laurie <dlaurie at google.com>
---
M src/ec/google/wilco/acpi/ec.asl
A src/ec/google/wilco/acpi/event.asl
2 files changed, 127 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/29124/1

diff --git a/src/ec/google/wilco/acpi/ec.asl b/src/ec/google/wilco/acpi/ec.asl
index d669854..cddfe3f 100644
--- a/src/ec/google/wilco/acpi/ec.asl
+++ b/src/ec/google/wilco/acpi/ec.asl
@@ -134,6 +134,7 @@
 	#include "ec_ram.asl"
 	#include "ac.asl"
 	#include "battery.asl"
+	#include "event.asl"
 	#include "lid.asl"
 	#include "platform.asl"
 }
diff --git a/src/ec/google/wilco/acpi/event.asl b/src/ec/google/wilco/acpi/event.asl
new file mode 100644
index 0000000..b43086c
--- /dev/null
+++ b/src/ec/google/wilco/acpi/event.asl
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * 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; version 2 of
+ * the License.
+ *
+ * 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.
+ */
+
+/* ACPI_POWER_RECORD */
+Name (ECPR, 0)
+
+Method (ECQP, 0, Serialized)
+{
+	Local0 = R (APWR)
+	Local1 = Local0 ^ ECPR
+	ECPR = Local0
+
+	If (EBIT (APAC, Local1)) {
+		Printf ("AC Power Status Changed")
+		Notify (AC, 0x80)
+	}
+
+	If (EBIT (APB1, Local1)) {
+		If (EBIT (APB1, Local0)) {
+			Printf ("BAT0 Inserted")
+			Notify (BAT0, 0x81)
+		} Else {
+			Printf ("BAT0 Removed")
+			Notify (BAT0, 0x80)
+			Notify (BAT0, 0x81)
+		}
+	}
+
+	If (EBIT (APC1, Local1)) {
+		Printf ("BAT0 Status Change")
+		Notify (BAT0, 0x80)
+	}
+}
+
+/* Handle events in PmEv1 */
+Method (ECQ1, 1, Serialized)
+{
+	/* Power button pressed */
+	If (EBIT (E1PB, Arg0)) {
+		Printf ("Power Button Event")
+		/* Do not notify \_SB.PWRB here to prevent double event */
+	}
+
+	/* LID state changed */
+	If (EBIT (E1LD, Arg0)) {
+		Printf ("Lid State Changed")
+		Notify (^LID, 0x80)
+	}
+
+	/* Power Event */
+	If (EBIT (E1PW, Arg0)) {
+		Printf ("Power Event")
+		ECQP ()
+	}
+
+	/* Sleep Button */
+	If (EBIT (E1SB, Arg0)) {
+		Printf ("Sleep Button")
+	}
+}
+
+/* Handle events in PmEv2 */
+Method (ECQ2, 1, Serialized)
+{
+	Printf ("EVT2: %o", Arg0)
+}
+
+/* Handle events in PmEv3 */
+Method (ECQ3, 1, Serialized)
+{
+	Printf ("EVT3: %o", Arg0)
+}
+
+/* Handle events in PmEv4 */
+Method (ECQ4, 1, Serialized)
+{
+	Printf ("EVT4: %o", Arg0)
+}
+
+/* Handle QuickSet events */
+Method (ECQS, 1, Serialized)
+{
+	Printf ("QS EVENT %o", Arg0)
+}
+
+/* Process all events */
+Method (_Q66, 0, Serialized)
+{
+	Local0 = R (EVT1)
+	If (Local0) {
+		ECQ1 (Local0)
+	}
+
+	Local0 = R (EVT2)
+	If (Local0) {
+		ECQ2 (Local0)
+	}
+
+	Local0 = R (EVT3)
+	If (Local0) {
+		ECQ3 (Local0)
+	}
+
+	Local0 = R (EVT4)
+	If (Local0) {
+		ECQ4 (Local0)
+	}
+
+	Local0 = R (QSEC)
+	For (Local1 = 0, Local1 < Local0, Local1++) {
+		ECQS (R (QSEB))
+	}
+}

-- 
To view, visit https://review.coreboot.org/29124
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0bd070940c8a2dfa6a251f3464301418bdb69c1
Gerrit-Change-Number: 29124
Gerrit-PatchSet: 1
Gerrit-Owner: Duncan Laurie <dlaurie at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181015/f22fab5a/attachment-0001.html>


More information about the coreboot-gerrit mailing list