ge_imp3a.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
  45. mpic = mpic_alloc(NULL, 0,
  46. MPIC_NO_RESET |
  47. MPIC_BIG_ENDIAN |
  48. MPIC_SINGLE_DEST_CPU,
  49. 0, 256, " OpenPIC ");
  50. } else {
  51. mpic = mpic_alloc(NULL, 0,
  52. MPIC_BIG_ENDIAN |
  53. MPIC_SINGLE_DEST_CPU,
  54. 0, 256, " OpenPIC ");
  55. }
  56. BUG_ON(mpic == NULL);
  57. mpic_init(mpic);
  58. /*
  59. * There is a simple interrupt handler in the main FPGA, this needs
  60. * to be cascaded into the MPIC
  61. */
  62. for_each_node_by_type(np, "interrupt-controller")
  63. if (of_device_is_compatible(np, "gef,fpga-pic-1.00")) {
  64. cascade_node = np;
  65. break;
  66. }
  67. if (cascade_node == NULL) {
  68. printk(KERN_WARNING "IMP3A: No FPGA PIC\n");
  69. return;
  70. }
  71. gef_pic_init(cascade_node);
  72. of_node_put(cascade_node);
  73. }
  74. static void ge_imp3a_pci_assign_primary(void)
  75. {
  76. #ifdef CONFIG_PCI
  77. struct device_node *np;
  78. struct resource rsrc;
  79. for_each_node_by_type(np, "pci") {
  80. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  81. of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
  82. of_device_is_compatible(np, "fsl,p2020-pcie")) {
  83. of_address_to_resource(np, 0, &rsrc);
  84. if ((rsrc.start & 0xfffff) == 0x9000)
  85. fsl_pci_primary = np;
  86. }
  87. }
  88. #endif
  89. }
  90. /*
  91. * Setup the architecture
  92. */
  93. static void __init ge_imp3a_setup_arch(void)
  94. {
  95. struct device_node *regs;
  96. if (ppc_md.progress)
  97. ppc_md.progress("ge_imp3a_setup_arch()", 0);
  98. mpc85xx_smp_init();
  99. ge_imp3a_pci_assign_primary();
  100. swiotlb_detect_4g();
  101. /* Remap basic board registers */
  102. regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
  103. if (regs) {
  104. imp3a_regs = of_iomap(regs, 0);
  105. if (imp3a_regs == NULL)
  106. printk(KERN_WARNING "Unable to map board registers\n");
  107. of_node_put(regs);
  108. }
  109. #if defined(CONFIG_MMIO_NVRAM)
  110. mmio_nvram_init();
  111. #endif
  112. printk(KERN_INFO "GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
  113. }
  114. /* Return the PCB revision */
  115. static unsigned int ge_imp3a_get_pcb_rev(void)
  116. {
  117. unsigned int reg;
  118. reg = ioread16(imp3a_regs);
  119. return (reg >> 8) & 0xff;
  120. }
  121. /* Return the board (software) revision */
  122. static unsigned int ge_imp3a_get_board_rev(void)
  123. {
  124. unsigned int reg;
  125. reg = ioread16(imp3a_regs + 0x2);
  126. return reg & 0xff;
  127. }
  128. /* Return the FPGA revision */
  129. static unsigned int ge_imp3a_get_fpga_rev(void)
  130. {
  131. unsigned int reg;
  132. reg = ioread16(imp3a_regs + 0x2);
  133. return (reg >> 8) & 0xff;
  134. }
  135. /* Return compactPCI Geographical Address */
  136. static unsigned int ge_imp3a_get_cpci_geo_addr(void)
  137. {
  138. unsigned int reg;
  139. reg = ioread16(imp3a_regs + 0x6);
  140. return (reg & 0x0f00) >> 8;
  141. }
  142. /* Return compactPCI System Controller Status */
  143. static unsigned int ge_imp3a_get_cpci_is_syscon(void)
  144. {
  145. unsigned int reg;
  146. reg = ioread16(imp3a_regs + 0x6);
  147. return reg & (1 << 12);
  148. }
  149. static void ge_imp3a_show_cpuinfo(struct seq_file *m)
  150. {
  151. seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");
  152. seq_printf(m, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
  153. ('A' + ge_imp3a_get_board_rev() - 1));
  154. seq_printf(m, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
  155. seq_printf(m, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
  156. seq_printf(m, "cPCI syscon\t: %s\n",
  157. ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
  158. }
  159. /*
  160. * Called very early, device-tree isn't unflattened
  161. */
  162. static int __init ge_imp3a_probe(void)
  163. {
  164. return of_machine_is_compatible("ge,IMP3A");
  165. }
  166. machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);
  167. machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
  168. define_machine(ge_imp3a) {
  169. .name = "GE_IMP3A",
  170. .probe = ge_imp3a_probe,
  171. .setup_arch = ge_imp3a_setup_arch,
  172. .init_IRQ = ge_imp3a_pic_init,
  173. .show_cpuinfo = ge_imp3a_show_cpuinfo,
  174. #ifdef CONFIG_PCI
  175. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  176. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  177. #endif
  178. .get_irq = mpic_get_irq,
  179. .calibrate_decr = generic_calibrate_decr,
  180. .progress = udbg_progress,
  181. };