mpc885ads_setup.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Platform setup for the Freescale mpc885ads board
  3. *
  4. * Vitaly Bordug <vbordug@ru.mvista.com>
  5. *
  6. * Copyright 2005 MontaVista Software Inc.
  7. *
  8. * Heavily modified by Scott Wood <scottwood@freescale.com>
  9. * Copyright 2007 Freescale Semiconductor, Inc.
  10. *
  11. * This file is licensed under the terms of the GNU General Public License
  12. * version 2. This program is licensed "as is" without any warranty of any
  13. * kind, whether express or implied.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <linux/param.h>
  18. #include <linux/string.h>
  19. #include <linux/ioport.h>
  20. #include <linux/device.h>
  21. #include <linux/delay.h>
  22. #include <linux/fs_enet_pd.h>
  23. #include <linux/fs_uart_pd.h>
  24. #include <linux/fsl_devices.h>
  25. #include <linux/mii.h>
  26. #include <linux/of_address.h>
  27. #include <linux/of_fdt.h>
  28. #include <linux/of_platform.h>
  29. #include <asm/delay.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #include <asm/page.h>
  33. #include <asm/processor.h>
  34. #include <asm/time.h>
  35. #include <asm/8xx_immap.h>
  36. #include <asm/cpm1.h>
  37. #include <asm/fs_pd.h>
  38. #include <asm/udbg.h>
  39. #include "mpc885ads.h"
  40. #include "mpc8xx.h"
  41. static u32 __iomem *bcsr, *bcsr5;
  42. struct cpm_pin {
  43. int port, pin, flags;
  44. };
  45. static struct cpm_pin mpc885ads_pins[] = {
  46. /* SMC1 */
  47. {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
  48. {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  49. /* SMC2 */
  50. #ifndef CONFIG_MPC8xx_SECOND_ETH_FEC2
  51. {CPM_PORTE, 21, CPM_PIN_INPUT}, /* RX */
  52. {CPM_PORTE, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  53. #endif
  54. /* SCC3 */
  55. {CPM_PORTA, 9, CPM_PIN_INPUT}, /* RX */
  56. {CPM_PORTA, 8, CPM_PIN_INPUT}, /* TX */
  57. {CPM_PORTC, 4, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
  58. {CPM_PORTC, 5, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
  59. {CPM_PORTE, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
  60. {CPM_PORTE, 17, CPM_PIN_INPUT}, /* CLK5 */
  61. {CPM_PORTE, 16, CPM_PIN_INPUT}, /* CLK6 */
  62. /* MII1 */
  63. {CPM_PORTA, 0, CPM_PIN_INPUT},
  64. {CPM_PORTA, 1, CPM_PIN_INPUT},
  65. {CPM_PORTA, 2, CPM_PIN_INPUT},
  66. {CPM_PORTA, 3, CPM_PIN_INPUT},
  67. {CPM_PORTA, 4, CPM_PIN_OUTPUT},
  68. {CPM_PORTA, 10, CPM_PIN_OUTPUT},
  69. {CPM_PORTA, 11, CPM_PIN_OUTPUT},
  70. {CPM_PORTB, 19, CPM_PIN_INPUT},
  71. {CPM_PORTB, 31, CPM_PIN_INPUT},
  72. {CPM_PORTC, 12, CPM_PIN_INPUT},
  73. {CPM_PORTC, 13, CPM_PIN_INPUT},
  74. {CPM_PORTE, 30, CPM_PIN_OUTPUT},
  75. {CPM_PORTE, 31, CPM_PIN_OUTPUT},
  76. /* MII2 */
  77. #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2
  78. {CPM_PORTE, 14, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  79. {CPM_PORTE, 15, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  80. {CPM_PORTE, 16, CPM_PIN_OUTPUT},
  81. {CPM_PORTE, 17, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  82. {CPM_PORTE, 18, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  83. {CPM_PORTE, 19, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  84. {CPM_PORTE, 20, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
  85. {CPM_PORTE, 21, CPM_PIN_OUTPUT},
  86. {CPM_PORTE, 22, CPM_PIN_OUTPUT},
  87. {CPM_PORTE, 23, CPM_PIN_OUTPUT},
  88. {CPM_PORTE, 24, CPM_PIN_OUTPUT},
  89. {CPM_PORTE, 25, CPM_PIN_OUTPUT},
  90. {CPM_PORTE, 26, CPM_PIN_OUTPUT},
  91. {CPM_PORTE, 27, CPM_PIN_OUTPUT},
  92. {CPM_PORTE, 28, CPM_PIN_OUTPUT},
  93. {CPM_PORTE, 29, CPM_PIN_OUTPUT},
  94. #endif
  95. /* I2C */
  96. {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  97. {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  98. };
  99. static void __init init_ioports(void)
  100. {
  101. int i;
  102. for (i = 0; i < ARRAY_SIZE(mpc885ads_pins); i++) {
  103. struct cpm_pin *pin = &mpc885ads_pins[i];
  104. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  105. }
  106. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  107. cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
  108. cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_TX);
  109. cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK6, CPM_CLK_RX);
  110. /* Set FEC1 and FEC2 to MII mode */
  111. clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
  112. }
  113. static void __init mpc885ads_setup_arch(void)
  114. {
  115. struct device_node *np;
  116. cpm_reset();
  117. init_ioports();
  118. np = of_find_compatible_node(NULL, NULL, "fsl,mpc885ads-bcsr");
  119. if (!np) {
  120. printk(KERN_CRIT "Could not find fsl,mpc885ads-bcsr node\n");
  121. return;
  122. }
  123. bcsr = of_iomap(np, 0);
  124. bcsr5 = of_iomap(np, 1);
  125. of_node_put(np);
  126. if (!bcsr || !bcsr5) {
  127. printk(KERN_CRIT "Could not remap BCSR\n");
  128. return;
  129. }
  130. clrbits32(&bcsr[1], BCSR1_RS232EN_1);
  131. #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2
  132. setbits32(&bcsr[1], BCSR1_RS232EN_2);
  133. #else
  134. clrbits32(&bcsr[1], BCSR1_RS232EN_2);
  135. #endif
  136. clrbits32(bcsr5, BCSR5_MII1_EN);
  137. setbits32(bcsr5, BCSR5_MII1_RST);
  138. udelay(1000);
  139. clrbits32(bcsr5, BCSR5_MII1_RST);
  140. #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2
  141. clrbits32(bcsr5, BCSR5_MII2_EN);
  142. setbits32(bcsr5, BCSR5_MII2_RST);
  143. udelay(1000);
  144. clrbits32(bcsr5, BCSR5_MII2_RST);
  145. #else
  146. setbits32(bcsr5, BCSR5_MII2_EN);
  147. #endif
  148. #ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3
  149. clrbits32(&bcsr[4], BCSR4_ETH10_RST);
  150. udelay(1000);
  151. setbits32(&bcsr[4], BCSR4_ETH10_RST);
  152. setbits32(&bcsr[1], BCSR1_ETHEN);
  153. np = of_find_node_by_path("/soc@ff000000/cpm@9c0/serial@a80");
  154. #else
  155. np = of_find_node_by_path("/soc@ff000000/cpm@9c0/ethernet@a40");
  156. #endif
  157. /* The SCC3 enet registers overlap the SMC1 registers, so
  158. * one of the two must be removed from the device tree.
  159. */
  160. if (np) {
  161. of_detach_node(np);
  162. of_node_put(np);
  163. }
  164. }
  165. static int __init mpc885ads_probe(void)
  166. {
  167. unsigned long root = of_get_flat_dt_root();
  168. return of_flat_dt_is_compatible(root, "fsl,mpc885ads");
  169. }
  170. static const struct of_device_id of_bus_ids[] __initconst = {
  171. { .name = "soc", },
  172. { .name = "cpm", },
  173. { .name = "localbus", },
  174. {},
  175. };
  176. static int __init declare_of_platform_devices(void)
  177. {
  178. /* Publish the QE devices */
  179. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  180. return 0;
  181. }
  182. machine_device_initcall(mpc885_ads, declare_of_platform_devices);
  183. define_machine(mpc885_ads) {
  184. .name = "Freescale MPC885 ADS",
  185. .probe = mpc885ads_probe,
  186. .setup_arch = mpc885ads_setup_arch,
  187. .init_IRQ = mpc8xx_pics_init,
  188. .get_irq = mpc8xx_get_irq,
  189. .restart = mpc8xx_restart,
  190. .calibrate_decr = mpc8xx_calibrate_decr,
  191. .set_rtc_time = mpc8xx_set_rtc_time,
  192. .get_rtc_time = mpc8xx_get_rtc_time,
  193. .progress = udbg_progress,
  194. };