[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/33] PPC: E500: Instantiate MPC8XXX gpio controller
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PULL 17/33] PPC: E500: Instantiate MPC8XXX gpio controller on virt machine |
Date: |
Tue, 4 Nov 2014 20:26:35 +0100 |
With the e500 virt machine, we don't have to adhere to the exact hardware
layout of an mpc8544ds board. So there we can just add a qoriq compatible
GPIO controller into the system that we can add a power off hook to.
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/e500.c | 32 ++++++++++++++++++++++++++++++++
hw/ppc/e500.h | 1 +
hw/ppc/e500plat.c | 1 +
3 files changed, 34 insertions(+)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 2157d87..304c124 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -61,6 +61,8 @@
#define MPC8544_PCI_IO 0xE1000000ULL
#define MPC8544_UTIL_OFFSET 0xe0000ULL
#define MPC8544_SPIN_BASE 0xEF000000ULL
+#define MPC8XXX_GPIO_OFFSET 0x000FF000ULL
+#define MPC8XXX_GPIO_IRQ 43
struct boot_info
{
@@ -122,6 +124,23 @@ static void dt_serial_create(void *fdt, unsigned long long
offset,
}
}
+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);
+
+ qemu_fdt_add_subnode(fdt, node);
+ qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,qoriq-gpio");
+ qemu_fdt_setprop_cells(fdt, node, "reg", mmio0, 0x1000);
+ qemu_fdt_setprop_cells(fdt, node, "interrupts", irq0, 0x2);
+ 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);
+
+ g_free(node);
+}
+
static int ppce500_load_device_tree(MachineState *machine,
PPCE500Params *params,
hwaddr addr,
@@ -379,6 +398,10 @@ static int ppce500_load_device_tree(MachineState *machine,
qemu_fdt_setprop_cell(fdt, pci, "#address-cells", 3);
qemu_fdt_setprop_string(fdt, "/aliases", "pci0", pci);
+ if (params->has_mpc8xxx_gpio) {
+ create_dt_mpc8xxx_gpio(fdt, soc, mpic);
+ }
+
params->fixup_devtree(params, fdt);
if (toplevel_compat) {
@@ -769,6 +792,15 @@ void ppce500_init(MachineState *machine, PPCE500Params
*params)
cur_base = (32 * 1024 * 1024);
}
+ if (params->has_mpc8xxx_gpio) {
+ 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));
+ }
+
/* Load kernel. */
if (machine->kernel_filename) {
kernel_base = cur_base;
diff --git a/hw/ppc/e500.h b/hw/ppc/e500.h
index 08b25fa..83c5b8b 100644
--- a/hw/ppc/e500.h
+++ b/hw/ppc/e500.h
@@ -11,6 +11,7 @@ typedef struct PPCE500Params {
void (*fixup_devtree)(struct PPCE500Params *params, void *fdt);
int mpic_version;
+ bool has_mpc8xxx_gpio;
} PPCE500Params;
void ppce500_init(MachineState *machine, PPCE500Params *params);
diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
index 27df31d..bafb56d 100644
--- a/hw/ppc/e500plat.c
+++ b/hw/ppc/e500plat.c
@@ -35,6 +35,7 @@ static void e500plat_init(MachineState *machine)
.pci_nr_slots = PCI_SLOT_MAX - 1,
.fixup_devtree = e500plat_fixup_devtree,
.mpic_version = OPENPIC_MODEL_FSL_MPIC_42,
+ .has_mpc8xxx_gpio = true,
};
/* Older KVM versions don't support EPR which breaks guests when we
announce
--
1.8.1.4
- [Qemu-devel] [PULL 19/33] spapr_nvram: Enable migration, (continued)
- [Qemu-devel] [PULL 19/33] spapr_nvram: Enable migration, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 02/33] ppc: use CRF_* in int_helper.c, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 06/33] target-ppc: Fix kvmppc_set_compat to use negotiated cpu-version, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 07/33] target-ppc: Implement IVOR[59] By Default for Book E, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 11/33] target-ppc : Allow fc[tf]id[*] mnemonics for non TARGET_PPC64, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 12/33] target-ppc : Add new processor type 440x5wDFPU, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 18/33] PPC: E500: Hook up power off GPIO to GPIO controller, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 13/33] hw/pci/ppc4xx_pci.c: Remove unused pci4xx_cfgaddr_read/write/ops, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 04/33] ppc: rename gen_set_cr6_from_fpscr, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 08/33] target-ppc: virtex-ml507 machine type should depend on CONFIG_XILINX, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 17/33] PPC: E500: Instantiate MPC8XXX gpio controller on virt machine,
Alexander Graf <=
- [Qemu-devel] [PULL 14/33] target-ppc: Use macros in opcodes table handling code, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 24/33] sysbus: Make devices spawnable via -device, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 05/33] ppc: compute mask from BI using right shift, Alexander Graf, 2014/11/04
- [Qemu-devel] [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-devel] [PULL 15/33] target-ppc: Fix an invalid free in opcode table handling code., Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 26/33] sysbus: Expose MMIO enumeration helper, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 23/33] sysbus: Add dynamic sysbus device search, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 27/33] sysbus: Add new platform bus helper device, Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 20/33] target-ppc: kvm: Fix memory overflow issue about strncat(), Alexander Graf, 2014/11/04
- [Qemu-devel] [PULL 30/33] target-ppc: simplify AES emulation, Alexander Graf, 2014/11/04