qemu_e500.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Paravirt target for a generic QEMU e500 machine
  3. *
  4. * This is intended to be a flexible device-tree-driven platform, not fixed
  5. * to a particular piece of hardware or a particular spec of virtual hardware,
  6. * beyond the assumption of an e500-family CPU. Some things are still hardcoded
  7. * here, such as MPIC, but this is a limitation of the current code rather than
  8. * an interface contract with QEMU.
  9. *
  10. * Copyright 2012 Freescale Semiconductor Inc.
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/of_fdt.h>
  19. #include <asm/machdep.h>
  20. #include <asm/pgtable.h>
  21. #include <asm/time.h>
  22. #include <asm/udbg.h>
  23. #include <asm/mpic.h>
  24. #include <sysdev/fsl_soc.h>
  25. #include <sysdev/fsl_pci.h>
  26. #include "smp.h"
  27. #include "mpc85xx.h"
  28. void __init qemu_e500_pic_init(void)
  29. {
  30. struct mpic *mpic;
  31. unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
  32. MPIC_ENABLE_COREINT;
  33. mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
  34. BUG_ON(mpic == NULL);
  35. mpic_init(mpic);
  36. }
  37. static void __init qemu_e500_setup_arch(void)
  38. {
  39. ppc_md.progress("qemu_e500_setup_arch()", 0);
  40. fsl_pci_assign_primary();
  41. swiotlb_detect_4g();
  42. #if defined(CONFIG_FSL_PCI) && defined(CONFIG_ZONE_DMA32)
  43. /*
  44. * Inbound windows don't cover the full lower 4 GiB
  45. * due to conflicts with PCICSRBAR and outbound windows,
  46. * so limit the DMA32 zone to 2 GiB, to allow consistent
  47. * allocations to succeed.
  48. */
  49. limit_zone_pfn(ZONE_DMA32, 1UL << (31 - PAGE_SHIFT));
  50. #endif
  51. mpc85xx_smp_init();
  52. }
  53. /*
  54. * Called very early, device-tree isn't unflattened
  55. */
  56. static int __init qemu_e500_probe(void)
  57. {
  58. unsigned long root = of_get_flat_dt_root();
  59. return !!of_flat_dt_is_compatible(root, "fsl,qemu-e500");
  60. }
  61. machine_arch_initcall(qemu_e500, mpc85xx_common_publish_devices);
  62. define_machine(qemu_e500) {
  63. .name = "QEMU e500",
  64. .probe = qemu_e500_probe,
  65. .setup_arch = qemu_e500_setup_arch,
  66. .init_IRQ = qemu_e500_pic_init,
  67. #ifdef CONFIG_PCI
  68. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  69. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  70. #endif
  71. .get_irq = mpic_get_coreint_irq,
  72. .restart = fsl_rstcr_restart,
  73. .calibrate_decr = generic_calibrate_decr,
  74. .progress = udbg_progress,
  75. };