ec/purism/librem-ec: Apply initial Purism customizations

- remove unused Kconfig options
- change ACPI device name and HID
- remove ACPI for unused color keyboard backlight
- add support for RGB notification LED
- rename Wifi LED ACPI variable
- set some battery info defaults not populated by the EC

Change-Id: I72eca9deb83e5a6d919d6fcbd3b354fbf6e7a925
Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52391
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nicole Faerber 2021-04-15 05:59:37 -05:00 committed by Patrick Georgi
parent 7d57d561b1
commit e00ea2fb38
5 changed files with 68 additions and 76 deletions

View File

@ -2,18 +2,3 @@ config EC_LIBREM_EC
bool
help
Purism Librem EC
config EC_LIBREM_EC_BAT_THRESHOLDS
depends on EC_LIBREM_EC
bool
default n
config EC_LIBREM_EC_COLOR_KEYBOARD
depends on EC_LIBREM_EC
bool
default n
config EC_LIBREM_EC_OLED
depends on EC_LIBREM_EC
bool
default n

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#define BATTERY_DESIGN_VOLTAGE_MV 14800
Device (BAT0)
{
Name (_HID, EisaId ("PNP0C0A") /* Control Method Battery */) // _HID: Hardware ID
@ -34,15 +36,15 @@ Device (BAT0)
0xFFFFFFFF, // 1 - Design Capacity
0xFFFFFFFF, // 2 - Last Full Charge Capacity
One, // 3 - Battery Technology
0xFFFFFFFF, // 4 - Design Voltage
BATTERY_DESIGN_VOLTAGE_MV, // 4 - Design Voltage
Zero, // 5 - Design Capacity of Warning
Zero, // 6 - Design Capacity of Low
0x40, // 7 - Battery Capacity Granularity 1
0x40, // 8 - Battery Capacity Granularity 2
" ", // 9 - Model Number
" ", // 10 - Serial Number
" ", // 11 - Battery Type
" " // 12 - OEM Information
"BAT", // 9 - Model Number
"0001", // 10 - Serial Number
"LION", // 11 - Battery Type
"Notebook" // 12 - OEM Information
})
Method (IVBI, 0, NotSerialized)
{
@ -101,14 +103,14 @@ Device (BAT0)
Zero, // 0 - Battery state
0xFFFFFFFF, // 1 - Battery present rate
0xFFFFFFFF, // 2 - Battery remaining capacity
0xFFFFFFFF // 3 - Battery present voltage
BATTERY_DESIGN_VOLTAGE_MV // 3 - Battery present voltage
})
Method (IVBS, 0, NotSerialized)
{
PBST [0] = Zero
PBST [1] = 0xFFFFFFFF
PBST [2] = 0xFFFFFFFF
PBST [3] = 0xFFFFFFFF
PBST [3] = 0x2710
}
Method (UPBS, 0, NotSerialized)

View File

@ -57,18 +57,14 @@ Device (\_SB.PCI0.LPCB.EC0)
// EC is now available
ECOK = Arg1
// Reset System76 Device
^^^^S76D.RSET()
// Reset Librem EC Device
^^^^LIEC.RSET()
}
}
Name (S3OS, Zero)
Method (PTS, 1, Serialized) {
Debug = Concatenate("EC: PTS: ", ToHexString(Arg0))
If (ECOK) {
// Save ECOS during sleep
S3OS = ECOS
// Clear wake cause
WFNO = Zero
}
@ -77,9 +73,6 @@ Device (\_SB.PCI0.LPCB.EC0)
Method (WAK, 1, Serialized) {
Debug = Concatenate("EC: WAK: ", ToHexString(Arg0))
If (ECOK) {
// Restore ECOS after sleep
ECOS = S3OS
// Set current AC state
^^^^AC.ACFG = ADP
@ -91,8 +84,8 @@ Device (\_SB.PCI0.LPCB.EC0)
Notify(^^^^AC, Zero)
Notify(^^^^BAT0, Zero)
// Reset System76 Device
^^^^S76D.RSET()
// Reset Librem EC Device
^^^^LIEC.RSET()
}
}
@ -104,9 +97,6 @@ Device (\_SB.PCI0.LPCB.EC0)
Method (_Q0B, 0, NotSerialized) // Screen Toggle
{
Debug = "EC: Screen Toggle"
#if CONFIG(EC_SYSTEM76_EC_OLED)
Notify (^^^^S76D, 0x85)
#endif // CONFIG(EC_SYSTEM76_EC_OLED)
}
Method (_Q0C, 0, NotSerialized) // Mute
@ -220,25 +210,23 @@ Device (\_SB.PCI0.LPCB.EC0)
Local0 = OEM4
If (Local0 == 0x8A) {
Debug = "EC: White Keyboard Backlight"
Notify (^^^^S76D, 0x80)
Notify (^^^^LIEC, 0x80)
} ElseIf (Local0 == 0x9F) {
Debug = "EC: Color Keyboard Toggle"
Notify (^^^^S76D, 0x81)
Notify (^^^^LIEC, 0x81)
} ElseIf (Local0 == 0x81) {
Debug = "EC: Color Keyboard Down"
Notify (^^^^S76D, 0x82)
Notify (^^^^LIEC, 0x82)
} ElseIf (Local0 == 0x82) {
Debug = "EC: Color Keyboard Up"
Notify (^^^^S76D, 0x83)
Notify (^^^^LIEC, 0x83)
} ElseIf (Local0 == 0x80) {
Debug = "EC: Color Keyboard Color Change"
Notify (^^^^S76D, 0x84)
Notify (^^^^LIEC, 0x84)
} Else {
Debug = Concatenate("EC: Other: ", ToHexString(Local0))
}
}
#if CONFIG(EC_SYSTEM76_EC_BAT_THRESHOLDS)
#include "battery_thresholds.asl"
#endif
}

