km82xx.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Keymile km82xx support
  3. * Copyright 2008-2011 DENX Software Engineering GmbH
  4. * Author: Heiko Schocher <hs@denx.de>
  5. *
  6. * based on code from:
  7. * Copyright 2007 Freescale Semiconductor, Inc.
  8. * Author: Scott Wood <scottwood@freescale.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/fsl_devices.h>
  18. #include <linux/of_platform.h>
  19. #include <asm/io.h>
  20. #include <asm/cpm2.h>
  21. #include <asm/udbg.h>
  22. #include <asm/machdep.h>
  23. #include <asm/time.h>
  24. #include <asm/mpc8260.h>
  25. #include <asm/prom.h>
  26. #include <sysdev/fsl_soc.h>
  27. #include <sysdev/cpm2_pic.h>
  28. #include "pq2.h"
  29. static void __init km82xx_pic_init(void)
  30. {
  31. struct device_node *np = of_find_compatible_node(NULL, NULL,
  32. "fsl,pq2-pic");
  33. if (!np) {
  34. printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
  35. return;
  36. }
  37. cpm2_pic_init(np);
  38. of_node_put(np);
  39. }
  40. struct cpm_pin {
  41. int port, pin, flags;
  42. };
  43. static __initdata struct cpm_pin km82xx_pins[] = {
  44. /* SMC2 */
  45. {0, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  46. {0, 9, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  47. /* SCC1 */
  48. {2, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  49. {2, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  50. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  51. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  52. /* SCC4 */
  53. {2, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  54. {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  55. {2, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  56. {2, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  57. {3, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  58. {3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  59. /* FCC1 */
  60. {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  61. {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  62. {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  63. {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  64. {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  65. {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  66. {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  67. {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  68. {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  69. {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  70. {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  71. {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  72. {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  73. {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  74. {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  75. {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  76. /* FCC2 */
  77. {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  78. {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  79. {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  80. {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  81. {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  82. {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  83. {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  84. {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  85. {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  86. {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  87. {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  88. {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  89. {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  90. {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  91. {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  92. {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  93. /* MDC */
  94. {0, 13, CPM_PIN_OUTPUT | CPM_PIN_GPIO},
  95. #if defined(CONFIG_I2C_CPM)
  96. /* I2C */
  97. {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  98. {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  99. #endif
  100. /* USB */
  101. {0, 10, CPM_PIN_OUTPUT | CPM_PIN_GPIO}, /* FULL_SPEED */
  102. {0, 11, CPM_PIN_OUTPUT | CPM_PIN_GPIO}, /*/SLAVE */
  103. {2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXN */
  104. {2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXP */
  105. {2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* /OE */
  106. {2, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXCLK */
  107. {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXP */
  108. {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXN */
  109. {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXD */
  110. };
  111. static void __init init_ioports(void)
  112. {
  113. int i;
  114. for (i = 0; i < ARRAY_SIZE(km82xx_pins); i++) {
  115. const struct cpm_pin *pin = &km82xx_pins[i];
  116. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  117. }
  118. cpm2_smc_clk_setup(CPM_CLK_SMC2, CPM_BRG8);
  119. cpm2_clk_setup(CPM_CLK_SCC1, CPM_CLK11, CPM_CLK_RX);
  120. cpm2_clk_setup(CPM_CLK_SCC1, CPM_CLK11, CPM_CLK_TX);
  121. cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_RTX);
  122. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK7, CPM_CLK_RX);
  123. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK8, CPM_CLK_TX);
  124. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_RX);
  125. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_TX);
  126. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
  127. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
  128. /* Force USB FULL SPEED bit to '1' */
  129. setbits32(&cpm2_immr->im_ioport.iop_pdata, 1 << (31 - 10));
  130. /* clear USB_SLAVE */
  131. clrbits32(&cpm2_immr->im_ioport.iop_pdata, 1 << (31 - 11));
  132. }
  133. static void __init km82xx_setup_arch(void)
  134. {
  135. if (ppc_md.progress)
  136. ppc_md.progress("km82xx_setup_arch()", 0);
  137. cpm2_reset();
  138. /* When this is set, snooping CPM DMA from RAM causes
  139. * machine checks. See erratum SIU18.
  140. */
  141. clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_bcr, MPC82XX_BCR_PLDP);
  142. init_ioports();
  143. if (ppc_md.progress)
  144. ppc_md.progress("km82xx_setup_arch(), finish", 0);
  145. }
  146. static __initdata struct of_device_id of_bus_ids[] = {
  147. { .compatible = "simple-bus", },
  148. {},
  149. };
  150. static int __init declare_of_platform_devices(void)
  151. {
  152. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  153. return 0;
  154. }
  155. machine_device_initcall(km82xx, declare_of_platform_devices);
  156. /*
  157. * Called very early, device-tree isn't unflattened
  158. */
  159. static int __init km82xx_probe(void)
  160. {
  161. unsigned long root = of_get_flat_dt_root();
  162. return of_flat_dt_is_compatible(root, "keymile,km82xx");
  163. }
  164. define_machine(km82xx)
  165. {
  166. .name = "Keymile km82xx",
  167. .probe = km82xx_probe,
  168. .setup_arch = km82xx_setup_arch,
  169. .init_IRQ = km82xx_pic_init,
  170. .get_irq = cpm2_get_irq,
  171. .calibrate_decr = generic_calibrate_decr,
  172. .restart = pq2_restart,
  173. .progress = udbg_progress,
  174. };