[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 18/33] PPC: E500: Hook up power off GPIO to GPIO contro
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PULL 18/33] PPC: E500: Hook up power off GPIO to GPIO controller |
Date: |
Tue, 4 Nov 2014 20:26:36 +0100 |
Now that we have a working GPIO controller on the virt machine, we can use
one pin to notify QEMU that the guests wants to power off the system.
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/e500.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 304c124..cfc46c4 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -129,6 +129,8 @@ static void create_dt_mpc8xxx_gpio(void *fdt, const char
*soc, const char *mpic)
hwaddr mmio0 = MPC8XXX_GPIO_OFFSET;
int irq0 = MPC8XXX_GPIO_IRQ;
gchar *node = g_strdup_printf("%s/address@hidden"PRIx64, soc, mmio0);
+ gchar *poweroff = g_strdup_printf("%s/power-off", soc);
+ int gpio_ph;
qemu_fdt_add_subnode(fdt, node);
qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,qoriq-gpio");
@@ -137,8 +139,17 @@ static void create_dt_mpc8xxx_gpio(void *fdt, const char
*soc, const char *mpic)
qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", mpic);
qemu_fdt_setprop_cells(fdt, node, "#gpio-cells", 2);
qemu_fdt_setprop(fdt, node, "gpio-controller", NULL, 0);
+ gpio_ph = qemu_fdt_alloc_phandle(fdt);
+ qemu_fdt_setprop_cell(fdt, node, "phandle", gpio_ph);
+ qemu_fdt_setprop_cell(fdt, node, "linux,phandle", gpio_ph);
+
+ /* Power Off Pin */
+ qemu_fdt_add_subnode(fdt, poweroff);
+ qemu_fdt_setprop_string(fdt, poweroff, "compatible", "gpio-poweroff");
+ qemu_fdt_setprop_cells(fdt, poweroff, "gpios", gpio_ph, 0, 0);
g_free(node);
+ g_free(poweroff);
}
static int ppce500_load_device_tree(MachineState *machine,
@@ -641,6 +652,13 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params,
MemoryRegion *ccsr,
return mpic;
}
+static void ppce500_power_off(void *opaque, int line, int on)
+{
+ if (on) {
+ qemu_system_shutdown_request();
+ }
+}
+
void ppce500_init(MachineState *machine, PPCE500Params *params)
{
MemoryRegion *address_space_mem = get_system_memory();
@@ -793,12 +811,18 @@ void ppce500_init(MachineState *machine, PPCE500Params
*params)
}
if (params->has_mpc8xxx_gpio) {
+ qemu_irq poweroff_irq;
+
dev = qdev_create(NULL, "mpc8xxx_gpio");
s = SYS_BUS_DEVICE(dev);
qdev_init_nofail(dev);
sysbus_connect_irq(s, 0, mpic[MPC8XXX_GPIO_IRQ]);
memory_region_add_subregion(ccsr_addr_space, MPC8XXX_GPIO_OFFSET,
sysbus_mmio_get_region(s, 0));
+
+ /* Power Off GPIO at Pin 0 */
+ poweroff_irq = qemu_allocate_irq(ppce500_power_off, NULL, 0);
+ qdev_connect_gpio_out(dev, 0, poweroff_irq);
}
/* Load kernel. */
--
1.8.1.4
- [Qemu-ppc] [PULL 01/33] ppc: fix monitor access to CR, (continued)
- [Qemu-ppc] [PULL 01/33] ppc: fix monitor access to CR, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 19/33] spapr_nvram: Enable migration, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 13/33] hw/pci/ppc4xx_pci.c: Remove unused pci4xx_cfgaddr_read/write/ops, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 10/33] PPC: openpic_kvm: Only map first occurence in address space, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 08/33] target-ppc: virtex-ml507 machine type should depend on CONFIG_XILINX, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 03/33] ppc: fix result of DLMZB when no zero bytes are found, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 06/33] target-ppc: Fix kvmppc_set_compat to use negotiated cpu-version, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 07/33] target-ppc: Implement IVOR[59] By Default for Book E, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 02/33] ppc: use CRF_* in int_helper.c, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 11/33] target-ppc : Allow fc[tf]id[*] mnemonics for non TARGET_PPC64, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 18/33] PPC: E500: Hook up power off GPIO to GPIO controller,
Alexander Graf <=
- [Qemu-ppc] [PULL 22/33] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*), Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 04/33] ppc: rename gen_set_cr6_from_fpscr, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 12/33] target-ppc : Add new processor type 440x5wDFPU, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 14/33] target-ppc: Use macros in opcodes table handling code, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 05/33] ppc: compute mask from BI using right shift, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 17/33] PPC: E500: Instantiate MPC8XXX gpio controller on virt machine, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 24/33] sysbus: Make devices spawnable via -device, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 15/33] target-ppc: Fix an invalid free in opcode table handling code., Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 26/33] sysbus: Expose MMIO enumeration helper, Alexander Graf, 2014/11/04
- [Qemu-ppc] [PULL 27/33] sysbus: Add new platform bus helper device, Alexander Graf, 2014/11/04