summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ec/starlabs/merlin/variants/glkr/ecdefs.h26
-rw-r--r--src/ec/starlabs/merlin/variants/glkr/emem.asl162
-rw-r--r--src/ec/starlabs/merlin/variants/glkr/events.asl78
3 files changed, 266 insertions, 0 deletions
diff --git a/src/ec/starlabs/merlin/variants/glkr/ecdefs.h b/src/ec/starlabs/merlin/variants/glkr/ecdefs.h
new file mode 100644
index 0000000000..51b34dfd3e
--- /dev/null
+++ b/src/ec/starlabs/merlin/variants/glkr/ecdefs.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <assert.h>
+#include <stdint.h>
+
+/*
+ * EC communication interface for Nuvoton Embedded Controller.
+ */
+
+#ifndef _EC_STARLABS_GLKR_EC_DEFS_H
+#define _EC_STARLABS_GLKR_EC_DEFS_H
+
+/* Nuvoton chip ID byte values. */
+#define NUVOTON_CHIPID_VAL 0x0004
+
+/* EC RAM offsets. */
+#define ECRAM_TRACKPAD_STATE 0x14
+#define ECRAM_KBL_STATE 0x16
+#define ECRAM_KBL_BRIGHTNESS 0x17
+#define ECRAM_KBL_TIMEOUT 0x12
+#define ECRAM_FN_LOCK_STATE 0x15
+#define ECRAM_FN_CTRL_REVERSE 0x13
+#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)
+#define ECRAM_FAN_MODE dead_code_t(uint8_t)
+
+#endif
diff --git a/src/ec/starlabs/merlin/variants/glkr/emem.asl b/src/ec/starlabs/merlin/variants/glkr/emem.asl
new file mode 100644
index 0000000000..d59135872e
--- /dev/null
+++ b/src/ec/starlabs/merlin/variants/glkr/emem.asl
@@ -0,0 +1,162 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+OperationRegion (ECF2, EmbeddedControl, 0x00, 0x100)
+Field (ECF2, ByteAcc, Lock, Preserve)
+{
+ Offset(0x00),
+ ECMV, 8, // Major Version Number
+ ECSV, 8, // Minor Version Number
+ KBVS, 8, // Keyboard Controller Version
+ ECTV, 8, // Test Version Number
+ P0MV, 8, // PD Port 0 Major Version
+ P0SV, 8, // PD Port 0 Minor Version
+ P1MV, 8, // PD Port 1 Major Version
+ P1SV, 8, // PD Port 1 Minor Version
+
+ Offset(0x0c),
+ ECT0, 8, // EC Build Time 0
+ ECT1, 8, // EC Build Time 1
+ ECT2, 8, // EC Build Time 2
+ ECT3, 8, // EC Build Time 3
+
+ Offset(0x12),
+ KLTE, 8, // Keyboard Backlight Timeout
+ FCLA, 8, // Fn Ctrl Reverse
+ TPLE, 8, // Trackpad State
+ FLKE, 8, // Function Lock State
+ KLSE, 8, // Keyboard Backlight State
+ KLBE, 8, // Keyboard Backlight Brightness
+
+ Offset(0x20),
+ RCMD, 8, // Send EC command
+ RCST, 8, // Status of EC command
+
+ Offset(0x60),
+ TSE1, 8, // Sensor 1 Temperature
+ TSE2, 8, // Sensor 2 Temperature
+ TSE3, 8, // Sensor 3 Temperature
+
+ Offset(0x63),
+ TSE4, 4, // Sensor 4 Temperature
+ SENF, 8, // Sensor F
+ TSHT, 8, // Thermal Sensor High Trip Point
+ TSLT, 8, // Thermal Sensor Low Trip Point
+ THER, 8, // Thermal Source
+ CHRA, 16, // Charge Rate
+
+ Offset(0x72),
+ CHAR, 8, // Charger Temperature
+
+ Offset(0x7e),
+ OSFG, 8, // OS Flag [TODO: Confirm]
+ LSTE, 1, // Lid Status
+ , 7, // Reserved
+
+ Offset(0x80),
+ ECPS, 8, // AC & Battery status
+ B1MN, 8, // Battery Model Number Code
+ B1SN, 16, // Battery Serial Number
+ B1DC, 16, // Battery Design Capacity
+ B1DV, 16, // Battery Design Voltage
+ B1FC, 16, // Battery Last Full Charge Capacity
+ B1TP, 16, // Battery Trip Point
+ B1ST, 8, // Battery State
+ B1PR, 16, // Battery Present Rate
+ B1RC, 16, // Battery Remaining Capacity
+ B1PV, 16, // Battery Present Voltage
+ BPRP, 8, // Battery Remaining percentage
+ BT1A, 8, // Bt1 ASOC
+ BT1T, 16, // Bt1 Temperature
+ BT1C, 8, // Bt1 Control
+
+ // Unicorn - doesn't actually exist
+ Offset(0x9d),
+ OPWE, 8, // OPM write to EC flag for UCSI
+ // Unicorn - doesn't actually exist
+
+ Offset(0xa0),
+ BSNL, 8, // Battery Serial Number Low byte
+ BSNH, 8, // Battery Serial Number High Byte
+ BMN1, 8, // Battery Manufactory Name 1
+ BMN2, 8, // Battery Manufactory Name 2
+ BMN3, 8, // Battery Manufactory Name 3
+ BMN4, 8, // Battery Manufactory Name 4
+ BMN5, 8, // Battery Manufactory Name 5
+ BMN6, 8, // Battery Manufactory Name 6
+ BMN7, 8, // Battery Manufactory Name 7
+ BMN8, 8, // Battery Manufactory Name 8
+ BMN9, 8, // Battery Manufactory Name 9
+ BMNA, 8, // Battery Manufactory Name 10
+ BMNB, 8, // Battery Manufactory Name 11
+ BMNC, 8, // Battery Manufactory Name 12
+ BDN1, 8, // Battery Device Name 1
+ BDN2, 8, // Battery Device Name 2
+ BDN3, 8, // Battery Device Name 3
+ BDN4, 8, // Battery Device Name 4
+ BDN5, 8, // Battery Device Name 5
+ BDN6, 8, // Battery Device Name 6
+ BDN7, 8, // Battery Device Name 7
+ BDN8, 8, // Battery Device Name 8
+ BDN9, 8, // Battery Device Name 9
+ BDNA, 8, // Battery Device Name 10
+ BDNB, 8, // Battery Device Name 11
+ BDNC, 8, // Battery Device Name 12
+ BCT1, 8, // Battery Chemistry Type 1
+ BCT2, 8, // Battery Chemistry Type 2
+ BCT3, 8, // Battery Chemistry Type 3
+ BCT4, 8, // Battery Chemistry Type 4
+ BCT5, 8, // Battery Chemistry Type 5
+ BCT6, 8, // Battery Chemistry Type 6
+
+ Offset(0xc0),
+ UCSV, 16, // UCSI DS Version
+ UCSD, 16, // UCSI DS Reserved
+ CCI0, 8, // UCSI DS CCI 0
+ CCI1, 8, // UCSI DS CCI 1
+ CCI2, 8, // UCSI DS CCI 2
+ CCI3, 8, // UCSI DS CCI 3
+ CTL0, 8, // UCSI DS Control 0
+ CTL1, 8, // UCSI DS Control 0
+ CTL2, 8, // UCSI DS Control 0
+ CTL3, 8, // UCSI DS Control 0
+ CTL4, 8, // UCSI DS Control 0
+ CTL5, 8, // UCSI DS Control 0
+ CTL6, 8, // UCSI DS Control 0
+ CTL7, 8, // UCSI DS Control 0
+
+ Offset(0xd0),
+ MGI0, 8, // UCSI DS MGI 0
+ MGI1, 8, // UCSI DS MGI 1
+ MGI2, 8, // UCSI DS MGI 2
+ MGI3, 8, // UCSI DS MGI 3
+ MGI4, 8, // UCSI DS MGI 4
+ MGI5, 8, // UCSI DS MGI 5
+ MGI6, 8, // UCSI DS MGI 6
+ MGI7, 8, // UCSI DS MGI 7
+ MGI8, 8, // UCSI DS MGI 8
+ MGI9, 8, // UCSI DS MGI 9
+ MGIA, 8, // UCSI DS MGI A
+ MGIB, 8, // UCSI DS MGI B
+ MGIC, 8, // UCSI DS MGI C
+ MGID, 8, // UCSI DS MGI D
+ MGIE, 8, // UCSI DS MGI E
+ MGIF, 8, // UCSI DS MGI F
+
+ Offset(0xe0),
+ MGO0, 8, // UCSI DS MGO 0
+ MGO1, 8, // UCSI DS MGO 1
+ MGO2, 8, // UCSI DS MGO 2
+ MGO3, 8, // UCSI DS MGO 3
+ MGO4, 8, // UCSI DS MGO 4
+ MGO5, 8, // UCSI DS MGO 5
+ MGO6, 8, // UCSI DS MGO 6
+ MGO7, 8, // UCSI DS MGO 7
+ MGO8, 8, // UCSI DS MGO 8
+ MGO9, 8, // UCSI DS MGO 9
+ MGOA, 8, // UCSI DS MGO A
+ MGOB, 8, // UCSI DS MGO B
+ MGOC, 8, // UCSI DS MGO C
+ MGOD, 8, // UCSI DS MGO D
+ MGOE, 8, // UCSI DS MGO E
+ MGOF, 8, // UCSI DS MGO F
+}
diff --git a/src/ec/starlabs/merlin/variants/glkr/events.asl b/src/ec/starlabs/merlin/variants/glkr/events.asl
new file mode 100644
index 0000000000..49589da4ef
--- /dev/null
+++ b/src/ec/starlabs/merlin/variants/glkr/events.asl
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+Method (_Q0D, 0, NotSerialized) // Event: Lid Opened
+{
+ \LIDS = LSTE
+ Notify (LID0, 0x80)
+}
+
+Method (_Q0C, 0, NotSerialized) // Event: Lid Closed
+{
+ \LIDS = LSTE
+ Notify (LID0, 0x80)
+}
+
+Method (_Q0A, 0, NotSerialized) // Event: AC Power Connected
+{
+ Notify (BAT0, 0x81)
+ Notify (ADP1, 0x80)
+}
+
+Method (_Q0B, 0, NotSerialized) // Event: AC Power Disconnected
+{
+ Notify (BAT0, 0x81)
+ Notify (BAT0, 0x80)
+}
+
+Method (_Q09, 0, NotSerialized) // Event: Backlight Brightness Down
+{
+ ^^^^HIDD.HPEM (20)
+}
+
+Method (_Q10, 0, NotSerialized) // Event: Backlight Brightness Up
+{
+ ^^^^HIDD.HPEM (19)
+}
+
+Method (_Q08, 0, NotSerialized) // Event: Airplane Mode
+{
+ ^^^^HIDD.HPEM (8)
+}
+
+Method (_QD5, 0, NotSerialized) // Event: 10 Second Power Button Pressed
+{
+ Notify (HIDD, 0xCE)
+}
+
+Method (_QD6, 0, NotSerialized) // Event: 10 Second Power Button Released
+{
+ Notify (HIDD, 0xCF)
+}
+
+Method (_Q54, 0, NotSerialized) // Event: Power Button Press
+{
+ Printf ("EC: PWRBTN")
+}
+
+Method (_Q02, 0, NotSerialized) // Event: Turn off Backlight
+{
+ Printf ("EC: Backlight off")
+}
+
+Method (_Q79, 0, NotSerialized) // Event: USB Type-C
+{
+ Printf ("EC: USB Type-C")
+ UCEV()
+}
+
+Method (_Q60, 0, NotSerialized) // Event: Trackpad Enable
+{
+ Printf ("EC: Trackpad Enable")
+ SPC0 (0xD0C80600, 0x40800102)
+}
+
+Method (_Q61, 0, NotSerialized) // Event: Trackpad Disable
+{
+ Printf ("EC: Trackpad Disable")
+ SPC0 (0xD0C80600, 0x40800200)
+}