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
This commit is contained in:
Jeremy Soller 2020-07-20 12:31:07 -06:00 committed by Philipp Deppenwiese
parent b8d6af9569
commit 0de0fe1104
13 changed files with 78 additions and 29 deletions

View File

@ -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

View File

@ -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 })
}

View File

@ -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)
}
}

View File

@ -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"

View File

@ -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)
}

View File

@ -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

View File

@ -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"
}

View File

@ -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

View File

@ -25,7 +25,6 @@ DefinitionBlock(
Scope (\_SB.PCI0.LPCB)
{
#include <drivers/pc80/pc/ps2_controller.asl>
#include "acpi/ec.asl"
}
#include "acpi/mainboard.asl"