mpc836x_mds.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 <asm/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, res.end - res.start +1);
  72. of_node_put(np);
  73. }
  74. #ifdef CONFIG_PCI
  75. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  76. mpc83xx_add_bridge(np);
  77. #endif
  78. #ifdef CONFIG_QUICC_ENGINE
  79. qe_reset();
  80. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  81. par_io_init(np);
  82. of_node_put(np);
  83. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  84. par_io_of_config(np);
  85. #ifdef CONFIG_QE_USB
  86. /* Must fixup Par IO before QE GPIO chips are registered. */
  87. par_io_config_pin(1, 2, 1, 0, 3, 0); /* USBOE */
  88. par_io_config_pin(1, 3, 1, 0, 3, 0); /* USBTP */
  89. par_io_config_pin(1, 8, 1, 0, 1, 0); /* USBTN */
  90. par_io_config_pin(1, 10, 2, 0, 3, 0); /* USBRXD */
  91. par_io_config_pin(1, 9, 2, 1, 3, 0); /* USBRP */
  92. par_io_config_pin(1, 11, 2, 1, 3, 0); /* USBRN */
  93. par_io_config_pin(2, 20, 2, 0, 1, 0); /* CLK21 */
  94. #endif /* CONFIG_QE_USB */
  95. }
  96. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  97. != NULL){
  98. uint svid;
  99. /* Reset the Ethernet PHY */
  100. #define BCSR9_GETHRST 0x20
  101. clrbits8(&bcsr_regs[9], BCSR9_GETHRST);
  102. udelay(1000);
  103. setbits8(&bcsr_regs[9], BCSR9_GETHRST);
  104. /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
  105. svid = mfspr(SPRN_SVR);
  106. if (svid == 0x80480021) {
  107. void __iomem *immap;
  108. immap = ioremap(get_immrbase() + 0x14a8, 8);
  109. /*
  110. * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
  111. * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
  112. */
  113. setbits32(immap, 0x0c003000);
  114. /*
  115. * IMMR + 0x14AC[20:27] = 10101010
  116. * (data delay for both UCC's)
  117. */
  118. clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
  119. iounmap(immap);
  120. }
  121. iounmap(bcsr_regs);
  122. of_node_put(np);
  123. }
  124. #endif /* CONFIG_QUICC_ENGINE */
  125. }
  126. static struct of_device_id mpc836x_ids[] = {
  127. { .type = "soc", },
  128. { .compatible = "soc", },
  129. { .compatible = "simple-bus", },
  130. { .type = "qe", },
  131. { .compatible = "fsl,qe", },
  132. {},
  133. };
  134. static int __init mpc836x_declare_of_platform_devices(void)
  135. {
  136. /* Publish the QE devices */
  137. of_platform_bus_probe(NULL, mpc836x_ids, NULL);
  138. return 0;
  139. }
  140. machine_device_initcall(mpc836x_mds, mpc836x_declare_of_platform_devices);
  141. #ifdef CONFIG_QE_USB
  142. static int __init mpc836x_usb_cfg(void)
  143. {
  144. u8 __iomem *bcsr;
  145. struct device_node *np;
  146. const char *mode;
  147. int ret = 0;
  148. np = of_find_compatible_node(NULL, NULL, "fsl,mpc8360mds-bcsr");
  149. if (!np)
  150. return -ENODEV;
  151. bcsr = of_iomap(np, 0);
  152. of_node_put(np);
  153. if (!bcsr)
  154. return -ENOMEM;
  155. np = of_find_compatible_node(NULL, NULL, "fsl,mpc8323-qe-usb");
  156. if (!np) {
  157. ret = -ENODEV;
  158. goto err;
  159. }
  160. #define BCSR8_TSEC1M_MASK (0x3 << 6)
  161. #define BCSR8_TSEC1M_RGMII (0x0 << 6)
  162. #define BCSR8_TSEC2M_MASK (0x3 << 4)
  163. #define BCSR8_TSEC2M_RGMII (0x0 << 4)
  164. /*
  165. * Default is GMII (2), but we should set it to RGMII (0) if we use
  166. * USB (Eth PHY is in RGMII mode anyway).
  167. */
  168. clrsetbits_8(&bcsr[8], BCSR8_TSEC1M_MASK | BCSR8_TSEC2M_MASK,
  169. BCSR8_TSEC1M_RGMII | BCSR8_TSEC2M_RGMII);
  170. #define BCSR13_USBMASK 0x0f
  171. #define BCSR13_nUSBEN 0x08 /* 1 - Disable, 0 - Enable */
  172. #define BCSR13_USBSPEED 0x04 /* 1 - Full, 0 - Low */
  173. #define BCSR13_USBMODE 0x02 /* 1 - Host, 0 - Function */
  174. #define BCSR13_nUSBVCC 0x01 /* 1 - gets VBUS, 0 - supplies VBUS */
  175. clrsetbits_8(&bcsr[13], BCSR13_USBMASK, BCSR13_USBSPEED);
  176. mode = of_get_property(np, "mode", NULL);
  177. if (mode && !strcmp(mode, "peripheral")) {
  178. setbits8(&bcsr[13], BCSR13_nUSBVCC);
  179. qe_usb_clock_set(QE_CLK21, 48000000);
  180. } else {
  181. setbits8(&bcsr[13], BCSR13_USBMODE);
  182. /*
  183. * The BCSR GPIOs are used to control power and
  184. * speed of the USB transceiver. This is needed for
  185. * the USB Host only.
  186. */
  187. simple_gpiochip_init("fsl,mpc8360mds-bcsr-gpio");
  188. }
  189. of_node_put(np);
  190. err:
  191. iounmap(bcsr);
  192. return ret;
  193. }
  194. machine_arch_initcall(mpc836x_mds, mpc836x_usb_cfg);
  195. #endif /* CONFIG_QE_USB */
  196. static void __init mpc836x_mds_init_IRQ(void)
  197. {
  198. struct device_node *np;
  199. np = of_find_node_by_type(NULL, "ipic");
  200. if (!np)
  201. return;
  202. ipic_init(np, 0);
  203. /* Initialize the default interrupt mapping priorities,
  204. * in case the boot rom changed something on us.
  205. */
  206. ipic_set_default_priority();
  207. of_node_put(np);
  208. #ifdef CONFIG_QUICC_ENGINE
  209. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  210. if (!np) {
  211. np = of_find_node_by_type(NULL, "qeic");
  212. if (!np)
  213. return;
  214. }
  215. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  216. of_node_put(np);
  217. #endif /* CONFIG_QUICC_ENGINE */
  218. }
  219. /*
  220. * Called very early, MMU is off, device-tree isn't unflattened
  221. */
  222. static int __init mpc836x_mds_probe(void)
  223. {
  224. unsigned long root = of_get_flat_dt_root();
  225. return of_flat_dt_is_compatible(root, "MPC836xMDS");
  226. }
  227. define_machine(mpc836x_mds) {
  228. .name = "MPC836x MDS",
  229. .probe = mpc836x_mds_probe,
  230. .setup_arch = mpc836x_mds_setup_arch,
  231. .init_IRQ = mpc836x_mds_init_IRQ,
  232. .get_irq = ipic_get_irq,
  233. .restart = mpc83xx_restart,
  234. .time_init = mpc83xx_time_init,
  235. .calibrate_decr = generic_calibrate_decr,
  236. .progress = udbg_progress,
  237. };