Implement airplane mode LED

This commit is contained in:
Jeremy Soller 2020-01-21 16:03:41 -07:00
parent a3aff2083a
commit 1a88f3e056
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
8 changed files with 30 additions and 18 deletions

View File

@ -57,6 +57,13 @@ uint8_t acpi_read(uint8_t addr) {
ACPI_16(0x2E, battery_remaining_capacity);
ACPI_16(0x32, battery_voltage);
// Airplane mode LED
case 0xD9:
if (!gpio_get(&LED_AIRPLANE_N)) {
data |= (1 << 6);
}
break;
// Set size of flash (from old firmware)
ACPI_8 (0xE5, 0x80);
}
@ -74,5 +81,10 @@ void acpi_write(uint8_t addr, uint8_t data) {
case 0x03:
lid_wake = (bool)(data & (1 << 2));
break;
// Airplane mode LED
case 0xD9:
gpio_set(&LED_AIRPLANE_N, !(bool)(data & (1 << 6)));
break;
}
}

View File

@ -12,6 +12,7 @@ struct Gpio __code DD_ON = GPIO(E, 4);
struct Gpio __code EC_EN = GPIO(E, 1);
struct Gpio __code EC_RSMRST_N = GPIO(E, 5);
struct Gpio __code LED_ACIN = GPIO(C, 7);
struct Gpio __code LED_AIRPLANE_N = GPIO(G, 6);
struct Gpio __code LED_BAT_CHG = GPIO(A, 5);
struct Gpio __code LED_BAT_FULL = GPIO(A, 6);
struct Gpio __code LED_PWR = GPIO(A, 7);
@ -48,7 +49,7 @@ void gpio_init() {
GPDRD = (1 << 5) | (1 << 4) | (1 << 3);
GPDRE = 0;
GPDRF = 0xC0; // (1 << 7) | (1 << 6)
GPDRG = 0;
GPDRG = (1 << 6);
GPDRH = 0;
GPDRI = 0;
GPDRJ = 0;

View File

@ -23,6 +23,7 @@ extern struct Gpio __code DD_ON;
extern struct Gpio __code EC_EN;
extern struct Gpio __code EC_RSMRST_N;
extern struct Gpio __code LED_ACIN;
extern struct Gpio __code LED_AIRPLANE_N;
extern struct Gpio __code LED_BAT_CHG;
extern struct Gpio __code LED_BAT_FULL;
extern struct Gpio __code LED_PWR;

View File

@ -113,17 +113,11 @@ void lid_event(void) {
last = new;
}
struct Gpio __code LED_SSD_N = GPIO(G, 6);
struct Gpio __code LED_AIRPLANE_N = GPIO(G, 6);
void main(void) {
init();
INFO("\n");
// Set the battery full LED (to know our firmware is loading)
gpio_set(&LED_BAT_CHG, true);
#if GPIO_DEBUG
gpio_debug();
#endif
@ -145,8 +139,6 @@ void main(void) {
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
// Set the battery full LED (to know our firmware is loaded)
gpio_set(&LED_BAT_FULL, true);
INFO("Hello from System76 EC for %s!\n", xstr(__BOARD__));
for(main_cycle = 0; ; main_cycle++) {

View File

@ -57,6 +57,13 @@ uint8_t acpi_read(uint8_t addr) {
ACPI_16(0x2E, battery_remaining_capacity);
ACPI_16(0x32, battery_voltage);
// Airplane mode LED
case 0xD9:
if (!gpio_get(&LED_AIRPLANE_N)) {
data |= (1 << 6);
}
break;
// Set size of flash (from old firmware)
ACPI_8 (0xE5, 0x80);
}
@ -74,5 +81,10 @@ void acpi_write(uint8_t addr, uint8_t data) {
case 0x03:
lid_wake = (bool)(data & (1 << 2));
break;
// Airplane mode LED
case 0xD9:
gpio_set(&LED_AIRPLANE_N, !(bool)(data & (1 << 6)));
break;
}
}

View File

@ -12,6 +12,7 @@ struct Gpio __code DD_ON = GPIO(E, 4);
struct Gpio __code EC_EN = GPIO(E, 1);
struct Gpio __code EC_RSMRST_N = GPIO(E, 5);
struct Gpio __code LED_ACIN = GPIO(C, 7);
struct Gpio __code LED_AIRPLANE_N = GPIO(G, 6);
struct Gpio __code LED_BAT_CHG = GPIO(A, 5);
struct Gpio __code LED_BAT_FULL = GPIO(A, 6);
struct Gpio __code LED_PWR = GPIO(A, 7);
@ -48,7 +49,7 @@ void gpio_init() {
GPDRD = (1 << 5) | (1 << 4) | (1 << 3);
GPDRE = 0;
GPDRF = 0xC0; // (1 << 7) | (1 << 6)
GPDRG = 0;
GPDRG = (1 << 6);
GPDRH = 0;
GPDRI = 0;
GPDRJ = 0;

View File

@ -23,6 +23,7 @@ extern struct Gpio __code DD_ON;
extern struct Gpio __code EC_EN;
extern struct Gpio __code EC_RSMRST_N;
extern struct Gpio __code LED_ACIN;
extern struct Gpio __code LED_AIRPLANE_N;
extern struct Gpio __code LED_BAT_CHG;
extern struct Gpio __code LED_BAT_FULL;
extern struct Gpio __code LED_PWR;

View File

@ -113,17 +113,11 @@ void lid_event(void) {
last = new;
}
struct Gpio __code LED_SSD_N = GPIO(G, 6);
struct Gpio __code LED_AIRPLANE_N = GPIO(G, 6);
void main(void) {
init();
INFO("\n");
// Set the battery full LED (to know our firmware is loading)
gpio_set(&LED_BAT_CHG, true);
#if GPIO_DEBUG
gpio_debug();
#endif
@ -145,8 +139,6 @@ void main(void) {
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
// Set the battery full LED (to know our firmware is loaded)
gpio_set(&LED_BAT_FULL, true);
INFO("Hello from System76 EC for %s!\n", xstr(__BOARD__));
for(main_cycle = 0; ; main_cycle++) {