mpc85xx_rdb.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. /*
  2. * MPC85xx RDB Board Setup
  3. *
  4. * Copyright 2009,2012 Freescale Semiconductor Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pci.h>
  14. #include <linux/kdev_t.h>
  15. #include <linux/delay.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/of_platform.h>
  19. #include <asm/system.h>
  20. #include <asm/time.h>
  21. #include <asm/machdep.h>
  22. #include <asm/pci-bridge.h>
  23. #include <mm/mmu_decl.h>
  24. #include <asm/prom.h>
  25. #include <asm/udbg.h>
  26. #include <asm/mpic.h>
  27. #include <asm/qe.h>
  28. #include <asm/qe_ic.h>
  29. #include <asm/fsl_guts.h>
  30. #include <sysdev/fsl_soc.h>
  31. #include <sysdev/fsl_pci.h>
  32. #include "smp.h"
  33. #include "mpc85xx.h"
  34. #undef DEBUG
  35. #ifdef DEBUG
  36. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
  37. #else
  38. #define DBG(fmt, args...)
  39. #endif
  40. void __init mpc85xx_rdb_pic_init(void)
  41. {
  42. struct mpic *mpic;
  43. unsigned long root = of_get_flat_dt_root();
  44. #ifdef CONFIG_QUICC_ENGINE
  45. struct device_node *np;
  46. #endif
  47. if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
  48. mpic = mpic_alloc(NULL, 0, MPIC_NO_RESET |
  49. MPIC_BIG_ENDIAN |
  50. MPIC_SINGLE_DEST_CPU,
  51. 0, 256, " OpenPIC ");
  52. } else {
  53. mpic = mpic_alloc(NULL, 0,
  54. MPIC_BIG_ENDIAN |
  55. MPIC_SINGLE_DEST_CPU,
  56. 0, 256, " OpenPIC ");
  57. }
  58. BUG_ON(mpic == NULL);
  59. mpic_init(mpic);
  60. #ifdef CONFIG_QUICC_ENGINE
  61. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  62. if (np) {
  63. qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
  64. qe_ic_cascade_high_mpic);
  65. of_node_put(np);
  66. } else
  67. pr_err("%s: Could not find qe-ic node\n", __func__);
  68. #endif
  69. }
  70. /*
  71. * Setup the architecture
  72. */
  73. static void __init mpc85xx_rdb_setup_arch(void)
  74. {
  75. #if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE)
  76. struct device_node *np;
  77. #endif
  78. if (ppc_md.progress)
  79. ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
  80. #ifdef CONFIG_PCI
  81. for_each_node_by_type(np, "pci") {
  82. if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
  83. fsl_add_bridge(np, 0);
  84. }
  85. #endif
  86. mpc85xx_smp_init();
  87. #ifdef CONFIG_QUICC_ENGINE
  88. np = of_find_compatible_node(NULL, NULL, "fsl,qe");
  89. if (!np) {
  90. pr_err("%s: Could not find Quicc Engine node\n", __func__);
  91. goto qe_fail;
  92. }
  93. qe_reset();
  94. of_node_put(np);
  95. np = of_find_node_by_name(NULL, "par_io");
  96. if (np) {
  97. struct device_node *ucc;
  98. par_io_init(np);
  99. of_node_put(np);
  100. for_each_node_by_name(ucc, "ucc")
  101. par_io_of_config(ucc);
  102. }
  103. #if defined(CONFIG_UCC_GETH) || defined(CONFIG_SERIAL_QE)
  104. if (machine_is(p1025_rdb)) {
  105. struct ccsr_guts_85xx __iomem *guts;
  106. np = of_find_node_by_name(NULL, "global-utilities");
  107. if (np) {
  108. guts = of_iomap(np, 0);
  109. if (!guts) {
  110. pr_err("mpc85xx-rdb: could not map global utilities register\n");
  111. } else {
  112. /* P1025 has pins muxed for QE and other functions. To
  113. * enable QE UEC mode, we need to set bit QE0 for UCC1
  114. * in Eth mode, QE0 and QE3 for UCC5 in Eth mode, QE9
  115. * and QE12 for QE MII management singals in PMUXCR
  116. * register.
  117. */
  118. setbits32(&guts->pmuxcr, MPC85xx_PMUXCR_QE(0) |
  119. MPC85xx_PMUXCR_QE(3) |
  120. MPC85xx_PMUXCR_QE(9) |
  121. MPC85xx_PMUXCR_QE(12));
  122. iounmap(guts);
  123. }
  124. of_node_put(np);
  125. }
  126. }
  127. #endif
  128. qe_fail:
  129. #endif /* CONFIG_QUICC_ENGINE */
  130. printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
  131. }
  132. machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices);
  133. machine_device_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
  134. machine_device_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices);
  135. machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices);
  136. machine_device_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices);
  137. machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices);
  138. machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices);
  139. machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices);
  140. /*
  141. * Called very early, device-tree isn't unflattened
  142. */
  143. static int __init p2020_rdb_probe(void)
  144. {
  145. unsigned long root = of_get_flat_dt_root();
  146. if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
  147. return 1;
  148. return 0;
  149. }
  150. static int __init p1020_rdb_probe(void)
  151. {
  152. unsigned long root = of_get_flat_dt_root();
  153. if (of_flat_dt_is_compatible(root, "fsl,P1020RDB"))
  154. return 1;
  155. return 0;
  156. }
  157. static int __init p1020_rdb_pc_probe(void)
  158. {
  159. unsigned long root = of_get_flat_dt_root();
  160. return of_flat_dt_is_compatible(root, "fsl,P1020RDB-PC");
  161. }
  162. static int __init p1021_rdb_pc_probe(void)
  163. {
  164. unsigned long root = of_get_flat_dt_root();
  165. if (of_flat_dt_is_compatible(root, "fsl,P1021RDB-PC"))
  166. return 1;
  167. return 0;
  168. }
  169. static int __init p2020_rdb_pc_probe(void)
  170. {
  171. unsigned long root = of_get_flat_dt_root();
  172. if (of_flat_dt_is_compatible(root, "fsl,P2020RDB-PC"))
  173. return 1;
  174. return 0;
  175. }
  176. static int __init p1025_rdb_probe(void)
  177. {
  178. unsigned long root = of_get_flat_dt_root();
  179. return of_flat_dt_is_compatible(root, "fsl,P1025RDB");
  180. }
  181. static int __init p1020_mbg_pc_probe(void)
  182. {
  183. unsigned long root = of_get_flat_dt_root();
  184. return of_flat_dt_is_compatible(root, "fsl,P1020MBG-PC");
  185. }
  186. static int __init p1020_utm_pc_probe(void)
  187. {
  188. unsigned long root = of_get_flat_dt_root();
  189. return of_flat_dt_is_compatible(root, "fsl,P1020UTM-PC");
  190. }
  191. define_machine(p2020_rdb) {
  192. .name = "P2020 RDB",
  193. .probe = p2020_rdb_probe,
  194. .setup_arch = mpc85xx_rdb_setup_arch,
  195. .init_IRQ = mpc85xx_rdb_pic_init,
  196. #ifdef CONFIG_PCI
  197. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  198. #endif
  199. .get_irq = mpic_get_irq,
  200. .restart = fsl_rstcr_restart,
  201. .calibrate_decr = generic_calibrate_decr,
  202. .progress = udbg_progress,
  203. };
  204. define_machine(p1020_rdb) {
  205. .name = "P1020 RDB",
  206. .probe = p1020_rdb_probe,
  207. .setup_arch = mpc85xx_rdb_setup_arch,
  208. .init_IRQ = mpc85xx_rdb_pic_init,
  209. #ifdef CONFIG_PCI
  210. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  211. #endif
  212. .get_irq = mpic_get_irq,
  213. .restart = fsl_rstcr_restart,
  214. .calibrate_decr = generic_calibrate_decr,
  215. .progress = udbg_progress,
  216. };
  217. define_machine(p1021_rdb_pc) {
  218. .name = "P1021 RDB-PC",
  219. .probe = p1021_rdb_pc_probe,
  220. .setup_arch = mpc85xx_rdb_setup_arch,
  221. .init_IRQ = mpc85xx_rdb_pic_init,
  222. #ifdef CONFIG_PCI
  223. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  224. #endif
  225. .get_irq = mpic_get_irq,
  226. .restart = fsl_rstcr_restart,
  227. .calibrate_decr = generic_calibrate_decr,
  228. .progress = udbg_progress,
  229. };
  230. define_machine(p2020_rdb_pc) {
  231. .name = "P2020RDB-PC",
  232. .probe = p2020_rdb_pc_probe,
  233. .setup_arch = mpc85xx_rdb_setup_arch,
  234. .init_IRQ = mpc85xx_rdb_pic_init,
  235. #ifdef CONFIG_PCI
  236. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  237. #endif
  238. .get_irq = mpic_get_irq,
  239. .restart = fsl_rstcr_restart,
  240. .calibrate_decr = generic_calibrate_decr,
  241. .progress = udbg_progress,
  242. };
  243. define_machine(p1025_rdb) {
  244. .name = "P1025 RDB",
  245. .probe = p1025_rdb_probe,
  246. .setup_arch = mpc85xx_rdb_setup_arch,
  247. .init_IRQ = mpc85xx_rdb_pic_init,
  248. #ifdef CONFIG_PCI
  249. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  250. #endif
  251. .get_irq = mpic_get_irq,
  252. .restart = fsl_rstcr_restart,
  253. .calibrate_decr = generic_calibrate_decr,
  254. .progress = udbg_progress,
  255. };
  256. define_machine(p1020_mbg_pc) {
  257. .name = "P1020 MBG-PC",
  258. .probe = p1020_mbg_pc_probe,
  259. .setup_arch = mpc85xx_rdb_setup_arch,
  260. .init_IRQ = mpc85xx_rdb_pic_init,
  261. #ifdef CONFIG_PCI
  262. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  263. #endif
  264. .get_irq = mpic_get_irq,
  265. .restart = fsl_rstcr_restart,
  266. .calibrate_decr = generic_calibrate_decr,
  267. .progress = udbg_progress,
  268. };
  269. define_machine(p1020_utm_pc) {
  270. .name = "P1020 UTM-PC",
  271. .probe = p1020_utm_pc_probe,
  272. .setup_arch = mpc85xx_rdb_setup_arch,
  273. .init_IRQ = mpc85xx_rdb_pic_init,
  274. #ifdef CONFIG_PCI
  275. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  276. #endif
  277. .get_irq = mpic_get_irq,
  278. .restart = fsl_rstcr_restart,
  279. .calibrate_decr = generic_calibrate_decr,
  280. .progress = udbg_progress,
  281. };
  282. define_machine(p1020_rdb_pc) {
  283. .name = "P1020RDB-PC",
  284. .probe = p1020_rdb_pc_probe,
  285. .setup_arch = mpc85xx_rdb_setup_arch,
  286. .init_IRQ = mpc85xx_rdb_pic_init,
  287. #ifdef CONFIG_PCI
  288. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  289. #endif
  290. .get_irq = mpic_get_irq,
  291. .restart = fsl_rstcr_restart,
  292. .calibrate_decr = generic_calibrate_decr,
  293. .progress = udbg_progress,
  294. };