aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Soller <jeremy@system76.com>2020-07-20 12:31:07 -0600
committerPhilipp Deppenwiese <zaolin.daisuki@gmail.com>2020-07-23 09:30:22 +0000
commit0de0fe110468cfd609a0aaa42ea9a4c29740e507 (patch)
treed44cc7211e9e44a6fd2712cfaf25b0db761ed6a0
parentb8d6af9569632745966199a21833f0ad426ca140 (diff)
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
-rw-r--r--src/ec/system76/ec/Kconfig9
-rw-r--r--src/ec/system76/ec/acpi/ac.asl (renamed from src/mainboard/system76/lemp9/acpi/ac.asl)0
-rw-r--r--src/ec/system76/ec/acpi/battery.asl (renamed from src/mainboard/system76/lemp9/acpi/battery.asl)0
-rw-r--r--src/ec/system76/ec/acpi/buttons.asl (renamed from src/mainboard/system76/lemp9/acpi/buttons.asl)4
-rw-r--r--src/ec/system76/ec/acpi/ec.asl (renamed from src/mainboard/system76/lemp9/acpi/ec.asl)36
-rw-r--r--src/ec/system76/ec/acpi/ec_ram.asl (renamed from src/mainboard/system76/lemp9/acpi/ec_ram.asl)0
-rw-r--r--src/ec/system76/ec/acpi/hid.asl (renamed from src/mainboard/system76/lemp9/acpi/hid.asl)0
-rw-r--r--src/ec/system76/ec/acpi/lid.asl (renamed from src/mainboard/system76/lemp9/acpi/lid.asl)2
-rw-r--r--src/ec/system76/ec/acpi/s76.asl (renamed from src/mainboard/system76/lemp9/acpi/s76.asl)30
-rw-r--r--src/mainboard/system76/lemp9/Kconfig2
-rw-r--r--src/mainboard/system76/lemp9/acpi/mainboard.asl11
-rw-r--r--src/mainboard/system76/lemp9/devicetree.cb12
-rw-r--r--src/mainboard/system76/lemp9/dsdt.asl1
13 files changed, 78 insertions, 29 deletions
diff --git a/src/ec/system76/ec/Kconfig b/src/ec/system76/ec/Kconfig
new file mode 100644
index 0000000000..fea4743593
--- /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
index 7326676198..7326676198 100644
--- a/src/mainboard/system76/lemp9/acpi/ac.asl
+++ b/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
index bc239dd9c0..bc239dd9c0 100644
--- a/src/mainboard/system76/lemp9/acpi/battery.asl
+++ b/src/ec/system76/ec/acpi/battery.asl
diff --git a/src/mainboard/system76/lemp9/acpi/buttons.asl b/src/ec/system76/ec/acpi/buttons.asl
index 81e61242bf..ae85c67ccc 100644
--- a/src/mainboard/system76/lemp9/acpi/buttons.asl
+++ b/src/ec/system76/ec/acpi/buttons.asl
@@ -3,11 +3,11 @@
Device (PWRB)
{
Name (_HID, EisaId ("PNP0C0C"))
- Name (_PRW, Package () { 0x29 /* GPP_D9 */, 3 })
+ Name (_PRW, Package () { EC_GPE_SWI, 3 })
}
Device (SLPB)
{
Name (_HID, EisaId ("PNP0C0E"))
- Name (_PRW, Package () { 0x29 /* GPP_D9 */, 3 })
+ 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
index f8496aed8c..5989f6d285 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 @@ Device (EC0)
)
})
- #include "acpi/ec_ram.asl"
+ #include "ec_ram.asl"
Name (ECOK, Zero)
Method (_REG, 2, Serialized) // _REG: Region Availability
@@ -39,6 +48,10 @@ Device (EC0)
^^^^BAT0.UPBI()
^^^^BAT0.UPBS()
+ // Notify of changes
+ Notify(^^^^AC, Zero)
+ Notify(^^^^BAT0, Zero)
+
PNOT ()
// EC is now available
@@ -71,8 +84,6 @@ Device (EC0)
Notify(^^^^AC, Zero)
Notify(^^^^BAT0, Zero)
- Sleep (1000)
-
// Reset System76 Device
^^^^S76D.RSET()
}
@@ -116,13 +127,17 @@ Device (EC0)
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 @@ Device (EC0)
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 @@ Device (EC0)
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
index d5f97edbd7..d5f97edbd7 100644
--- a/src/mainboard/system76/lemp9/acpi/ec_ram.asl
+++ b/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
index ce8fd3f28b..ce8fd3f28b 100644
--- a/src/mainboard/system76/lemp9/acpi/hid.asl
+++ b/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
index ea382eb045..45e646acbb 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
index 399e569734..7beb50b813 100644
--- a/src/mainboard/system76/lemp9/acpi/s76.asl
+++ b/src/ec/system76/ec/acpi/s76.asl
@@ -14,6 +14,9 @@ Device (S76D) {
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 @@ Device (S76D) {
}
}
+#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 @@ Device (S76D) {
^^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 b2ce9e3edf..3431de1988 100644
--- a/src/mainboard/system76/lemp9/Kconfig
+++ b/src/mainboard/system76/lemp9/Kconfig
@@ -3,7 +3,7 @@ if BOARD_SYSTEM76_LEMP9
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/mainboard.asl b/src/mainboard/system76/lemp9/acpi/mainboard.asl
index 11735e8e01..4e8691d3d5 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 4c6c866440..25ae62febf 100644
--- a/src/mainboard/system76/lemp9/devicetree.cb
+++ b/src/mainboard/system76/lemp9/devicetree.cb
@@ -147,14 +147,14 @@ chip soc/intel/cannonlake
# 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 7ae8ac4394..eac27b56f1 100644
--- a/src/mainboard/system76/lemp9/dsdt.asl
+++ b/src/mainboard/system76/lemp9/dsdt.asl
@@ -25,7 +25,6 @@ DefinitionBlock(
Scope (\_SB.PCI0.LPCB)
{
#include <drivers/pc80/pc/ps2_controller.asl>
- #include "acpi/ec.asl"
}
#include "acpi/mainboard.asl"