corenet_generic.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Corenet based SoC DS Setup
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2009-2011 Freescale Semiconductor Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/kdev_t.h>
  16. #include <linux/delay.h>
  17. #include <linux/interrupt.h>
  18. #include <asm/time.h>
  19. #include <asm/machdep.h>
  20. #include <asm/pci-bridge.h>
  21. #include <asm/pgtable.h>
  22. #include <asm/ppc-pci.h>
  23. #include <mm/mmu_decl.h>
  24. #include <asm/prom.h>
  25. #include <asm/udbg.h>
  26. #include <asm/mpic.h>
  27. #include <asm/ehv_pic.h>
  28. #include <asm/qe_ic.h>
  29. #include <linux/of_platform.h>
  30. #include <sysdev/fsl_soc.h>
  31. #include <sysdev/fsl_pci.h>
  32. #include "smp.h"
  33. #include "mpc85xx.h"
  34. void __init corenet_gen_pic_init(void)
  35. {
  36. struct mpic *mpic;
  37. unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
  38. MPIC_NO_RESET;
  39. struct device_node *np;
  40. if (ppc_md.get_irq == mpic_get_coreint_irq)
  41. flags |= MPIC_ENABLE_COREINT;
  42. mpic = mpic_alloc(NULL, 0, flags, 0, 512, " OpenPIC ");
  43. BUG_ON(mpic == NULL);
  44. mpic_init(mpic);
  45. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  46. if (np) {
  47. qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
  48. qe_ic_cascade_high_mpic);
  49. of_node_put(np);
  50. }
  51. }
  52. /*
  53. * Setup the architecture
  54. */
  55. void __init corenet_gen_setup_arch(void)
  56. {
  57. mpc85xx_smp_init();
  58. swiotlb_detect_4g();
  59. #if defined(CONFIG_FSL_PCI) && defined(CONFIG_ZONE_DMA32)
  60. /*
  61. * Inbound windows don't cover the full lower 4 GiB
  62. * due to conflicts with PCICSRBAR and outbound windows,
  63. * so limit the DMA32 zone to 2 GiB, to allow consistent
  64. * allocations to succeed.
  65. */
  66. limit_zone_pfn(ZONE_DMA32, 1UL << (31 - PAGE_SHIFT));
  67. #endif
  68. pr_info("%s board\n", ppc_md.name);
  69. mpc85xx_qe_init();
  70. }
  71. static const struct of_device_id of_device_ids[] = {
  72. {
  73. .compatible = "simple-bus"
  74. },
  75. {
  76. .compatible = "fsl,srio",
  77. },
  78. {
  79. .compatible = "fsl,p4080-pcie",
  80. },
  81. {
  82. .compatible = "fsl,qoriq-pcie-v2.2",
  83. },
  84. {
  85. .compatible = "fsl,qoriq-pcie-v2.3",
  86. },
  87. {
  88. .compatible = "fsl,qoriq-pcie-v2.4",
  89. },
  90. {
  91. .compatible = "fsl,qoriq-pcie-v3.0",
  92. },
  93. {
  94. .compatible = "fsl,qe",
  95. },
  96. /* The following two are for the Freescale hypervisor */
  97. {
  98. .name = "hypervisor",
  99. },
  100. {
  101. .name = "handles",
  102. },
  103. {}
  104. };
  105. int __init corenet_gen_publish_devices(void)
  106. {
  107. return of_platform_bus_probe(NULL, of_device_ids, NULL);
  108. }
  109. static const char * const boards[] __initconst = {
  110. "fsl,P2041RDB",
  111. "fsl,P3041DS",
  112. "fsl,OCA4080",
  113. "fsl,P4080DS",
  114. "fsl,P5020DS",
  115. "fsl,P5040DS",
  116. "fsl,T2080QDS",
  117. "fsl,T2080RDB",
  118. "fsl,T2081QDS",
  119. "fsl,T4240QDS",
  120. "fsl,T4240RDB",
  121. "fsl,B4860QDS",
  122. "fsl,B4420QDS",
  123. "fsl,B4220QDS",
  124. "fsl,T1040QDS",
  125. "fsl,T1042QDS",
  126. "fsl,T1040RDB",
  127. "fsl,T1042RDB",
  128. "fsl,T1042RDB_PI",
  129. "keymile,kmcoge4",
  130. NULL
  131. };
  132. /*
  133. * Called very early, device-tree isn't unflattened
  134. */
  135. static int __init corenet_generic_probe(void)
  136. {
  137. unsigned long root = of_get_flat_dt_root();
  138. char hv_compat[24];
  139. int i;
  140. #ifdef CONFIG_SMP
  141. extern struct smp_ops_t smp_85xx_ops;
  142. #endif
  143. if (of_flat_dt_match(root, boards))
  144. return 1;
  145. /* Check if we're running under the Freescale hypervisor */
  146. for (i = 0; boards[i]; i++) {
  147. snprintf(hv_compat, sizeof(hv_compat), "%s-hv", boards[i]);
  148. if (of_flat_dt_is_compatible(root, hv_compat)) {
  149. ppc_md.init_IRQ = ehv_pic_init;
  150. ppc_md.get_irq = ehv_pic_get_irq;
  151. ppc_md.restart = fsl_hv_restart;
  152. ppc_md.power_off = fsl_hv_halt;
  153. ppc_md.halt = fsl_hv_halt;
  154. #ifdef CONFIG_SMP
  155. /*
  156. * Disable the timebase sync operations because we
  157. * can't write to the timebase registers under the
  158. * hypervisor.
  159. */
  160. smp_85xx_ops.give_timebase = NULL;
  161. smp_85xx_ops.take_timebase = NULL;
  162. #endif
  163. return 1;
  164. }
  165. }
  166. return 0;
  167. }
  168. define_machine(corenet_generic) {
  169. .name = "CoreNet Generic",
  170. .probe = corenet_generic_probe,
  171. .setup_arch = corenet_gen_setup_arch,
  172. .init_IRQ = corenet_gen_pic_init,
  173. #ifdef CONFIG_PCI
  174. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  175. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  176. #endif
  177. .get_irq = mpic_get_coreint_irq,
  178. .restart = fsl_rstcr_restart,
  179. .calibrate_decr = generic_calibrate_decr,
  180. .progress = udbg_progress,
  181. #ifdef CONFIG_PPC64
  182. .power_save = book3e_idle,
  183. #else
  184. .power_save = e500_idle,
  185. #endif
  186. };
  187. machine_arch_initcall(corenet_generic, corenet_gen_publish_devices);
  188. #ifdef CONFIG_SWIOTLB
  189. machine_arch_initcall(corenet_generic, swiotlb_setup_bus_notifier);
  190. #endif