Send SWI on lid open
This commit is contained in:
parent
c1236b9e4a
commit
2e6a556e4b
@ -4,6 +4,8 @@
|
||||
#include <common/debug.h>
|
||||
#include <ec/gpio.h>
|
||||
|
||||
extern bool lid_wake;
|
||||
|
||||
static struct Gpio __code ACIN_N = GPIO(B, 0);
|
||||
static struct Gpio __code LID_SW_N = GPIO(B, 1);
|
||||
|
||||
@ -30,6 +32,9 @@ uint8_t acpi_read(uint8_t addr) {
|
||||
// Lid is open
|
||||
data |= 1 << 0;
|
||||
}
|
||||
if (lid_wake) {
|
||||
data |= 1 << 2;
|
||||
}
|
||||
break;
|
||||
|
||||
// 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) {
|
||||
DEBUG("acpi_write %02X = %02X\n", addr, data);
|
||||
|
||||
switch (addr) {
|
||||
//TODO
|
||||
// Lid state and other flags
|
||||
case 0x03:
|
||||
lid_wake = (bool)(data & (1 << 2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma restore
|
||||
|
@ -72,8 +72,10 @@ void touchpad_event(struct Ps2 * ps2) {
|
||||
}
|
||||
}
|
||||
|
||||
bool lid_wake = false;
|
||||
void lid_event(void) {
|
||||
extern struct Gpio __code LID_SW_N;
|
||||
extern struct Gpio __code SWI_N;
|
||||
|
||||
static bool send_sci = true;
|
||||
static bool last = true;
|
||||
@ -87,6 +89,16 @@ void lid_event(void) {
|
||||
DEBUG("open\n");
|
||||
|
||||
//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 {
|
||||
DEBUG("closed\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user