mpc8272_ads.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * MPC8272 ADS board support
  3. *
  4. * Copyright 2007 Freescale Semiconductor, Inc.
  5. * Author: Scott Wood <scottwood@freescale.com>
  6. *
  7. * Based on code 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 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_address.h>
  19. #include <linux/of_fdt.h>
  20. #include <linux/of_platform.h>
  21. #include <linux/io.h>
  22. #include <asm/cpm2.h>
  23. #include <asm/udbg.h>
  24. #include <asm/machdep.h>
  25. #include <asm/time.h>
  26. #include <platforms/82xx/pq2.h>
  27. #include <sysdev/fsl_soc.h>
  28. #include <sysdev/cpm2_pic.h>
  29. #include "pq2.h"
  30. static void __init mpc8272_ads_pic_init(void)
  31. {
  32. struct device_node *np = of_find_compatible_node(NULL, NULL,
  33. "fsl,cpm2-pic");
  34. if (!np) {
  35. printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
  36. return;
  37. }
  38. cpm2_pic_init(np);
  39. of_node_put(np);
  40. /* Initialize stuff for the 82xx CPLD IC and install demux */
  41. pq2ads_pci_init_irq();
  42. }
  43. struct cpm_pin {
  44. int port, pin, flags;
  45. };
  46. static struct cpm_pin mpc8272_ads_pins[] = {
  47. /* SCC1 */
  48. {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  49. {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  50. /* SCC4 */
  51. {3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  52. {3, 22, CPM_PIN_INPUT | 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, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  69. {2, 22, 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, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  86. {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  87. /* I2C */
  88. {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  89. {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
  90. /* USB */
  91. {2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  92. {2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  93. {2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  94. {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  95. {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  96. {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  97. {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  98. };
  99. static void __init init_ioports(void)
  100. {
  101. int i;
  102. for (i = 0; i < ARRAY_SIZE(mpc8272_ads_pins); i++) {
  103. struct cpm_pin *pin = &mpc8272_ads_pins[i];
  104. cpm2_set_pin(pin->port, pin->pin, pin->flags);
  105. }
  106. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
  107. cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
  108. cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_RX);
  109. cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_TX);
  110. cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_RX);
  111. cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_TX);
  112. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK11, CPM_CLK_RX);
  113. cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
  114. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK15, CPM_CLK_RX);
  115. cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK16, CPM_CLK_TX);
  116. }
  117. static void __init mpc8272_ads_setup_arch(void)
  118. {
  119. struct device_node *np;
  120. __be32 __iomem *bcsr;
  121. if (ppc_md.progress)
  122. ppc_md.progress("mpc8272_ads_setup_arch()", 0);
  123. cpm2_reset();
  124. np = of_find_compatible_node(NULL, NULL, "fsl,mpc8272ads-bcsr");
  125. if (!np) {
  126. printk(KERN_ERR "No bcsr in device tree\n");
  127. return;
  128. }
  129. bcsr = of_iomap(np, 0);
  130. of_node_put(np);
  131. if (!bcsr) {
  132. printk(KERN_ERR "Cannot map BCSR registers\n");
  133. return;
  134. }
  135. #define BCSR1_FETHIEN 0x08000000
  136. #define BCSR1_FETH_RST 0x04000000
  137. #define BCSR1_RS232_EN1 0x02000000
  138. #define BCSR1_RS232_EN2 0x01000000
  139. #define BCSR3_USB_nEN 0x80000000
  140. #define BCSR3_FETHIEN2 0x10000000
  141. #define BCSR3_FETH2_RST 0x08000000
  142. clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);
  143. setbits32(&bcsr[1], BCSR1_FETH_RST);
  144. clrbits32(&bcsr[3], BCSR3_FETHIEN2);
  145. setbits32(&bcsr[3], BCSR3_FETH2_RST);
  146. clrbits32(&bcsr[3], BCSR3_USB_nEN);
  147. iounmap(bcsr);
  148. init_ioports();
  149. pq2_init_pci();
  150. if (ppc_md.progress)
  151. ppc_md.progress("mpc8272_ads_setup_arch(), finish", 0);
  152. }
  153. static const struct of_device_id of_bus_ids[] __initconst = {
  154. { .name = "soc", },
  155. { .name = "cpm", },
  156. { .name = "localbus", },
  157. {},
  158. };
  159. static int __init declare_of_platform_devices(void)
  160. {
  161. /* Publish the QE devices */
  162. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  163. return 0;
  164. }
  165. machine_device_initcall(mpc8272_ads, declare_of_platform_devices);
  166. /*
  167. * Called very early, device-tree isn't unflattened
  168. */
  169. static int __init mpc8272_ads_probe(void)
  170. {
  171. unsigned long root = of_get_flat_dt_root();
  172. return of_flat_dt_is_compatible(root, "fsl,mpc8272ads");
  173. }
  174. define_machine(mpc8272_ads)
  175. {
  176. .name = "Freescale MPC8272 ADS",
  177. .probe = mpc8272_ads_probe,
  178. .setup_arch = mpc8272_ads_setup_arch,
  179. .init_IRQ = mpc8272_ads_pic_init,
  180. .get_irq = cpm2_get_irq,
  181. .calibrate_decr = generic_calibrate_decr,
  182. .restart = pq2_restart,
  183. .progress = udbg_progress,
  184. };