mpc85xx_ds.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 <asm/system.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 <sysdev/fsl_soc.h>
  31. #include <sysdev/fsl_pci.h>
  32. #undef DEBUG
  33. #ifdef DEBUG
  34. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
  35. #else
  36. #define DBG(fmt, args...)
  37. #endif
  38. #ifdef CONFIG_PPC_I8259
  39. static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  40. {
  41. unsigned int cascade_irq = i8259_irq();
  42. if (cascade_irq != NO_IRQ) {
  43. generic_handle_irq(cascade_irq);
  44. }
  45. desc->chip->eoi(irq);
  46. }
  47. #endif /* CONFIG_PPC_I8259 */
  48. void __init mpc85xx_ds_pic_init(void)
  49. {
  50. struct mpic *mpic;
  51. struct resource r;
  52. struct device_node *np = NULL;
  53. #ifdef CONFIG_PPC_I8259
  54. struct device_node *cascade_node = NULL;
  55. int cascade_irq;
  56. #endif
  57. np = of_find_node_by_type(np, "open-pic");
  58. if (np == NULL) {
  59. printk(KERN_ERR "Could not find open-pic node\n");
  60. return;
  61. }
  62. if (of_address_to_resource(np, 0, &r)) {
  63. printk(KERN_ERR "Failed to map mpic register space\n");
  64. of_node_put(np);
  65. return;
  66. }
  67. mpic = mpic_alloc(np, r.start,
  68. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  69. 0, 256, " OpenPIC ");
  70. BUG_ON(mpic == NULL);
  71. mpic_init(mpic);
  72. #ifdef CONFIG_PPC_I8259
  73. /* Initialize the i8259 controller */
  74. for_each_node_by_type(np, "interrupt-controller")
  75. if (of_device_is_compatible(np, "chrp,iic")) {
  76. cascade_node = np;
  77. break;
  78. }
  79. if (cascade_node == NULL) {
  80. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  81. return;
  82. }
  83. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  84. if (cascade_irq == NO_IRQ) {
  85. printk(KERN_ERR "Failed to map cascade interrupt\n");
  86. return;
  87. }
  88. DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
  89. i8259_init(cascade_node, 0);
  90. of_node_put(cascade_node);
  91. set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  92. #endif /* CONFIG_PPC_I8259 */
  93. }
  94. #ifdef CONFIG_PCI
  95. static int primary_phb_addr;
  96. extern int uses_fsl_uli_m1575;
  97. extern int uli_exclude_device(struct pci_controller *hose,
  98. u_char bus, u_char devfn);
  99. static int mpc85xx_exclude_device(struct pci_controller *hose,
  100. u_char bus, u_char devfn)
  101. {
  102. struct device_node* node;
  103. struct resource rsrc;
  104. node = (struct device_node *)hose->arch_data;
  105. of_address_to_resource(node, 0, &rsrc);
  106. if ((rsrc.start & 0xfffff) == primary_phb_addr) {
  107. return uli_exclude_device(hose, bus, devfn);
  108. }
  109. return PCIBIOS_SUCCESSFUL;
  110. }
  111. #endif /* CONFIG_PCI */
  112. /*
  113. * Setup the architecture
  114. */
  115. static void __init mpc85xx_ds_setup_arch(void)
  116. {
  117. #ifdef CONFIG_PCI
  118. struct device_node *np;
  119. #endif
  120. if (ppc_md.progress)
  121. ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
  122. #ifdef CONFIG_PCI
  123. for_each_node_by_type(np, "pci") {
  124. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  125. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  126. struct resource rsrc;
  127. of_address_to_resource(np, 0, &rsrc);
  128. if ((rsrc.start & 0xfffff) == primary_phb_addr)
  129. fsl_add_bridge(np, 1);
  130. else
  131. fsl_add_bridge(np, 0);
  132. }
  133. }
  134. uses_fsl_uli_m1575 = 1;
  135. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  136. #endif
  137. printk("MPC85xx DS board from Freescale Semiconductor\n");
  138. }
  139. /*
  140. * Called very early, device-tree isn't unflattened
  141. */
  142. static int __init mpc8544_ds_probe(void)
  143. {
  144. unsigned long root = of_get_flat_dt_root();
  145. if (of_flat_dt_is_compatible(root, "MPC8544DS")) {
  146. #ifdef CONFIG_PCI
  147. primary_phb_addr = 0xb000;
  148. #endif
  149. return 1;
  150. } else {
  151. return 0;
  152. }
  153. }
  154. /*
  155. * Called very early, device-tree isn't unflattened
  156. */
  157. static int __init mpc8572_ds_probe(void)
  158. {
  159. unsigned long root = of_get_flat_dt_root();
  160. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) {
  161. #ifdef CONFIG_PCI
  162. primary_phb_addr = 0x8000;
  163. #endif
  164. return 1;
  165. } else {
  166. return 0;
  167. }
  168. }
  169. define_machine(mpc8544_ds) {
  170. .name = "MPC8544 DS",
  171. .probe = mpc8544_ds_probe,
  172. .setup_arch = mpc85xx_ds_setup_arch,
  173. .init_IRQ = mpc85xx_ds_pic_init,
  174. #ifdef CONFIG_PCI
  175. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  176. #endif
  177. .get_irq = mpic_get_irq,
  178. .restart = fsl_rstcr_restart,
  179. .calibrate_decr = generic_calibrate_decr,
  180. .progress = udbg_progress,
  181. };
  182. define_machine(mpc8572_ds) {
  183. .name = "MPC8572 DS",
  184. .probe = mpc8572_ds_probe,
  185. .setup_arch = mpc85xx_ds_setup_arch,
  186. .init_IRQ = mpc85xx_ds_pic_init,
  187. #ifdef CONFIG_PCI
  188. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  189. #endif
  190. .get_irq = mpic_get_irq,
  191. .restart = fsl_rstcr_restart,
  192. .calibrate_decr = generic_calibrate_decr,
  193. .progress = udbg_progress,
  194. };