mpc836x_mds.c 5.7 KB

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