Sean Rhodes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56089 )
Change subject: ec: Support specific Q events for different models ......................................................................
ec: Support specific Q events for different models
Add/remove certain events that are only used on specific models that share the same EC
Signed-off-by: Sean Rhodes sean@starlabs.systems Change-Id: I08c4fa7802019038cca7a7c9abfd3af52cf029c3 --- A src/ec/starlabs/it5570/Kconfig A src/ec/starlabs/it5570/Makefile.inc A src/ec/starlabs/it5570/acpi/ac.asl A src/ec/starlabs/it5570/acpi/battery.asl A src/ec/starlabs/it5570/acpi/cmos.asl A src/ec/starlabs/it5570/acpi/ec.asl A src/ec/starlabs/it5570/acpi/hid.asl A src/ec/starlabs/it5570/acpi/keyboard.asl A src/ec/starlabs/it5570/acpi/lid.asl A src/ec/starlabs/it5570/acpi/thermal.asl A src/ec/starlabs/it5570/chip.h A src/ec/starlabs/it5570/ec.c A src/ec/starlabs/it5570/ec.h 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/ec.c M src/ec/starlabs/it8987/ec.h M src/mainboard/starlabs/labtop/Kconfig 23 files changed, 846 insertions(+), 34 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/56089/1
diff --git a/src/ec/starlabs/it5570/Kconfig b/src/ec/starlabs/it5570/Kconfig new file mode 100644 index 0000000..7651757 --- /dev/null +++ b/src/ec/starlabs/it5570/Kconfig @@ -0,0 +1,7 @@ +## SPDX-License-Identifier: GPL-2.0-only + +config EC_STARLABS_IT5570 + bool + select EC_ACPI + help + Interface to IT8987 embedded controller principally in Star Labs notebooks. diff --git a/src/ec/starlabs/it5570/Makefile.inc b/src/ec/starlabs/it5570/Makefile.inc new file mode 100644 index 0000000..3d93ab5 --- /dev/null +++ b/src/ec/starlabs/it5570/Makefile.inc @@ -0,0 +1,26 @@ +## SPDX-License-Identifier: GPL-2.0-only + +PHONY+=add_ite_fw +INTERMEDIATE+=add_ite_fw + +ifeq ($(CONFIG_EC_STARLABS_IT5570),y) +all-y += ec.c +smm-$(CONFIG_DEBUG_SMI) += ec.c + +ifeq ($(CONFIG_EC_STARLABS_IT_BIN),y) +add_ite_fw: $(obj)/coreboot.pre + $(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_EC_STARLABS_IT_BIN_PATH) -u +endif + +ifeq ($(CONFIG_EC_STARLABS_IT_BIN_PATH),) +files_added:: warn_no_ite_fw +endif + +PHONY+=warn_no_ite_fw +warn_no_ite_fw: + printf "\n\t** WARNING **\n" + printf "coreboot has been built without the IT5570 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 diff --git a/src/ec/starlabs/it5570/acpi/ac.asl b/src/ec/starlabs/it5570/acpi/ac.asl new file mode 100644 index 0000000..21c848f --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/ac.asl @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device (ADP1) +{ + Name (_HID, "ACPI0003") + Name (_PCL, Package () { _SB }) + + Method (_STA, 0, NotSerialized) // _STA: Status + { + Return (0x0F) + } + + Method (_PSR, 0, NotSerialized) // _PSR: Power Source + { + If (ECRD (RefOf (ECPS)) & 0x01) + { + PWRS = 1 + } + Else + { + PWRS = 0 + } + Return (PWRS) + } +} + +Method (_Q0A, 0, NotSerialized) +{ + Notify(BAT0, 0x81) + Notify(ADP1, 0x80) +} + +Method (_Q0B, 0, NotSerialized) +{ + Notify(BAT0, 0x81) + Notify(BAT0, 0x80) +} diff --git a/src/ec/starlabs/it5570/acpi/battery.asl b/src/ec/starlabs/it5570/acpi/battery.asl new file mode 100644 index 0000000..a40b124 --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/battery.asl @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device(BAT0) +{ + Name(_HID, EISAID("PNP0C0A")) + Name(_UID, 1) + Name (_PCL, Package () { _SB }) + + Method(_STA, 0) + { + If(And(ECRD(RefOf(ECPS)), 0x02)) + { + Return(0x1F) + } + Return(0x0F) + } + + Name(BPKG, Package() { + 1, // 0: Power Unit + 0xFFFFFFFF, // 1: Design Capacity + 0xFFFFFFFF, // 2: Last Full Charge Capacity + 1, // 3: Battery Technology(Rechargeable) + 0xFFFFFFFF, // 4: Design Voltage 10.8V + 0, // 5: Design capacity of warning + 0, // 6: Design capacity of low + 0x00000100, // 7: Battery capacity granularity 1 + 0x00000040, // 8: Battery capacity granularity 2 + "CN6613-2S3P", // 9: Model Number + "6UA3", // 10: Serial Number + "Real", // 11: Battery Type + "GDPT" // 12: OEM Information + }) + + Name (B1CN, "Real") + + Method(_BIF, 0, Serialized) + { + BPKG[1] = ECRD (RefOf(B1DC)) + BPKG[2] = ECRD (RefOf(B1FC)) + BPKG[4] = ECRD (RefOf(B1DV)) + + If(ECRD(RefOf(B1FC))) + { + BPKG[5] = ECRD (RefOf(B1FC)) / 10 + BPKG[6] = ECRD (RefOf(B1FC)) / 25 + BPKG[7] = ECRD (RefOf(B1DC)) / 100 + } + Return(BPKG) + } + + Name(PKG1, Package() { + 0xFFFFFFFF, // Battery State. + 0xFFFFFFFF, // Battery Present Rate. (in mWh) + 0xFFFFFFFF, // Battery Remaining Capacity. (in mWh) + 0xFFFFFFFF // Battery Present Voltage. (in mV) + }) + + Method(_BST, 0, Serialized) + { + PKG1[0] = ECRD (RefOf(B1ST)) & 0x07 + PKG1[1] = ECRD (RefOf(B1PR)) + PKG1[2] = ECRD (RefOf(B1RC)) + PKG1[3] = ECRD (RefOf(B1PV)) + Return(PKG1) + } +} diff --git a/src/ec/starlabs/it5570/acpi/cmos.asl b/src/ec/starlabs/it5570/acpi/cmos.asl new file mode 100644 index 0000000..052094c --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/cmos.asl @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +OperationRegion (CMOS, SystemIO, 0x70, 0x02) +Field (CMOS, ByteAcc, NoLock, Preserve) +{ + NVRI, 8, + NVRD, 8 +} + +IndexField (NVRI, NVRD, ByteAcc, NoLock, Preserve) +{ + Offset (0x40), + KBBL, 8, // Keyboard backlight timeout + FNSW, 8, // Ctrl Fn Reverse (make keyboard Apple-like) + + Offset (0x7D), + FNLC, 8 // Current state of Fn Lock key. +} diff --git a/src/ec/starlabs/it5570/acpi/ec.asl b/src/ec/starlabs/it5570/acpi/ec.asl new file mode 100644 index 0000000..c4a002d --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/ec.asl @@ -0,0 +1,196 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#define ASL_PVOL_DEFOF_NUM 0xe8 + +Scope (_SB) +{ + #include "hid.asl" +} + +Scope (_SB.PCI0) +{ + // Add the entries for the PS/2 keyboard and mouse. + #include <drivers/pc80/pc/ps2_controller.asl> +} + +Scope (_SB.PCI0.LPCB) +{ + // Include the definitions for accessing CMOS. + #include "cmos.asl" + + // Our embedded controller device. + Device (H_EC) + { + Name(_HID, EISAID("PNP0C09")) + Name(_UID,1) + Name(ECAV, Zero) // OS Bug Checks if EC OpRegion accessed before Embedded Controller Driver loaded + Name(ECTK, One) // ECDT (Embedded Controller Boot Resources Table) Check to correct ECAV flag in the beginning + Name(LIDS, 0) + + Mutex(ECMT, 0) // EC Mutex + + Name (BFFR, ResourceTemplate() + { + IO(Decode16, 0x62, 0x62, 0, 1) // DIN/DOUT + IO(Decode16, 0x66, 0x66, 0, 1) // CMD/STS + }) + + Method (_CRS, 0, Serialized) + { + Return(BFFR) + } + + Method (_STA, 0, NotSerialized) + { + // Store (0x03, _SB.PCI0.GFX0.CLID) + Return (0x0F) + } + + Method (_REG, 2) + { + If ((Arg0 == 0x03) && (Arg1 == 0x01)) + { + EREG() + } + } + + OperationRegion (SMIP,SystemIO, 0xB2, 0x1) + Field (SMIP, ByteAcc, Lock, Preserve) { + SMB2, 8 + } + + // EC RAM fields + OperationRegion(ECF2, EmbeddedControl, 0, 0xFF) + Field (ECF2, ByteAcc, Lock, Preserve) + { + Offset(0x00), + ECMV, 8, //0x00 EC Firmware main version + ECSV, 8, //0x01 EC Firmware sub version + KBVS, 8, //0x02 Keyboard revision + ECTV, 8, //0x03 EC Firmware test version + OSFG, 8, //0X04 Flag for enter OS //ICL_010+ + + Offset(0x2C), + FNST, 8, + + Offset(0x7F), //Support LID feature + LSTE, 1, //BIT0LID GPI + , 7, //Reserved + + Offset(0x80), + ECPS, 8, //0x80 AC & Battery status + B1MN, 8, //0x81 Battery#1 Model Number Code + B1SN, 16, //0x82~83 Battery#1 Serial Number + B1DC, 16, //0x84~85 Battery#1 Design Capacity + B1DV, 16, //0x86~87 Battery#1 Design Voltage + B1FC, 16, //0x88~89 Battery#1 Last Full Charge Capacity + B1TP, 16, //0x8A~8B Battery#1 Trip Point + B1ST, 8, //0x8C Battery#1 State + B1PR, 16, //0x8D~8E Battery#1 Present Rate + B1RC, 16, //0x8F~90 Battery#1 Remaining Capacity + B1PV, 16, //0x91~92 Battery#1 Present Voltage + B1RP, 8, //0x93 Battery#1 Remaining percentage + } + + Method (ECRD, 1, Serialized, 0, IntObj, FieldUnitObj) + { + // Check for ECDT support, set ECAV to One if ECDT is supported by OS + // Only check once at beginning since ECAV might be clear later in certain conditions + If (ECTK) + { + If (_REV >= 2) + { + ECAV = 0x01 + } + ECTK = 0x00 // Clear flag for checking once only + } + + Local0 = Acquire(ECMT, 1000) // save Acquire result so we can check for Mutex acquired + If (Local0 == 0x00) + { + If (ECAV) + { + Store(DerefOf (Arg0), Local1) // Execute Read from EC + Release(ECMT) + Return(Local1) + } + Else + { + Release(ECMT) + } + } + Return(0) + } + + Method(ECWT,2,Serialized,,, {IntObj, FieldUnitObj}) + { + If (ECTK) + { + If (_REV >= 2) + { + ECAV = 1 + } + ECTK = 0x00 + } + + Local0 = Acquire(ECMT, 1000) // save Acquire result so we can check for Mutex acquired + If (Local0 == 0x00) + { + If (ECAV) + { + Arg1 = Arg0 // Execute Write to EC + } + Release(ECMT) + } + } + + // EREG method will be used in _REG (evaluated by OS without + // ECDT support) or _INI (for OS with ECDT support) + Method (EREG) + { + // Update ECAV Object. ASL should check for this value + // to be 1 before accessing EC OpRegion. + ECAV = 1 + + LIDS = ECRD (RefOf (LSTE)) + + // Report OSFG to notify EC + ECWT(0x01, RefOf (OSFG)) + + // Save the current Power State for later. + // PWRS = Local0 + + // Update power state + PWRS = (ECRD (RefOf (ECPS)) & 0x01) + + //_SB.CPPC = 0x00 // Note: _SB.CPPC must be an Integer not a Method + + //Perform needed ACPI Notifications. + PNOT() + } + + Method(_GPE) + { + Local0 = 0x6E // GPI6E for eSPI + Return (Local0) + } + + Method (PTS, 1, Serialized) + { + Debug = Concatenate("EC: PTS: ", ToHexString(Arg0)) + _SB.PCI0.LPCB.H_EC.OSFG = 0 + } + + Method (WAK, 1, Serialized) + { + Debug = Concatenate("EC: WAK: ", ToHexString(Arg0)) + _SB.PCI0.LPCB.H_EC.OSFG = 1 + } + + // Include the other parts of the Embedded Controller ASL. + #include "keyboard.asl" + #include "battery.asl" + #include "ac.asl" + #include "lid.asl" + } +} diff --git a/src/ec/starlabs/it5570/acpi/hid.asl b/src/ec/starlabs/it5570/acpi/hid.asl new file mode 100644 index 0000000..7f23018 --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/hid.asl @@ -0,0 +1,179 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device(HIDD) //HID ACPI Device. +{ + Name(_HID,"INTC1051") // 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) + { + If (OSYS > 2013) { + Return(0x0F) + } Else { + Return(0) + } + } + + Method(HDDM,0,Serialized) + { + // Placeholder. + Name(DPKG, Package(4) {0x11111111, 0x22222222, 0x33333333, 0x44444444}) + Return(DPKG) + } + + Method(HDEM,0,Serialized) + { + HBSY = 0x00 // Clear HID Busy. + If (LEqual(HMDE,0)) + { + Return(HIDX) + } + Return(HMDE) + } + + Method(HDMM,0,Serialized) + { + Return(HMDE) // Return Mode of operation. + } + + Method(HDSM,1,Serialized) + { + HRDY = Arg0 // Store HID Ready Status. + } + + Method(HPEM,1,Serialized) // HID Platform Event Method. + { + HBSY = 1 + If (LEqual(HMDE,0)) + { + HIDX = Arg0 + } Else { + HIDX = Arg0 + } + Notify(_SB.HIDD,0xC0) + Local0 = 0 + While((Local0 < 250) && (HBSY)) + { + Sleep(4) + Increment(Local0) + } + If (HBSY <= 1) + { + HBSY = 0 + HIDX = 0 + Return(1) + } Else { + Return(0) + } + } + + Method(BTNL,0,Serialized) + { + BTS1 = 0 + } + + Method(BTNE,1,Serialized) + { + Return(BTS1) + } + + Method(BTNS,0,Serialized) + { + Return(BTS1) + } + + Method(BTNC,0,Serialized) // HID Button Capabilities Method + { + Return(0x1F) + } + + Method (HEBC,0,Serialized) { + Return (0x00063002) + } + + Method (H2BC,0,Serialized) { + Return (0x00063002) + } + + Method (HEEC,0,Serialized) { + Return(0) + } + + Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj}) + { + If (LEqual(Arg0, ToUUID ("EEEC56B3-4442-408F-A792-4EDD4D758054"))) + { + If (LEqual(1,ToInteger(Arg1))) + { + Switch (ToInteger(Arg2)) + { + Case (0) + { + Return (Buffer() {0xFF, 0x03}) + } + + Case (1) + { + BTNL() + } + + Case (2) + { + Return(HDMM()) + } + + Case (3) + { + HDSM(DeRefOf(Index(Arg3, 0))) + } + + Case (4) + { + Return(HDEM()) + } + + Case (5) + { + Return(BTNS()) + } + + Case (6) + { + BTNE(DeRefOf(Index(Arg3, 0))) + } + + Case (7) + { + Return(HEBC()) + } + + Case (8) + { + Return(0x40) + } + + Case (9) + { + Return(H2BC()) + } + } + } + } + Return (Buffer() {0x00}) + } +} + +Method(PWPR, 0, Serialized) // Power Button Press Helper Method +{ + Notify(_SB.HIDD,0xCE) // Notify HID driver that Power button is pressed. +} + +Method(PWRR, 0, Serialized) // Power Button Release Helper Method +{ + Notify(_SB.HIDD,0xCF) // Notify HID driver that Power button is released. +} diff --git a/src/ec/starlabs/it5570/acpi/keyboard.asl b/src/ec/starlabs/it5570/acpi/keyboard.asl new file mode 100644 index 0000000..f5b1d52 --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/keyboard.asl @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Method(_Q80) // Volume up +{ + Store ("-----> _Q80", Debug) + Notify (_SB.HIDD, 0xC4) + Notify (_SB.HIDD, 0xC5) + Store ("<----- _Q80", Debug) +} + +Method(_Q81) // Volume down +{ + Store ("-----> _Q81", Debug) + Notify (_SB.HIDD, 0xC6) + Notify (_SB.HIDD, 0xC7) + Store ("<----- _Q81", Debug) +} + +Method(_Q99) // Wireless mode +{ + Store ("-----> _Q99", Debug) + _SB.HIDD.HPEM(8) + Store ("<----- _Q80", Debug) +} + +Method(_Q06) // Brightness decrease +{ + _SB.PCI0.GFX0.DECB() +} + +Method(_Q07) // Brightness increase +{ + _SB.PCI0.GFX0.INCB() +} + +Method(_Q08) // FN lock QEvent +{ + FNLC = FNST +} + +Method(_Q54) // Power Button Event +{ + Store ("-----> _Q54", Debug) + If (CondRefOf (_SB.PWRB)) + { + Notify(_SB.PWRB, 0x80) + } + Store ("<----- _Q54", Debug) +} + +Method(_QD5) // 10 second power button press +{ + Store ("-----> _QD5", Debug) + _SB.PWPR() + Store ("<----- _QD5", Debug) +} + +Method(_QD6) // 10 second power button de-press +{ + Store ("-----> _QD6", Debug) + _SB.PWRR() + Store ("<----- _QD6", Debug) +} diff --git a/src/ec/starlabs/it5570/acpi/lid.asl b/src/ec/starlabs/it5570/acpi/lid.asl new file mode 100644 index 0000000..2295a24 --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/lid.asl @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +Device (LID0) +{ + Name (_HID, EisaId ("PNP0C0D")) + + Method (_STA, 0, NotSerialized) + { + DEBUG = "---> IT5570 LID: _STA" + Return (0x0F) + } + + + Method (_LID, 0, NotSerialized) + { + DEBUG = "---> IT5570 LID: _LID" + If (_SB.PCI0.LPCB.H_EC.ECRD (RefOf (_SB.PCI0.LPCB.H_EC.LSTE)) == 0x01) + { + Local0 = 1 + } + else + { + Local0 = 0 + } + Return (Local0) + } +} + +Method (_Q0C, 0, NotSerialized) // Lid close event +{ + DEBUG = "---> IT5570 LID: Q0C (close event)" + LIDS = 0 + \LIDS = _SB.PCI0.LPCB.H_EC.LIDS + Notify (LID0, 0x80) +} + +Method (_Q0D, 0, NotSerialized) // Lid open event +{ + DEBUG = "---> IT5570 LID: Q0D (open event)" + LIDS = 1 + \LIDS = _SB.PCI0.LPCB.H_EC.LIDS + Notify (LID0, 0x80) +} diff --git a/src/ec/starlabs/it5570/acpi/thermal.asl b/src/ec/starlabs/it5570/acpi/thermal.asl new file mode 100644 index 0000000..a112fa2 --- /dev/null +++ b/src/ec/starlabs/it5570/acpi/thermal.asl @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Method(_QF0) // Thermal event. +{ + Notify (_TZ.TZ01, 0x80 +} diff --git a/src/ec/starlabs/it5570/chip.h b/src/ec/starlabs/it5570/chip.h new file mode 100644 index 0000000..d822358 --- /dev/null +++ b/src/ec/starlabs/it5570/chip.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _EC_STARLABS_IT5570_CHIP_H +#define _EC_STARLABS_IT5570_CHIP_H + +struct ec_starlabs_it5570_config { + u8 cpuhot_limit; /* temperature in °C which asserts PROCHOT# */ +}; + +#endif /* _EC_STARLABS_IT5570_CHIP_H */ diff --git a/src/ec/starlabs/it5570/ec.c b/src/ec/starlabs/it5570/ec.c new file mode 100644 index 0000000..8ed2e87 --- /dev/null +++ b/src/ec/starlabs/it5570/ec.c @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/device.h> +#include <device/pnp.h> +#include <pc80/keyboard.h> +#include <ec/acpi/ec.h> +#include <delay.h> +#include <option.h> + +#include "ec.h" +#include "chip.h" + +u16 it_get_version(void) +{ + return (ec_read(0x00) << 8) | ec_read(0x01); +} + +static void it5570_init(struct device *dev) +{ + if (!dev->enabled) + return; + + /* + * The address/data IO port pair for the it5570 EC are configurable + * through the EC domain and are fixed by the EC's firmware blob. If + * the value(s) passed through the "dev" structure don't match the + * expected values then output severe warnings. + */ + if (dev->path.pnp.port != IT5570E_FIXED_ADDR) { + printk(BIOS_ERR, "IT5570: Incorrect ports defined in devicetree.cb.\n"); + printk(BIOS_ERR, "IT5570: Serious operational issues will arise.\n"); + return; + } + + u8 chipid1 = pnp_read_index(dev->path.pnp.port, IT5570_CHIPID1); + u8 chipid2 = pnp_read_index(dev->path.pnp.port, IT5570_CHIPID2); + if (chipid1 != IT5570_CHIPID1_VAL || chipid2 != IT5570_CHIPID2_VAL) { + printk(BIOS_DEBUG, "IT5570: Device not found.\n"); + return; + } + + printk(BIOS_DEBUG, "IT5570: Initializing keyboard.\n"); + pc_keyboard_init(NO_AUX_DEVICE); + + /* Enable the keyboard backlight support. */ + ec_write(0x18, 0xaa); + ec_write(0x19, 0xdd); + + /* Set the timeout for the keyboard backlight. */ + ec_write(ECRAM_KBL_TIMEOUT, get_uint_option("kbl_timeout", 0)); + + /* + * Set the correct state for the Ctrl Fn Reverse option. This + * swaps the Ctrl and Fn keys to make it like an Apple keyboard. + */ + ec_write(ECRAM_FN_CTRL_REVERSE, get_uint_option("fn_ctrl_swap", 0)); + /* + * Copy the stored state of the fn_lock_state CMOS variable to the + * corresponding location within the EC RAM. + */ + ec_write(ECRAM_FN_LOCK_STATE, get_uint_option("fn_lock_state", 0)); +} + +static struct device_operations ops = { + .init = it5570_init, + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, +}; + +static struct pnp_info pnp_dev_info[] = { + { NULL, 0, 0, 0, } +}; + +static void enable_dev(struct device *dev) +{ + pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); +} + +struct chip_operations ec_starlabs_it5570_ops = { + CHIP_NAME("ITE IT5570 EC") + .enable_dev = enable_dev +}; diff --git a/src/ec/starlabs/it5570/ec.h b/src/ec/starlabs/it5570/ec.h new file mode 100644 index 0000000..20da6db --- /dev/null +++ b/src/ec/starlabs/it5570/ec.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * EC communication interface for ITE IT5570 Embedded Controller. + */ + +#ifndef _EC_STARLABS_IT5570_H +#define _EC_STARLABS_IT5570_H + +/* + * Define the expected value of the PNP base address that is fixed through + * the BADRSEL register controlled within the EC domain by the binary blob. + */ +#define IT5570E_FIXED_ADDR 0x4e + +/* Logical device number (LDN) assignments. */ +#define IT5570E_SP1 0x01 /* Com1 */ +#define IT5570E_SP2 0x02 /* Com2 */ +#define IT5570E_SWUC 0x04 /* System Wake-Up */ +#define IT5570E_KBCM 0x05 /* PS/2 mouse */ +#define IT5570E_KBCK 0x06 /* PS/2 keyboard */ +#define IT5570E_IR 0x0a /* Consumer IR */ +#define IT5570E_SMFI 0x0f /* Shared Memory/Flash Interface */ +#define IT5570E_RTCT 0x10 /* RTC-like Timer */ +#define IT5570E_PMC1 0x11 /* Power Management Channel 1 */ +#define IT5570E_PMC2 0x12 /* Power Management Channel 2 */ +#define IT5570E_SSPI 0x13 /* Serial Peripheral Interface */ +#define IT5570E_PECI 0x14 /* Platform EC Interface */ +#define IT5570E_PMC3 0x17 /* Power Management Channel 3 */ +#define IT5570E_PMC4 0x18 /* Power Management Channel 4 */ +#define IT5570E_PMC5 0x19 /* Power Management Channel 5 */ + +/* Host domain registers. */ +#define IT5570_CHIPID1 0x20 /* Device ID register 1 */ +#define IT5570_CHIPID2 0x21 /* Device ID register 2 */ + +/* IT5570 chip ID byte values. */ +#define IT5570_CHIPID1_VAL 0x55 +#define IT5570_CHIPID2_VAL 0x70 + +/* EC RAM offsets. */ +#define ECRAM_KBL_TIMEOUT 0x07 +#define ECRAM_FN_CTRL_REVERSE 0x08 +#define ECRAM_FN_LOCK_STATE 0x2C + +u16 it_get_version(void); + +#endif diff --git a/src/ec/starlabs/it8987/Makefile.inc b/src/ec/starlabs/it8987/Makefile.inc index b021d0f..d2e79ac 100644 --- a/src/ec/starlabs/it8987/Makefile.inc +++ b/src/ec/starlabs/it8987/Makefile.inc @@ -6,16 +6,14 @@ 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 + $(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_EC_STARLABS_IT_BIN_PATH) -u +endif + +ifeq ($(CONFIG_EC_STARLABS_IT_BIN_PATH),) +files_added:: warn_no_ite_fw endif
PHONY+=warn_no_ite_fw @@ -24,3 +22,5 @@ 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 diff --git a/src/ec/starlabs/it8987/acpi/ac.asl b/src/ec/starlabs/it8987/acpi/ac.asl index 97ae147..5b16945 100644 --- a/src/ec/starlabs/it8987/acpi/ac.asl +++ b/src/ec/starlabs/it8987/acpi/ac.asl @@ -32,7 +32,11 @@ } }
+#if CONFIG(BOARD_STARLABS_LABTOP_KBL) +Method (_Q0A, 0, NotSerialized) // AC Power Connected +#else Method (_QA0, 0, NotSerialized) // AC Power Connected +#endif { If (ECWR & 0x01) { diff --git a/src/ec/starlabs/it8987/acpi/battery.asl b/src/ec/starlabs/it8987/acpi/battery.asl index 8936701..2dd0d96 100644 --- a/src/ec/starlabs/it8987/acpi/battery.asl +++ b/src/ec/starlabs/it8987/acpi/battery.asl @@ -75,3 +75,25 @@ Return (PKG1) } } + +// Not used in coreboot +// Device (BAT1) +// { +// Name (_HID, EISAID ("PNP0C0A")) +// Name (_UID, 1) // "Unique" that's the same as BAT0? +// Method (_STA, 0, NotSerialized) +// { +// Return (0x00) +// } +// } + +// Not used in coreboot +// Device (BAT2) +// { +// Name (_HID, EISAID ("PNP0C0A")) +// Name (_UID, 2) +// Method (_STA, 0, NotSerialized) +// { +// Return (0x00) +// } +// } diff --git a/src/ec/starlabs/it8987/acpi/ec.asl b/src/ec/starlabs/it8987/acpi/ec.asl index 451cdf1..48ea0b8 100644 --- a/src/ec/starlabs/it8987/acpi/ec.asl +++ b/src/ec/starlabs/it8987/acpi/ec.asl @@ -94,6 +94,7 @@
Method (_STA, 0, NotSerialized) { +// Store (0x03, _SB.PCI0.GFX0.CLID) If ((ECON == 1)) { Return (0x0F) @@ -102,12 +103,10 @@ Return (0x00) }
- Name (ECOK, Zero) Method(_REG, 2, NotSerialized) { If ((Arg0 == 0x03) && (Arg1 == 0x01)) { - ECOS = 1 ECAV = 1
// Unconditionally fix up the Battery and Power State. @@ -142,25 +141,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) @@ -371,9 +362,11 @@ #include "ac.asl" #include "lid.asl"
- // Method(_Q45) // SMM Mode - Not used in coreboot - // { - // SMB2 = 0xC1 - // } +#if CONFIG(BOARD_STARLABS_LABTOP_CML) + Method(_Q45) // SMM Mode + { + SMB2 = 0xC1 + } +#endif } } diff --git a/src/ec/starlabs/it8987/acpi/hid.asl b/src/ec/starlabs/it8987/acpi/hid.asl index 25e3cd2..cc6bce6 100644 --- a/src/ec/starlabs/it8987/acpi/hid.asl +++ b/src/ec/starlabs/it8987/acpi/hid.asl @@ -13,6 +13,7 @@
Method (_STA, 0, Serialized) // _STA: Status { +// If (((OSYS >= 0x07DD) && (HEFE == One))) If ((OSYS >= 0x07DD)) { Return (0x0F) diff --git a/src/ec/starlabs/it8987/acpi/keyboard.asl b/src/ec/starlabs/it8987/acpi/keyboard.asl index f5b1d52..bf9d264 100644 --- a/src/ec/starlabs/it8987/acpi/keyboard.asl +++ b/src/ec/starlabs/it8987/acpi/keyboard.asl @@ -33,6 +33,13 @@ _SB.PCI0.GFX0.INCB() }
+#if CONFIG(BOARD_STARLABS_LABTOP_KBL) +Method (_Q0E) + { + FNLC = FNST + } +#endif + 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 22e8eeb..ad02f3c 100644 --- a/src/ec/starlabs/it8987/acpi/lid.asl +++ b/src/ec/starlabs/it8987/acpi/lid.asl @@ -4,6 +4,10 @@ { Name (_HID, EisaId ("PNP0C0D"))
+#if CONFIG(BOARD_STARLABS_LABTOP_KBL) + Name (_PRW, Package() { EC_GPE_SWI, 3 }) +#endif + Method (_STA, 0, NotSerialized) { DEBUG = "---> IT8987 LID: _STA" 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 diff --git a/src/mainboard/starlabs/labtop/Kconfig b/src/mainboard/starlabs/labtop/Kconfig index 73f66b2..a730cca 100644 --- a/src/mainboard/starlabs/labtop/Kconfig +++ b/src/mainboard/starlabs/labtop/Kconfig @@ -26,7 +26,7 @@ select HAVE_IFD_BIN select HAVE_ME_BIN select EC_STARLABS_IT8987 if BOARD_STARLABS_LABTOP_CML || BOARD_STARLABS_LABTOP_KBL - select EC_STARLABS_IT5570 if BOARD_STARLABS_STARBOOK_TGL +# select EC_STARLABS_IT5570 if BOARD_STARLABS_STARBOOK_TGL select EC_STARLABS_IT_BIN if BOARD_STARLABS_LABTOP_CML || BOARD_STARLABS_STARBOOK_TGL select SYSTEM_TYPE_LAPTOP select SPI_FLASH_WINBOND if BOARD_STARLABS_LABTOP_CML || BOARD_STARLABS_STARBOOK_TGL