ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3
Currently mach-virt model doesn't support powerdown request. Guest VM doesn't react to system_powerdown from monitor console (or QMP) because there is no communication mechanism for such requests. This patch registers GPIO Pin 3 with powerdown notification. So guest VM can receive notification when such powerdown request is triggered. Signed-off-by: Wei Huang <wei@redhat.com> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Reviewed-by: Wei Huang <wei@redhat.com> Tested-by: Wei Huang <wei@redhat.com> Message-id: 1449804086-3464-10-git-send-email-zhaoshenglong@huawei.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
c1a158b7ed
commit
4bedd8495b
|
@ -540,6 +540,17 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||||
g_free(nodename);
|
g_free(nodename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DeviceState *pl061_dev;
|
||||||
|
static void virt_powerdown_req(Notifier *n, void *opaque)
|
||||||
|
{
|
||||||
|
/* use gpio Pin 3 for power button event */
|
||||||
|
qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Notifier virt_system_powerdown_notifier = {
|
||||||
|
.notify = virt_powerdown_req
|
||||||
|
};
|
||||||
|
|
||||||
static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
|
static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||||
{
|
{
|
||||||
char *nodename;
|
char *nodename;
|
||||||
|
@ -548,7 +559,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||||
int irq = vbi->irqmap[VIRT_GPIO];
|
int irq = vbi->irqmap[VIRT_GPIO];
|
||||||
const char compat[] = "arm,pl061\0arm,primecell";
|
const char compat[] = "arm,pl061\0arm,primecell";
|
||||||
|
|
||||||
sysbus_create_simple("pl061", base, pic[irq]);
|
pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
|
||||||
|
|
||||||
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
|
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
|
||||||
qemu_fdt_add_subnode(vbi->fdt, nodename);
|
qemu_fdt_add_subnode(vbi->fdt, nodename);
|
||||||
|
@ -563,6 +574,9 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||||
qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
|
qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
|
||||||
qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
|
qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
|
||||||
|
|
||||||
|
/* connect powerdown request */
|
||||||
|
qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
|
||||||
|
|
||||||
g_free(nodename);
|
g_free(nodename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue