mgcoge.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Keymile mgcoge support
  3. * Copyright 2008 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 mgcoge_pic_init(void)
  30. {
  31. struct device_node *np = of_find_compatible_node(NULL, NULL, "fsl,pq2-pic");
  32. if (!np) {
  33. printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
  34. return;
  35. }
  36. cpm2_pic_init(np);
  37. of_node_put(np);
  38. }
  39. struct cpm_pin {
  40. int port, pin, flags;
  41. };
  42. static __initdata struct cpm_pin mgcoge_pins[] = {
  43. /* SMC2 */
  44. {0, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  45. {0, 9, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  46. /* SCC4 */
  47. {2, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  48. {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  49. {2, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  50. {2, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  51. {3, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  52. {3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  53. /* FCC1 */
  54. {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  55. {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  56. {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  57. {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  58. {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  59. {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  60. {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  61. {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  62. {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  63. {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  64. {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  65. {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  66. {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  67. {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
  68. {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  69. {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  70. /* FCC2 */
  71. {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  72. {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  73. {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  74. {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  75. {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  76. {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  77. {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  78. {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  79. {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  80. {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  81. {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  82. {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  83. {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  84. {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  85. {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  86. {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  87. /* MDC */
  88. {0, 13, CPM_PIN_OUTPUT | CPM_PIN_GPIO},
  89. #if defined(CONFIG_I2C_CPM)
  90. /* I2C */
  91. {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  92. {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  93. #endif
  94. };
  95. static void __init init_ioports(void)
  96. {
  97. int i;
  98. for (i = 0; i < ARRAY_SIZE(mgcoge_pins); i++) {
  99. const struct cpm_pin *pin = &mgcoge_pins[i];
  100. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  101. }
  102. cpm2_smc_clk_setup(CPM_CLK_SMC2, CPM_BRG8);
  103. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK7, CPM_CLK_RX);
  104. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK8, CPM_CLK_TX);
  105. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_RX);
  106. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_TX);
  107. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
  108. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
  109. }
  110. static void __init mgcoge_setup_arch(void)
  111. {
  112. if (ppc_md.progress)
  113. ppc_md.progress("mgcoge_setup_arch()", 0);
  114. cpm2_reset();
  115. /* When this is set, snooping CPM DMA from RAM causes
  116. * machine checks. See erratum SIU18.
  117. */
  118. clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_bcr, MPC82XX_BCR_PLDP);
  119. init_ioports();
  120. if (ppc_md.progress)
  121. ppc_md.progress("mgcoge_setup_arch(), finish", 0);
  122. }
  123. static __initdata struct of_device_id of_bus_ids[] = {
  124. { .compatible = "simple-bus", },
  125. {},
  126. };
  127. static int __init declare_of_platform_devices(void)
  128. {
  129. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  130. return 0;
  131. }
  132. machine_device_initcall(mgcoge, declare_of_platform_devices);
  133. /*
  134. * Called very early, device-tree isn't unflattened
  135. */
  136. static int __init mgcoge_probe(void)
  137. {
  138. unsigned long root = of_get_flat_dt_root();
  139. return of_flat_dt_is_compatible(root, "keymile,mgcoge");
  140. }
  141. define_machine(mgcoge)
  142. {
  143. .name = "Keymile MGCOGE",
  144. .probe = mgcoge_probe,
  145. .setup_arch = mgcoge_setup_arch,
  146. .init_IRQ = mgcoge_pic_init,
  147. .get_irq = cpm2_get_irq,
  148. .calibrate_decr = generic_calibrate_decr,
  149. .restart = pq2_restart,
  150. .progress = udbg_progress,
  151. };