ksi8560.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Board setup routines for the Emerson KSI8560
  3. *
  4. * Author: Alexandr Smirnov <asmirnov@ru.mvista.com>
  5. *
  6. * Based on mpc85xx_ads.c maintained by Kumar Gala
  7. *
  8. * 2008 (c) MontaVista, Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. *
  13. */
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/delay.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/of_platform.h>
  21. #include <asm/system.h>
  22. #include <asm/time.h>
  23. #include <asm/machdep.h>
  24. #include <asm/pci-bridge.h>
  25. #include <asm/mpic.h>
  26. #include <mm/mmu_decl.h>
  27. #include <asm/udbg.h>
  28. #include <asm/prom.h>
  29. #include <sysdev/fsl_soc.h>
  30. #include <sysdev/fsl_pci.h>
  31. #include <asm/cpm2.h>
  32. #include <sysdev/cpm2_pic.h>
  33. #include "mpc85xx.h"
  34. #define KSI8560_CPLD_HVR 0x04 /* Hardware Version Register */
  35. #define KSI8560_CPLD_PVR 0x08 /* PLD Version Register */
  36. #define KSI8560_CPLD_RCR1 0x30 /* Reset Command Register 1 */
  37. #define KSI8560_CPLD_RCR1_CPUHR 0x80 /* CPU Hard Reset */
  38. static void __iomem *cpld_base = NULL;
  39. static void machine_restart(char *cmd)
  40. {
  41. if (cpld_base)
  42. out_8(cpld_base + KSI8560_CPLD_RCR1, KSI8560_CPLD_RCR1_CPUHR);
  43. else
  44. printk(KERN_ERR "Can't find CPLD base, hang forever\n");
  45. for (;;);
  46. }
  47. static void __init ksi8560_pic_init(void)
  48. {
  49. struct mpic *mpic;
  50. struct device_node *np;
  51. np = of_find_node_by_type(NULL, "open-pic");
  52. if (np == NULL) {
  53. printk(KERN_ERR "Could not find open-pic node\n");
  54. return;
  55. }
  56. mpic = mpic_alloc(np, 0,
  57. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  58. 0, 256, " OpenPIC ");
  59. BUG_ON(mpic == NULL);
  60. of_node_put(np);
  61. mpic_init(mpic);
  62. mpc85xx_cpm2_pic_init();
  63. }
  64. #ifdef CONFIG_CPM2
  65. /*
  66. * Setup I/O ports
  67. */
  68. struct cpm_pin {
  69. int port, pin, flags;
  70. };
  71. static struct cpm_pin __initdata ksi8560_pins[] = {
  72. /* SCC1 */
  73. {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  74. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  75. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  76. /* SCC2 */
  77. {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  78. {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  79. {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  80. /* FCC1 */
  81. {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  82. {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  83. {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  84. {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  85. {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  86. {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  87. {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  88. {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  89. {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  90. {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  91. {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  92. {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  93. {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  94. {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  95. {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK9 */
  96. {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK10 */
  97. };
  98. static void __init init_ioports(void)
  99. {
  100. int i;
  101. for (i = 0; i < ARRAY_SIZE(ksi8560_pins); i++) {
  102. struct cpm_pin *pin = &ksi8560_pins[i];
  103. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  104. }
  105. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
  106. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
  107. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
  108. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
  109. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_RX);
  110. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
  111. }
  112. #endif
  113. /*
  114. * Setup the architecture
  115. */
  116. static void __init ksi8560_setup_arch(void)
  117. {
  118. struct device_node *cpld;
  119. cpld = of_find_compatible_node(NULL, NULL, "emerson,KSI8560-cpld");
  120. if (cpld)
  121. cpld_base = of_iomap(cpld, 0);
  122. else
  123. printk(KERN_ERR "Can't find CPLD in device tree\n");
  124. if (ppc_md.progress)
  125. ppc_md.progress("ksi8560_setup_arch()", 0);
  126. #ifdef CONFIG_CPM2
  127. cpm2_reset();
  128. init_ioports();
  129. #endif
  130. }
  131. static void ksi8560_show_cpuinfo(struct seq_file *m)
  132. {
  133. uint pvid, svid, phid1;
  134. pvid = mfspr(SPRN_PVR);
  135. svid = mfspr(SPRN_SVR);
  136. seq_printf(m, "Vendor\t\t: Emerson Network Power\n");
  137. seq_printf(m, "Board\t\t: KSI8560\n");
  138. if (cpld_base) {
  139. seq_printf(m, "Hardware rev\t: %d\n",
  140. in_8(cpld_base + KSI8560_CPLD_HVR));
  141. seq_printf(m, "CPLD rev\t: %d\n",
  142. in_8(cpld_base + KSI8560_CPLD_PVR));
  143. } else
  144. seq_printf(m, "Unknown Hardware and CPLD revs\n");
  145. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  146. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  147. /* Display cpu Pll setting */
  148. phid1 = mfspr(SPRN_HID1);
  149. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  150. }
  151. machine_device_initcall(ksi8560, mpc85xx_common_publish_devices);
  152. /*
  153. * Called very early, device-tree isn't unflattened
  154. */
  155. static int __init ksi8560_probe(void)
  156. {
  157. unsigned long root = of_get_flat_dt_root();
  158. return of_flat_dt_is_compatible(root, "emerson,KSI8560");
  159. }
  160. define_machine(ksi8560) {
  161. .name = "KSI8560",
  162. .probe = ksi8560_probe,
  163. .setup_arch = ksi8560_setup_arch,
  164. .init_IRQ = ksi8560_pic_init,
  165. .show_cpuinfo = ksi8560_show_cpuinfo,
  166. .get_irq = mpic_get_irq,
  167. .restart = machine_restart,
  168. .calibrate_decr = generic_calibrate_decr,
  169. };