Send SWI on lid open

This commit is contained in:
Jeremy Soller 2020-01-13 20:40:29 -07:00
parent c1236b9e4a
commit 2e6a556e4b
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 21 additions and 5 deletions

View File

@ -4,6 +4,8 @@
#include <common/debug.h> #include <common/debug.h>
#include <ec/gpio.h> #include <ec/gpio.h>
extern bool lid_wake;
static struct Gpio __code ACIN_N = GPIO(B, 0); static struct Gpio __code ACIN_N = GPIO(B, 0);
static struct Gpio __code LID_SW_N = GPIO(B, 1); static struct Gpio __code LID_SW_N = GPIO(B, 1);
@ -30,6 +32,9 @@ uint8_t acpi_read(uint8_t addr) {
// Lid is open // Lid is open
data |= 1 << 0; data |= 1 << 0;
} }
if (lid_wake) {
data |= 1 << 2;
}
break; break;
// Handle AC adapter and battery present // Handle AC adapter and battery present
@ -64,14 +69,13 @@ uint8_t acpi_read(uint8_t addr) {
} }
// If not in debug mode, data is not used, ignore warning
#pragma save
#pragma disable_warning 85
void acpi_write(uint8_t addr, uint8_t data) { void acpi_write(uint8_t addr, uint8_t data) {
DEBUG("acpi_write %02X = %02X\n", addr, data); DEBUG("acpi_write %02X = %02X\n", addr, data);
switch (addr) { switch (addr) {
//TODO // Lid state and other flags
case 0x03:
lid_wake = (bool)(data & (1 << 2));
break;
} }
} }
#pragma restore

View File

@ -72,8 +72,10 @@ void touchpad_event(struct Ps2 * ps2) {
} }
} }
bool lid_wake = false;
void lid_event(void) { void lid_event(void) {
extern struct Gpio __code LID_SW_N; extern struct Gpio __code LID_SW_N;
extern struct Gpio __code SWI_N;
static bool send_sci = true; static bool send_sci = true;
static bool last = true; static bool last = true;
@ -87,6 +89,16 @@ void lid_event(void) {
DEBUG("open\n"); DEBUG("open\n");
//TODO: send SWI if needed //TODO: send SWI if needed
if (lid_wake) {
gpio_set(&SWI_N, false);
//TODO: find correct delay
delay_ticks(10);
gpio_set(&SWI_N, true);
lid_wake = false;
}
} else { } else {
DEBUG("closed\n"); DEBUG("closed\n");
} }