mpc85xx_ads.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * MPC85xx setup and early boot code plus other random bits.
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2005 Freescale Semiconductor 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. #include <linux/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/pci.h>
  16. #include <linux/kdev_t.h>
  17. #include <linux/delay.h>
  18. #include <linux/seq_file.h>
  19. #include <linux/of_platform.h>
  20. #include <asm/system.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 <sysdev/fsl_soc.h>
  28. #include <sysdev/fsl_pci.h>
  29. #ifdef CONFIG_CPM2
  30. #include <asm/cpm2.h>
  31. #include <sysdev/cpm2_pic.h>
  32. #endif
  33. #include "mpc85xx.h"
  34. #ifdef CONFIG_PCI
  35. static int mpc85xx_exclude_device(struct pci_controller *hose,
  36. u_char bus, u_char devfn)
  37. {
  38. if (bus == 0 && PCI_SLOT(devfn) == 0)
  39. return PCIBIOS_DEVICE_NOT_FOUND;
  40. else
  41. return PCIBIOS_SUCCESSFUL;
  42. }
  43. #endif /* CONFIG_PCI */
  44. static void __init mpc85xx_ads_pic_init(void)
  45. {
  46. struct mpic *mpic;
  47. struct device_node *np = NULL;
  48. np = of_find_node_by_type(np, "open-pic");
  49. if (!np) {
  50. printk(KERN_ERR "Could not find open-pic node\n");
  51. return;
  52. }
  53. mpic = mpic_alloc(np, 0,
  54. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  55. 0, 256, " OpenPIC ");
  56. BUG_ON(mpic == NULL);
  57. of_node_put(np);
  58. mpic_init(mpic);
  59. mpc85xx_cpm2_pic_init();
  60. }
  61. /*
  62. * Setup the architecture
  63. */
  64. #ifdef CONFIG_CPM2
  65. struct cpm_pin {
  66. int port, pin, flags;
  67. };
  68. static const struct cpm_pin mpc8560_ads_pins[] = {
  69. /* SCC1 */
  70. {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  71. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  72. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  73. /* SCC2 */
  74. {2, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  75. {2, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  76. {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  77. {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  78. {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  79. /* FCC2 */
  80. {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  81. {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  82. {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  83. {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  84. {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  85. {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  86. {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  87. {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  88. {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  89. {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  90. {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  91. {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  92. {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  93. {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  94. {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK14 */
  95. {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK13 */
  96. /* FCC3 */
  97. {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  98. {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  99. {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  100. {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  101. {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  102. {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  103. {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  104. {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  105. {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  106. {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  107. {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  108. {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  109. {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  110. {2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK16 */
  111. {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK15 */
  112. {2, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  113. };
  114. static void __init init_ioports(void)
  115. {
  116. int i;
  117. for (i = 0; i < ARRAY_SIZE(mpc8560_ads_pins); i++) {
  118. const struct cpm_pin *pin = &mpc8560_ads_pins[i];
  119. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  120. }
  121. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
  122. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
  123. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
  124. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
  125. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
  126. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
  127. cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);
  128. cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);
  129. }
  130. #endif
  131. static void __init mpc85xx_ads_setup_arch(void)
  132. {
  133. #ifdef CONFIG_PCI
  134. struct device_node *np;
  135. #endif
  136. if (ppc_md.progress)
  137. ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
  138. #ifdef CONFIG_CPM2
  139. cpm2_reset();
  140. init_ioports();
  141. #endif
  142. #ifdef CONFIG_PCI
  143. for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
  144. fsl_add_bridge(np, 1);
  145. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  146. #endif
  147. }
  148. static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
  149. {
  150. uint pvid, svid, phid1;
  151. pvid = mfspr(SPRN_PVR);
  152. svid = mfspr(SPRN_SVR);
  153. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  154. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  155. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  156. /* Display cpu Pll setting */
  157. phid1 = mfspr(SPRN_HID1);
  158. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  159. }
  160. machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
  161. /*
  162. * Called very early, device-tree isn't unflattened
  163. */
  164. static int __init mpc85xx_ads_probe(void)
  165. {
  166. unsigned long root = of_get_flat_dt_root();
  167. return of_flat_dt_is_compatible(root, "MPC85xxADS");
  168. }
  169. define_machine(mpc85xx_ads) {
  170. .name = "MPC85xx ADS",
  171. .probe = mpc85xx_ads_probe,
  172. .setup_arch = mpc85xx_ads_setup_arch,
  173. .init_IRQ = mpc85xx_ads_pic_init,
  174. .show_cpuinfo = mpc85xx_ads_show_cpuinfo,
  175. .get_irq = mpic_get_irq,
  176. .restart = fsl_rstcr_restart,
  177. .calibrate_decr = generic_calibrate_decr,
  178. .progress = udbg_progress,
  179. };