-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aarch64 powerdown: add support for GPIO power key
If ACPI tables are not present in a given Qemu aarch64 instance (e.g. when running an instance with the "virt" machine type and without a UEFI firmware), upon reception of the "system_powerdown" command (which is used to gracefully shut down the instance), Qemu toggles the "poweroff" GPIO instead of generating an ACPI event. Add parsing of GPIO key information from the device tree, and if such information can be found, enable interrupt generation on the PL061 GPIO controller when the poweroff GPIO is toggled, so that the kernel can be shut down by the interrupt handler. This allows a graceful shutdown to be performed when an on-prem instance launched with `ops run --arch=arm64` is terminated with CTRL-C.
- Loading branch information
1 parent
c345e6f
commit 338d1d1
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <kernel.h> | ||
#include <gpio.h> | ||
|
||
#define PL061_GPIOIEV 0x40c | ||
#define PL061_GPIOIE 0x410 | ||
#define PL061_GPIOIC 0x41c | ||
|
||
void gpio_irq_enable(u64 mask) | ||
{ | ||
mmio_write_32(mmio_base_addr(GPIO) + PL061_GPIOIEV, mask); | ||
mmio_write_32(mmio_base_addr(GPIO) + PL061_GPIOIE, mask); | ||
} | ||
|
||
void gpio_irq_clear(u64 mask) | ||
{ | ||
mmio_write_32(mmio_base_addr(GPIO) + PL061_GPIOIC, mask); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void gpio_irq_enable(u64 mask); | ||
void gpio_irq_clear(u64 mask); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters