mpc85xx_rdb.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * MPC85xx RDB Board Setup
  3. *
  4. * Copyright 2009 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 <sysdev/fsl_soc.h>
  28. #include <sysdev/fsl_pci.h>
  29. #include "mpc85xx.h"
  30. #undef DEBUG
  31. #ifdef DEBUG
  32. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
  33. #else
  34. #define DBG(fmt, args...)
  35. #endif
  36. void __init mpc85xx_rdb_pic_init(void)
  37. {
  38. struct mpic *mpic;
  39. struct resource r;
  40. struct device_node *np;
  41. unsigned long root = of_get_flat_dt_root();
  42. np = of_find_node_by_type(NULL, "open-pic");
  43. if (np == NULL) {
  44. printk(KERN_ERR "Could not find open-pic node\n");
  45. return;
  46. }
  47. if (of_address_to_resource(np, 0, &r)) {
  48. printk(KERN_ERR "Failed to map mpic register space\n");
  49. of_node_put(np);
  50. return;
  51. }
  52. if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
  53. mpic = mpic_alloc(np, r.start,
  54. MPIC_PRIMARY |
  55. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  56. MPIC_SINGLE_DEST_CPU,
  57. 0, 256, " OpenPIC ");
  58. } else {
  59. mpic = mpic_alloc(np, r.start,
  60. MPIC_PRIMARY | MPIC_WANTS_RESET |
  61. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  62. MPIC_SINGLE_DEST_CPU,
  63. 0, 256, " OpenPIC ");
  64. }
  65. BUG_ON(mpic == NULL);
  66. of_node_put(np);
  67. mpic_init(mpic);
  68. }
  69. /*
  70. * Setup the architecture
  71. */
  72. #ifdef CONFIG_SMP
  73. extern void __init mpc85xx_smp_init(void);
  74. #endif
  75. static void __init mpc85xx_rdb_setup_arch(void)
  76. {
  77. #ifdef CONFIG_PCI
  78. struct device_node *np;
  79. #endif
  80. if (ppc_md.progress)
  81. ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
  82. #ifdef CONFIG_PCI
  83. for_each_node_by_type(np, "pci") {
  84. if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
  85. fsl_add_bridge(np, 0);
  86. }
  87. #endif
  88. #ifdef CONFIG_SMP
  89. mpc85xx_smp_init();
  90. #endif
  91. printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
  92. }
  93. static struct of_device_id __initdata mpc85xxrdb_ids[] = {
  94. { .type = "soc", },
  95. { .compatible = "soc", },
  96. { .compatible = "simple-bus", },
  97. { .compatible = "gianfar", },
  98. {},
  99. };
  100. static int __init mpc85xxrdb_publish_devices(void)
  101. {
  102. return of_platform_bus_probe(NULL, mpc85xxrdb_ids, NULL);
  103. }
  104. machine_device_initcall(p2020_rdb, mpc85xxrdb_publish_devices);
  105. machine_device_initcall(p1020_rdb, mpc85xxrdb_publish_devices);
  106. /*
  107. * Called very early, device-tree isn't unflattened
  108. */
  109. static int __init p2020_rdb_probe(void)
  110. {
  111. unsigned long root = of_get_flat_dt_root();
  112. if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
  113. return 1;
  114. return 0;
  115. }
  116. static int __init p1020_rdb_probe(void)
  117. {
  118. unsigned long root = of_get_flat_dt_root();
  119. if (of_flat_dt_is_compatible(root, "fsl,P1020RDB"))
  120. return 1;
  121. return 0;
  122. }
  123. define_machine(p2020_rdb) {
  124. .name = "P2020 RDB",
  125. .probe = p2020_rdb_probe,
  126. .setup_arch = mpc85xx_rdb_setup_arch,
  127. .init_IRQ = mpc85xx_rdb_pic_init,
  128. #ifdef CONFIG_PCI
  129. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  130. #endif
  131. .get_irq = mpic_get_irq,
  132. .restart = fsl_rstcr_restart,
  133. .calibrate_decr = generic_calibrate_decr,
  134. .progress = udbg_progress,
  135. };
  136. define_machine(p1020_rdb) {
  137. .name = "P1020 RDB",
  138. .probe = p1020_rdb_probe,
  139. .setup_arch = mpc85xx_rdb_setup_arch,
  140. .init_IRQ = mpc85xx_rdb_pic_init,
  141. #ifdef CONFIG_PCI
  142. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  143. #endif
  144. .get_irq = mpic_get_irq,
  145. .restart = fsl_rstcr_restart,
  146. .calibrate_decr = generic_calibrate_decr,
  147. .progress = udbg_progress,
  148. };