pq2fads.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * PQ2FADS board support
  4. *
  5. * Copyright 2007 Freescale Semiconductor, Inc.
  6. * Author: Scott Wood <[email protected]>
  7. *
  8. * Loosely based on mp82xx ADS support by Vitaly Bordug <[email protected]>
  9. * Copyright (c) 2006 MontaVista Software, Inc.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/fsl_devices.h>
  14. #include <linux/of_address.h>
  15. #include <linux/of_fdt.h>
  16. #include <linux/of_platform.h>
  17. #include <asm/io.h>
  18. #include <asm/cpm2.h>
  19. #include <asm/udbg.h>
  20. #include <asm/machdep.h>
  21. #include <asm/time.h>
  22. #include <sysdev/fsl_soc.h>
  23. #include <sysdev/cpm2_pic.h>
  24. #include "pq2ads.h"
  25. #include "pq2.h"
  26. static void __init pq2fads_pic_init(void)
  27. {
  28. struct device_node *np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
  29. if (!np) {
  30. printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
  31. return;
  32. }
  33. cpm2_pic_init(np);
  34. of_node_put(np);
  35. /* Initialize stuff for the 82xx CPLD IC and install demux */
  36. pq2ads_pci_init_irq();
  37. }
  38. struct cpm_pin {
  39. int port, pin, flags;
  40. };
  41. static struct cpm_pin pq2fads_pins[] = {
  42. /* SCC1 */
  43. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  44. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  45. /* SCC2 */
  46. {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  47. {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  48. /* FCC2 */
  49. {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  50. {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  51. {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  52. {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  53. {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  54. {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  55. {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  56. {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  57. {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  58. {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  59. {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  60. {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  61. {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  62. {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  63. {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  64. {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  65. /* FCC3 */
  66. {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  67. {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  68. {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  69. {1, 7, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  70. {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  71. {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  72. {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  73. {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  74. {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  75. {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  76. {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  77. {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  78. {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  79. {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  80. {2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  81. {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  82. };
  83. static void __init init_ioports(void)
  84. {
  85. int i;
  86. for (i = 0; i < ARRAY_SIZE(pq2fads_pins); i++) {
  87. struct cpm_pin *pin = &pq2fads_pins[i];
  88. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  89. }
  90. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
  91. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
  92. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
  93. cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
  94. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
  95. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
  96. cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);
  97. cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);
  98. }
  99. static void __init pq2fads_setup_arch(void)
  100. {
  101. struct device_node *np;
  102. __be32 __iomem *bcsr;
  103. if (ppc_md.progress)
  104. ppc_md.progress("pq2fads_setup_arch()", 0);
  105. cpm2_reset();
  106. np = of_find_compatible_node(NULL, NULL, "fsl,pq2fads-bcsr");
  107. if (!np) {
  108. printk(KERN_ERR "No fsl,pq2fads-bcsr in device tree\n");
  109. return;
  110. }
  111. bcsr = of_iomap(np, 0);
  112. of_node_put(np);
  113. if (!bcsr) {
  114. printk(KERN_ERR "Cannot map BCSR registers\n");
  115. return;
  116. }
  117. /* Enable the serial and ethernet ports */
  118. clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);
  119. setbits32(&bcsr[1], BCSR1_FETH_RST);
  120. clrbits32(&bcsr[3], BCSR3_FETHIEN2);
  121. setbits32(&bcsr[3], BCSR3_FETH2_RST);
  122. iounmap(bcsr);
  123. init_ioports();
  124. /* Enable external IRQs */
  125. clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_siumcr, 0x0c000000);
  126. if (ppc_md.progress)
  127. ppc_md.progress("pq2fads_setup_arch(), finish", 0);
  128. }
  129. /*
  130. * Called very early, device-tree isn't unflattened
  131. */
  132. static int __init pq2fads_probe(void)
  133. {
  134. return of_machine_is_compatible("fsl,pq2fads");
  135. }
  136. static const struct of_device_id of_bus_ids[] __initconst = {
  137. { .name = "soc", },
  138. { .name = "cpm", },
  139. { .name = "localbus", },
  140. {},
  141. };
  142. static int __init declare_of_platform_devices(void)
  143. {
  144. /* Publish the QE devices */
  145. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  146. return 0;
  147. }
  148. machine_device_initcall(pq2fads, declare_of_platform_devices);
  149. define_machine(pq2fads)
  150. {
  151. .name = "Freescale PQ2FADS",
  152. .probe = pq2fads_probe,
  153. .setup_arch = pq2fads_setup_arch,
  154. .discover_phbs = pq2_init_pci,
  155. .init_IRQ = pq2fads_pic_init,
  156. .get_irq = cpm2_get_irq,
  157. .calibrate_decr = generic_calibrate_decr,
  158. .restart = pq2_restart,
  159. .progress = udbg_progress,
  160. };