xref: /openbmc/qemu/hw/ppc/e500plat.c (revision b88e77f4)
14d5c29caSScott Wood /*
24d5c29caSScott Wood  * Generic device-tree-driven paravirt PPC e500 platform
34d5c29caSScott Wood  *
44d5c29caSScott Wood  * Copyright 2012 Freescale Semiconductor, Inc.
54d5c29caSScott Wood  *
64d5c29caSScott Wood  * This is free software; you can redistribute it and/or modify
74d5c29caSScott Wood  * it under the terms of  the GNU General  Public License as published by
84d5c29caSScott Wood  * the Free Software Foundation;  either version 2 of the  License, or
94d5c29caSScott Wood  * (at your option) any later version.
104d5c29caSScott Wood  */
114d5c29caSScott Wood 
124d5c29caSScott Wood #include "config.h"
134d5c29caSScott Wood #include "qemu-common.h"
144d5c29caSScott Wood #include "e500.h"
157948b4b0SPaolo Bonzini #include "hw/boards.h"
169c17d615SPaolo Bonzini #include "sysemu/device_tree.h"
179c17d615SPaolo Bonzini #include "hw/pci/pci.h"
180d09e41aSPaolo Bonzini #include "hw/ppc/openpic.h"
193b961124SStuart Yoder #include "kvm_ppc.h"
204d5c29caSScott Wood 
214d5c29caSScott Wood static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt)
224d5c29caSScott Wood {
234d5c29caSScott Wood     const char model[] = "QEMU ppce500";
244d5c29caSScott Wood     const char compatible[] = "fsl,qemu-e500";
254d5c29caSScott Wood 
265a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "model", model, sizeof(model));
275a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "compatible", compatible,
284d5c29caSScott Wood                      sizeof(compatible));
294d5c29caSScott Wood }
304d5c29caSScott Wood 
313ef96221SMarcel Apfelbaum static void e500plat_init(MachineState *machine)
324d5c29caSScott Wood {
334d5c29caSScott Wood     PPCE500Params params = {
343bb7e02aSAlexander Graf         .pci_first_slot = 0x1,
353bb7e02aSAlexander Graf         .pci_nr_slots = PCI_SLOT_MAX - 1,
364d5c29caSScott Wood         .fixup_devtree = e500plat_fixup_devtree,
37f5fba9d2SScott Wood         .mpic_version = OPENPIC_MODEL_FSL_MPIC_42,
38*b88e77f4SAlexander Graf         .has_mpc8xxx_gpio = true,
394d5c29caSScott Wood     };
404d5c29caSScott Wood 
413b961124SStuart Yoder     /* Older KVM versions don't support EPR which breaks guests when we announce
423b961124SStuart Yoder        MPIC variants that support EPR. Revert to an older one for those */
433b961124SStuart Yoder     if (kvm_enabled() && !kvmppc_has_cap_epr()) {
443b961124SStuart Yoder         params.mpic_version = OPENPIC_MODEL_FSL_MPIC_20;
453b961124SStuart Yoder     }
463b961124SStuart Yoder 
473ef96221SMarcel Apfelbaum     ppce500_init(machine, &params);
484d5c29caSScott Wood }
494d5c29caSScott Wood 
504d5c29caSScott Wood static QEMUMachine e500plat_machine = {
514d5c29caSScott Wood     .name = "ppce500",
524d5c29caSScott Wood     .desc = "generic paravirt e500 platform",
534d5c29caSScott Wood     .init = e500plat_init,
54f5fba9d2SScott Wood     .max_cpus = 32,
554d5c29caSScott Wood };
564d5c29caSScott Wood 
574d5c29caSScott Wood static void e500plat_machine_init(void)
584d5c29caSScott Wood {
594d5c29caSScott Wood     qemu_register_machine(&e500plat_machine);
604d5c29caSScott Wood }
614d5c29caSScott Wood 
624d5c29caSScott Wood machine_init(e500plat_machine_init);
63