stx_gp3.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. struct irq_chip *chip = irq_desc_get_chip(desc);
  45. int cascade_irq;
  46. while ((cascade_irq = cpm2_get_irq()) >= 0)
  47. generic_handle_irq(cascade_irq);
  48. chip->irq_eoi(&desc->irq_data);
  49. }
  50. #endif /* CONFIG_CPM2 */
  51. static void __init stx_gp3_pic_init(void)
  52. {
  53. struct mpic *mpic;
  54. struct resource r;
  55. struct device_node *np;
  56. #ifdef CONFIG_CPM2
  57. int irq;
  58. #endif
  59. np = of_find_node_by_type(NULL, "open-pic");
  60. if (!np) {
  61. printk(KERN_ERR "Could not find open-pic node\n");
  62. return;
  63. }
  64. if (of_address_to_resource(np, 0, &r)) {
  65. printk(KERN_ERR "Could not map mpic register space\n");
  66. of_node_put(np);
  67. return;
  68. }
  69. mpic = mpic_alloc(np, r.start,
  70. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  71. 0, 256, " OpenPIC ");
  72. BUG_ON(mpic == NULL);
  73. of_node_put(np);
  74. mpic_init(mpic);
  75. #ifdef CONFIG_CPM2
  76. /* Setup CPM2 PIC */
  77. np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
  78. if (np == NULL) {
  79. printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
  80. return;
  81. }
  82. irq = irq_of_parse_and_map(np, 0);
  83. if (irq == NO_IRQ) {
  84. of_node_put(np);
  85. printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
  86. return;
  87. }
  88. cpm2_pic_init(np);
  89. of_node_put(np);
  90. irq_set_chained_handler(irq, cpm2_cascade);
  91. #endif
  92. }
  93. /*
  94. * Setup the architecture
  95. */
  96. static void __init stx_gp3_setup_arch(void)
  97. {
  98. #ifdef CONFIG_PCI
  99. struct device_node *np;
  100. #endif
  101. if (ppc_md.progress)
  102. ppc_md.progress("stx_gp3_setup_arch()", 0);
  103. #ifdef CONFIG_CPM2
  104. cpm2_reset();
  105. #endif
  106. #ifdef CONFIG_PCI
  107. for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
  108. fsl_add_bridge(np, 1);
  109. #endif
  110. }
  111. static void stx_gp3_show_cpuinfo(struct seq_file *m)
  112. {
  113. uint pvid, svid, phid1;
  114. pvid = mfspr(SPRN_PVR);
  115. svid = mfspr(SPRN_SVR);
  116. seq_printf(m, "Vendor\t\t: RPC Electronics STx\n");
  117. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  118. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  119. /* Display cpu Pll setting */
  120. phid1 = mfspr(SPRN_HID1);
  121. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  122. }
  123. static struct of_device_id __initdata of_bus_ids[] = {
  124. { .compatible = "simple-bus", },
  125. { .compatible = "gianfar", },
  126. {},
  127. };
  128. static int __init declare_of_platform_devices(void)
  129. {
  130. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  131. return 0;
  132. }
  133. machine_device_initcall(stx_gp3, declare_of_platform_devices);
  134. /*
  135. * Called very early, device-tree isn't unflattened
  136. */
  137. static int __init stx_gp3_probe(void)
  138. {
  139. unsigned long root = of_get_flat_dt_root();
  140. return of_flat_dt_is_compatible(root, "stx,gp3-8560");
  141. }
  142. define_machine(stx_gp3) {
  143. .name = "STX GP3",
  144. .probe = stx_gp3_probe,
  145. .setup_arch = stx_gp3_setup_arch,
  146. .init_IRQ = stx_gp3_pic_init,
  147. .show_cpuinfo = stx_gp3_show_cpuinfo,
  148. .get_irq = mpic_get_irq,
  149. .restart = fsl_rstcr_restart,
  150. .calibrate_decr = generic_calibrate_decr,
  151. .progress = udbg_progress,
  152. };