Sean Rhodes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57268 )
Change subject: ec/starlabs/it8987: Nit, generally tidy up ......................................................................
ec/starlabs/it8987: Nit, generally tidy up
* Remove commented original code * Standardise values (Zero or 0)
Signed-off-by: Sean Rhodes sean@starlabs.systems Change-Id: Id0f30bdbc97b95a8b2153c3ecb6aa49f170403a0 --- 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 7 files changed, 76 insertions(+), 227 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/57268/1
diff --git a/src/ec/starlabs/it8987/acpi/battery.asl b/src/ec/starlabs/it8987/acpi/battery.asl index b76720f..786ad05 100644 --- a/src/ec/starlabs/it8987/acpi/battery.asl +++ b/src/ec/starlabs/it8987/acpi/battery.asl @@ -2,12 +2,12 @@
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 (ECPS & 0x02) { @@ -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 d456891..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)
@@ -79,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) }
@@ -101,39 +88,13 @@ 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. - - // 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 (ECPS)) & 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 (ECPS)) & 0x01) - } - PNOT() - } + // Inform platform code + \PNOT ()
/* Initialize LID switch state */ Store (LIDS, \LIDS) @@ -141,25 +102,17 @@ // 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) @@ -171,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 @@ -214,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 @@ -224,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), @@ -243,7 +197,6 @@ Offset(0x7F), LIDS, 1, // BIT0 LID GPI , 7, // Reserved - , 7, // Reserved
Offset(0x80), ECPS, 8, // AC & Battery status @@ -319,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}) @@ -370,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 6c68656..7f6b405 100644 --- a/src/ec/starlabs/it8987/acpi/hid.asl +++ b/src/ec/starlabs/it8987/acpi/hid.asl @@ -34,8 +34,8 @@ Method (HDEM, 0, Serialized) { Store ("-----> HDEM", Debug) - HBSY = Zero - If ((HMDE == Zero)) + HBSY = 0 + If ((HMDE == 0)) { Return (HIDX) } @@ -57,26 +57,26 @@ 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) } }
@@ -88,134 +88,36 @@ 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 6821028..c78bfed 100644 --- a/src/ec/starlabs/it8987/acpi/keyboard.asl +++ b/src/ec/starlabs/it8987/acpi/keyboard.asl @@ -33,6 +33,11 @@ ^^^^HIDD.HPEM (19) }
+Method (_Q0E) +{ + FNLC = FNST +} + Method(_Q08) // FN lock QEvent { FNLC = FNST diff --git a/src/ec/starlabs/it8987/acpi/lid.asl b/src/ec/starlabs/it8987/acpi/lid.asl index 441145e..306a270 100644 --- a/src/ec/starlabs/it8987/acpi/lid.asl +++ b/src/ec/starlabs/it8987/acpi/lid.asl @@ -3,7 +3,6 @@ Device (LID0) { Name (_HID, EisaId ("PNP0C0D")) - Method (_LID, 0) { Return (^^LIDS) 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 e40b6f2..7443732 100644 --- a/src/ec/starlabs/it8987/ec.c +++ b/src/ec/starlabs/it8987/ec.c @@ -69,10 +69,10 @@ };
static struct pnp_info pnp_dev_info[] = { - NULL, - 0, - 0, - 0, + { NULL, + 0, + 0, + 0, } };
static void enable_dev(struct device *dev)