Philipp Deppenwiese has submitted this change. ( https://review.coreboot.org/c/coreboot/+/43612 )
Change subject: ec/system76_ec: add support for System76 EC ......................................................................
ec/system76_ec: add support for System76 EC
This adds ACPI code for System76 EC and converts system76/lemp9 to use EC_SYSTEM76_EC.
Tested on system76/lemp9.
Signed-off-by: Jeremy Soller jeremy@system76.com Change-Id: I1f693268d94b693b6764e4a3baf4c3180689f3be Reviewed-on: https://review.coreboot.org/c/coreboot/+/43612 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Philipp Deppenwiese zaolin.daisuki@gmail.com Reviewed-by: Michael Niewöhner --- A src/ec/system76/ec/Kconfig R src/ec/system76/ec/acpi/ac.asl R src/ec/system76/ec/acpi/battery.asl A src/ec/system76/ec/acpi/buttons.asl R src/ec/system76/ec/acpi/ec.asl R src/ec/system76/ec/acpi/ec_ram.asl R src/ec/system76/ec/acpi/hid.asl R src/ec/system76/ec/acpi/lid.asl R src/ec/system76/ec/acpi/s76.asl M src/mainboard/system76/lemp9/Kconfig D src/mainboard/system76/lemp9/acpi/buttons.asl M src/mainboard/system76/lemp9/acpi/mainboard.asl M src/mainboard/system76/lemp9/devicetree.cb M src/mainboard/system76/lemp9/dsdt.asl 14 files changed, 89 insertions(+), 40 deletions(-)
Approvals: build bot (Jenkins): Verified Philipp Deppenwiese: Looks good to me, approved Michael Niewöhner: Looks good to me, but someone else must approve
diff --git a/src/ec/system76/ec/Kconfig b/src/ec/system76/ec/Kconfig new file mode 100644 index 0000000..fea4743 --- /dev/null +++ b/src/ec/system76/ec/Kconfig @@ -0,0 +1,9 @@ +config EC_SYSTEM76_EC + bool + help + System76 EC + +config EC_SYSTEM76_EC_COLOR_KEYBOARD + depends on EC_SYSTEM76_EC + bool + default n diff --git a/src/mainboard/system76/lemp9/acpi/ac.asl b/src/ec/system76/ec/acpi/ac.asl similarity index 100% rename from src/mainboard/system76/lemp9/acpi/ac.asl rename to src/ec/system76/ec/acpi/ac.asl diff --git a/src/mainboard/system76/lemp9/acpi/battery.asl b/src/ec/system76/ec/acpi/battery.asl similarity index 100% rename from src/mainboard/system76/lemp9/acpi/battery.asl rename to src/ec/system76/ec/acpi/battery.asl diff --git a/src/ec/system76/ec/acpi/buttons.asl b/src/ec/system76/ec/acpi/buttons.asl new file mode 100644 index 0000000..ae85c67 --- /dev/null +++ b/src/ec/system76/ec/acpi/buttons.asl @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +Device (PWRB) +{ + Name (_HID, EisaId ("PNP0C0C")) + Name (_PRW, Package () { EC_GPE_SWI, 3 }) +} + +Device (SLPB) +{ + Name (_HID, EisaId ("PNP0C0E")) + Name (_PRW, Package () { EC_GPE_SWI, 3 }) +} diff --git a/src/mainboard/system76/lemp9/acpi/ec.asl b/src/ec/system76/ec/acpi/ec.asl similarity index 89% rename from src/mainboard/system76/lemp9/acpi/ec.asl rename to src/ec/system76/ec/acpi/ec.asl index f8496ae..5989f6d 100644 --- a/src/mainboard/system76/lemp9/acpi/ec.asl +++ b/src/ec/system76/ec/acpi/ec.asl @@ -1,9 +1,18 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-Device (EC0) +Scope (_SB) { + #include "ac.asl" + #include "battery.asl" + #include "buttons.asl" + #include "hid.asl" + #include "lid.asl" + #include "s76.asl" +} + +Device (_SB.PCI0.LPCB.EC0) { Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) // _HID: Hardware ID - Name (_GPE, 0x50 /* GPP_E16 */) // _GPE: General Purpose Events + Name (_GPE, EC_GPE_SCI) // _GPE: General Purpose Events Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IO (Decode16, @@ -20,7 +29,7 @@ ) })
- #include "acpi/ec_ram.asl" + #include "ec_ram.asl"
Name (ECOK, Zero) Method (_REG, 2, Serialized) // _REG: Region Availability @@ -39,6 +48,10 @@ ^^^^BAT0.UPBI() ^^^^BAT0.UPBS()
+ // Notify of changes + Notify(^^^^AC, Zero) + Notify(^^^^BAT0, Zero) + PNOT ()
// EC is now available @@ -71,8 +84,6 @@ Notify(^^^^AC, Zero) Notify(^^^^BAT0, Zero)
- Sleep (1000) - // Reset System76 Device ^^^^S76D.RSET() } @@ -116,13 +127,17 @@ Method (_Q11, 0, NotSerialized) // Brightness Down { Debug = "EC: Brightness Down" - ^^^^HIDD.HPEM (20) + if (^^^^HIDD.HRDY) { + ^^^^HIDD.HPEM (20) + } }
Method (_Q12, 0, NotSerialized) // Brightness Up { Debug = "EC: Brightness Up" - ^^^^HIDD.HPEM (19) + if (^^^^HIDD.HRDY) { + ^^^^HIDD.HPEM (19) + } }
Method (_Q13, 0, NotSerialized) // Camera Toggle @@ -133,10 +148,10 @@ Method (_Q14, 0, NotSerialized) // Airplane Mode { Debug = "EC: Airplane Mode" - // Only send HIDD message when hardware airplane mode not in use - If (ECOS == 2) { + if (^^^^HIDD.HRDY) { ^^^^HIDD.HPEM (8) } + // TODO: hardware airplane mode }
Method (_Q15, 0, NotSerialized) // Suspend Button @@ -150,13 +165,10 @@ Debug = "EC: AC Detect" ^^^^AC.ACFG = ADP Notify (AC, 0x80) // Status Change - Sleep (0x01F4) If (BAT0) { Notify (^^^^BAT0, 0x81) // Information Change - Sleep (0x32) Notify (^^^^BAT0, 0x80) // Status Change - Sleep (0x32) } }
diff --git a/src/mainboard/system76/lemp9/acpi/ec_ram.asl b/src/ec/system76/ec/acpi/ec_ram.asl similarity index 100% rename from src/mainboard/system76/lemp9/acpi/ec_ram.asl rename to src/ec/system76/ec/acpi/ec_ram.asl diff --git a/src/mainboard/system76/lemp9/acpi/hid.asl b/src/ec/system76/ec/acpi/hid.asl similarity index 100% rename from src/mainboard/system76/lemp9/acpi/hid.asl rename to src/ec/system76/ec/acpi/hid.asl diff --git a/src/mainboard/system76/lemp9/acpi/lid.asl b/src/ec/system76/ec/acpi/lid.asl similarity index 88% rename from src/mainboard/system76/lemp9/acpi/lid.asl rename to src/ec/system76/ec/acpi/lid.asl index ea382eb..45e646a 100644 --- a/src/mainboard/system76/lemp9/acpi/lid.asl +++ b/src/ec/system76/ec/acpi/lid.asl @@ -3,7 +3,7 @@ Device (LID0) { Name (_HID, EisaId ("PNP0C0D")) - Name (_PRW, Package () { 0x29 /* GPP_D9 */, 3 }) + Name (_PRW, Package () { EC_GPE_SWI, 3 })
Method (_LID, 0, NotSerialized) { DEBUG = "LID: _LID" diff --git a/src/mainboard/system76/lemp9/acpi/s76.asl b/src/ec/system76/ec/acpi/s76.asl similarity index 65% rename from src/mainboard/system76/lemp9/acpi/s76.asl rename to src/ec/system76/ec/acpi/s76.asl index 399e569..7beb50b 100644 --- a/src/mainboard/system76/lemp9/acpi/s76.asl +++ b/src/ec/system76/ec/acpi/s76.asl @@ -14,6 +14,9 @@ Debug = "S76D: RSET" SAPL(0) SKBL(0) +#if CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD) + SKBC(0xFFFFFF) +#endif // CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD) }
Method (INIT, 0, Serialized) { @@ -61,6 +64,32 @@ } }
+#if CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD) + // Set KB LED Brightness + Method (SKBL, 1, Serialized) { + If (^^PCI0.LPCB.EC0.ECOK) { + ^^PCI0.LPCB.EC0.FDAT = 6 + ^^PCI0.LPCB.EC0.FBUF = Arg0 + ^^PCI0.LPCB.EC0.FBF1 = 0 + ^^PCI0.LPCB.EC0.FBF2 = Arg0 + ^^PCI0.LPCB.EC0.FCMD = 0xCA + } + } + + // Set Keyboard Color + Method (SKBC, 1, Serialized) { + If (^^PCI0.LPCB.EC0.ECOK) { + ^^PCI0.LPCB.EC0.FDAT = 0x3 + ^^PCI0.LPCB.EC0.FBUF = (Arg0 & 0xFF) + ^^PCI0.LPCB.EC0.FBF1 = ((Arg0 >> 16) & 0xFF) + ^^PCI0.LPCB.EC0.FBF2 = ((Arg0 >> 8) & 0xFF) + ^^PCI0.LPCB.EC0.FCMD = 0xCA + Return (Arg0) + } Else { + Return (0) + } + } +#else // CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD) // Get KB LED Method (GKBL, 0, Serialized) { Local0 = 0 @@ -81,4 +110,5 @@ ^^PCI0.LPCB.EC0.FCMD = 0xCA } } +#endif // CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD) } diff --git a/src/mainboard/system76/lemp9/Kconfig b/src/mainboard/system76/lemp9/Kconfig index b2ce9e3..3431de1 100644 --- a/src/mainboard/system76/lemp9/Kconfig +++ b/src/mainboard/system76/lemp9/Kconfig @@ -3,7 +3,7 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select BOARD_ROMSIZE_KB_16384 - select EC_ACPI + select EC_SYSTEM76_EC select HAVE_ACPI_RESUME select HAVE_ACPI_TABLES select HAVE_SMI_HANDLER diff --git a/src/mainboard/system76/lemp9/acpi/buttons.asl b/src/mainboard/system76/lemp9/acpi/buttons.asl deleted file mode 100644 index 81e6124..0000000 --- a/src/mainboard/system76/lemp9/acpi/buttons.asl +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -Device (PWRB) -{ - Name (_HID, EisaId ("PNP0C0C")) - Name (_PRW, Package () { 0x29 /* GPP_D9 */, 3 }) -} - -Device (SLPB) -{ - Name (_HID, EisaId ("PNP0C0E")) - Name (_PRW, Package () { 0x29 /* GPP_D9 */, 3 }) -} diff --git a/src/mainboard/system76/lemp9/acpi/mainboard.asl b/src/mainboard/system76/lemp9/acpi/mainboard.asl index 11735e8..4e8691d 100644 --- a/src/mainboard/system76/lemp9/acpi/mainboard.asl +++ b/src/mainboard/system76/lemp9/acpi/mainboard.asl @@ -1,12 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#define EC_GPE_SCI 0x50 /* GPP_E16 */ +#define EC_GPE_SWI 0x29 /* GPP_D9 */ +#define EC_COLOR_KEYBOARD 0 +#include <ec/system76/ec/acpi/ec.asl> + Scope (_SB) { - #include "ac.asl" - #include "battery.asl" - #include "buttons.asl" - #include "hid.asl" - #include "lid.asl" - #include "s76.asl" #include "sleep.asl" }
diff --git a/src/mainboard/system76/lemp9/devicetree.cb b/src/mainboard/system76/lemp9/devicetree.cb index 4c6c866..25ae62f 100644 --- a/src/mainboard/system76/lemp9/devicetree.cb +++ b/src/mainboard/system76/lemp9/devicetree.cb @@ -147,14 +147,14 @@
# LPC (soc/intel/cannonlake/lpc.c) # LPC configuration from lspci -s 1f.0 -xxx - # Address 0x84: Decode 0x80 - 0x8F + # Address 0x84: Decode 0x80 - 0x8F (Port 80) register "gen1_dec" = "0x000c0081" - # Address 0x88: Decode 0x68 - 0x6F + # Address 0x88: Decode 0x68 - 0x6F (PMC) register "gen2_dec" = "0x00040069" - # Address 0x8C: Decode 0x3320 - 0x332F - register "gen3_dec" = "0x000c3321" - # Address 0x90: Disabled - register "gen4_dec" = "0x00000000" + # Address 0x8C: Decode 0xE00 - 0xEFF (AP/EC command) + register "gen3_dec" = "0x00fc0E01" + # Address 0x90: Decode 0xF00 - 0xFFF (AP/EC debug) + register "gen4_dec" = "0x00fc0F01"
# PMC (soc/intel/cannonlake/pmc.c) # Enable deep Sx states diff --git a/src/mainboard/system76/lemp9/dsdt.asl b/src/mainboard/system76/lemp9/dsdt.asl index 7ae8ac4..eac27b5 100644 --- a/src/mainboard/system76/lemp9/dsdt.asl +++ b/src/mainboard/system76/lemp9/dsdt.asl @@ -25,7 +25,6 @@ Scope (_SB.PCI0.LPCB) { #include <drivers/pc80/pc/ps2_controller.asl> - #include "acpi/ec.asl" }
#include "acpi/mainboard.asl"