mpc85xx_ds.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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/system.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 <sysdev/fsl_soc.h>
  32. #include <sysdev/fsl_pci.h>
  33. #undef DEBUG
  34. #ifdef DEBUG
  35. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
  36. #else
  37. #define DBG(fmt, args...)
  38. #endif
  39. #ifdef CONFIG_PPC_I8259
  40. static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  41. {
  42. unsigned int cascade_irq = i8259_irq();
  43. if (cascade_irq != NO_IRQ) {
  44. generic_handle_irq(cascade_irq);
  45. }
  46. desc->chip->eoi(irq);
  47. }
  48. #endif /* CONFIG_PPC_I8259 */
  49. void __init mpc85xx_ds_pic_init(void)
  50. {
  51. struct mpic *mpic;
  52. struct resource r;
  53. struct device_node *np;
  54. #ifdef CONFIG_PPC_I8259
  55. struct device_node *cascade_node = NULL;
  56. int cascade_irq;
  57. #endif
  58. unsigned long root = of_get_flat_dt_root();
  59. np = of_find_node_by_type(NULL, "open-pic");
  60. if (np == NULL) {
  61. printk(KERN_ERR "Could not find open-pic node\n");
  62. return;
  63. }
  64. if (of_address_to_resource(np, 0, &r)) {
  65. printk(KERN_ERR "Failed to map mpic register space\n");
  66. of_node_put(np);
  67. return;
  68. }
  69. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
  70. mpic = mpic_alloc(np, r.start,
  71. MPIC_PRIMARY |
  72. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
  73. 0, 256, " OpenPIC ");
  74. } else {
  75. mpic = mpic_alloc(np, r.start,
  76. MPIC_PRIMARY | MPIC_WANTS_RESET |
  77. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  78. MPIC_SINGLE_DEST_CPU,
  79. 0, 256, " OpenPIC ");
  80. }
  81. BUG_ON(mpic == NULL);
  82. of_node_put(np);
  83. mpic_init(mpic);
  84. #ifdef CONFIG_PPC_I8259
  85. /* Initialize the i8259 controller */
  86. for_each_node_by_type(np, "interrupt-controller")
  87. if (of_device_is_compatible(np, "chrp,iic")) {
  88. cascade_node = np;
  89. break;
  90. }
  91. if (cascade_node == NULL) {
  92. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  93. return;
  94. }
  95. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  96. if (cascade_irq == NO_IRQ) {
  97. printk(KERN_ERR "Failed to map cascade interrupt\n");
  98. return;
  99. }
  100. DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
  101. i8259_init(cascade_node, 0);
  102. of_node_put(cascade_node);
  103. set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  104. #endif /* CONFIG_PPC_I8259 */
  105. }
  106. #ifdef CONFIG_PCI
  107. static int primary_phb_addr;
  108. extern int uli_exclude_device(struct pci_controller *hose,
  109. u_char bus, u_char devfn);
  110. static int mpc85xx_exclude_device(struct pci_controller *hose,
  111. u_char bus, u_char devfn)
  112. {
  113. struct device_node* node;
  114. struct resource rsrc;
  115. node = hose->dn;
  116. of_address_to_resource(node, 0, &rsrc);
  117. if ((rsrc.start & 0xfffff) == primary_phb_addr) {
  118. return uli_exclude_device(hose, bus, devfn);
  119. }
  120. return PCIBIOS_SUCCESSFUL;
  121. }
  122. #endif /* CONFIG_PCI */
  123. /*
  124. * Setup the architecture
  125. */
  126. #ifdef CONFIG_SMP
  127. extern void __init mpc85xx_smp_init(void);
  128. #endif
  129. static void __init mpc85xx_ds_setup_arch(void)
  130. {
  131. #ifdef CONFIG_PCI
  132. struct device_node *np;
  133. #endif
  134. if (ppc_md.progress)
  135. ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
  136. #ifdef CONFIG_PCI
  137. for_each_node_by_type(np, "pci") {
  138. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  139. of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
  140. of_device_is_compatible(np, "fsl,p2020-pcie")) {
  141. struct resource rsrc;
  142. of_address_to_resource(np, 0, &rsrc);
  143. if ((rsrc.start & 0xfffff) == primary_phb_addr)
  144. fsl_add_bridge(np, 1);
  145. else
  146. fsl_add_bridge(np, 0);
  147. }
  148. }
  149. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  150. #endif
  151. #ifdef CONFIG_SMP
  152. mpc85xx_smp_init();
  153. #endif
  154. printk("MPC85xx DS board from Freescale Semiconductor\n");
  155. }
  156. /*
  157. * Called very early, device-tree isn't unflattened
  158. */
  159. static int __init mpc8544_ds_probe(void)
  160. {
  161. unsigned long root = of_get_flat_dt_root();
  162. if (of_flat_dt_is_compatible(root, "MPC8544DS")) {
  163. #ifdef CONFIG_PCI
  164. primary_phb_addr = 0xb000;
  165. #endif
  166. return 1;
  167. }
  168. return 0;
  169. }
  170. static struct of_device_id __initdata mpc85xxds_ids[] = {
  171. { .type = "soc", },
  172. { .compatible = "soc", },
  173. { .compatible = "simple-bus", },
  174. { .compatible = "gianfar", },
  175. {},
  176. };
  177. static int __init mpc85xxds_publish_devices(void)
  178. {
  179. return of_platform_bus_probe(NULL, mpc85xxds_ids, NULL);
  180. }
  181. machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices);
  182. machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices);
  183. machine_device_initcall(p2020_ds, mpc85xxds_publish_devices);
  184. /*
  185. * Called very early, device-tree isn't unflattened
  186. */
  187. static int __init mpc8572_ds_probe(void)
  188. {
  189. unsigned long root = of_get_flat_dt_root();
  190. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) {
  191. #ifdef CONFIG_PCI
  192. primary_phb_addr = 0x8000;
  193. #endif
  194. return 1;
  195. }
  196. return 0;
  197. }
  198. /*
  199. * Called very early, device-tree isn't unflattened
  200. */
  201. static int __init p2020_ds_probe(void)
  202. {
  203. unsigned long root = of_get_flat_dt_root();
  204. if (of_flat_dt_is_compatible(root, "fsl,P2020DS")) {
  205. #ifdef CONFIG_PCI
  206. primary_phb_addr = 0x9000;
  207. #endif
  208. return 1;
  209. }
  210. return 0;
  211. }
  212. define_machine(mpc8544_ds) {
  213. .name = "MPC8544 DS",
  214. .probe = mpc8544_ds_probe,
  215. .setup_arch = mpc85xx_ds_setup_arch,
  216. .init_IRQ = mpc85xx_ds_pic_init,
  217. #ifdef CONFIG_PCI
  218. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  219. #endif
  220. .get_irq = mpic_get_irq,
  221. .restart = fsl_rstcr_restart,
  222. .calibrate_decr = generic_calibrate_decr,
  223. .progress = udbg_progress,
  224. };
  225. define_machine(mpc8572_ds) {
  226. .name = "MPC8572 DS",
  227. .probe = mpc8572_ds_probe,
  228. .setup_arch = mpc85xx_ds_setup_arch,
  229. .init_IRQ = mpc85xx_ds_pic_init,
  230. #ifdef CONFIG_PCI
  231. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  232. #endif
  233. .get_irq = mpic_get_irq,
  234. .restart = fsl_rstcr_restart,
  235. .calibrate_decr = generic_calibrate_decr,
  236. .progress = udbg_progress,
  237. };
  238. define_machine(p2020_ds) {
  239. .name = "P2020 DS",
  240. .probe = p2020_ds_probe,
  241. .setup_arch = mpc85xx_ds_setup_arch,
  242. .init_IRQ = mpc85xx_ds_pic_init,
  243. #ifdef CONFIG_PCI
  244. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  245. #endif
  246. .get_irq = mpic_get_irq,
  247. .restart = fsl_rstcr_restart,
  248. .calibrate_decr = generic_calibrate_decr,
  249. .progress = udbg_progress,
  250. };