Move EC initialization from kernel driver to ACPI and motherboard init

This commit is contained in:
Jeremy Soller
2019-08-21 12:36:20 -06:00
parent 7c8a9f60f4
commit d472cda80a
2 changed files with 39 additions and 0 deletions

View File

@@ -23,6 +23,26 @@ Device (S76D) {
Name (_HID, "17761776") Name (_HID, "17761776")
Name (_UID, 0) Name (_UID, 0)
Method (INIT, 0, Serialized) {
Debug = "INIT"
If (^^PCI0.LPCB.EC0.ECOK) {
//TODO: Set flags to use software control
Return (0)
} Else {
Return (1)
}
}
Method (FINI, 0, Serialized) {
Debug = "FINI"
If (^^PCI0.LPCB.EC0.ECOK) {
//TODO: Set flags to use hardware control
Return (0)
} Else {
Return (1)
}
}
// Get Airplane LED // Get Airplane LED
Method (GAPL, 0, Serialized) { Method (GAPL, 0, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) { If (^^PCI0.LPCB.EC0.ECOK) {

View File

@@ -26,9 +26,28 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) {
cnl_configure_pads(gpio_table, ARRAY_SIZE(gpio_table)); cnl_configure_pads(gpio_table, ARRAY_SIZE(gpio_table));
} }
static int ec_cmd(u8 data) {
int i = 1000000;
while ((inb(0x66) & 2) == 2 && i > 0) {
i -= 1;
}
if (i == 0) {
return 1;
} else {
outb(data, 0x66);
return 0;
}
}
static void mainboard_init(struct device *dev) { static void mainboard_init(struct device *dev) {
printk(BIOS_INFO, "system76: keyboard init\n"); printk(BIOS_INFO, "system76: keyboard init\n");
pc_keyboard_init(NO_AUX_DEVICE); pc_keyboard_init(NO_AUX_DEVICE);
// Rescan for EC devices - fixes camera toggle
printk(BIOS_INFO, "system76: EC init\n");
if (ec_cmd(0xA8)) {
printk(BIOS_ERR, "system76: failed to send EC command 0xA8\n");
}
} }
static void mainboard_enable(struct device *dev) { static void mainboard_enable(struct device *dev) {