mpc85xx_mds.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Copyright (C) Freescale Semicondutor, Inc. 2006-2007. All rights reserved.
  3. *
  4. * Author: Andy Fleming <afleming@freescale.com>
  5. *
  6. * Based on 83xx/mpc8360e_pb.c by:
  7. * Li Yang <LeoLi@freescale.com>
  8. * Yin Olivia <Hong-hua.Yin@freescale.com>
  9. *
  10. * Description:
  11. * MPC85xx MDS board specific routines.
  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/init.h>
  21. #include <linux/errno.h>
  22. #include <linux/reboot.h>
  23. #include <linux/pci.h>
  24. #include <linux/kdev_t.h>
  25. #include <linux/major.h>
  26. #include <linux/console.h>
  27. #include <linux/delay.h>
  28. #include <linux/seq_file.h>
  29. #include <linux/initrd.h>
  30. #include <linux/module.h>
  31. #include <linux/fsl_devices.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/pci-bridge.h>
  40. #include <asm/irq.h>
  41. #include <mm/mmu_decl.h>
  42. #include <asm/prom.h>
  43. #include <asm/udbg.h>
  44. #include <sysdev/fsl_soc.h>
  45. #include <sysdev/fsl_pci.h>
  46. #include <asm/qe.h>
  47. #include <asm/qe_ic.h>
  48. #include <asm/mpic.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 mpc85xx_mds_setup_arch(void)
  61. {
  62. struct device_node *np;
  63. static u8 *bcsr_regs = NULL;
  64. if (ppc_md.progress)
  65. ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
  66. /* Map BCSR area */
  67. np = of_find_node_by_name(NULL, "bcsr");
  68. if (np != NULL) {
  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_node_by_type(np, "pci") {
  76. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  77. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  78. struct resource rsrc;
  79. of_address_to_resource(np, 0, &rsrc);
  80. if ((rsrc.start & 0xfffff) == 0x8000)
  81. fsl_add_bridge(np, 1);
  82. else
  83. fsl_add_bridge(np, 0);
  84. }
  85. }
  86. #endif
  87. #ifdef CONFIG_QUICC_ENGINE
  88. np = of_find_compatible_node(NULL, NULL, "fsl,qe");
  89. if (!np) {
  90. np = of_find_node_by_name(NULL, "qe");
  91. if (!np)
  92. return;
  93. }
  94. qe_reset();
  95. of_node_put(np);
  96. np = of_find_node_by_name(NULL, "par_io");
  97. if (np) {
  98. struct device_node *ucc;
  99. par_io_init(np);
  100. of_node_put(np);
  101. for_each_node_by_name(ucc, "ucc")
  102. par_io_of_config(ucc);
  103. }
  104. if (bcsr_regs) {
  105. #define BCSR_UCC1_GETH_EN (0x1 << 7)
  106. #define BCSR_UCC2_GETH_EN (0x1 << 7)
  107. #define BCSR_UCC1_MODE_MSK (0x3 << 4)
  108. #define BCSR_UCC2_MODE_MSK (0x3 << 0)
  109. /* Turn off UCC1 & UCC2 */
  110. clrbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
  111. clrbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
  112. /* Mode is RGMII, all bits clear */
  113. clrbits8(&bcsr_regs[11], BCSR_UCC1_MODE_MSK |
  114. BCSR_UCC2_MODE_MSK);
  115. /* Turn UCC1 & UCC2 on */
  116. setbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
  117. setbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
  118. iounmap(bcsr_regs);
  119. }
  120. #endif /* CONFIG_QUICC_ENGINE */
  121. }
  122. static struct of_device_id mpc85xx_ids[] = {
  123. { .type = "soc", },
  124. { .compatible = "soc", },
  125. { .type = "qe", },
  126. { .compatible = "fsl,qe", },
  127. {},
  128. };
  129. static int __init mpc85xx_publish_devices(void)
  130. {
  131. /* Publish the QE devices */
  132. of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
  133. return 0;
  134. }
  135. machine_device_initcall(mpc85xx_mds, mpc85xx_publish_devices);
  136. static void __init mpc85xx_mds_pic_init(void)
  137. {
  138. struct mpic *mpic;
  139. struct resource r;
  140. struct device_node *np = NULL;
  141. np = of_find_node_by_type(NULL, "open-pic");
  142. if (!np)
  143. return;
  144. if (of_address_to_resource(np, 0, &r)) {
  145. printk(KERN_ERR "Failed to map mpic register space\n");
  146. of_node_put(np);
  147. return;
  148. }
  149. mpic = mpic_alloc(np, r.start,
  150. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  151. 0, 256, " OpenPIC ");
  152. BUG_ON(mpic == NULL);
  153. of_node_put(np);
  154. mpic_init(mpic);
  155. #ifdef CONFIG_QUICC_ENGINE
  156. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  157. if (!np) {
  158. np = of_find_node_by_type(NULL, "qeic");
  159. if (!np)
  160. return;
  161. }
  162. qe_ic_init(np, 0, qe_ic_cascade_muxed_mpic, NULL);
  163. of_node_put(np);
  164. #endif /* CONFIG_QUICC_ENGINE */
  165. }
  166. static int __init mpc85xx_mds_probe(void)
  167. {
  168. unsigned long root = of_get_flat_dt_root();
  169. return of_flat_dt_is_compatible(root, "MPC85xxMDS");
  170. }
  171. define_machine(mpc85xx_mds) {
  172. .name = "MPC85xx MDS",
  173. .probe = mpc85xx_mds_probe,
  174. .setup_arch = mpc85xx_mds_setup_arch,
  175. .init_IRQ = mpc85xx_mds_pic_init,
  176. .get_irq = mpic_get_irq,
  177. .restart = fsl_rstcr_restart,
  178. .calibrate_decr = generic_calibrate_decr,
  179. .progress = udbg_progress,
  180. #ifdef CONFIG_PCI
  181. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  182. #endif
  183. };