ksi8560.c 4.8 KB

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