gef_ppc9a.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * GE PPC9A board support
  3. *
  4. * Author: Martyn Welch <martyn.welch@ge.com>
  5. *
  6. * Copyright 2008 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: mpc86xx_hpcn.c (MPC86xx HPCN board specific routines)
  14. * Copyright 2006 Freescale Semiconductor Inc.
  15. *
  16. * NEC fixup adapted from arch/mips/pci/fixup-lm2e.c
  17. */
  18. #include <linux/stddef.h>
  19. #include <linux/kernel.h>
  20. #include <linux/pci.h>
  21. #include <linux/kdev_t.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/of_platform.h>
  25. #include <asm/system.h>
  26. #include <asm/time.h>
  27. #include <asm/machdep.h>
  28. #include <asm/pci-bridge.h>
  29. #include <asm/prom.h>
  30. #include <mm/mmu_decl.h>
  31. #include <asm/udbg.h>
  32. #include <asm/mpic.h>
  33. #include <asm/nvram.h>
  34. #include <sysdev/fsl_pci.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include "mpc86xx.h"
  37. #include "gef_pic.h"
  38. #undef DEBUG
  39. #ifdef DEBUG
  40. #define DBG (fmt...) do { printk(KERN_ERR "PPC9A: " fmt); } while (0)
  41. #else
  42. #define DBG (fmt...) do { } while (0)
  43. #endif
  44. void __iomem *ppc9a_regs;
  45. static void __init gef_ppc9a_init_irq(void)
  46. {
  47. struct device_node *cascade_node = NULL;
  48. mpc86xx_init_irq();
  49. /*
  50. * There is a simple interrupt handler in the main FPGA, this needs
  51. * to be cascaded into the MPIC
  52. */
  53. cascade_node = of_find_compatible_node(NULL, NULL, "gef,fpga-pic-1.00");
  54. if (!cascade_node) {
  55. printk(KERN_WARNING "PPC9A: No FPGA PIC\n");
  56. return;
  57. }
  58. gef_pic_init(cascade_node);
  59. of_node_put(cascade_node);
  60. }
  61. static void __init gef_ppc9a_setup_arch(void)
  62. {
  63. struct device_node *regs;
  64. #ifdef CONFIG_PCI
  65. struct device_node *np;
  66. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  67. fsl_add_bridge(np, 1);
  68. }
  69. #endif
  70. printk(KERN_INFO "GE Intelligent Platforms PPC9A 6U VME SBC\n");
  71. #ifdef CONFIG_SMP
  72. mpc86xx_smp_init();
  73. #endif
  74. /* Remap basic board registers */
  75. regs = of_find_compatible_node(NULL, NULL, "gef,ppc9a-fpga-regs");
  76. if (regs) {
  77. ppc9a_regs = of_iomap(regs, 0);
  78. if (ppc9a_regs == NULL)
  79. printk(KERN_WARNING "Unable to map board registers\n");
  80. of_node_put(regs);
  81. }
  82. #if defined(CONFIG_MMIO_NVRAM)
  83. mmio_nvram_init();
  84. #endif
  85. }
  86. /* Return the PCB revision */
  87. static unsigned int gef_ppc9a_get_pcb_rev(void)
  88. {
  89. unsigned int reg;
  90. reg = ioread32be(ppc9a_regs);
  91. return (reg >> 16) & 0xff;
  92. }
  93. /* Return the board (software) revision */
  94. static unsigned int gef_ppc9a_get_board_rev(void)
  95. {
  96. unsigned int reg;
  97. reg = ioread32be(ppc9a_regs);
  98. return (reg >> 8) & 0xff;
  99. }
  100. /* Return the FPGA revision */
  101. static unsigned int gef_ppc9a_get_fpga_rev(void)
  102. {
  103. unsigned int reg;
  104. reg = ioread32be(ppc9a_regs);
  105. return reg & 0xf;
  106. }
  107. /* Return VME Geographical Address */
  108. static unsigned int gef_ppc9a_get_vme_geo_addr(void)
  109. {
  110. unsigned int reg;
  111. reg = ioread32be(ppc9a_regs + 0x4);
  112. return reg & 0x1f;
  113. }
  114. /* Return VME System Controller Status */
  115. static unsigned int gef_ppc9a_get_vme_is_syscon(void)
  116. {
  117. unsigned int reg;
  118. reg = ioread32be(ppc9a_regs + 0x4);
  119. return (reg >> 9) & 0x1;
  120. }
  121. static void gef_ppc9a_show_cpuinfo(struct seq_file *m)
  122. {
  123. uint svid = mfspr(SPRN_SVR);
  124. seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");
  125. seq_printf(m, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(),
  126. ('A' + gef_ppc9a_get_board_rev()));
  127. seq_printf(m, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev());
  128. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  129. seq_printf(m, "VME geo. addr\t: %u\n", gef_ppc9a_get_vme_geo_addr());
  130. seq_printf(m, "VME syscon\t: %s\n",
  131. gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");
  132. }
  133. static void __init gef_ppc9a_nec_fixup(struct pci_dev *pdev)
  134. {
  135. unsigned int val;
  136. /* Do not do the fixup on other platforms! */
  137. if (!machine_is(gef_ppc9a))
  138. return;
  139. printk(KERN_INFO "Running NEC uPD720101 Fixup\n");
  140. /* Ensure ports 1, 2, 3, 4 & 5 are enabled */
  141. pci_read_config_dword(pdev, 0xe0, &val);
  142. pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x5);
  143. /* System clock is 48-MHz Oscillator and EHCI Enabled. */
  144. pci_write_config_dword(pdev, 0xe4, 1 << 5);
  145. }
  146. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
  147. gef_ppc9a_nec_fixup);
  148. /*
  149. * Called very early, device-tree isn't unflattened
  150. *
  151. * This function is called to determine whether the BSP is compatible with the
  152. * supplied device-tree, which is assumed to be the correct one for the actual
  153. * board. It is expected thati, in the future, a kernel may support multiple
  154. * boards.
  155. */
  156. static int __init gef_ppc9a_probe(void)
  157. {
  158. unsigned long root = of_get_flat_dt_root();
  159. if (of_flat_dt_is_compatible(root, "gef,ppc9a"))
  160. return 1;
  161. return 0;
  162. }
  163. static long __init mpc86xx_time_init(void)
  164. {
  165. unsigned int temp;
  166. /* Set the time base to zero */
  167. mtspr(SPRN_TBWL, 0);
  168. mtspr(SPRN_TBWU, 0);
  169. temp = mfspr(SPRN_HID0);
  170. temp |= HID0_TBEN;
  171. mtspr(SPRN_HID0, temp);
  172. asm volatile("isync");
  173. return 0;
  174. }
  175. static __initdata struct of_device_id of_bus_ids[] = {
  176. { .compatible = "simple-bus", },
  177. { .compatible = "gianfar", },
  178. {},
  179. };
  180. static int __init declare_of_platform_devices(void)
  181. {
  182. printk(KERN_DEBUG "Probe platform devices\n");
  183. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  184. return 0;
  185. }
  186. machine_device_initcall(gef_ppc9a, declare_of_platform_devices);
  187. define_machine(gef_ppc9a) {
  188. .name = "GE PPC9A",
  189. .probe = gef_ppc9a_probe,
  190. .setup_arch = gef_ppc9a_setup_arch,
  191. .init_IRQ = gef_ppc9a_init_irq,
  192. .show_cpuinfo = gef_ppc9a_show_cpuinfo,
  193. .get_irq = mpic_get_irq,
  194. .restart = fsl_rstcr_restart,
  195. .time_init = mpc86xx_time_init,
  196. .calibrate_decr = generic_calibrate_decr,
  197. .progress = udbg_progress,
  198. #ifdef CONFIG_PCI
  199. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  200. #endif
  201. };