mpc836x_mds.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Copyright 2006 Freescale Semiconductor, Inc. All rights reserved.
  3. *
  4. * Author: Li Yang <LeoLi@freescale.com>
  5. * Yin Olivia <Hong-hua.Yin@freescale.com>
  6. *
  7. * Description:
  8. * MPC8360E MDS board specific routines.
  9. *
  10. * Changelog:
  11. * Jun 21, 2006 Initial version
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. */
  18. #include <linux/stddef.h>
  19. #include <linux/kernel.h>
  20. #include <linux/compiler.h>
  21. #include <linux/init.h>
  22. #include <linux/errno.h>
  23. #include <linux/reboot.h>
  24. #include <linux/pci.h>
  25. #include <linux/kdev_t.h>
  26. #include <linux/major.h>
  27. #include <linux/console.h>
  28. #include <linux/delay.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/root_dev.h>
  31. #include <linux/initrd.h>
  32. #include <linux/of_platform.h>
  33. #include <linux/of_device.h>
  34. #include <linux/atomic.h>
  35. #include <asm/time.h>
  36. #include <asm/io.h>
  37. #include <asm/machdep.h>
  38. #include <asm/ipic.h>
  39. #include <asm/irq.h>
  40. #include <asm/prom.h>
  41. #include <asm/udbg.h>
  42. #include <sysdev/fsl_soc.h>
  43. #include <sysdev/fsl_pci.h>
  44. #include <sysdev/simple_gpio.h>
  45. #include <soc/fsl/qe/qe.h>
  46. #include <soc/fsl/qe/qe_ic.h>
  47. #include "mpc83xx.h"
  48. #undef DEBUG
  49. #ifdef DEBUG
  50. #define DBG(fmt...) udbg_printf(fmt)
  51. #else
  52. #define DBG(fmt...)
  53. #endif
  54. /* ************************************************************************
  55. *
  56. * Setup the architecture
  57. *
  58. */
  59. static void __init mpc836x_mds_setup_arch(void)
  60. {
  61. struct device_node *np;
  62. u8 __iomem *bcsr_regs = NULL;
  63. mpc83xx_setup_arch();
  64. /* Map BCSR area */
  65. np = of_find_node_by_name(NULL, "bcsr");
  66. if (np) {
  67. struct resource res;
  68. of_address_to_resource(np, 0, &res);
  69. bcsr_regs = ioremap(res.start, resource_size(&res));
  70. of_node_put(np);
  71. }
  72. #ifdef CONFIG_QUICC_ENGINE
  73. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  74. par_io_init(np);
  75. of_node_put(np);
  76. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  77. par_io_of_config(np);
  78. #ifdef CONFIG_QE_USB
  79. /* Must fixup Par IO before QE GPIO chips are registered. */
  80. par_io_config_pin(1, 2, 1, 0, 3, 0); /* USBOE */
  81. par_io_config_pin(1, 3, 1, 0, 3, 0); /* USBTP */
  82. par_io_config_pin(1, 8, 1, 0, 1, 0); /* USBTN */
  83. par_io_config_pin(1, 10, 2, 0, 3, 0); /* USBRXD */
  84. par_io_config_pin(1, 9, 2, 1, 3, 0); /* USBRP */
  85. par_io_config_pin(1, 11, 2, 1, 3, 0); /* USBRN */
  86. par_io_config_pin(2, 20, 2, 0, 1, 0); /* CLK21 */
  87. #endif /* CONFIG_QE_USB */
  88. }
  89. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  90. != NULL){
  91. uint svid;
  92. /* Reset the Ethernet PHY */
  93. #define BCSR9_GETHRST 0x20
  94. clrbits8(&bcsr_regs[9], BCSR9_GETHRST);
  95. udelay(1000);
  96. setbits8(&bcsr_regs[9], BCSR9_GETHRST);
  97. /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
  98. svid = mfspr(SPRN_SVR);
  99. if (svid == 0x80480021) {
  100. void __iomem *immap;
  101. immap = ioremap(get_immrbase() + 0x14a8, 8);
  102. /*
  103. * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
  104. * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
  105. */
  106. setbits32(immap, 0x0c003000);
  107. /*
  108. * IMMR + 0x14AC[20:27] = 10101010
  109. * (data delay for both UCC's)
  110. */
  111. clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
  112. iounmap(immap);
  113. }
  114. iounmap(bcsr_regs);
  115. of_node_put(np);
  116. }
  117. #endif /* CONFIG_QUICC_ENGINE */
  118. }
  119. machine_device_initcall(mpc836x_mds, mpc83xx_declare_of_platform_devices);
  120. #ifdef CONFIG_QE_USB
  121. static int __init mpc836x_usb_cfg(void)
  122. {
  123. u8 __iomem *bcsr;
  124. struct device_node *np;
  125. const char *mode;
  126. int ret = 0;
  127. np = of_find_compatible_node(NULL, NULL, "fsl,mpc8360mds-bcsr");
  128. if (!np)
  129. return -ENODEV;
  130. bcsr = of_iomap(np, 0);
  131. of_node_put(np);
  132. if (!bcsr)
  133. return -ENOMEM;
  134. np = of_find_compatible_node(NULL, NULL, "fsl,mpc8323-qe-usb");
  135. if (!np) {
  136. ret = -ENODEV;
  137. goto err;
  138. }
  139. #define BCSR8_TSEC1M_MASK (0x3 << 6)
  140. #define BCSR8_TSEC1M_RGMII (0x0 << 6)
  141. #define BCSR8_TSEC2M_MASK (0x3 << 4)
  142. #define BCSR8_TSEC2M_RGMII (0x0 << 4)
  143. /*
  144. * Default is GMII (2), but we should set it to RGMII (0) if we use
  145. * USB (Eth PHY is in RGMII mode anyway).
  146. */
  147. clrsetbits_8(&bcsr[8], BCSR8_TSEC1M_MASK | BCSR8_TSEC2M_MASK,
  148. BCSR8_TSEC1M_RGMII | BCSR8_TSEC2M_RGMII);
  149. #define BCSR13_USBMASK 0x0f
  150. #define BCSR13_nUSBEN 0x08 /* 1 - Disable, 0 - Enable */
  151. #define BCSR13_USBSPEED 0x04 /* 1 - Full, 0 - Low */
  152. #define BCSR13_USBMODE 0x02 /* 1 - Host, 0 - Function */
  153. #define BCSR13_nUSBVCC 0x01 /* 1 - gets VBUS, 0 - supplies VBUS */
  154. clrsetbits_8(&bcsr[13], BCSR13_USBMASK, BCSR13_USBSPEED);
  155. mode = of_get_property(np, "mode", NULL);
  156. if (mode && !strcmp(mode, "peripheral")) {
  157. setbits8(&bcsr[13], BCSR13_nUSBVCC);
  158. qe_usb_clock_set(QE_CLK21, 48000000);
  159. } else {
  160. setbits8(&bcsr[13], BCSR13_USBMODE);
  161. /*
  162. * The BCSR GPIOs are used to control power and
  163. * speed of the USB transceiver. This is needed for
  164. * the USB Host only.
  165. */
  166. simple_gpiochip_init("fsl,mpc8360mds-bcsr-gpio");
  167. }
  168. of_node_put(np);
  169. err:
  170. iounmap(bcsr);
  171. return ret;
  172. }
  173. machine_arch_initcall(mpc836x_mds, mpc836x_usb_cfg);
  174. #endif /* CONFIG_QE_USB */
  175. /*
  176. * Called very early, MMU is off, device-tree isn't unflattened
  177. */
  178. static int __init mpc836x_mds_probe(void)
  179. {
  180. return of_machine_is_compatible("MPC836xMDS");
  181. }
  182. define_machine(mpc836x_mds) {
  183. .name = "MPC836x MDS",
  184. .probe = mpc836x_mds_probe,
  185. .setup_arch = mpc836x_mds_setup_arch,
  186. .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ,
  187. .get_irq = ipic_get_irq,
  188. .restart = mpc83xx_restart,
  189. .time_init = mpc83xx_time_init,
  190. .calibrate_decr = generic_calibrate_decr,
  191. .progress = udbg_progress,
  192. };