diff options
author | Michael Niewöhner <foss@mniewoehner.de> | 2021-12-01 19:09:13 +0100 |
---|---|---|
committer | Michael Niewöhner <foss@mniewoehner.de> | 2022-11-11 22:42:46 +0000 |
commit | e1e65cb0f1cad6117d48503f2f78d115caecc55b (patch) | |
tree | b6d42b3968fd2e6d57062031a48ac65123bb03ca /src/ec/clevo/it5570e/acpi | |
parent | 064c6ced40a0acd7c4127414ee04c90b3a458751 (diff) |
ec/clevo/it5570e: add driver for EC used on various Clevo laptops
This adds a driver for the ITE IT5570E EC in combination with Clevo
vendor EC firmware. The interface is mostly identical on various laptop
models. Thus, we have implemented one common driver to support them all.
The following features were implemented:
- Basics like battery, ac, etc.
- Suspend/hibernate support: S0ix, S3*, S4/S5
- Save/restore of keyboard backlight level during S0ix without the need
for Clevo vendor software (ControlCenter)
- Flexicharger
- Fn keys (backlight, volume, airplane etc.)
- Various configuration options via Kconfig / CMOS options
* Note: S3 support works at least on L140CU (Cometlake), but it's not
enabled for this board because S0ix is used.
Not implemented, yet:
- Type-C UCSI: the EC firmware seems to be buggy (with vendor fw, too)
- dGPU support is WIP
An example of how this driver can be hooked up by a board can be seen in
in change CB:59850, where support for the L140MU is added.
Known issues:
- Touchpad toggle:
The touchpad toggle (Fn-F1) has two modes, Ctrl-Alt-F9 mode and
keycodes 0xf7/0xf8 mode. Ctrl-Alt-F9 is the native touchpad toggle
shortcut on Windows. On Linux this would switch to virtual console 9,
if enabled. Thus, one should use the keycodes mode and add udev
rules as specified in [1]. If VT9 is disabled, Ctrl-Alt-F9 mode could
be used to set up a keyboard shortcut command toggling the touchpad.
- Multi-fan systems
The Clevo NV41MZ (w/o dGPU) has two fans that should be in-sync.
However, the second fan does not spin. This needs further
investigation.
[1] https://docs.dasharo.com/variants/clevo_nv41/post_install/
Testing the various functionalities of this EC driver was done in the
changes hooking up this driver for the boards.
Change-Id: Ic8c0bee9002ad9edcd10c83b775fc723744caaa0
Co-authored-by: Michał Kopeć <michal.kopec@3mdeb.com>
Co-authored-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68791
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/ec/clevo/it5570e/acpi')
-rw-r--r-- | src/ec/clevo/it5570e/acpi/ac.asl | 12 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/battery.asl | 116 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/buttons.asl | 13 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/common.asl | 28 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/ec.asl | 176 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/ec_queries.asl | 387 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/ec_ram.asl | 265 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/hid.asl | 109 | ||||
-rw-r--r-- | src/ec/clevo/it5570e/acpi/lid.asl | 21 |
9 files changed, 1127 insertions, 0 deletions
diff --git a/src/ec/clevo/it5570e/acpi/ac.asl b/src/ec/clevo/it5570e/acpi/ac.asl new file mode 100644 index 0000000000..49f4c26f83 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/ac.asl @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device (AC) +{ + Name (_HID, "ACPI0003") + Name (_PCL, Package () { \_SB }) + + Method (_PSR) + { + Return (\_SB.PCI0.LPCB.EC0.ADP) + } +} diff --git a/src/ec/clevo/it5570e/acpi/battery.asl b/src/ec/clevo/it5570e/acpi/battery.asl new file mode 100644 index 0000000000..7b29a2ef9b --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/battery.asl @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#define PBST_STATE 0 +#define PBST_PRESENT_RATE 1 +#define PBST_REMAINING_CAP 2 +#define PBST_PRESENT_VOLT 3 + +#define PBIX_DESIGN_CAP 2 +#define PBIX_LAST_FULL_CHG_CAP 3 +#define PBIX_DESIGN_VOLT 5 +#define PBIX_DESIGN_CAP_WARN 6 +#define PBIX_DESIGN_CAP_LOW 7 +#define PBIX_CYCLE_COUNT 8 +#define PBIX_MODEL 16 +#define PBIX_SERIAL 17 +#define PBIX_TYPE 18 +#define PBIX_OEM_INFO 19 + +Device (BAT0) +{ + Name (_HID, EisaId ("PNP0C0A")) + Name (_UID, 0) + Name (_PCL, Package () { \_SB }) + + Name (BFCC, 0) /* Full Charge Capacity */ + + Name (PBST, Package () { + 0, // Battery State + // [0] : Discharging + // [1] : Charging + // [2] : Critical Low + 0, // Battery Present Rate + 0, // Battery Remaining Capacity + 0, // Battery Present Voltage + }) + + Name (PBIX, Package () { + 1, // Revision + 1, // Power Unit (1 = mA(h)) + 0, // Design Capacity + 0, // Last Full Charge Capacity + 1, // Battery Technology (1 = rechargeable) + 0, // Design Voltage + 0, // Design Capacity of Warning + 0, // Design Capacity of Low + 0, // Cycle Count + 95000, // Measurement Accuracy (95 %) + 0, // Max Sampling Time + 0, // Min Sampling Time + 0, // Max Averaging Interval + 0, // Min Averaging Interval + 1, // Battery Capacity Granularity 1 (low < warning) + 1, // Battery Capacity Granularity 2 (warning < full) + " ", // Model Number + " ", // Serial Number + " ", // Battery Type + " ", // OEM Information + 0, // Battery Swapping Capability (0 = not swappable) + }) + + Method (_STA) + { + Local0 = 0x0f + + If (\_SB.PCI0.LPCB.EC0.BAT0) + { + Local0 |= 0x10 /* battery present */ + } + + Return (Local0) + } + + Method (_BST) + { + /* + * Trigger update of static info update when + * the last full charge capacity changes. + * (This is what the vendor does.) + */ + If (BFCC != ToInteger (\_SB.PCI0.LPCB.EC0.BFC0)) + { + Notify (BAT0, 0x81) /* information change */ + } + + /* Convert signed current to absolute value */ + Local0 = ToInteger (\_SB.PCI0.LPCB.EC0.BPR0) + If (Local0 & 0x8000) + { + Local0 = (~Local0 & 0xffff) + 1 + } + + PBST [PBST_STATE] = ToInteger (\_SB.PCI0.LPCB.EC0.BST0) + PBST [PBST_PRESENT_RATE] = Local0 + PBST [PBST_REMAINING_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BRC0) + PBST [PBST_PRESENT_VOLT] = ToInteger (\_SB.PCI0.LPCB.EC0.BPV0) + + Return (PBST) + } + + Method (_BIX) + { + BFCC = ToInteger (\_SB.PCI0.LPCB.EC0.BFC0) + PBIX [PBIX_DESIGN_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BDC0) + PBIX [PBIX_LAST_FULL_CHG_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BFC0) + PBIX [PBIX_DESIGN_VOLT] = ToInteger (\_SB.PCI0.LPCB.EC0.BDV0) + PBIX [PBIX_DESIGN_CAP_WARN] = ToInteger (\_SB.PCI0.LPCB.EC0.BCW0) + PBIX [PBIX_DESIGN_CAP_LOW] = ToInteger (\_SB.PCI0.LPCB.EC0.BCL0) + PBIX [PBIX_CYCLE_COUNT] = ToInteger (\_SB.PCI0.LPCB.EC0.CYC0) + PBIX [PBIX_MODEL] = ToBuffer (\_SB.PCI0.LPCB.EC0.BMO0) + PBIX [PBIX_SERIAL] = ToHexString (\_SB.PCI0.LPCB.EC0.BSN0) + PBIX [PBIX_TYPE] = ToBuffer (\_SB.PCI0.LPCB.EC0.BTY0) + PBIX [PBIX_OEM_INFO] = ToBuffer (\_SB.PCI0.LPCB.EC0.BIF0) + + Return (PBIX) + } +} diff --git a/src/ec/clevo/it5570e/acpi/buttons.asl b/src/ec/clevo/it5570e/acpi/buttons.asl new file mode 100644 index 0000000000..3f5dd12973 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/buttons.asl @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device (PWRB) +{ + Name (_HID, "PNP0C0C") + Name (_PRW, Package () { EC_GPE_PWRB, 4 }) +} + +Device (SLPB) +{ + Name (_HID, "PNP0C0E") + Name (_PRW, Package () { EC_GPE_SLPB, 3 }) +} diff --git a/src/ec/clevo/it5570e/acpi/common.asl b/src/ec/clevo/it5570e/acpi/common.asl new file mode 100644 index 0000000000..21ddbd9816 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/common.asl @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef EC_GPE_SCI +#error EC_GPE_SCI must be defined by mainboard. +#endif +#ifndef EC_GPE_PWRB +#error EC_GPE_PWRB must be defined by mainboard. +#endif +#ifndef EC_GPE_SLPB +#error EC_GPE_PWRB must be defined by mainboard. +#endif +#ifndef EC_GPE_LID +#error EC_GPE_LID must be defined by mainboard. +#endif + +Scope (\_SB) +{ + #include "ac.asl" + #include "battery.asl" + #include "buttons.asl" + #include "lid.asl" + #include "hid.asl" + + Scope (PCI0.LPCB) + { + #include "ec.asl" + } +} diff --git a/src/ec/clevo/it5570e/acpi/ec.asl b/src/ec/clevo/it5570e/acpi/ec.asl new file mode 100644 index 0000000000..a4b282c4cc --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/ec.asl @@ -0,0 +1,176 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <ec/clevo/it5570e/commands.h> + +#define EC_DATA_IO 0x62 +#define EC_SC_IO 0x66 + +Device (EC0) +{ + Name (_HID, "PNP0C09") + Name (_GPE, EC_GPE_SCI) + + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x62, 0x62, 0, 1) + IO (Decode16, 0x66, 0x66, 0, 1) + }) + + #include <ec/acpi/ec.asl> + + OperationRegion (PMS0, SystemMemory, 0xfe001b1c, 4) + Field (PMS0, DWordAcc, NoLock, Preserve) + { + , 15, + GS0E, 1, /* Global SLP_S0# enable */ + } + + #include "ec_ram.asl" + + External (SFCV, MethodObj) /* Generated in SSDT */ + + Method (INIT) + { + Printf ("EC: INIT") + + ECOS = 2 /* ACPI with driver */ + BLCT = 1 /* Enable ACPI brightness control */ + CAMK = 1 /* Enable camera hotkey */ + + SFCV () /* Apply custom fan curve */ + + PNOT () + } + + Method (_INI) + { + Printf ("EC: _INI") + + INIT () + } + + /* Send FCMD */ + Method (SFCC, 1, Serialized) + { + FCMD = Arg0 + SEND_EC_COMMAND(0) + + /* EC sets FCMD = 0x00 on completion (FCMD = 0xfa on some commands) */ + Local0 = 50 + While (Local0--) + { + Stall (1) + If (FCMD == 0x00 || FCMD == 0xfa) + { + Printf("EC: FCMD 0x%o completed after %o ms", + ToHexString(Arg0), ToDecimalString(50 - Local0)) + Return (1) + } + } + Printf("EC: FCMD 0x%o timed out", ToHexString(Arg0)) + Return (0) + } + + /* + * Method called from _PTS prior to system sleep state entry + */ + Method (PTS, 1, Serialized) + { + Printf ("EC: PTS: Arg0=%o", ToDecimalString(Arg0)) + + WFNO = 0 /* Clear wake cause */ + } + + /* + * Method called from _WAK prior to system sleep state wakeup + */ + Method (WAK, 1, Serialized) + { + Printf ("EC: WAK: Arg0=%o, WFNO=%o", ToDecimalString(Arg0), ToHexString (WFNO)) + + INIT () + + /* update battery */ + Notify (\_SB.BAT0, 0x00) /* bus check */ + Notify (\_SB.BAT0, 0x80) /* state change */ + Notify (\_SB.BAT0, 0x81) /* information change */ + + /* update AC */ + Notify (\_SB.AC, 0x00) /* bus check */ + Notify (\_SB.AC, 0x80) /* state change */ + + If (Arg0 == 0x03 || Arg0 == 0x04) { + Notify (\_SB.PWRB, 0x02) /* Wake */ + } + } + + /* + * Display On/Off Notifications + * Called from \_SB.PEPD._DSM + */ + Name (KBLV, 0) + Method (EDSX, 1, Serialized) + { + Printf ("EC: PEP display hook, state=%o", ToDecimalString (Arg0)) + + If (S5FG) + { + Return () + } + + /* Display off */ + If (!Arg0) + { + /* Store current keyboard backlight level */ + FDAT = FDAT_KBLED_WHITE_GET_LEVEL + SFCC (FCMD_KLED) + KBLV = FBUF + + /* Turn off keyboard backlight */ + FDAT = FDAT_KBLED_WHITE_SET_LEVEL + FBUF = 0x00 + SFCC (FCMD_KLED) + } + + /* Display on */ + Else + { + /* Restore keyboard backlight level */ + FDAT = FDAT_KBLED_WHITE_SET_LEVEL + FBUF = KBLV + SFCC (FCMD_KLED) + } + } + + /* + * S0ix Entry/Exit Notifications + * Called from \_SB.PEPD._DSM + */ + Method (S0IX, 1, Serialized) + { + If (S5FG) + { + Return () + } + + Printf ("EC: S0ix change, state=%o", ToDecimalString (Arg0)) + + /* S0ix entry */ + If (Arg0) + { + MSFG = 1 /* Notify EC */ + } + + /* S0ix exit */ + Else + { + GS0E = 0 /* Block SLP_S0# assertion during wakeup */ + MSFG = 0 /* Notfiy EC */ + Sleep (150) /* wait for EC to become ready */ + SFCV () /* Apply custom fan curve */ + GS0E = 1 /* Unblock SLP_S0# */ + } + } + + #include "ec_queries.asl" +} diff --git a/src/ec/clevo/it5570e/acpi/ec_queries.asl b/src/ec/clevo/it5570e/acpi/ec_queries.asl new file mode 100644 index 0000000000..ff9cd06470 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/ec_queries.asl @@ -0,0 +1,387 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * Note: + * The code contains all queries/events that are known to be implemented by the EC firmware. + * Not all events are known yet, though. + */ + +Method (_Q0A) +{ + Printf ("EC: _Q0A: Toggle touchpad, SCIE=0x%o, state=%o", + ToHexString (SCIE), ToDecimalString(SCIE & 1)) +} + +Method (_Q0B) +{ + Printf ("EC: _Q0B: LCD off, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q0C) +{ + Printf ("EC: _Q0C: Toggle mute, SCIE=0x%o, state=%o", + ToHexString (SCIE), ToDecimalString(SCIE & 1)) +} + +Method (_Q0E) +{ + Printf ("EC: _Q0E: Decrease volume") +} + +Method (_Q0F) +{ + Printf ("EC: _Q0F: Increase volume") +} + +Method (_Q10) +{ + Printf ("EC: _Q10, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q11) +{ + Printf ("EC: _Q11: Decrease brightness") + + If (CondRefOf (\_SB.PCI0.GFX0.LCD0)) { + Notify (\_SB.PCI0.GFX0.LCD0, 0x87) + } +} + +Method (_Q12) +{ + Printf ("EC: _Q12: Increase brightness") + + If (CondRefOf (\_SB.PCI0.GFX0.LCD0)) { + Notify (\_SB.PCI0.GFX0.LCD0, 0x86) + } +} + +Method (_Q13) +{ + Printf ("EC: _Q13: Toggle camera, SCIE=0x%o, state=%o", + ToHexString (SCIE), ToDecimalString(SCIE & 1)) +} + +Method (_Q14) +{ + Printf ("EC: _Q14: Toggle airplane mode, SCIE=0x%o", ToHexString (SCIE)) + + \_SB.HIDD.HPEM (8) +} + +Method (_Q15) +{ + Printf ("EC: _Q15: Sleep button") + + Notify (\_SB.SLPB, 0x80) +} + +Method (_Q16) +{ + Printf ("EC: _Q16: Power event (AC/BAT0)") + + Notify (AC, 0x80) /* status change */ + If (BAT0) + { + Notify (\_SB.BAT0, 0x80) /* status change */ + Notify (\_SB.BAT0, 0x81) /* information change */ + } +} + +Method (_Q17) +{ + Printf ("EC: _Q17: Battery presence change, state=%o", ToDecimalString (BAT0)) + + Notify (\_SB.BAT0, 0x81) /* information change */ +} + +Method (_Q19) +{ + Printf ("EC: _Q19: Battery critical") + + Notify (\_SB.BAT0, 0x80) /* status change */ +} + +Method (_Q1A) +{ + Printf ("EC: _Q1A: Wake event, WFNO=0x%o", ToHexString (WFNO)) + + Switch (ToInteger (WFNO)) + { + Case (0x01) + { + Printf ("EC: Wake reason: Lid") + Notify (\_SB.LID, 0x02) /* wake */ + } + + Case (0x04) + { + Printf ("EC: Wake reason: Sleep button") + Notify (\_SB.SLPB, 0x02) /* wake */ + } + + Case (0x05) + { + Printf ("EC: Wake reason: Timer") + Notify (\_SB.PWRB, 0x02) /* wake */ + } + + Case (0x10) + { + Printf ("EC: Wake reason: Battery low") + Notify (\_SB.BAT0, 0x02) /* wake */ + } + + Default + { + Printf ("EC: Wake reason: other") + Notify (\_SB.PWRB, 0x02) /* wake */ + } + } +} + +Method (_Q1B) +{ + Printf ("EC: _Q1B: Lid state change, state=%o", ToDecimalString (LSTE)) + + Notify (\_SB.LID, 0x80) +} + +Method (_Q1D) +{ + Printf ("EC: _Q1D: Power button") + + Notify (\_SB.PWRB, 0x80) +} + +Method (_Q1E) +{ + Printf ("EC: _Q1E: Battery low") +} + +Method (_Q32) +{ + Printf ("EC: _Q32: Battery thermal trip") +} + +Method (_Q35) +{ + Printf ("EC: _Q35: Silent fan mode change, state=%o", ToDecimalString (SLFG)) +} + +Method (_Q37) +{ + Printf ("EC: _Q37: B15C flag change, B15C=%o", ToHexString (B15C)) +} + +Method (_Q42) +{ + Printf ("EC: _Q42, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q46) +{ + Printf ("EC: _Q46, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q4A) +{ + Printf ("EC: _Q4A: KBC beep on/off, SCIE=0x%o, state=%o", + ToHexString (SCIE), ToDecimalString(SCIE & 1)) +} + +Method (_Q50) +{ + Printf ("EC: _Q50: SCI event, SCIE=0x%o", ToHexString (SCIE)) + + Switch (ToInteger (SCIE)) + { + Case (0x68) // L140MU only + { + } + + Case (0x69) // L140MU only + { + } + + Case (0x6a) + { + Printf ("EC: Fan mode: MaxQ") + } + + Case (0x6c) + { + Printf ("EC: Fan mode: custom") + } + + Case (0x7a) + { + } + + Case (0x7b) + { + Printf ("EC: Fn + Backspace pressed") + } + + Case (0x7c) + { + Printf ("EC: Screen rotate (Fn + R)") + } + + Case (0x80) + { + Printf ("EC: Color keyboard color change") + } + + Case (0x81) + { + Printf ("EC: Color keyboard brightness down") + } + + Case (0x82) + { + Printf ("EC: Color keyboard brightness up") + } + + Case (0x8a) + { + Printf ("EC: White keyboard backlight toggle") + } + + Case (0x9f) + { + Printf ("EC: Color keyboard backlight toggle") + } + + Case (0xa0) + { + } + + Case (0xa8) + { + Printf ("EC: Fn + ESC pressed") + } + + Case (0xae) + { + Printf ("EC: airplane mode LED off") + } + + Case (0xaf) + { + Printf ("EC: airplane mode LED on") + } + + Case (0xb0) + { + } + + Case (0xc7) + { + Printf ("EC: NumLock off") + } + + Case (0xc8) + { + Printf ("EC: NumLock on") + } + + Case (0xc9) + { + Printf ("EC: CapsLock off") + } + + Case (0xca) + { + Printf ("EC: CapsLock on") + } + + Case (0xcf) + { + Printf ("EC: ScrollLock off") + } + + Case (0xd0) + { + Printf ("EC: ScrollLock on") + } + + Case (0xf0) + { + } + + Case (0xf1) + { + } + + Case (0xf2) + { + Printf ("EC: Fan mode: auto") + } + + Case (0xf3) + { + Printf ("EC: Fan mode: turbo") + } + } +} + +Method (_Q51) +{ + Printf ("EC: _Q51, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q52) +{ + Printf ("EC: _Q52, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q53) +{ + Printf ("EC: _Q53, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q56) +{ + Printf ("EC: _Q56, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q57) +{ + Printf ("EC: _Q57, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q58) +{ + Printf ("EC: _Q58, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q59) +{ + Printf ("EC: _Q59, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q5A) +{ + Printf ("EC: _Q5A, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q5D) +{ + Printf ("EC: _Q5D: Performance profile hotkey pressed (Fn + 3)") +} + +Method (_Q5E) +{ + Printf ("EC: _Q5E, SCIE=0x%o", ToHexString (SCIE)) +} + +Method (_Q61) +{ + Printf ("EC: _Q61: Board thermal trip") +} + +Method (_Q62) +{ + Printf ("EC: _Q62: UCSI event") +} diff --git a/src/ec/clevo/it5570e/acpi/ec_ram.asl b/src/ec/clevo/it5570e/acpi/ec_ram.asl new file mode 100644 index 0000000000..0f4b39baa4 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/ec_ram.asl @@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * Labeling: + * - just offset bits + * ? unknown / not fully understood, used by vendor fw / ec fw + */ + +/* + * Note: not all fields are used by all mainboards. Also some bits/fields are + * still unknown and will be amended as soon as more details are known. + * Naming differs from vendor firmware, since there were many completely + * wrong/misleading names. Fields unused by the vendor EC fw have been + * dropped, since they just were present due to vendor doing copy-pasting. + */ + +OperationRegion (RAM1, SystemMemory, CONFIG_EC_CLEVO_IT5570E_MEM_BASE + 0x100, 0x400) +Field (RAM1, ByteAcc, Lock, Preserve) +{ + Offset (0x03), + LSTE, 1, // Lid open 3h.0 + , 1, // - 3h.1 + LWKE, 1, // Lid wake enable 3h.2 + + Offset (0x04), + AC0, 8, // Active cooling temp 0 4h + PSV, 8, // Passive cooling temp 5h + CRT, 8, // Critical temp 6h + TMP, 8, // CPU temp read from PECI 7h + AC1, 8, // Active cooling temp 1 8h + BBST, 8, // ? dGPU related (BatteryBooST?) 9h + BTMP, 8, // Board temperature ah + + Offset (0x10), + ADP, 1, // AC connected 10h.0 + , 1, // - 10h.1 + BAT0, 1, // BAT0 connected 10h.2 + + Offset (0x11), + WFNO, 8, // Wake cause 11h + // 0x01 = lid + // 0x04 = sleep button + // 0x05 = timer + // 0x10 = battery low + + Offset (0x16), + BDC0, 32, // BAT0 design capacity 16h-19h + BFC0, 32, // BAT0 last full charge capacity 1ah-1dh + + Offset (0x22), + BDV0, 32, // BAT0 design voltage 22h-25h + BST0, 8, // BAT0 status 26h + // BST0[0] : discharging + // BST0[1] : charging + // BST0[2] : critical low + + Offset (0x2a), + BPR0, 32, // BAT0 present current 2ah-2dh + BRC0, 32, // BAT0 remaining capacity 2eh-31h + BPV0, 32, // BAT0 present voltage 32h-35h + + Offset (0x38), + BRS0, 8, // BAT0 relative charge 38h + + Offset (0x3a), + BCW0, 32, // Design capacity of warning 3ah-3dh + BCL0, 32, // Design capacity of low 3eh-41h + + Offset (0x4a), + BMO0, 64, // Model 4ah-51h + BIF0, 64, // Vendor 52h-59h + BSN0, 32, // Serial number 5ah-5dh + BTY0, 64, // Type 5eh-65h + + Offset (0x68), + ECOS, 8, // ACPI OS support 68h + // 0 = no ACPI + // 1 = ACPI w/o driver + // 2 = ACPI w/ driver + + Offset (0x78), + /* + * PECI + * Maybe usable for debugging. Must never be written directly! + */ + PCAD, 8, // PECI address 78h + PEWL, 8, // PECI write length 79h + PWRL, 8, // PECI read length 7ah + PECD, 8, // PECI command 7bh + PEHI, 8, // PECI host ID 7ch + PECI, 8, // PECI index 7dh + PEPL, 8, // PECI LSB 7eh + PEPM, 8, // PECI MSB 7fh + PWFC, 8, // ? 80h + PECC, 8, // PECI completion code 81h + PDT0, 8, // PECI data 82h + PDT1, 8, // PECI data 83h + PDT2, 8, // PECI data 84h + PDT3, 8, // PECI data 85h + + Offset (0x92), + BMD0, 16, // BAT0 manufacturing date 92h-93h + // BMD0[4:0] : day + // BMD0[8:5] : month + // BMD0[15:9] : year - 1980 + CYC0, 16, // BAT0 cycle count 94h-95h + + Offset (0xc7), + VOFF, 8, // VGA fan base offset c7h + FANC, 8, // FAN count (FANC == FANQ) c8h + BLVL, 8, // Legacy display brightness level (unused) c9h + + Offset (0xca), + , 1, // - cah.0 + , 1, // ? cah.1 + CAMK, 1, // Enable webcam hotkey cah.2 + , 2, // - cah.3-4 + WWAN, 1, // WWAN/3G/LTE present (enables WWAN) cah.5 + + Offset (0xcb), + , 5, // - cbh.0-4 + B15C, 1, // ? cbh.5 + , 1, // - cbh.6 + SLFG, 1, // silent fan mode flag cbh.7 + + Offset (0xcc), + SCIE, 8, // SCI extra value cch + + Offset (0xce), + DUT1, 8, // Fan 1 duty ceh + DUT2, 8, // Fan 2 duty cfh + + Offset (0xd0), + RPM1, 16, // Fan 1 RPM d0h-d1h + RPM2, 16, // Fan 2 RPM d2h-d3h + RPM4, 16, // Fan 4 RPM d4h-d5h + + Offset (0xd7), + DTHL, 8, // ? d7h + DTBP, 8, // ? d8h + , 1, // - d9h.0 + WOLD, 1, // ? Disable Wake-on-LAN d9h.1 + PWRM, 2, // current performance profile d9h.2-3 + // 0 = entertainment + // 1 = performance + // 2 = quiet + // 3 = powersave + FN3E, 1, // Fn + 3 enable (power profile toggle) d9h.4 + , 1, // ? d9h.5 + AIRP, 1, // airplane mode status (in non-ACPI mode) d9h.6 + GPUP, 1, // dGPU power status d9h.7 + + Offset (0xda), + BLCT, 1, // ACPI backlight control dah.0 + DBGP, 1, // 3IN1 debug card present flag dah.1 + , 1, // WINF[2] ? dah.2 + MEUL, 1, // ME/IFD unlock (ACPI usage unclear) dah.3 + + Offset (0xdb), + RINF, 8, // dbh + // RINF[0] : set when EC cmd A8 was called + // RINF[1] : - + // RINF[2] : ? TP + // RINF[3] : ? + // RINF[4] : I2C TP SupportSandTPScanCode + // RINF[5] : ? + // RINF[6] : set on first airplane mode activation + // RINF[7] : ? + DBG, 8, // P80 + 3in1 debug dch + + Offset (0xdd), + , 1, // ddh.0 + , 1, // INF2[1] : ? ddh.1 + , 4, // - ddh.2-5 + BWKE, 1, // S3 wake on low battery ddh.6 + FF2D, 1, // Fn + F2 (LCD off) disable ddh.7 + EID2, 8, // EC CHIPID LSB deh + BWKT, 8, // threshold for S3 wake on low battery dfh + + Offset (0xe0), + RPM3, 16, // Fan 3 RPM e0h-e1h + + Offset (0xe2), + , 3, // - e2h.0-2 + SWFN, 1, // swap Fn and left Win key e2h.3 + LWIN, 1, // enable left Win key e2h.4 + , 2, // - e2h.5-6 + AIRK, 1, // enable airplane hotkey support e2h.7 + + Offset (0xe4), + , 1, // ? e4h.0 + , 2, // - e4h.1-2 + , 1, // ? e4h.3 + , 1, // - e4h.4 + EP12, 1, // ? (gpu related) e4h.5 + FN_G, 1, // Fn + G pressed (GPU reset on vendor fw) e4h.6 + , 1, // ? e4h.7 + + Offset (0xe5), + ECSZ, 8, // EC eFlash size e5h + + Offset (0xe6), + , 2, // - e6h.0-1 + G3FG, 1, // Enter G3 (all power off) in S4/S5 e6h.2 + , 3, // - e6h.3-5 + FOAC, 1, // Fan always on when AC connected e6h.6 + + Offset (0xe7), + FOFF, 8, // Fan base offset e7h + + Offset (0xe8), + , 1, // ? static 1; vendor: if 1: eccmd c6, val 0 e8h.0 + CNVI, 1, // CNVI card present e8h.1 + , 3, // - e8h.2-4 + FN_D, 1, // Fn + D pressed (CMOS reset on vendor fw) e8h.5 + , 1, // ? fan related e8h.6 + + Offset (0xe9), + KBBO, 1, // KB LED supports boot effect override e9h.0 + + Offset (0xea), + , 3, // - eah.0-2 + PDFG, 1, // Power supplied via USB-C eah.3 + MSFG, 1, // Modern standby flag eah.4 + RCHG, 1, // ? eah.5 + ACOT, 1, // ? eah.6 + S5FG, 1, // ? eah.7 + + Offset (0xeb), + , 1, // ? (unknown keypress status, NV4x only) ebh.0 + , 1, // ? (unknown keypress status, NV4x only) ebh.1 + , 1, // - ebh.2 + DGPT, 1, // ? ebh.3 + TOPN, 1, // ? ebh.4 + , 1, // ? (kbc beep related?) ebh.5 + , 1, // ? (kbc beep related?) ebh.6 + APRD, 1, // AP ready ebh.7 + + Offset (0xf0), + PL2B, 16, // Power Limit 2 set when on battery f0h-f1h + PL2T, 16, // Power Limit 2 (note: never enabled by EC!) f2h-f3h + TAUT, 8, // Tau (for PL1, not effective) f4h + + /* FCMD interface */ + Offset (0xf8), + FCMD, 8, // Command f8h + FDAT, 8, // Data f9h + FBUF, 8, // Buffer[0] fah + FBF1, 8, // Buffer[1] fbh + FBF2, 8, // Buffer[2] fch + FBF3, 8, // Buffer[3] fdh + + Offset (0xff), + , 8, // ? static, l14xcu/mu: 0xe0, nv4x 0x22 ffh + + Offset (0x28a), + FANQ, 8, // FAN count (FANC == FANQ) 28ah + KBTP, 8, // Keyboard backlight type 28bh + // 0x00 = none + // 0x01 = white + // 0x02 = RGB + // 0x*3 = per-key RGB + // 0x06 = RGB15Color + // 0x16 = RGB15ColorCustom +} diff --git a/src/ec/clevo/it5570e/acpi/hid.asl b/src/ec/clevo/it5570e/acpi/hid.asl new file mode 100644 index 0000000000..10d23f5330 --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/hid.asl @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* Minimal implementation of HID event filter device for airplane hotkey support */ + +Device (HIDD) +{ + Name (_HID, "INTC1051") + + Name (HRDY, 0) + Name (HBSY, 0) + Name (HIDX, 0) + + /* + * Workaround: + * There was a bug in Linux' HID driver, making evaluation of function 2 fail. + * The driver falls back to legacy mode and evaluates integers instead of _DSM. + * A bugfix for this was merged to mainline and stable but not LTS-branches. Thus, + * let's keep this for some time. + * https://lore.kernel.org/r/66f813f5bcc724a0f6dd5adefe6a9728dbe509e3.camel@mniewoehner.de + */ + Name (HDMM, 0) + + Method (_STA) + { + Return (0x0f) + } + + Method (_DSM, 4, Serialized) + { + If (Arg0 == ToUUID ("eeec56b3-4442-408f-a792-4edd4d758054")) + { + If (Arg1 == 1) /* Revision 1 */ + { + Printf ("HIDD: _DSM called, fn=%o", ToDecimalString(Arg2)) + + Switch (ToInteger (Arg2)) + { + Case (0) + { + /* Supported functions: 0, 2, 3, 4, 7 */ + Return (Buffer () {0x9d, 0x00}) + } + Case (2) + { + /* Simple mode */ + Return (0) + } + Case (3) + { + /* Driver status */ + HRDY = DeRefOf (Index (Arg3, 0)) + } + Case (4) + { + /* HID driver calls this to get event */ + HBSY = 0 + Return (HIDX) + } + Case (7) + { + /* Only airplane mode button implemented */ + Return (1 << 1) + } + } + } + } + + Return (Buffer () {0}) + } + + /* + * HID Platform Event Method + * Called to trigger HID event. + */ + Method (HPEM, 1, Serialized) + { + Printf ("HIDD: HPEM called, event=%o", ToHexString (Arg0)) + + If (!HRDY) + { + Printf ("HIDD: HID driver not ready. Ignoring event.") + } + + HBSY = 1 + HIDX = Arg0 + + Notify (HIDD, 0xc0) + + /* Wait max. 1 second for HID driver */ + Local0 = 0 + While ((Local0 < 250) && HBSY) + { + Sleep (4) + Local0++ + } + + If (HBSY) + { + Printf ("HIDD: HPEM timeout") + + HBSY = 0 + HIDX = 0 + + Return (1) /* Timeout */ + } + + Return (0) + } +} diff --git a/src/ec/clevo/it5570e/acpi/lid.asl b/src/ec/clevo/it5570e/acpi/lid.asl new file mode 100644 index 0000000000..3a1ab1750e --- /dev/null +++ b/src/ec/clevo/it5570e/acpi/lid.asl @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device (LID) +{ + Name (_HID, "PNP0C0D") + Name (_PRW, Package () { EC_GPE_LID, 3 }) + + Method (_LID) + { + Printf ("LID: _LID: state=%o", ToDecimalString (\_SB.PCI0.LPCB.EC0.LSTE)) + + Return (\_SB.PCI0.LPCB.EC0.LSTE) + } + + Method (_PSW, 1) + { + Printf ("LID: _PSW: set lid wake enable=%o", ToDecimalString (Arg0)) + + \_SB.PCI0.LPCB.EC0.LWKE = Arg0 + } +} |