mpc85xx_ds.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * MPC85xx DS Board Setup
  3. *
  4. * Author Xianghua Xiao (x.xiao@freescale.com)
  5. * Roy Zang <tie-fei.zang@freescale.com>
  6. * - Add PCI/PCI Exprees support
  7. * Copyright 2007 Freescale Semiconductor Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/delay.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/of_platform.h>
  22. #include <asm/time.h>
  23. #include <asm/machdep.h>
  24. #include <asm/pci-bridge.h>
  25. #include <mm/mmu_decl.h>
  26. #include <asm/prom.h>
  27. #include <asm/udbg.h>
  28. #include <asm/mpic.h>
  29. #include <asm/i8259.h>
  30. #include <asm/swiotlb.h>
  31. #include <sysdev/fsl_soc.h>
  32. #include <sysdev/fsl_pci.h>
  33. #include "smp.h"
  34. #include "mpc85xx.h"
  35. #undef DEBUG
  36. #ifdef DEBUG
  37. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
  38. #else
  39. #define DBG(fmt, args...)
  40. #endif
  41. #ifdef CONFIG_PPC_I8259
  42. static void mpc85xx_8259_cascade(struct irq_desc *desc)
  43. {
  44. struct irq_chip *chip = irq_desc_get_chip(desc);
  45. unsigned int cascade_irq = i8259_irq();
  46. if (cascade_irq) {
  47. generic_handle_irq(cascade_irq);
  48. }
  49. chip->irq_eoi(&desc->irq_data);
  50. }
  51. #endif /* CONFIG_PPC_I8259 */
  52. void __init mpc85xx_ds_pic_init(void)
  53. {
  54. struct mpic *mpic;
  55. #ifdef CONFIG_PPC_I8259
  56. struct device_node *np;
  57. struct device_node *cascade_node = NULL;
  58. int cascade_irq;
  59. #endif
  60. if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
  61. mpic = mpic_alloc(NULL, 0,
  62. MPIC_NO_RESET |
  63. MPIC_BIG_ENDIAN |
  64. MPIC_SINGLE_DEST_CPU,
  65. 0, 256, " OpenPIC ");
  66. } else {
  67. mpic = mpic_alloc(NULL, 0,
  68. MPIC_BIG_ENDIAN |
  69. MPIC_SINGLE_DEST_CPU,
  70. 0, 256, " OpenPIC ");
  71. }
  72. BUG_ON(mpic == NULL);
  73. mpic_init(mpic);
  74. #ifdef CONFIG_PPC_I8259
  75. /* Initialize the i8259 controller */
  76. for_each_node_by_type(np, "interrupt-controller")
  77. if (of_device_is_compatible(np, "chrp,iic")) {
  78. cascade_node = np;
  79. break;
  80. }
  81. if (cascade_node == NULL) {
  82. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  83. return;
  84. }
  85. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  86. if (!cascade_irq) {
  87. printk(KERN_ERR "Failed to map cascade interrupt\n");
  88. return;
  89. }
  90. DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
  91. i8259_init(cascade_node, 0);
  92. of_node_put(cascade_node);
  93. irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  94. #endif /* CONFIG_PPC_I8259 */
  95. }
  96. #ifdef CONFIG_PCI
  97. extern int uli_exclude_device(struct pci_controller *hose,
  98. u_char bus, u_char devfn);
  99. static struct device_node *pci_with_uli;
  100. static int mpc85xx_exclude_device(struct pci_controller *hose,
  101. u_char bus, u_char devfn)
  102. {
  103. if (hose->dn == pci_with_uli)
  104. return uli_exclude_device(hose, bus, devfn);
  105. return PCIBIOS_SUCCESSFUL;
  106. }
  107. #endif /* CONFIG_PCI */
  108. static void __init mpc85xx_ds_uli_init(void)
  109. {
  110. #ifdef CONFIG_PCI
  111. struct device_node *node;
  112. /* See if we have a ULI under the primary */
  113. node = of_find_node_by_name(NULL, "uli1575");
  114. while ((pci_with_uli = of_get_parent(node))) {
  115. of_node_put(node);
  116. node = pci_with_uli;
  117. if (pci_with_uli == fsl_pci_primary) {
  118. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  119. break;
  120. }
  121. }
  122. #endif
  123. }
  124. /*
  125. * Setup the architecture
  126. */
  127. static void __init mpc85xx_ds_setup_arch(void)
  128. {
  129. if (ppc_md.progress)
  130. ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
  131. swiotlb_detect_4g();
  132. fsl_pci_assign_primary();
  133. mpc85xx_ds_uli_init();
  134. mpc85xx_smp_init();
  135. printk("MPC85xx DS board from Freescale Semiconductor\n");
  136. }
  137. /*
  138. * Called very early, device-tree isn't unflattened
  139. */
  140. static int __init mpc8544_ds_probe(void)
  141. {
  142. return !!of_machine_is_compatible("MPC8544DS");
  143. }
  144. machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
  145. machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
  146. machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
  147. machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
  148. machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
  149. machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
  150. /*
  151. * Called very early, device-tree isn't unflattened
  152. */
  153. static int __init mpc8572_ds_probe(void)
  154. {
  155. return !!of_machine_is_compatible("fsl,MPC8572DS");
  156. }
  157. /*
  158. * Called very early, device-tree isn't unflattened
  159. */
  160. static int __init p2020_ds_probe(void)
  161. {
  162. return !!of_machine_is_compatible("fsl,P2020DS");
  163. }
  164. define_machine(mpc8544_ds) {
  165. .name = "MPC8544 DS",
  166. .probe = mpc8544_ds_probe,
  167. .setup_arch = mpc85xx_ds_setup_arch,
  168. .init_IRQ = mpc85xx_ds_pic_init,
  169. #ifdef CONFIG_PCI
  170. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  171. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  172. #endif
  173. .get_irq = mpic_get_irq,
  174. .calibrate_decr = generic_calibrate_decr,
  175. .progress = udbg_progress,
  176. };
  177. define_machine(mpc8572_ds) {
  178. .name = "MPC8572 DS",
  179. .probe = mpc8572_ds_probe,
  180. .setup_arch = mpc85xx_ds_setup_arch,
  181. .init_IRQ = mpc85xx_ds_pic_init,
  182. #ifdef CONFIG_PCI
  183. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  184. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  185. #endif
  186. .get_irq = mpic_get_irq,
  187. .calibrate_decr = generic_calibrate_decr,
  188. .progress = udbg_progress,
  189. };
  190. define_machine(p2020_ds) {
  191. .name = "P2020 DS",
  192. .probe = p2020_ds_probe,
  193. .setup_arch = mpc85xx_ds_setup_arch,
  194. .init_IRQ = mpc85xx_ds_pic_init,
  195. #ifdef CONFIG_PCI
  196. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  197. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  198. #endif
  199. .get_irq = mpic_get_irq,
  200. .calibrate_decr = generic_calibrate_decr,
  201. .progress = udbg_progress,
  202. };