ge_imp3a.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 <linux/memblock.h>
  25. #include <asm/system.h>
  26. #include <asm/time.h>
  27. #include <asm/machdep.h>
  28. #include <asm/pci-bridge.h>
  29. #include <mm/mmu_decl.h>
  30. #include <asm/prom.h>
  31. #include <asm/udbg.h>
  32. #include <asm/mpic.h>
  33. #include <asm/swiotlb.h>
  34. #include <asm/nvram.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include <sysdev/fsl_pci.h>
  37. #include "smp.h"
  38. #include "mpc85xx.h"
  39. #include <sysdev/ge/ge_pic.h>
  40. void __iomem *imp3a_regs;
  41. void __init ge_imp3a_pic_init(void)
  42. {
  43. struct mpic *mpic;
  44. struct device_node *np;
  45. struct device_node *cascade_node = NULL;
  46. unsigned long root = of_get_flat_dt_root();
  47. if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
  48. mpic = mpic_alloc(NULL, 0,
  49. MPIC_NO_RESET |
  50. MPIC_BIG_ENDIAN |
  51. MPIC_SINGLE_DEST_CPU,
  52. 0, 256, " OpenPIC ");
  53. } else {
  54. mpic = mpic_alloc(NULL, 0,
  55. MPIC_BIG_ENDIAN |
  56. MPIC_SINGLE_DEST_CPU,
  57. 0, 256, " OpenPIC ");
  58. }
  59. BUG_ON(mpic == NULL);
  60. mpic_init(mpic);
  61. /*
  62. * There is a simple interrupt handler in the main FPGA, this needs
  63. * to be cascaded into the MPIC
  64. */
  65. for_each_node_by_type(np, "interrupt-controller")
  66. if (of_device_is_compatible(np, "gef,fpga-pic-1.00")) {
  67. cascade_node = np;
  68. break;
  69. }
  70. if (cascade_node == NULL) {
  71. printk(KERN_WARNING "IMP3A: No FPGA PIC\n");
  72. return;
  73. }
  74. gef_pic_init(cascade_node);
  75. of_node_put(cascade_node);
  76. }
  77. #ifdef CONFIG_PCI
  78. static int primary_phb_addr;
  79. #endif /* CONFIG_PCI */
  80. /*
  81. * Setup the architecture
  82. */
  83. static void __init ge_imp3a_setup_arch(void)
  84. {
  85. struct device_node *regs;
  86. #ifdef CONFIG_PCI
  87. struct device_node *np;
  88. struct pci_controller *hose;
  89. #endif
  90. dma_addr_t max = 0xffffffff;
  91. if (ppc_md.progress)
  92. ppc_md.progress("ge_imp3a_setup_arch()", 0);
  93. #ifdef CONFIG_PCI
  94. for_each_node_by_type(np, "pci") {
  95. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  96. of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
  97. of_device_is_compatible(np, "fsl,p2020-pcie")) {
  98. struct resource rsrc;
  99. of_address_to_resource(np, 0, &rsrc);
  100. if ((rsrc.start & 0xfffff) == primary_phb_addr)
  101. fsl_add_bridge(np, 1);
  102. else
  103. fsl_add_bridge(np, 0);
  104. hose = pci_find_hose_for_OF_device(np);
  105. max = min(max, hose->dma_window_base_cur +
  106. hose->dma_window_size);
  107. }
  108. }
  109. #endif
  110. mpc85xx_smp_init();
  111. #ifdef CONFIG_SWIOTLB
  112. if (memblock_end_of_DRAM() > max) {
  113. ppc_swiotlb_enable = 1;
  114. set_pci_dma_ops(&swiotlb_dma_ops);
  115. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  116. }
  117. #endif
  118. /* Remap basic board registers */
  119. regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
  120. if (regs) {
  121. imp3a_regs = of_iomap(regs, 0);
  122. if (imp3a_regs == NULL)
  123. printk(KERN_WARNING "Unable to map board registers\n");
  124. of_node_put(regs);
  125. }
  126. #if defined(CONFIG_MMIO_NVRAM)
  127. mmio_nvram_init();
  128. #endif
  129. printk(KERN_INFO "GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
  130. }
  131. /* Return the PCB revision */
  132. static unsigned int ge_imp3a_get_pcb_rev(void)
  133. {
  134. unsigned int reg;
  135. reg = ioread16(imp3a_regs);
  136. return (reg >> 8) & 0xff;
  137. }
  138. /* Return the board (software) revision */
  139. static unsigned int ge_imp3a_get_board_rev(void)
  140. {
  141. unsigned int reg;
  142. reg = ioread16(imp3a_regs + 0x2);
  143. return reg & 0xff;
  144. }
  145. /* Return the FPGA revision */
  146. static unsigned int ge_imp3a_get_fpga_rev(void)
  147. {
  148. unsigned int reg;
  149. reg = ioread16(imp3a_regs + 0x2);
  150. return (reg >> 8) & 0xff;
  151. }
  152. /* Return compactPCI Geographical Address */
  153. static unsigned int ge_imp3a_get_cpci_geo_addr(void)
  154. {
  155. unsigned int reg;
  156. reg = ioread16(imp3a_regs + 0x6);
  157. return (reg & 0x0f00) >> 8;
  158. }
  159. /* Return compactPCI System Controller Status */
  160. static unsigned int ge_imp3a_get_cpci_is_syscon(void)
  161. {
  162. unsigned int reg;
  163. reg = ioread16(imp3a_regs + 0x6);
  164. return reg & (1 << 12);
  165. }
  166. static void ge_imp3a_show_cpuinfo(struct seq_file *m)
  167. {
  168. seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");
  169. seq_printf(m, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
  170. ('A' + ge_imp3a_get_board_rev() - 1));
  171. seq_printf(m, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
  172. seq_printf(m, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
  173. seq_printf(m, "cPCI syscon\t: %s\n",
  174. ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
  175. }
  176. /*
  177. * Called very early, device-tree isn't unflattened
  178. */
  179. static int __init ge_imp3a_probe(void)
  180. {
  181. unsigned long root = of_get_flat_dt_root();
  182. if (of_flat_dt_is_compatible(root, "ge,IMP3A")) {
  183. #ifdef CONFIG_PCI
  184. primary_phb_addr = 0x9000;
  185. #endif
  186. return 1;
  187. }
  188. return 0;
  189. }
  190. machine_device_initcall(ge_imp3a, mpc85xx_common_publish_devices);
  191. machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
  192. define_machine(ge_imp3a) {
  193. .name = "GE_IMP3A",
  194. .probe = ge_imp3a_probe,
  195. .setup_arch = ge_imp3a_setup_arch,
  196. .init_IRQ = ge_imp3a_pic_init,
  197. .show_cpuinfo = ge_imp3a_show_cpuinfo,
  198. #ifdef CONFIG_PCI
  199. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  200. #endif
  201. .get_irq = mpic_get_irq,
  202. .restart = fsl_rstcr_restart,
  203. .calibrate_decr = generic_calibrate_decr,
  204. .progress = udbg_progress,
  205. };