ge_imp3a.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * GE IMP3A Board Setup
  3. *
  4. * Author Martyn Welch <martyn.welch@ge.com>
  5. *
  6. * Copyright 2010 GE Intelligent Platforms Embedded Systems, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * Based on: mpc85xx_ds.c (MPC85xx DS Board Setup)
  14. * Copyright 2007 Freescale Semiconductor Inc.
  15. */
  16. #include <linux/stddef.h>
  17. #include <linux/kernel.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/delay.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/of_platform.h>
  24. #include <asm/time.h>
  25. #include <asm/machdep.h>
  26. #include <asm/pci-bridge.h>
  27. #include <mm/mmu_decl.h>
  28. #include <asm/prom.h>
  29. #include <asm/udbg.h>
  30. #include <asm/mpic.h>
  31. #include <asm/swiotlb.h>
  32. #include <asm/nvram.h>
  33. #include <sysdev/fsl_soc.h>
  34. #include <sysdev/fsl_pci.h>
  35. #include "smp.h"
  36. #include "mpc85xx.h"
  37. #include <sysdev/ge/ge_pic.h>
  38. void __iomem *imp3a_regs;
  39. void __init ge_imp3a_pic_init(void)
  40. {
  41. struct mpic *mpic;
  42. struct device_node *np;
  43. struct device_node *cascade_node = NULL;
  44. unsigned long root = of_get_flat_dt_root();
  45. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
  46. mpic = mpic_alloc(NULL, 0,
  47. MPIC_NO_RESET |
  48. MPIC_BIG_ENDIAN |
  49. MPIC_SINGLE_DEST_CPU,
  50. 0, 256, " OpenPIC ");
  51. } else {
  52. mpic = mpic_alloc(NULL, 0,
  53. MPIC_BIG_ENDIAN |
  54. MPIC_SINGLE_DEST_CPU,
  55. 0, 256, " OpenPIC ");
  56. }
  57. BUG_ON(mpic == NULL);
  58. mpic_init(mpic);
  59. /*
  60. * There is a simple interrupt handler in the main FPGA, this needs
  61. * to be cascaded into the MPIC
  62. */
  63. for_each_node_by_type(np, "interrupt-controller")
  64. if (of_device_is_compatible(np, "gef,fpga-pic-1.00")) {
  65. cascade_node = np;
  66. break;
  67. }
  68. if (cascade_node == NULL) {
  69. printk(KERN_WARNING "IMP3A: No FPGA PIC\n");
  70. return;
  71. }
  72. gef_pic_init(cascade_node);
  73. of_node_put(cascade_node);
  74. }
  75. static void ge_imp3a_pci_assign_primary(void)
  76. {
  77. #ifdef CONFIG_PCI
  78. struct device_node *np;
  79. struct resource rsrc;
  80. for_each_node_by_type(np, "pci") {
  81. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  82. of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
  83. of_device_is_compatible(np, "fsl,p2020-pcie")) {
  84. of_address_to_resource(np, 0, &rsrc);
  85. if ((rsrc.start & 0xfffff) == 0x9000)
  86. fsl_pci_primary = np;
  87. }
  88. }
  89. #endif
  90. }
  91. /*
  92. * Setup the architecture
  93. */
  94. static void __init ge_imp3a_setup_arch(void)
  95. {
  96. struct device_node *regs;
  97. if (ppc_md.progress)
  98. ppc_md.progress("ge_imp3a_setup_arch()", 0);
  99. mpc85xx_smp_init();
  100. ge_imp3a_pci_assign_primary();
  101. swiotlb_detect_4g();
  102. /* Remap basic board registers */
  103. regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
  104. if (regs) {
  105. imp3a_regs = of_iomap(regs, 0);
  106. if (imp3a_regs == NULL)
  107. printk(KERN_WARNING "Unable to map board registers\n");
  108. of_node_put(regs);
  109. }
  110. #if defined(CONFIG_MMIO_NVRAM)
  111. mmio_nvram_init();
  112. #endif
  113. printk(KERN_INFO "GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
  114. }
  115. /* Return the PCB revision */
  116. static unsigned int ge_imp3a_get_pcb_rev(void)
  117. {
  118. unsigned int reg;
  119. reg = ioread16(imp3a_regs);
  120. return (reg >> 8) & 0xff;
  121. }
  122. /* Return the board (software) revision */
  123. static unsigned int ge_imp3a_get_board_rev(void)
  124. {
  125. unsigned int reg;
  126. reg = ioread16(imp3a_regs + 0x2);
  127. return reg & 0xff;
  128. }
  129. /* Return the FPGA revision */
  130. static unsigned int ge_imp3a_get_fpga_rev(void)
  131. {
  132. unsigned int reg;
  133. reg = ioread16(imp3a_regs + 0x2);
  134. return (reg >> 8) & 0xff;
  135. }
  136. /* Return compactPCI Geographical Address */
  137. static unsigned int ge_imp3a_get_cpci_geo_addr(void)
  138. {
  139. unsigned int reg;
  140. reg = ioread16(imp3a_regs + 0x6);
  141. return (reg & 0x0f00) >> 8;
  142. }
  143. /* Return compactPCI System Controller Status */
  144. static unsigned int ge_imp3a_get_cpci_is_syscon(void)
  145. {
  146. unsigned int reg;
  147. reg = ioread16(imp3a_regs + 0x6);
  148. return reg & (1 << 12);
  149. }
  150. static void ge_imp3a_show_cpuinfo(struct seq_file *m)
  151. {
  152. seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");
  153. seq_printf(m, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
  154. ('A' + ge_imp3a_get_board_rev() - 1));
  155. seq_printf(m, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
  156. seq_printf(m, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
  157. seq_printf(m, "cPCI syscon\t: %s\n",
  158. ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
  159. }
  160. /*
  161. * Called very early, device-tree isn't unflattened
  162. */
  163. static int __init ge_imp3a_probe(void)
  164. {
  165. unsigned long root = of_get_flat_dt_root();
  166. return of_flat_dt_is_compatible(root, "ge,IMP3A");
  167. }
  168. machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);
  169. machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
  170. define_machine(ge_imp3a) {
  171. .name = "GE_IMP3A",
  172. .probe = ge_imp3a_probe,
  173. .setup_arch = ge_imp3a_setup_arch,
  174. .init_IRQ = ge_imp3a_pic_init,
  175. .show_cpuinfo = ge_imp3a_show_cpuinfo,
  176. #ifdef CONFIG_PCI
  177. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  178. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  179. #endif
  180. .get_irq = mpic_get_irq,
  181. .restart = fsl_rstcr_restart,
  182. .calibrate_decr = generic_calibrate_decr,
  183. .progress = udbg_progress,
  184. };