mpc8544_ds.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * MPC8544 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 <asm/mpc85xx.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. #include "mpc85xx.h"
  34. #undef DEBUG
  35. #ifdef DEBUG
  36. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
  37. #else
  38. #define DBG(fmt, args...)
  39. #endif
  40. #ifdef CONFIG_PPC_I8259
  41. static void mpc8544_8259_cascade(unsigned int irq, struct irq_desc *desc)
  42. {
  43. unsigned int cascade_irq = i8259_irq();
  44. if (cascade_irq != NO_IRQ) {
  45. generic_handle_irq(cascade_irq);
  46. }
  47. desc->chip->eoi(irq);
  48. }
  49. #endif /* CONFIG_PPC_I8259 */
  50. void __init mpc8544_ds_pic_init(void)
  51. {
  52. struct mpic *mpic;
  53. struct resource r;
  54. struct device_node *np = NULL;
  55. #ifdef CONFIG_PPC_I8259
  56. struct device_node *cascade_node = NULL;
  57. int cascade_irq;
  58. #endif
  59. np = of_find_node_by_type(np, "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. mpic = mpic_alloc(np, r.start,
  70. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  71. 0, 256, " OpenPIC ");
  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 == NO_IRQ) {
  87. printk(KERN_ERR "Failed to map cascade interrupt\n");
  88. return;
  89. }
  90. DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq);
  91. i8259_init(cascade_node, 0);
  92. of_node_put(cascade_node);
  93. set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade);
  94. #endif /* CONFIG_PPC_I8259 */
  95. }
  96. #ifdef CONFIG_PCI
  97. extern int uses_fsl_uli_m1575;
  98. extern int uli_exclude_device(struct pci_controller *hose,
  99. u_char bus, u_char devfn);
  100. static int mpc85xx_exclude_device(struct pci_controller *hose,
  101. u_char bus, u_char devfn)
  102. {
  103. struct device_node* node;
  104. struct resource rsrc;
  105. node = (struct device_node *)hose->arch_data;
  106. of_address_to_resource(node, 0, &rsrc);
  107. if ((rsrc.start & 0xfffff) == 0xb000) {
  108. return uli_exclude_device(hose, bus, devfn);
  109. }
  110. return PCIBIOS_SUCCESSFUL;
  111. }
  112. #endif /* CONFIG_PCI */
  113. /*
  114. * Setup the architecture
  115. */
  116. static void __init mpc8544_ds_setup_arch(void)
  117. {
  118. #ifdef CONFIG_PCI
  119. struct device_node *np;
  120. #endif
  121. if (ppc_md.progress)
  122. ppc_md.progress("mpc8544_ds_setup_arch()", 0);
  123. #ifdef CONFIG_PCI
  124. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
  125. struct resource rsrc;
  126. of_address_to_resource(np, 0, &rsrc);
  127. if ((rsrc.start & 0xfffff) == 0xb000)
  128. fsl_add_bridge(np, 1);
  129. else
  130. fsl_add_bridge(np, 0);
  131. }
  132. uses_fsl_uli_m1575 = 1;
  133. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  134. #endif
  135. printk("MPC8544 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. unsigned long root = of_get_flat_dt_root();
  143. return of_flat_dt_is_compatible(root, "MPC8544DS");
  144. }
  145. define_machine(mpc8544_ds) {
  146. .name = "MPC8544 DS",
  147. .probe = mpc8544_ds_probe,
  148. .setup_arch = mpc8544_ds_setup_arch,
  149. .init_IRQ = mpc8544_ds_pic_init,
  150. #ifdef CONFIG_PCI
  151. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  152. #endif
  153. .get_irq = mpic_get_irq,
  154. .restart = mpc85xx_restart,
  155. .calibrate_decr = generic_calibrate_decr,
  156. .progress = udbg_progress,
  157. };