xref: /openbmc/qemu/hw/ppc/e500plat.c (revision 59e816fd)
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 
120d75590dSPeter Maydell #include "qemu/osdep.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"
1777ac58ddSPaolo Bonzini #include "sysemu/kvm.h"
189c17d615SPaolo Bonzini #include "hw/pci/pci.h"
190d09e41aSPaolo Bonzini #include "hw/ppc/openpic.h"
203b961124SStuart Yoder #include "kvm_ppc.h"
214d5c29caSScott Wood 
224d5c29caSScott Wood static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt)
234d5c29caSScott Wood {
244d5c29caSScott Wood     const char model[] = "QEMU ppce500";
254d5c29caSScott Wood     const char compatible[] = "fsl,qemu-e500";
264d5c29caSScott Wood 
275a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "model", model, sizeof(model));
285a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "compatible", compatible,
294d5c29caSScott Wood                      sizeof(compatible));
304d5c29caSScott Wood }
314d5c29caSScott Wood 
323ef96221SMarcel Apfelbaum static void e500plat_init(MachineState *machine)
334d5c29caSScott Wood {
344d5c29caSScott Wood     PPCE500Params params = {
353bb7e02aSAlexander Graf         .pci_first_slot = 0x1,
363bb7e02aSAlexander Graf         .pci_nr_slots = PCI_SLOT_MAX - 1,
374d5c29caSScott Wood         .fixup_devtree = e500plat_fixup_devtree,
38f5fba9d2SScott Wood         .mpic_version = OPENPIC_MODEL_FSL_MPIC_42,
39b88e77f4SAlexander Graf         .has_mpc8xxx_gpio = true,
40f7087343SAlexander Graf         .has_platform_bus = true,
41f7087343SAlexander Graf         .platform_bus_base = 0xf00000000ULL,
42f7087343SAlexander Graf         .platform_bus_size = (128ULL * 1024 * 1024),
43f7087343SAlexander Graf         .platform_bus_first_irq = 5,
44f7087343SAlexander Graf         .platform_bus_num_irqs = 10,
45e6b4e5f4SAlexander Graf         .ccsrbar_base = 0xFE0000000ULL,
46e6b4e5f4SAlexander Graf         .pci_pio_base = 0xFE1000000ULL,
47cb3778a0SAlexander Graf         .pci_mmio_base = 0xC00000000ULL,
48cb3778a0SAlexander Graf         .pci_mmio_bus_base = 0xE0000000ULL,
49e6b4e5f4SAlexander Graf         .spin_base = 0xFEF000000ULL,
504d5c29caSScott Wood     };
514d5c29caSScott Wood 
523b961124SStuart Yoder     /* Older KVM versions don't support EPR which breaks guests when we announce
533b961124SStuart Yoder        MPIC variants that support EPR. Revert to an older one for those */
543b961124SStuart Yoder     if (kvm_enabled() && !kvmppc_has_cap_epr()) {
553b961124SStuart Yoder         params.mpic_version = OPENPIC_MODEL_FSL_MPIC_20;
563b961124SStuart Yoder     }
573b961124SStuart Yoder 
583ef96221SMarcel Apfelbaum     ppce500_init(machine, &params);
594d5c29caSScott Wood }
604d5c29caSScott Wood 
61e264d29dSEduardo Habkost static void e500plat_machine_init(MachineClass *mc)
624d5c29caSScott Wood {
63e264d29dSEduardo Habkost     mc->desc = "generic paravirt e500 platform";
64e264d29dSEduardo Habkost     mc->init = e500plat_init;
65e264d29dSEduardo Habkost     mc->max_cpus = 32;
66e264d29dSEduardo Habkost     mc->has_dynamic_sysbus = true;
67*59e816fdSIgor Mammedov     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30");
684d5c29caSScott Wood }
694d5c29caSScott Wood 
70e264d29dSEduardo Habkost DEFINE_MACHINE("ppce500", e500plat_machine_init)
71