mpc8568_mds.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. * MPC8568E MDS PB 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/root_dev.h>
  30. #include <linux/initrd.h>
  31. #include <linux/module.h>
  32. #include <linux/fsl_devices.h>
  33. #include <asm/of_device.h>
  34. #include <asm/of_platform.h>
  35. #include <asm/system.h>
  36. #include <asm/atomic.h>
  37. #include <asm/time.h>
  38. #include <asm/io.h>
  39. #include <asm/machdep.h>
  40. #include <asm/bootinfo.h>
  41. #include <asm/pci-bridge.h>
  42. #include <asm/mpc85xx.h>
  43. #include <asm/irq.h>
  44. #include <mm/mmu_decl.h>
  45. #include <asm/prom.h>
  46. #include <asm/udbg.h>
  47. #include <sysdev/fsl_soc.h>
  48. #include <asm/qe.h>
  49. #include <asm/qe_ic.h>
  50. #include <asm/mpic.h>
  51. #include "mpc85xx.h"
  52. #undef DEBUG
  53. #ifdef DEBUG
  54. #define DBG(fmt...) udbg_printf(fmt)
  55. #else
  56. #define DBG(fmt...)
  57. #endif
  58. #ifndef CONFIG_PCI
  59. unsigned long isa_io_base = 0;
  60. unsigned long isa_mem_base = 0;
  61. #endif
  62. /* ************************************************************************
  63. *
  64. * Setup the architecture
  65. *
  66. */
  67. static void __init mpc8568_mds_setup_arch(void)
  68. {
  69. struct device_node *np;
  70. static u8 *bcsr_regs = NULL;
  71. if (ppc_md.progress)
  72. ppc_md.progress("mpc8568_mds_setup_arch()", 0);
  73. np = of_find_node_by_type(NULL, "cpu");
  74. if (np != NULL) {
  75. const unsigned int *fp =
  76. get_property(np, "clock-frequency", NULL);
  77. if (fp != NULL)
  78. loops_per_jiffy = *fp / HZ;
  79. else
  80. loops_per_jiffy = 50000000 / HZ;
  81. of_node_put(np);
  82. }
  83. /* Map BCSR area */
  84. np = of_find_node_by_name(NULL, "bcsr");
  85. if (np != NULL) {
  86. struct resource res;
  87. of_address_to_resource(np, 0, &res);
  88. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  89. of_node_put(np);
  90. }
  91. #ifdef CONFIG_PCI
  92. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
  93. add_bridge(np);
  94. }
  95. of_node_put(np);
  96. #endif
  97. #ifdef CONFIG_QUICC_ENGINE
  98. if ((np = of_find_node_by_name(NULL, "qe")) != NULL) {
  99. qe_reset();
  100. of_node_put(np);
  101. }
  102. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  103. struct device_node *ucc = NULL;
  104. par_io_init(np);
  105. of_node_put(np);
  106. for ( ;(ucc = of_find_node_by_name(ucc, "ucc")) != NULL;)
  107. par_io_of_config(ucc);
  108. of_node_put(ucc);
  109. }
  110. if (bcsr_regs) {
  111. u8 bcsr_phy;
  112. /* Reset the Ethernet PHY */
  113. bcsr_phy = in_be8(&bcsr_regs[9]);
  114. bcsr_phy &= ~0x20;
  115. out_be8(&bcsr_regs[9], bcsr_phy);
  116. udelay(1000);
  117. bcsr_phy = in_be8(&bcsr_regs[9]);
  118. bcsr_phy |= 0x20;
  119. out_be8(&bcsr_regs[9], bcsr_phy);
  120. iounmap(bcsr_regs);
  121. }
  122. #endif /* CONFIG_QUICC_ENGINE */
  123. }
  124. static struct of_device_id mpc8568_ids[] = {
  125. { .type = "soc", },
  126. { .compatible = "soc", },
  127. { .type = "qe", },
  128. {},
  129. };
  130. static int __init mpc8568_publish_devices(void)
  131. {
  132. if (!machine_is(mpc8568_mds))
  133. return 0;
  134. /* Publish the QE devices */
  135. of_platform_bus_probe(NULL,mpc8568_ids,NULL);
  136. return 0;
  137. }
  138. device_initcall(mpc8568_publish_devices);
  139. static void __init mpc8568_mds_pic_init(void)
  140. {
  141. struct mpic *mpic;
  142. struct resource r;
  143. struct device_node *np = NULL;
  144. np = of_find_node_by_type(NULL, "open-pic");
  145. if (!np)
  146. return;
  147. if (of_address_to_resource(np, 0, &r)) {
  148. printk(KERN_ERR "Failed to map mpic register space\n");
  149. of_node_put(np);
  150. return;
  151. }
  152. mpic = mpic_alloc(np, r.start,
  153. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  154. 4, 0, " OpenPIC ");
  155. BUG_ON(mpic == NULL);
  156. of_node_put(np);
  157. /* Internal Interrupts */
  158. mpic_assign_isu(mpic, 0, r.start + 0x10200);
  159. mpic_assign_isu(mpic, 1, r.start + 0x10280);
  160. mpic_assign_isu(mpic, 2, r.start + 0x10300);
  161. mpic_assign_isu(mpic, 3, r.start + 0x10380);
  162. mpic_assign_isu(mpic, 4, r.start + 0x10400);
  163. mpic_assign_isu(mpic, 5, r.start + 0x10480);
  164. mpic_assign_isu(mpic, 6, r.start + 0x10500);
  165. mpic_assign_isu(mpic, 7, r.start + 0x10580);
  166. mpic_assign_isu(mpic, 8, r.start + 0x10600);
  167. mpic_assign_isu(mpic, 9, r.start + 0x10680);
  168. mpic_assign_isu(mpic, 10, r.start + 0x10700);
  169. mpic_assign_isu(mpic, 11, r.start + 0x10780);
  170. /* External Interrupts */
  171. mpic_assign_isu(mpic, 12, r.start + 0x10000);
  172. mpic_assign_isu(mpic, 13, r.start + 0x10080);
  173. mpic_assign_isu(mpic, 14, r.start + 0x10100);
  174. mpic_init(mpic);
  175. #ifdef CONFIG_QUICC_ENGINE
  176. np = of_find_node_by_type(NULL, "qeic");
  177. if (!np)
  178. return;
  179. qe_ic_init(np, 0);
  180. of_node_put(np);
  181. #endif /* CONFIG_QUICC_ENGINE */
  182. }
  183. static int __init mpc8568_mds_probe(void)
  184. {
  185. char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
  186. "model", NULL);
  187. if (model == NULL)
  188. return 0;
  189. if (strcmp(model, "MPC8568EMDS"))
  190. return 0;
  191. DBG("MPC8568EMDS found\n");
  192. return 1;
  193. }
  194. define_machine(mpc8568_mds) {
  195. .name = "MPC8568E MDS",
  196. .probe = mpc8568_mds_probe,
  197. .setup_arch = mpc8568_mds_setup_arch,
  198. .init_IRQ = mpc8568_mds_pic_init,
  199. .get_irq = mpic_get_irq,
  200. .restart = mpc85xx_restart,
  201. .calibrate_decr = generic_calibrate_decr,
  202. .progress = udbg_progress,
  203. };