1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Paravirt target for a generic QEMU e500 machine
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * This is intended to be a flexible device-tree-driven platform, not fixed
6*4882a593Smuzhiyun * to a particular piece of hardware or a particular spec of virtual hardware,
7*4882a593Smuzhiyun * beyond the assumption of an e500-family CPU. Some things are still hardcoded
8*4882a593Smuzhiyun * here, such as MPIC, but this is a limitation of the current code rather than
9*4882a593Smuzhiyun * an interface contract with QEMU.
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * Copyright 2012 Freescale Semiconductor Inc.
12*4882a593Smuzhiyun */
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun #include <linux/kernel.h>
15*4882a593Smuzhiyun #include <linux/of_fdt.h>
16*4882a593Smuzhiyun #include <linux/pgtable.h>
17*4882a593Smuzhiyun #include <asm/machdep.h>
18*4882a593Smuzhiyun #include <asm/time.h>
19*4882a593Smuzhiyun #include <asm/udbg.h>
20*4882a593Smuzhiyun #include <asm/mpic.h>
21*4882a593Smuzhiyun #include <asm/swiotlb.h>
22*4882a593Smuzhiyun #include <sysdev/fsl_soc.h>
23*4882a593Smuzhiyun #include <sysdev/fsl_pci.h>
24*4882a593Smuzhiyun #include "smp.h"
25*4882a593Smuzhiyun #include "mpc85xx.h"
26*4882a593Smuzhiyun
qemu_e500_pic_init(void)27*4882a593Smuzhiyun void __init qemu_e500_pic_init(void)
28*4882a593Smuzhiyun {
29*4882a593Smuzhiyun struct mpic *mpic;
30*4882a593Smuzhiyun unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
31*4882a593Smuzhiyun MPIC_ENABLE_COREINT;
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun BUG_ON(mpic == NULL);
36*4882a593Smuzhiyun mpic_init(mpic);
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun
qemu_e500_setup_arch(void)39*4882a593Smuzhiyun static void __init qemu_e500_setup_arch(void)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun ppc_md.progress("qemu_e500_setup_arch()", 0);
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun fsl_pci_assign_primary();
44*4882a593Smuzhiyun swiotlb_detect_4g();
45*4882a593Smuzhiyun mpc85xx_smp_init();
46*4882a593Smuzhiyun }
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun /*
49*4882a593Smuzhiyun * Called very early, device-tree isn't unflattened
50*4882a593Smuzhiyun */
qemu_e500_probe(void)51*4882a593Smuzhiyun static int __init qemu_e500_probe(void)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun return !!of_machine_is_compatible("fsl,qemu-e500");
54*4882a593Smuzhiyun }
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun machine_arch_initcall(qemu_e500, mpc85xx_common_publish_devices);
57*4882a593Smuzhiyun
define_machine(qemu_e500)58*4882a593Smuzhiyun define_machine(qemu_e500) {
59*4882a593Smuzhiyun .name = "QEMU e500",
60*4882a593Smuzhiyun .probe = qemu_e500_probe,
61*4882a593Smuzhiyun .setup_arch = qemu_e500_setup_arch,
62*4882a593Smuzhiyun .init_IRQ = qemu_e500_pic_init,
63*4882a593Smuzhiyun #ifdef CONFIG_PCI
64*4882a593Smuzhiyun .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
65*4882a593Smuzhiyun .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
66*4882a593Smuzhiyun #endif
67*4882a593Smuzhiyun .get_irq = mpic_get_coreint_irq,
68*4882a593Smuzhiyun .calibrate_decr = generic_calibrate_decr,
69*4882a593Smuzhiyun .progress = udbg_progress,
70*4882a593Smuzhiyun };
71