ksi8560.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 = mpic_alloc(NULL, 0,
  50. MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  51. 0, 256, " OpenPIC ");
  52. BUG_ON(mpic == NULL);
  53. mpic_init(mpic);
  54. mpc85xx_cpm2_pic_init();
  55. }
  56. #ifdef CONFIG_CPM2
  57. /*
  58. * Setup I/O ports
  59. */
  60. struct cpm_pin {
  61. int port, pin, flags;
  62. };
  63. static struct cpm_pin __initdata ksi8560_pins[] = {
  64. /* SCC1 */
  65. {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  66. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  67. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  68. /* SCC2 */
  69. {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  70. {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  71. {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  72. /* FCC1 */
  73. {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  74. {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  75. {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  76. {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  77. {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  78. {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  79. {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  80. {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  81. {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  82. {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  83. {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  84. {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  85. {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  86. {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  87. {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK9 */
  88. {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK10 */
  89. };
  90. static void __init init_ioports(void)
  91. {
  92. int i;
  93. for (i = 0; i < ARRAY_SIZE(ksi8560_pins); i++) {
  94. struct cpm_pin *pin = &ksi8560_pins[i];
  95. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  96. }
  97. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
  98. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
  99. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
  100. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
  101. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_RX);
  102. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
  103. }
  104. #endif
  105. /*
  106. * Setup the architecture
  107. */
  108. static void __init ksi8560_setup_arch(void)
  109. {
  110. struct device_node *cpld;
  111. cpld = of_find_compatible_node(NULL, NULL, "emerson,KSI8560-cpld");
  112. if (cpld)
  113. cpld_base = of_iomap(cpld, 0);
  114. else
  115. printk(KERN_ERR "Can't find CPLD in device tree\n");
  116. if (ppc_md.progress)
  117. ppc_md.progress("ksi8560_setup_arch()", 0);
  118. #ifdef CONFIG_CPM2
  119. cpm2_reset();
  120. init_ioports();
  121. #endif
  122. }
  123. static void ksi8560_show_cpuinfo(struct seq_file *m)
  124. {
  125. uint pvid, svid, phid1;
  126. pvid = mfspr(SPRN_PVR);
  127. svid = mfspr(SPRN_SVR);
  128. seq_printf(m, "Vendor\t\t: Emerson Network Power\n");
  129. seq_printf(m, "Board\t\t: KSI8560\n");
  130. if (cpld_base) {
  131. seq_printf(m, "Hardware rev\t: %d\n",
  132. in_8(cpld_base + KSI8560_CPLD_HVR));
  133. seq_printf(m, "CPLD rev\t: %d\n",
  134. in_8(cpld_base + KSI8560_CPLD_PVR));
  135. } else
  136. seq_printf(m, "Unknown Hardware and CPLD revs\n");
  137. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  138. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  139. /* Display cpu Pll setting */
  140. phid1 = mfspr(SPRN_HID1);
  141. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  142. }
  143. machine_device_initcall(ksi8560, mpc85xx_common_publish_devices);
  144. /*
  145. * Called very early, device-tree isn't unflattened
  146. */
  147. static int __init ksi8560_probe(void)
  148. {
  149. unsigned long root = of_get_flat_dt_root();
  150. return of_flat_dt_is_compatible(root, "emerson,KSI8560");
  151. }
  152. define_machine(ksi8560) {
  153. .name = "KSI8560",
  154. .probe = ksi8560_probe,
  155. .setup_arch = ksi8560_setup_arch,
  156. .init_IRQ = ksi8560_pic_init,
  157. .show_cpuinfo = ksi8560_show_cpuinfo,
  158. .get_irq = mpic_get_irq,
  159. .restart = machine_restart,
  160. .calibrate_decr = generic_calibrate_decr,
  161. };