pq2fads.c 5.1 KB

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