mpc836x_mds.c 5.6 KB

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