xref: /openbmc/qemu/hw/ppc/e500plat.c (revision 0bd1909d)
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"
18*0bd1909dSEduardo Habkost #include "hw/sysbus.h"
199c17d615SPaolo Bonzini #include "hw/pci/pci.h"
200d09e41aSPaolo Bonzini #include "hw/ppc/openpic.h"
213b961124SStuart Yoder #include "kvm_ppc.h"
224d5c29caSScott Wood 
234d5c29caSScott Wood static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt)
244d5c29caSScott Wood {
254d5c29caSScott Wood     const char model[] = "QEMU ppce500";
264d5c29caSScott Wood     const char compatible[] = "fsl,qemu-e500";
274d5c29caSScott Wood 
285a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "model", model, sizeof(model));
295a4348d1SPeter Crosthwaite     qemu_fdt_setprop(fdt, "/", "compatible", compatible,
304d5c29caSScott Wood                      sizeof(compatible));
314d5c29caSScott Wood }
324d5c29caSScott Wood 
333ef96221SMarcel Apfelbaum static void e500plat_init(MachineState *machine)
344d5c29caSScott Wood {
354d5c29caSScott Wood     PPCE500Params params = {
363bb7e02aSAlexander Graf         .pci_first_slot = 0x1,
373bb7e02aSAlexander Graf         .pci_nr_slots = PCI_SLOT_MAX - 1,
384d5c29caSScott Wood         .fixup_devtree = e500plat_fixup_devtree,
39f5fba9d2SScott Wood         .mpic_version = OPENPIC_MODEL_FSL_MPIC_42,
40b88e77f4SAlexander Graf         .has_mpc8xxx_gpio = true,
41f7087343SAlexander Graf         .has_platform_bus = true,
42f7087343SAlexander Graf         .platform_bus_base = 0xf00000000ULL,
43f7087343SAlexander Graf         .platform_bus_size = (128ULL * 1024 * 1024),
44f7087343SAlexander Graf         .platform_bus_first_irq = 5,
45f7087343SAlexander Graf         .platform_bus_num_irqs = 10,
46e6b4e5f4SAlexander Graf         .ccsrbar_base = 0xFE0000000ULL,
47e6b4e5f4SAlexander Graf         .pci_pio_base = 0xFE1000000ULL,
48cb3778a0SAlexander Graf         .pci_mmio_base = 0xC00000000ULL,
49cb3778a0SAlexander Graf         .pci_mmio_bus_base = 0xE0000000ULL,
50e6b4e5f4SAlexander Graf         .spin_base = 0xFEF000000ULL,
514d5c29caSScott Wood     };
524d5c29caSScott Wood 
533b961124SStuart Yoder     /* Older KVM versions don't support EPR which breaks guests when we announce
543b961124SStuart Yoder        MPIC variants that support EPR. Revert to an older one for those */
553b961124SStuart Yoder     if (kvm_enabled() && !kvmppc_has_cap_epr()) {
563b961124SStuart Yoder         params.mpic_version = OPENPIC_MODEL_FSL_MPIC_20;
573b961124SStuart Yoder     }
583b961124SStuart Yoder 
593ef96221SMarcel Apfelbaum     ppce500_init(machine, &params);
604d5c29caSScott Wood }
614d5c29caSScott Wood 
62e264d29dSEduardo Habkost static void e500plat_machine_init(MachineClass *mc)
634d5c29caSScott Wood {
64e264d29dSEduardo Habkost     mc->desc = "generic paravirt e500 platform";
65e264d29dSEduardo Habkost     mc->init = e500plat_init;
66e264d29dSEduardo Habkost     mc->max_cpus = 32;
67*0bd1909dSEduardo Habkost     /*TODO: allow only sysbus devices that really work with this machine */
68*0bd1909dSEduardo Habkost     machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE);
6959e816fdSIgor Mammedov     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30");
704d5c29caSScott Wood }
714d5c29caSScott Wood 
72e264d29dSEduardo Habkost DEFINE_MACHINE("ppce500", e500plat_machine_init)
73