summaryrefslogtreecommitdiff
path: root/src/ec/google/wilco/acpi/dptf.asl
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2018-11-20 17:30:47 -0800
committerDuncan Laurie <dlaurie@chromium.org>2018-12-04 17:34:38 +0000
commit98d7de7ea93379957fc3f48bef6912e9947e1099 (patch)
tree5f638ec5330ebe11b4ebf59a9cad0377e690c856 /src/ec/google/wilco/acpi/dptf.asl
parent106a0823c92593fe35150c5255d9852b9bff9c5d (diff)
ec/google/wilco/acpi: Add DPTF support
Add the support needed for DPTF. This includes the methods to write trip point values, read temperatures, and handle events. This was tested on a sarien board by inspecting AML debug output with the kernel while monitoring temperatures and trip points in sysfs and controlling temperatures with a fan to ensure that when a trip point is crossed an SCI is generated and the event is handled properly. Change-Id: I8d8570d176c0896fa709a6c782b319f58d3c1e52 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://review.coreboot.org/c/29761 Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/ec/google/wilco/acpi/dptf.asl')
-rw-r--r--src/ec/google/wilco/acpi/dptf.asl134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/ec/google/wilco/acpi/dptf.asl b/src/ec/google/wilco/acpi/dptf.asl
new file mode 100644
index 0000000000..f5545d0c79
--- /dev/null
+++ b/src/ec/google/wilco/acpi/dptf.asl
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+
+/*
+ * Dynamic Platform Thermal Framework support
+ */
+
+External (\_SB.DPTF.CTOK, MethodObj)
+External (\_SB.DPTF.KTOC, MethodObj)
+External (\_SB.DPTF.TEVT, MethodObj)
+
+/* Mutex for EC PAT interface */
+Mutex (PATM, 1)
+
+/* Read requested temperature sensor */
+Method (TSRD, 1, Serialized)
+{
+ If (Acquire (^PATM, 1000)) {
+ Return (0)
+ }
+
+ /* Set sensor ID */
+ W (DWTI, ToInteger (Arg0))
+
+ Local0 = R (DRTV)
+
+ Release (^PATM)
+ Return (\_SB.DPTF.CTOK (Local0))
+}
+
+/*
+ * Set Aux Trip Point 0
+ * Arg0 = Temp Sensor ID
+ * Arg1 = Value to set
+ */
+Method (PAT0, 2, Serialized)
+{
+ If (Acquire (^PATM, 1000)) {
+ Return (0)
+ }
+
+ /* Set sensor ID */
+ W (DWTI, ToInteger (Arg0))
+
+ /* Set LOW trip point for this sensor */
+ W (DWTL, \_SB.DPTF.KTOC (Arg1))
+
+ Release (^PATM)
+ Return (1)
+}
+
+/*
+ * Set Aux Trip Point 1
+ * Arg0 = Temp Sensor ID
+ * Arg1 = Value to set
+ */
+Method (PAT1, 2, Serialized)
+{
+ If (Acquire (^PATM, 1000)) {
+ Return (0)
+ }
+
+ /* Set sensor ID */
+ W (DWTI, ToInteger (Arg0))
+
+ /* Set HIGH trip point for this sensor */
+ W (DWTH, \_SB.DPTF.KTOC (Arg1))
+
+ Release (^PATM)
+ Return (1)
+}
+
+/*
+ * Disable Aux Trip Points
+ * Arg0 = Temp Sensor ID
+ */
+Method (PATD, 1, Serialized)
+{
+ If (Acquire (^PATM, 1000)) {
+ Return (0)
+ }
+
+ /* Set sensor ID */
+ W (DWTI, ToInteger (Arg0))
+
+ /* Disable LOW and HIGH trip points */
+ W (DWTL, 0xff)
+ W (DWTH, 0xff)
+
+ Release (^PATM)
+ Return (1)
+}
+
+/*
+ * Handle sensor trip events
+ */
+Method (PATX, 0, Serialized)
+{
+ Local0 = R (DRTQ)
+ Local1 = Local0
+
+ Printf ("Sensor trip mask: %o", Local0)
+
+ If (LNot (Acquire (^PATM, 1000))) {
+
+ /* Handle bits that are set */
+ While (FindSetRightBit (Local1, Local2))
+ {
+ /* DPTF will Notify sensor devices */
+ \_SB.DPTF.TEVT (Local2)
+
+ /* Clear current sensor number */
+ Local1 &= ~(1 << (Local2 - 1))
+ }
+
+ Release (^PATM)
+ }
+
+ /* Clear sensor events */
+ W (DWTQ, Local0)
+}