diff --git a/src/board/system76/darp5/acpi.c b/src/board/system76/darp5/acpi.c index 85d5fda..e42f6ae 100644 --- a/src/board/system76/darp5/acpi.c +++ b/src/board/system76/darp5/acpi.c @@ -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; } } diff --git a/src/board/system76/darp5/gpio.c b/src/board/system76/darp5/gpio.c index b8c39da..c9a882c 100644 --- a/src/board/system76/darp5/gpio.c +++ b/src/board/system76/darp5/gpio.c @@ -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; diff --git a/src/board/system76/darp5/include/board/gpio.h b/src/board/system76/darp5/include/board/gpio.h index bb2bc9a..c08a40f 100644 --- a/src/board/system76/darp5/include/board/gpio.h +++ b/src/board/system76/darp5/include/board/gpio.h @@ -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; diff --git a/src/board/system76/darp5/main.c b/src/board/system76/darp5/main.c index 3bc8107..996092f 100644 --- a/src/board/system76/darp5/main.c +++ b/src/board/system76/darp5/main.c @@ -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++) { diff --git a/src/board/system76/galp3-c/acpi.c b/src/board/system76/galp3-c/acpi.c index 85d5fda..e42f6ae 100644 --- a/src/board/system76/galp3-c/acpi.c +++ b/src/board/system76/galp3-c/acpi.c @@ -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; } } diff --git a/src/board/system76/galp3-c/gpio.c b/src/board/system76/galp3-c/gpio.c index b8c39da..c9a882c 100644 --- a/src/board/system76/galp3-c/gpio.c +++ b/src/board/system76/galp3-c/gpio.c @@ -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; diff --git a/src/board/system76/galp3-c/include/board/gpio.h b/src/board/system76/galp3-c/include/board/gpio.h index bb2bc9a..c08a40f 100644 --- a/src/board/system76/galp3-c/include/board/gpio.h +++ b/src/board/system76/galp3-c/include/board/gpio.h @@ -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; diff --git a/src/board/system76/galp3-c/main.c b/src/board/system76/galp3-c/main.c index 3bc8107..996092f 100644 --- a/src/board/system76/galp3-c/main.c +++ b/src/board/system76/galp3-c/main.c @@ -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++) {