Sean Rhodes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57044 )
Change subject: ec/starlabs/it8987: Adjust ACPI to be more complaint ......................................................................
ec/starlabs/it8987: Adjust ACPI to be more complaint
Fix build warning when EC binary not included when it shouldn't be Make LID method compliant with SW_LID (Fixes two backlight controls) Remove power button device Add Kconfig option for including EC binary
Change-Id: Id16881fd7901a2eaafc6108676ff429fb71c3571 --- M src/ec/starlabs/it8987/Kconfig M src/ec/starlabs/it8987/Makefile.inc M src/ec/starlabs/it8987/acpi/ac.asl M src/ec/starlabs/it8987/acpi/battery.asl M src/ec/starlabs/it8987/acpi/ec.asl M src/ec/starlabs/it8987/acpi/hid.asl M src/ec/starlabs/it8987/acpi/keyboard.asl M src/ec/starlabs/it8987/acpi/lid.asl M src/ec/starlabs/it8987/acpi/thermal.asl M src/ec/starlabs/it8987/ec.c M src/ec/starlabs/it8987/ec.h 11 files changed, 122 insertions(+), 320 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/57044/1
diff --git a/src/ec/starlabs/it8987/Kconfig b/src/ec/starlabs/it8987/Kconfig index ba9e908..146d911 100644 --- a/src/ec/starlabs/it8987/Kconfig +++ b/src/ec/starlabs/it8987/Kconfig @@ -5,3 +5,10 @@ select EC_ACPI help Interface to IT8987 embedded controller principally in Star Labs notebooks. + +config EC_STARLABS_IT_BIN + bool "Add Star Labs EC binary file" + default n + depends on EC_STARLABS_IT8987 + help + The EC binary diff --git a/src/ec/starlabs/it8987/Makefile.inc b/src/ec/starlabs/it8987/Makefile.inc index b021d0f..49764c7 100644 --- a/src/ec/starlabs/it8987/Makefile.inc +++ b/src/ec/starlabs/it8987/Makefile.inc @@ -6,17 +6,13 @@ ifeq ($(CONFIG_EC_STARLABS_IT8987),y) all-y += ec.c smm-$(CONFIG_DEBUG_SMI) += ec.c -endif
-ifeq ($(CONFIG_EC_STARLABS_IT8987_BIN),y) - -ifeq ($(CONFIG_EC_STARLABS_IT8987_BIN_PATH),) -files_added:: warn_no_ite_fw -endif - +ifeq ($(CONFIG_EC_STARLABS_IT_BIN),y) add_ite_fw: $(obj)/coreboot.pre - $(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_EC_STARLABS_IT8987_BIN_PATH) -u -endif + $(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_EC_STARLABS_IT_BIN_PATH) -u + +ifeq ($(CONFIG_EC_STARLABS_IT_BIN_PATH),) +files_added:: warn_no_ite_fw
PHONY+=warn_no_ite_fw warn_no_ite_fw: @@ -24,3 +20,7 @@ printf "coreboot has been built without the IT8987 EC Firmware.\n" printf "Do not flash this image. Your LabTop Mk IV's power button\n" printf "may not respond when you press it.\n\n" + +endif +endif +endif diff --git a/src/ec/starlabs/it8987/acpi/ac.asl b/src/ec/starlabs/it8987/acpi/ac.asl index 97ae147..0d73728 100644 --- a/src/ec/starlabs/it8987/acpi/ac.asl +++ b/src/ec/starlabs/it8987/acpi/ac.asl @@ -20,7 +20,7 @@
Method (_PSR, 0, NotSerialized) // _PSR: Power Source { - If (ECWR & 0x01) + If (ECPS & 0x01) { \PWRS = 1 } @@ -34,7 +34,7 @@
Method (_QA0, 0, NotSerialized) // AC Power Connected { - If (ECWR & 0x01) + If (ECPS & 0x01) { \PWRS = 1 } @@ -43,18 +43,12 @@ \PWRS = 0 }
- // 500ms delay - Not used in coreboot - // Sleep (500) Notify (BAT0, 0x81) - // Sleep (500) Notify (ADP1, 0x80) }
Method(_Q0B, 0, NotSerialized) // Battery Connected { - // 500ms delay - Not used in coreboot - // Sleep (500) Notify (BAT0, 0x81) - // Sleep (500) Notify (BAT0, 0x80) } diff --git a/src/ec/starlabs/it8987/acpi/battery.asl b/src/ec/starlabs/it8987/acpi/battery.asl index 8936701..786ad05 100644 --- a/src/ec/starlabs/it8987/acpi/battery.asl +++ b/src/ec/starlabs/it8987/acpi/battery.asl @@ -2,14 +2,14 @@
Device (BAT0) { - Name (_HID, EISAID ("PNP0C0A")) + Name (_HID, EisaId ("PNP0C0A")) Name (_UID, 1) Name (_PCL, Package () { _SB })
// Battery Slot Status - Method (_STA, 0, Serialized) + Method (_STA, 0) { - If (ECWR & 0x02) + If (ECPS & 0x02) { Return (0x1F) } @@ -17,7 +17,7 @@ }
// Default Static Battery Information - Name (BPKG, Package (13) + Name (BPKG, Package () { 1, // 0: Power Unit 0xFFFFFFFF, // 1: Design Capacity @@ -34,6 +34,8 @@ "GDPT" // 12: OEM Information })
+ Name (B1CN, "Real") + Method (_BIF, 0, Serialized) { BPKG[1] = B1DC diff --git a/src/ec/starlabs/it8987/acpi/ec.asl b/src/ec/starlabs/it8987/acpi/ec.asl index 451cdf1..02c1bed 100644 --- a/src/ec/starlabs/it8987/acpi/ec.asl +++ b/src/ec/starlabs/it8987/acpi/ec.asl @@ -1,19 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#define ASL_PVOL_DEFOF_NUM 0xe8 - -Scope() -{ - // These fields come from the Global NVS area - Field (GNVS,AnyAcc,Lock,Preserve) - { - Offset(33), - B2SC, 8, // (33) Battery 2 Stored Capacity - Offset(36), - B2SS, 8 // (36) Battery 2 Stored Status - } -} - Scope (_SB) { #include "hid.asl" @@ -33,7 +19,7 @@ // Our embedded controller device. Device (H_EC) { - Name (_HID, EISAID ("PNP0C09")) // ACPI Embedded Controller + Name (_HID, EisaId ("PNP0C09")) // ACPI Embedded Controller Name (_UID, 1) Name (_GPE, EC_GPE_SCI)
@@ -44,9 +30,9 @@ Name(WIBT, 0) Name(APST, 0)
- Name(ECON, 1) // AC debug - Name(BNUM, 0) // Number Of Batteries Present - Name(PVOL, ASL_PVOL_DEFOF_NUM) + Name(ECON, 1) // AC debug + Name(BNUM, 0) // Number Of Batteries Present + Name(PVOL, 0xe8) Name(B1CC, 0) Name(B2CC, 0)
@@ -65,7 +51,6 @@ Name(PPSL, 0) Name(PSTP, 0) Name(RPWR, 0) - Name(LIDS, 0) Name(SLPC, 0) Name(VPWR, 0) Name(WTMS, 0) @@ -80,15 +65,16 @@ Name(IWCW, 0) Name(IWCR, 0) Name(BTEN, 0) + Mutex(ECMT, 0)
+ Name (BFFR, ResourceTemplate() + { + IO (Decode16, 0x62, 0x62, 0x00, 0x01) + IO (Decode16, 0x66, 0x66, 0x00, 0x01) + }) Method (_CRS, 0, Serialized) { - Name (BFFR, ResourceTemplate() - { - IO (Decode16, 0x62, 0x62, 0x00, 0x01) - IO (Decode16, 0x66, 0x66, 0x00, 0x01) - }) Return (BFFR) }
@@ -102,65 +88,31 @@ Return (0x00) }
- Name (ECOK, Zero) Method(_REG, 2, NotSerialized) { - If ((Arg0 == 0x03) && (Arg1 == 0x01)) - { - ECOS = 1 - ECAV = 1 + // Initialise the AC Power State + Store ((ECRD (RefOf (ECPS)) & 0x01), \PWRS)
- // Unconditionally fix up the Battery and Power State. + // Inform platform code + \PNOT ()
- // Initialize the Number of Present Batteries. - // 1 = Real Battery 1 is present - // 2 = Real Battery 2 is present - // 3 = Real Battery 1 and 2 are present - BNUM = 0 - BNUM |= ((ECRD (RefOf (ECWR)) & 0x02) >> 1) - - // Save the current Power State for later. - // Store (PWRS, Local0) - - // Initialize the Power State. - // BNUM = 0 = Virtual Power State - // BNUM > 0 = Real Power State - If (BNUM == 0x00) - { - \PWRS = ECRD (RefOf (VPWR)) - } - Else - { - \PWRS = (ECRD (RefOf (ECWR)) & 0x01) - } - PNOT() - - /* Initialize LID switch state */ - \LIDS = LIDS - } + /* Initialize LID switch state */ + Store (LIDS, \LIDS)
// Flag that the OS supports ACPI. _SB.PCI0.LPCB.H_EC.ECOS = 1 } - - Name (S3OS, Zero) - Method (PTS, 1, Serialized) - { - Debug = Concatenate("EC: PTS: ", ToHexString(Arg0)) - If (ECOK) { - S3OS = ECOS - } + Method (PTS, 1, Serialized) + { + Debug = Concatenate("EC: PTS: ", ToHexString(Arg0)) _SB.PCI0.LPCB.H_EC.ECOS = 0 - } + }
- Method (WAK, 1, Serialized) - { - Debug = Concatenate("EC: WAK: ", ToHexString(Arg0)) - If (ECOK) { - ECOS = S3OS - } - _SB.PCI0.LPCB.H_EC.ECOS = 1 - } + Method (WAK, 1, Serialized) + { + Debug = Concatenate("EC: WAK: ", ToHexString(Arg0)) + _SB.PCI0.LPCB.H_EC.ECOS = 1 + }
OperationRegion (SIPR, SystemIO, 0xB2, 0x1) Field (SIPR, ByteAcc, Lock, Preserve) @@ -172,9 +124,10 @@ OperationRegion(ECF2, EmbeddedControl, 0, 0xFF) Field (ECF2, ByteAcc, Lock, Preserve) { - XXX0, 8, // EC Firmware main- version number. - XXX1, 8, // EC Firmware sub- version number. - XXX2, 8, // EC Firmware test- version number. + Offset(0x00), + XXX0, 8, // EC Firmware main - version number. + XXX1, 8, // EC Firmware sub - version number. + XXX2, 8, // EC Firmware test - version number.
Offset(0x06), SKID, 8, // SKU ID @@ -215,7 +168,7 @@ TER4, 8, // Thermal Sensor Register 3 (skin temperature)
Offset(0x63), - TSI,4, // [0..3] 0 = SEN1 - CPU VR temperature sensor + TSI, 4, // [0..3] 0 = SEN1 - CPU VR temperature sensor // 1 = SEN2 - Heat Exchanger temperature sensor // 2 = SEN3 - Skin temperature sensor // 3 = SEN4 - Ambient temperature sensor @@ -225,14 +178,14 @@ TSHT, 8, // Thermal Sensor (N) high trip point(set default value =70) TSLT, 8, // Thermal Sensor (N) low trip point (set default value =70) TSSR, 8, // TSSR- thermal sensor status register (set bit2 =1) - // BIT0:SEN1 - CPU VR Temp Sensor Trip Flag - // BIT1:SEN2 - Fan Temp Sensor Trip Flag - // BIT2:SEN3 - Skin Temp Sensor Trip Flag - // BIT3:SEN4 - Ambient Temp Sensor Trip Flag - // BIT4:Reserved - // BIT5:Reserved - // BIT6:Reserved - // BIT7:Reserved + // BIT0: SEN1 - CPU VR Temp Sensor Trip Flag + // BIT1: SEN2 - Fan Temp Sensor Trip Flag + // BIT2: SEN3 - Skin Temp Sensor Trip Flag + // BIT3: SEN4 - Ambient Temp Sensor Trip Flag + // BIT4: Reserved + // BIT5: Reserved + // BIT6: Reserved + // BIT7: Reserved CHGR, 16, // Charge Rate
Offset(0x70), @@ -242,12 +195,11 @@ TER2, 8, // Charger Temperature, Charger thermistor support
Offset(0x7F), - LSTE, 1, // Lid feature - // BIT0LID GPI - , 7, // Reserved + LIDS, 1, // BIT0 LID GPI + , 7, // Reserved
Offset(0x80), - ECWR, 8, // AC & Battery status + ECPS, 8, // AC & Battery status XX10, 8, // Battery#1 Model Number Code XX11, 16, // Battery#1 Serial Number B1DC, 16, // Battery#1 Design Capacity @@ -320,15 +272,11 @@ CTL7, 8,
Offset(0xF0), - , 3,// BIT0 .. BIT2 Reserved - TPCC, 1,// BIT3 TypeC connection bit - , 2,// BIT4 .. BIT5 Reserved - DRMD, 1,// Bit6 Dual Role Mode. 0->DFP: Host mode; 1->UFP: Device Mode. - , 1,// BIT7 Reserved - } - - Method (ECMD, 0, Serialized) - { + , 3, // BIT0 .. BIT2 Reserved + TPCC, 1, // BIT3 TypeC connection bit + , 2, // BIT4 .. BIT5 Reserved + DRMD, 1, // Bit6 Dual Role Mode. 0->DFP: Host mode; 1->UFP: Device Mode. + , 1, // BIT7 Reserved }
Method (ECWT, 2, Serialized,,, {IntObj, FieldUnitObj}) @@ -371,9 +319,9 @@ #include "ac.asl" #include "lid.asl"
- // Method(_Q45) // SMM Mode - Not used in coreboot - // { - // SMB2 = 0xC1 - // } + Method(_Q45) // SMM Mode + { + SMB2 = 0xC1 + } } } diff --git a/src/ec/starlabs/it8987/acpi/hid.asl b/src/ec/starlabs/it8987/acpi/hid.asl index 25e3cd2..7f6b405 100644 --- a/src/ec/starlabs/it8987/acpi/hid.asl +++ b/src/ec/starlabs/it8987/acpi/hid.asl @@ -1,26 +1,21 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-Device (HIDD) +Device (HIDD) // HID APCI Device { - Name (_HID, "INT33D5") - Name (HBSY, Zero) - Name (HIDX, Zero) - Name (HMDE, Zero) - Name (HRDY, Zero) - Name (BTLD, Zero) - Name (BTS1, Zero) - Name (HEB1, 0x3003) + Name (_HID, "INT33D5") // Intel Ultrabook HID Platform Event Driver. + Name (HBSY, 0) // HID Busy + Name (HIDX, 0) // HID Index + Name (HMDE, 0) // HID Mode + Name (HRDY, 0) // HID Ready + Name (BTLD, 0) // Button Driver Loaded + Name (BTS1, 0) // Button Status
- Method (_STA, 0, Serialized) // _STA: Status + Method (_STA, 0, Serialized) // Status Method { - If ((OSYS >= 0x07DD)) - { - Return (0x0F) - } - Else - { - Return (Zero) - } + // Usually, ACPI will check if the OS is 0x07DD (2013 - Windows 8.1ish) + // before showing the HID event filter. Seeing as we use Linux we show + // it regardless. + Return (0x0F) }
Method (HDDM, 0, Serialized) @@ -39,8 +34,8 @@ Method (HDEM, 0, Serialized) { Store ("-----> HDEM", Debug) - HBSY = Zero - If ((HMDE == Zero)) + HBSY = 0 + If ((HMDE == 0)) { Return (HIDX) } @@ -62,181 +57,67 @@ Method (HPEM, 1, Serialized) { Store ("-----> HPEM", Debug) - HBSY = One + HBSY = 1 HIDX = Arg0
- Notify (HIDD, 0xC0) - Local0 = Zero + Notify (^^HIDD, 0xC0) + Local0 = 0 While ((Local0 < 0xFA) && HBSY) { Sleep (0x04) Local0++ }
- If (HBSY == One) + If (HBSY == 1) { - HBSY = Zero - HIDX = Zero - Return (One) + HBSY = 0 + HIDX = 0 + Return (1) } Else { - Return (Zero) + Return (0) } }
Method (BTNL, 0, Serialized) { - Store ("-----> BTNL", Debug) - If (CondRefOf (_SB.PWRB.PBST)) - { - _SB.PWRB.PBST = Zero - Notify (PWRB, One) // Device Check - } - - BTLD = One -// If ((AEAB == One)) -// { - BTS1 = 0x1F - _SB.PCI0.LPCB.H_EC.ECWT (BTS1, RefOf (_SB.PCI0.LPCB.H_EC.BTEN)) -// } -// Else -// { -// BTS1 = Zero -// } + BTS1 = 0 }
Method (BTNE, 1, Serialized) { Store ("-----> BTNE", Debug) -// If ((AEAB == One)) -// { - BTS1 = ((Arg0 & 0x1E) | One) - _SB.PCI0.LPCB.H_EC.ECWT (BTS1, RefOf (_SB.PCI0.LPCB.H_EC.BTEN)) -// } + Return(BTS1) }
Method (BTNS, 0, Serialized) { Store ("-----> BTNS", Debug) -// If ((AEAB == One)) -// { - BTS1 = _SB.PCI0.LPCB.H_EC.ECRD (RefOf (_SB.PCI0.LPCB.H_EC.BTEN)) -// } Return (BTS1) }
Method (BTNC, 0, Serialized) { Store ("-----> BTNC", Debug) -// If ((AEAB == One)) -// { - Return (0x1F) -// } -// Else -// { -// Return (Zero) -// } + Return (0x1F) }
- Name (HEB2, Zero) - Method (HEBC, 0, Serialized) - { + Method (HEBC,0,Serialized) { Store ("-----> HEBC", Debug) -// If ((AHDB == One)) -// { -// Return (\HEB1) -// } -// Else -// { - Return (Zero) -// } + Return (0) }
Method (H2BC, 0, Serialized) { Store ("-----> H2BC", Debug) -// If ((AHDB == One)) -// { -// Return (\HEB1) -// } -// Else -// { - Return (Zero) -// } + Return (0) }
Method (HEEC, 0, Serialized) { Store ("-----> HEEC", Debug) -// If ((AHDB == One)) -// { - Return (HEB2) /* _SB_.HIDD.HEB2 */ -// } -// Else -// { -// Return (Zero) -// } - } - - Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method - { - If ((Arg0 == ToUUID ("eeec56b3-4442-408f-a792-4edd4d758054"))) - { - If ((One == ToInteger (Arg1))) - { - Switch (ToInteger (Arg2)) - { - Case (Zero) - { - Return (Buffer (0x02) - { - 0xFF, 0x03 - }) - } - Case (One) - { - BTNL () - } - Case (0x02) - { - Return (HDMM ()) - } - Case (0x03) - { - HDSM (DerefOf (Arg3 [Zero])) - } - Case (0x04) - { - Return (HDEM ()) - } - Case (0x05) - { - Return (BTNS ()) - } - Case (0x06) - { - BTNE (DerefOf (Arg3 [Zero])) - } - Case (0x07) - { - Return (HEBC ()) - } - Case (0x08) - { - } - Case (0x09) - { - Return (H2BC ()) - } - } - } - } - - Return (Buffer (One) - { - 0x00 - }) + Return (0) } }
diff --git a/src/ec/starlabs/it8987/acpi/keyboard.asl b/src/ec/starlabs/it8987/acpi/keyboard.asl index f5b1d52..c78bfed 100644 --- a/src/ec/starlabs/it8987/acpi/keyboard.asl +++ b/src/ec/starlabs/it8987/acpi/keyboard.asl @@ -19,18 +19,23 @@ Method(_Q99) // Wireless mode { Store ("-----> _Q99", Debug) - _SB.HIDD.HPEM(8) - Store ("<----- _Q80", Debug) + ^^^^HIDD.HPEM (8) + Store ("<----- _Q99", Debug) }
Method(_Q06) // Brightness decrease { - _SB.PCI0.GFX0.DECB() + ^^^^HIDD.HPEM (20) }
Method(_Q07) // Brightness increase { - _SB.PCI0.GFX0.INCB() + ^^^^HIDD.HPEM (19) +} + +Method (_Q0E) +{ + FNLC = FNST }
Method(_Q08) // FN lock QEvent @@ -41,10 +46,6 @@ Method(_Q54) // Power Button Event { Store ("-----> _Q54", Debug) - If (CondRefOf (_SB.PWRB)) - { - Notify(_SB.PWRB, 0x80) - } Store ("<----- _Q54", Debug) }
diff --git a/src/ec/starlabs/it8987/acpi/lid.asl b/src/ec/starlabs/it8987/acpi/lid.asl index 22e8eeb..306a270 100644 --- a/src/ec/starlabs/it8987/acpi/lid.asl +++ b/src/ec/starlabs/it8987/acpi/lid.asl @@ -3,45 +3,22 @@ Device (LID0) { Name (_HID, EisaId ("PNP0C0D")) - - Method (_STA, 0, NotSerialized) + Method (_LID, 0) { - DEBUG = "---> IT8987 LID: _STA" - Return (0x0F) - } - - Method (_PSW, 1, NotSerialized) - { - DEBUG = Concatenate ("---> IT8987 LID: _PSW", ToHexString(Arg0)) - } - - Method (_LID, 0, NotSerialized) - { - DEBUG = "---> IT8987 LID: _LID" - If (_SB.PCI0.LPCB.H_EC.ECRD (RefOf (_SB.PCI0.LPCB.H_EC.LSTE)) == 0x01) - { - Local0 = 1 - } - else - { - Local0 = 0 - } - Return (Local0) + Return (^^LIDS) } }
Method (_Q0C, 0, NotSerialized) // Lid close event { - DEBUG = "---> IT8987 LID: Q0C (close event)" - LIDS = 0 - \LIDS = LIDS + Store ("EC: LID CLOSE", Debug) + Store (LIDS, \LIDS) Notify (LID0, 0x80) }
Method (_Q0D, 0, NotSerialized) // Lid open event { - DEBUG = "---> IT8987 LID: Q0D (open event)" - LIDS = 1 - \LIDS = LIDS + Store ("EC: LID OPEN", Debug) + Store (LIDS, \LIDS) Notify (LID0, 0x80) } diff --git a/src/ec/starlabs/it8987/acpi/thermal.asl b/src/ec/starlabs/it8987/acpi/thermal.asl index 6bf25bf..a112fa2 100644 --- a/src/ec/starlabs/it8987/acpi/thermal.asl +++ b/src/ec/starlabs/it8987/acpi/thermal.asl @@ -2,13 +2,5 @@
Method(_QF0) // Thermal event. { - If (LEqual (DBGS, 0x00)) - { - /* Only handle the numerous thermal events if we are */ - /* NOT doing ACPI Debugging. */ - If (CondRefOf (_TZ.TZ01)) - { - Notify (_TZ.TZ01, 0x80) - } - } + Notify (_TZ.TZ01, 0x80 } diff --git a/src/ec/starlabs/it8987/ec.c b/src/ec/starlabs/it8987/ec.c index b555d28..131f942 100644 --- a/src/ec/starlabs/it8987/ec.c +++ b/src/ec/starlabs/it8987/ec.c @@ -11,7 +11,7 @@ #include "ec.h" #include "chip.h"
-u16 it8987_get_version(void) +u16 it_get_version(void) { return (ec_read(0x00) << 8) | ec_read(0x01); } diff --git a/src/ec/starlabs/it8987/ec.h b/src/ec/starlabs/it8987/ec.h index c6d5a7a..423c874 100644 --- a/src/ec/starlabs/it8987/ec.h +++ b/src/ec/starlabs/it8987/ec.h @@ -43,6 +43,6 @@ #define ECRAM_FN_CTRL_REVERSE 0x08 #define ECRAM_FN_LOCK_STATE 0x2C
-u16 it8987_get_version(void); +u16 it_get_version(void);
#endif