corenet_generic.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 = "mdio-mux-gpio"
  77. },
  78. {
  79. .compatible = "fsl,fpga-ngpixis"
  80. },
  81. {
  82. .compatible = "fsl,fpga-qixis"
  83. },
  84. {
  85. .compatible = "fsl,srio",
  86. },
  87. {
  88. .compatible = "fsl,p4080-pcie",
  89. },
  90. {
  91. .compatible = "fsl,qoriq-pcie-v2.2",
  92. },
  93. {
  94. .compatible = "fsl,qoriq-pcie-v2.3",
  95. },
  96. {
  97. .compatible = "fsl,qoriq-pcie-v2.4",
  98. },
  99. {
  100. .compatible = "fsl,qoriq-pcie-v3.0",
  101. },
  102. {
  103. .compatible = "fsl,qe",
  104. },
  105. {
  106. .compatible = "fsl,fman",
  107. },
  108. /* The following two are for the Freescale hypervisor */
  109. {
  110. .name = "hypervisor",
  111. },
  112. {
  113. .name = "handles",
  114. },
  115. {}
  116. };
  117. int __init corenet_gen_publish_devices(void)
  118. {
  119. return of_platform_bus_probe(NULL, of_device_ids, NULL);
  120. }
  121. static const char * const boards[] __initconst = {
  122. "fsl,P2041RDB",
  123. "fsl,P3041DS",
  124. "fsl,OCA4080",
  125. "fsl,P4080DS",
  126. "fsl,P5020DS",
  127. "fsl,P5040DS",
  128. "fsl,T2080QDS",
  129. "fsl,T2080RDB",
  130. "fsl,T2081QDS",
  131. "fsl,T4240QDS",
  132. "fsl,T4240RDB",
  133. "fsl,B4860QDS",
  134. "fsl,B4420QDS",
  135. "fsl,B4220QDS",
  136. "fsl,T1023RDB",
  137. "fsl,T1024QDS",
  138. "fsl,T1024RDB",
  139. "fsl,T1040D4RDB",
  140. "fsl,T1042D4RDB",
  141. "fsl,T1040QDS",
  142. "fsl,T1042QDS",
  143. "fsl,T1040RDB",
  144. "fsl,T1042RDB",
  145. "fsl,T1042RDB_PI",
  146. "keymile,kmcoge4",
  147. "varisys,CYRUS",
  148. NULL
  149. };
  150. /*
  151. * Called very early, device-tree isn't unflattened
  152. */
  153. static int __init corenet_generic_probe(void)
  154. {
  155. unsigned long root = of_get_flat_dt_root();
  156. char hv_compat[24];
  157. int i;
  158. #ifdef CONFIG_SMP
  159. extern struct smp_ops_t smp_85xx_ops;
  160. #endif
  161. if (of_flat_dt_match(root, boards))
  162. return 1;
  163. /* Check if we're running under the Freescale hypervisor */
  164. for (i = 0; boards[i]; i++) {
  165. snprintf(hv_compat, sizeof(hv_compat), "%s-hv", boards[i]);
  166. if (of_flat_dt_is_compatible(root, hv_compat)) {
  167. ppc_md.init_IRQ = ehv_pic_init;
  168. ppc_md.get_irq = ehv_pic_get_irq;
  169. ppc_md.restart = fsl_hv_restart;
  170. pm_power_off = fsl_hv_halt;
  171. ppc_md.halt = fsl_hv_halt;
  172. #ifdef CONFIG_SMP
  173. /*
  174. * Disable the timebase sync operations because we
  175. * can't write to the timebase registers under the
  176. * hypervisor.
  177. */
  178. smp_85xx_ops.give_timebase = NULL;
  179. smp_85xx_ops.take_timebase = NULL;
  180. #endif
  181. return 1;
  182. }
  183. }
  184. return 0;
  185. }
  186. define_machine(corenet_generic) {
  187. .name = "CoreNet Generic",
  188. .probe = corenet_generic_probe,
  189. .setup_arch = corenet_gen_setup_arch,
  190. .init_IRQ = corenet_gen_pic_init,
  191. #ifdef CONFIG_PCI
  192. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  193. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  194. #endif
  195. /*
  196. * Core reset may cause issues if using the proxy mode of MPIC.
  197. * So, use the mixed mode of MPIC if enabling CPU hotplug.
  198. *
  199. * Likewise, problems have been seen with kexec when coreint is enabled.
  200. */
  201. #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_KEXEC)
  202. .get_irq = mpic_get_irq,
  203. #else
  204. .get_irq = mpic_get_coreint_irq,
  205. #endif
  206. .restart = fsl_rstcr_restart,
  207. .calibrate_decr = generic_calibrate_decr,
  208. .progress = udbg_progress,
  209. #ifdef CONFIG_PPC64
  210. .power_save = book3e_idle,
  211. #else
  212. .power_save = e500_idle,
  213. #endif
  214. };
  215. machine_arch_initcall(corenet_generic, corenet_gen_publish_devices);
  216. #ifdef CONFIG_SWIOTLB
  217. machine_arch_initcall(corenet_generic, swiotlb_setup_bus_notifier);
  218. #endif