View File

@ -42,7 +42,10 @@ Field (ERAM, ByteAcc, Lock, Preserve)
RPM1, 16, // Fan 1 RPM
RPM2, 16, // Fan 2 RPM
Offset (0xD9),
AIRP, 8, // Airplane mode LED
WLED, 8, // WiFi LED
NOTR, 8, // notification LED R
NOTG, 8, // notification LED G
NOTB, 8, // notification LED B
WINF, 8, // Enable ACPI brightness controls
Offset (0xF8),
FCMD, 8,

View File

@ -6,22 +6,18 @@
// 0x82 - backlight down
// 0x83 - backlight up
// 0x84 - backlight color change
// 0x85 - OLED screen toggle
Device (S76D) {
Name (_HID, "17761776")
Device (LIEC) {
Name (_HID, "PURI4543")
Name (_UID, 0)
Method (RSET, 0, Serialized) {
Debug = "S76D: RSET"
Debug = "LIEC: 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) {
Debug = "S76D: INIT"
Debug = "LIEC: INIT"
RSET()
If (^^PCI0.LPCB.EC0.ECOK) {
// Set flags to use software control
@ -33,7 +29,7 @@ Device (S76D) {
}
Method (FINI, 0, Serialized) {
Debug = "S76D: FINI"
Debug = "LIEC: FINI"
RSET()
If (^^PCI0.LPCB.EC0.ECOK) {
// Set flags to use hardware control
@ -47,7 +43,7 @@ Device (S76D) {
// Get Airplane LED
Method (GAPL, 0, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
If (^^PCI0.LPCB.EC0.AIRP & 0x40) {
If (^^PCI0.LPCB.EC0.WLED & 0x40) {
Return (1)
}
}
@ -58,39 +54,58 @@ Device (S76D) {
Method (SAPL, 1, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
If (Arg0) {
^^PCI0.LPCB.EC0.AIRP |= 0x40
^^PCI0.LPCB.EC0.WLED |= 0x40
} Else {
^^PCI0.LPCB.EC0.AIRP &= 0xBF
^^PCI0.LPCB.EC0.WLED &= 0xBF
}
}
}
#if CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD)
// Set KB LED Brightness
Method (SKBL, 1, Serialized) {
// Get notification red LED
Method (GNTR, 0, 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
Return (^^PCI0.LPCB.EC0.NOTR)
}
Return (0)
}
// Set notification red LED
Method (SNTR, 1, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
^^PCI0.LPCB.EC0.NOTR = Arg0
}
}
// Set Keyboard Color
Method (SKBC, 1, Serialized) {
// Get notification green LED
Method (GNTG, 0, 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)
Return (^^PCI0.LPCB.EC0.NOTG)
}
Return (0)
}
// Set notification green LED
Method (SNTG, 1, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
^^PCI0.LPCB.EC0.NOTG = Arg0
}
}
#else // CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD)
// Get notification blue LED
Method (GNTB, 0, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
Return (^^PCI0.LPCB.EC0.NOTB)
}
Return (0)
}
// Set notification blue LED
Method (SNTB, 1, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
^^PCI0.LPCB.EC0.NOTB = Arg0
}
}
// Get KB LED
Method (GKBL, 0, Serialized) {
Local0 = 0
@ -111,7 +126,6 @@ Device (S76D) {
^^PCI0.LPCB.EC0.FCMD = 0xCA
}
}
#endif // CONFIG(EC_SYSTEM76_EC_COLOR_KEYBOARD)
// Fan names
Method (NFAN, 0, Serialized) {