gef_ppc9a.c 5.6 KB

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