tqm85xx.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Based on MPC8560 ADS and arch/ppc tqm85xx ports
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2008 Freescale Semiconductor Inc.
  7. *
  8. * Copyright (c) 2005-2006 DENX Software Engineering
  9. * Stefan Roese <sr@denx.de>
  10. *
  11. * Based on original work by
  12. * Kumar Gala <kumar.gala@freescale.com>
  13. * Copyright 2004 Freescale Semiconductor Inc.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <linux/stddef.h>
  21. #include <linux/kernel.h>
  22. #include <linux/pci.h>
  23. #include <linux/kdev_t.h>
  24. #include <linux/delay.h>
  25. #include <linux/seq_file.h>
  26. #include <linux/of_platform.h>
  27. #include <asm/system.h>
  28. #include <asm/time.h>
  29. #include <asm/machdep.h>
  30. #include <asm/pci-bridge.h>
  31. #include <asm/mpic.h>
  32. #include <asm/prom.h>
  33. #include <mm/mmu_decl.h>
  34. #include <asm/udbg.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include <sysdev/fsl_pci.h>
  37. #ifdef CONFIG_CPM2
  38. #include <asm/cpm2.h>
  39. #include <sysdev/cpm2_pic.h>
  40. static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
  41. {
  42. int cascade_irq;
  43. while ((cascade_irq = cpm2_get_irq()) >= 0)
  44. generic_handle_irq(cascade_irq);
  45. desc->chip->eoi(irq);
  46. }
  47. #endif /* CONFIG_CPM2 */
  48. static void __init tqm85xx_pic_init(void)
  49. {
  50. struct mpic *mpic;
  51. struct resource r;
  52. struct device_node *np;
  53. #ifdef CONFIG_CPM2
  54. int irq;
  55. #endif
  56. np = of_find_node_by_type(NULL, "open-pic");
  57. if (!np) {
  58. printk(KERN_ERR "Could not find open-pic node\n");
  59. return;
  60. }
  61. if (of_address_to_resource(np, 0, &r)) {
  62. printk(KERN_ERR "Could not map mpic register space\n");
  63. of_node_put(np);
  64. return;
  65. }
  66. mpic = mpic_alloc(np, r.start,
  67. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  68. 0, 256, " OpenPIC ");
  69. BUG_ON(mpic == NULL);
  70. of_node_put(np);
  71. mpic_init(mpic);
  72. #ifdef CONFIG_CPM2
  73. /* Setup CPM2 PIC */
  74. np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
  75. if (np == NULL) {
  76. printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
  77. return;
  78. }
  79. irq = irq_of_parse_and_map(np, 0);
  80. if (irq == NO_IRQ) {
  81. of_node_put(np);
  82. printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
  83. return;
  84. }
  85. cpm2_pic_init(np);
  86. of_node_put(np);
  87. set_irq_chained_handler(irq, cpm2_cascade);
  88. #endif
  89. }
  90. /*
  91. * Setup the architecture
  92. */
  93. static void __init tqm85xx_setup_arch(void)
  94. {
  95. #ifdef CONFIG_PCI
  96. struct device_node *np;
  97. #endif
  98. if (ppc_md.progress)
  99. ppc_md.progress("tqm85xx_setup_arch()", 0);
  100. #ifdef CONFIG_CPM2
  101. cpm2_reset();
  102. #endif
  103. #ifdef CONFIG_PCI
  104. for_each_node_by_type(np, "pci") {
  105. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  106. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  107. struct resource rsrc;
  108. if (!of_address_to_resource(np, 0, &rsrc)) {
  109. if ((rsrc.start & 0xfffff) == 0x8000)
  110. fsl_add_bridge(np, 1);
  111. else
  112. fsl_add_bridge(np, 0);
  113. }
  114. }
  115. }
  116. #endif
  117. }
  118. static void tqm85xx_show_cpuinfo(struct seq_file *m)
  119. {
  120. uint pvid, svid, phid1;
  121. uint memsize = total_memory;
  122. pvid = mfspr(SPRN_PVR);
  123. svid = mfspr(SPRN_SVR);
  124. seq_printf(m, "Vendor\t\t: TQ Components\n");
  125. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  126. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  127. /* Display cpu Pll setting */
  128. phid1 = mfspr(SPRN_HID1);
  129. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  130. /* Display the amount of memory */
  131. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  132. }
  133. static struct of_device_id __initdata of_bus_ids[] = {
  134. { .compatible = "simple-bus", },
  135. {},
  136. };
  137. static int __init declare_of_platform_devices(void)
  138. {
  139. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  140. return 0;
  141. }
  142. machine_device_initcall(tqm85xx, declare_of_platform_devices);
  143. /*
  144. * Called very early, device-tree isn't unflattened
  145. */
  146. static int __init tqm85xx_probe(void)
  147. {
  148. unsigned long root = of_get_flat_dt_root();
  149. if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
  150. (of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
  151. (of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
  152. (of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
  153. (of_flat_dt_is_compatible(root, "tqc,tqm8560")))
  154. return 1;
  155. return 0;
  156. }
  157. define_machine(tqm85xx) {
  158. .name = "TQM85xx",
  159. .probe = tqm85xx_probe,
  160. .setup_arch = tqm85xx_setup_arch,
  161. .init_IRQ = tqm85xx_pic_init,
  162. .show_cpuinfo = tqm85xx_show_cpuinfo,
  163. .get_irq = mpic_get_irq,
  164. .restart = fsl_rstcr_restart,
  165. .calibrate_decr = generic_calibrate_decr,
  166. .progress = udbg_progress,
  167. };