mpc85xx_ds.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 <linux/memblock.h>
  23. #include <asm/time.h>
  24. #include <asm/machdep.h>
  25. #include <asm/pci-bridge.h>
  26. #include <mm/mmu_decl.h>
  27. #include <asm/prom.h>
  28. #include <asm/udbg.h>
  29. #include <asm/mpic.h>
  30. #include <asm/i8259.h>
  31. #include <asm/swiotlb.h>
  32. #include <sysdev/fsl_soc.h>
  33. #include <sysdev/fsl_pci.h>
  34. #include "smp.h"
  35. #include "mpc85xx.h"
  36. #undef DEBUG
  37. #ifdef DEBUG
  38. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
  39. #else
  40. #define DBG(fmt, args...)
  41. #endif
  42. #ifdef CONFIG_PPC_I8259
  43. static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  44. {
  45. struct irq_chip *chip = irq_desc_get_chip(desc);
  46. unsigned int cascade_irq = i8259_irq();
  47. if (cascade_irq != NO_IRQ) {
  48. generic_handle_irq(cascade_irq);
  49. }
  50. chip->irq_eoi(&desc->irq_data);
  51. }
  52. #endif /* CONFIG_PPC_I8259 */
  53. void __init mpc85xx_ds_pic_init(void)
  54. {
  55. struct mpic *mpic;
  56. #ifdef CONFIG_PPC_I8259
  57. struct device_node *np;
  58. struct device_node *cascade_node = NULL;
  59. int cascade_irq;
  60. #endif
  61. unsigned long root = of_get_flat_dt_root();
  62. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
  63. mpic = mpic_alloc(NULL, 0,
  64. MPIC_NO_RESET |
  65. MPIC_BIG_ENDIAN |
  66. MPIC_SINGLE_DEST_CPU,
  67. 0, 256, " OpenPIC ");
  68. } else {
  69. mpic = mpic_alloc(NULL, 0,
  70. MPIC_BIG_ENDIAN |
  71. MPIC_SINGLE_DEST_CPU,
  72. 0, 256, " OpenPIC ");
  73. }
  74. BUG_ON(mpic == NULL);
  75. mpic_init(mpic);
  76. #ifdef CONFIG_PPC_I8259
  77. /* Initialize the i8259 controller */
  78. for_each_node_by_type(np, "interrupt-controller")
  79. if (of_device_is_compatible(np, "chrp,iic")) {
  80. cascade_node = np;
  81. break;
  82. }
  83. if (cascade_node == NULL) {
  84. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  85. return;
  86. }
  87. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  88. if (cascade_irq == NO_IRQ) {
  89. printk(KERN_ERR "Failed to map cascade interrupt\n");
  90. return;
  91. }
  92. DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
  93. i8259_init(cascade_node, 0);
  94. of_node_put(cascade_node);
  95. irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  96. #endif /* CONFIG_PPC_I8259 */
  97. }
  98. #ifdef CONFIG_PCI
  99. extern int uli_exclude_device(struct pci_controller *hose,
  100. u_char bus, u_char devfn);
  101. static struct device_node *pci_with_uli;
  102. static int mpc85xx_exclude_device(struct pci_controller *hose,
  103. u_char bus, u_char devfn)
  104. {
  105. if (hose->dn == pci_with_uli)
  106. return uli_exclude_device(hose, bus, devfn);
  107. return PCIBIOS_SUCCESSFUL;
  108. }
  109. #endif /* CONFIG_PCI */
  110. static void __init mpc85xx_ds_pci_init(void)
  111. {
  112. #ifdef CONFIG_PCI
  113. struct device_node *node;
  114. fsl_pci_init();
  115. /* See if we have a ULI under the primary */
  116. node = of_find_node_by_name(NULL, "uli1575");
  117. while ((pci_with_uli = of_get_parent(node))) {
  118. of_node_put(node);
  119. node = pci_with_uli;
  120. if (pci_with_uli == fsl_pci_primary) {
  121. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  122. break;
  123. }
  124. }
  125. #endif
  126. }
  127. /*
  128. * Setup the architecture
  129. */
  130. static void __init mpc85xx_ds_setup_arch(void)
  131. {
  132. if (ppc_md.progress)
  133. ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
  134. mpc85xx_ds_pci_init();
  135. mpc85xx_smp_init();
  136. printk("MPC85xx DS board from Freescale Semiconductor\n");
  137. }
  138. /*
  139. * Called very early, device-tree isn't unflattened
  140. */
  141. static int __init mpc8544_ds_probe(void)
  142. {
  143. unsigned long root = of_get_flat_dt_root();
  144. return !!of_flat_dt_is_compatible(root, "MPC8544DS");
  145. }
  146. machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
  147. machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
  148. machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
  149. machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
  150. machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
  151. machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
  152. /*
  153. * Called very early, device-tree isn't unflattened
  154. */
  155. static int __init mpc8572_ds_probe(void)
  156. {
  157. unsigned long root = of_get_flat_dt_root();
  158. return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
  159. }
  160. /*
  161. * Called very early, device-tree isn't unflattened
  162. */
  163. static int __init p2020_ds_probe(void)
  164. {
  165. unsigned long root = of_get_flat_dt_root();
  166. return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
  167. }
  168. define_machine(mpc8544_ds) {
  169. .name = "MPC8544 DS",
  170. .probe = mpc8544_ds_probe,
  171. .setup_arch = mpc85xx_ds_setup_arch,
  172. .init_IRQ = mpc85xx_ds_pic_init,
  173. #ifdef CONFIG_PCI
  174. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  175. #endif
  176. .get_irq = mpic_get_irq,
  177. .restart = fsl_rstcr_restart,
  178. .calibrate_decr = generic_calibrate_decr,
  179. .progress = udbg_progress,
  180. };
  181. define_machine(mpc8572_ds) {
  182. .name = "MPC8572 DS",
  183. .probe = mpc8572_ds_probe,
  184. .setup_arch = mpc85xx_ds_setup_arch,
  185. .init_IRQ = mpc85xx_ds_pic_init,
  186. #ifdef CONFIG_PCI
  187. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  188. #endif
  189. .get_irq = mpic_get_irq,
  190. .restart = fsl_rstcr_restart,
  191. .calibrate_decr = generic_calibrate_decr,
  192. .progress = udbg_progress,
  193. };
  194. define_machine(p2020_ds) {
  195. .name = "P2020 DS",
  196. .probe = p2020_ds_probe,
  197. .setup_arch = mpc85xx_ds_setup_arch,
  198. .init_IRQ = mpc85xx_ds_pic_init,
  199. #ifdef CONFIG_PCI
  200. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  201. #endif
  202. .get_irq = mpic_get_irq,
  203. .restart = fsl_rstcr_restart,
  204. .calibrate_decr = generic_calibrate_decr,
  205. .progress = udbg_progress,
  206. };