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