stx_gp3.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Based on MPC8560 ADS and arch/ppc stx_gp3 ports
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2008 Freescale Semiconductor Inc.
  7. *
  8. * Dan Malek <dan@embeddededge.com>
  9. * Copyright 2004 Embedded Edge, LLC
  10. *
  11. * Copied from mpc8560_ads.c
  12. * Copyright 2002, 2003 Motorola Inc.
  13. *
  14. * Ported to 2.6, Matt Porter <mporter@kernel.crashing.org>
  15. * Copyright 2004-2005 MontaVista Software, Inc.
  16. *
  17. * This program is free software; you can redistribute it and/or modify it
  18. * under the terms of the GNU General Public License as published by the
  19. * Free Software Foundation; either version 2 of the License, or (at your
  20. * option) any later version.
  21. */
  22. #include <linux/stddef.h>
  23. #include <linux/kernel.h>
  24. #include <linux/pci.h>
  25. #include <linux/kdev_t.h>
  26. #include <linux/delay.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/of_platform.h>
  29. #include <asm/system.h>
  30. #include <asm/time.h>
  31. #include <asm/machdep.h>
  32. #include <asm/pci-bridge.h>
  33. #include <asm/mpic.h>
  34. #include <asm/prom.h>
  35. #include <mm/mmu_decl.h>
  36. #include <asm/udbg.h>
  37. #include <sysdev/fsl_soc.h>
  38. #include <sysdev/fsl_pci.h>
  39. #ifdef CONFIG_CPM2
  40. #include <asm/cpm2.h>
  41. #include <sysdev/cpm2_pic.h>
  42. static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
  43. {
  44. int cascade_irq;
  45. while ((cascade_irq = cpm2_get_irq()) >= 0)
  46. generic_handle_irq(cascade_irq);
  47. desc->chip->eoi(irq);
  48. }
  49. #endif /* CONFIG_CPM2 */
  50. static void __init stx_gp3_pic_init(void)
  51. {
  52. struct mpic *mpic;
  53. struct resource r;
  54. struct device_node *np;
  55. #ifdef CONFIG_CPM2
  56. int irq;
  57. #endif
  58. np = of_find_node_by_type(NULL, "open-pic");
  59. if (!np) {
  60. printk(KERN_ERR "Could not find open-pic node\n");
  61. return;
  62. }
  63. if (of_address_to_resource(np, 0, &r)) {
  64. printk(KERN_ERR "Could not map mpic register space\n");
  65. of_node_put(np);
  66. return;
  67. }
  68. mpic = mpic_alloc(np, r.start,
  69. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  70. 0, 256, " OpenPIC ");
  71. BUG_ON(mpic == NULL);
  72. of_node_put(np);
  73. mpic_init(mpic);
  74. #ifdef CONFIG_CPM2
  75. /* Setup CPM2 PIC */
  76. np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
  77. if (np == NULL) {
  78. printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
  79. return;
  80. }
  81. irq = irq_of_parse_and_map(np, 0);
  82. if (irq == NO_IRQ) {
  83. of_node_put(np);
  84. printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
  85. return;
  86. }
  87. cpm2_pic_init(np);
  88. of_node_put(np);
  89. set_irq_chained_handler(irq, cpm2_cascade);
  90. #endif
  91. }
  92. /*
  93. * Setup the architecture
  94. */
  95. static void __init stx_gp3_setup_arch(void)
  96. {
  97. #ifdef CONFIG_PCI
  98. struct device_node *np;
  99. #endif
  100. if (ppc_md.progress)
  101. ppc_md.progress("stx_gp3_setup_arch()", 0);
  102. #ifdef CONFIG_CPM2
  103. cpm2_reset();
  104. #endif
  105. #ifdef CONFIG_PCI
  106. for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
  107. fsl_add_bridge(np, 1);
  108. #endif
  109. }
  110. static void stx_gp3_show_cpuinfo(struct seq_file *m)
  111. {
  112. uint pvid, svid, phid1;
  113. pvid = mfspr(SPRN_PVR);
  114. svid = mfspr(SPRN_SVR);
  115. seq_printf(m, "Vendor\t\t: RPC Electronics STx \n");
  116. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  117. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  118. /* Display cpu Pll setting */
  119. phid1 = mfspr(SPRN_HID1);
  120. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  121. }
  122. static struct of_device_id __initdata of_bus_ids[] = {
  123. { .compatible = "simple-bus", },
  124. { .compatible = "gianfar", },
  125. {},
  126. };
  127. static int __init declare_of_platform_devices(void)
  128. {
  129. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  130. return 0;
  131. }
  132. machine_device_initcall(stx_gp3, declare_of_platform_devices);
  133. /*
  134. * Called very early, device-tree isn't unflattened
  135. */
  136. static int __init stx_gp3_probe(void)
  137. {
  138. unsigned long root = of_get_flat_dt_root();
  139. return of_flat_dt_is_compatible(root, "stx,gp3-8560");
  140. }
  141. define_machine(stx_gp3) {
  142. .name = "STX GP3",
  143. .probe = stx_gp3_probe,
  144. .setup_arch = stx_gp3_setup_arch,
  145. .init_IRQ = stx_gp3_pic_init,
  146. .show_cpuinfo = stx_gp3_show_cpuinfo,
  147. .get_irq = mpic_get_irq,
  148. .restart = fsl_rstcr_restart,
  149. .calibrate_decr = generic_calibrate_decr,
  150. .progress = udbg_progress,
  151. };