mpc836x_mds.c 5.7 KB

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