iss4xx.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * PPC476 board specific routines
  3. *
  4. * Copyright 2010 Torez Smith, IBM Corporation.
  5. *
  6. * Based on earlier code:
  7. * Matt Porter <mporter@kernel.crashing.org>
  8. * Copyright 2002-2005 MontaVista Software Inc.
  9. *
  10. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  11. * Copyright (c) 2003-2005 Zultys Technologies
  12. *
  13. * Rewritten and ported to the merged powerpc tree:
  14. * Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation.
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the
  18. * Free Software Foundation; either version 2 of the License, or (at your
  19. * option) any later version.
  20. */
  21. #include <linux/init.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/rtc.h>
  24. #include <asm/machdep.h>
  25. #include <asm/prom.h>
  26. #include <asm/udbg.h>
  27. #include <asm/time.h>
  28. #include <asm/uic.h>
  29. #include <asm/ppc4xx.h>
  30. #include <asm/mpic.h>
  31. #include <asm/mmu.h>
  32. static const struct of_device_id iss4xx_of_bus[] __initconst = {
  33. { .compatible = "ibm,plb4", },
  34. { .compatible = "ibm,plb6", },
  35. { .compatible = "ibm,opb", },
  36. { .compatible = "ibm,ebc", },
  37. {},
  38. };
  39. static int __init iss4xx_device_probe(void)
  40. {
  41. of_platform_bus_probe(NULL, iss4xx_of_bus, NULL);
  42. of_instantiate_rtc();
  43. return 0;
  44. }
  45. machine_device_initcall(iss4xx, iss4xx_device_probe);
  46. /* We can have either UICs or MPICs */
  47. static void __init iss4xx_init_irq(void)
  48. {
  49. struct device_node *np;
  50. /* Find top level interrupt controller */
  51. for_each_node_with_property(np, "interrupt-controller") {
  52. if (of_get_property(np, "interrupts", NULL) == NULL)
  53. break;
  54. }
  55. if (np == NULL)
  56. panic("Can't find top level interrupt controller");
  57. /* Check type and do appropriate initialization */
  58. if (of_device_is_compatible(np, "ibm,uic")) {
  59. uic_init_tree();
  60. ppc_md.get_irq = uic_get_irq;
  61. #ifdef CONFIG_MPIC
  62. } else if (of_device_is_compatible(np, "chrp,open-pic")) {
  63. /* The MPIC driver will get everything it needs from the
  64. * device-tree, just pass 0 to all arguments
  65. */
  66. struct mpic *mpic = mpic_alloc(np, 0, MPIC_NO_RESET, 0, 0, " MPIC ");
  67. BUG_ON(mpic == NULL);
  68. mpic_init(mpic);
  69. ppc_md.get_irq = mpic_get_irq;
  70. #endif
  71. } else
  72. panic("Unrecognized top level interrupt controller");
  73. }
  74. #ifdef CONFIG_SMP
  75. static void smp_iss4xx_setup_cpu(int cpu)
  76. {
  77. mpic_setup_this_cpu();
  78. }
  79. static int smp_iss4xx_kick_cpu(int cpu)
  80. {
  81. struct device_node *cpunode = of_get_cpu_node(cpu, NULL);
  82. const u64 *spin_table_addr_prop;
  83. u32 *spin_table;
  84. extern void start_secondary_47x(void);
  85. BUG_ON(cpunode == NULL);
  86. /* Assume spin table. We could test for the enable-method in
  87. * the device-tree but currently there's little point as it's
  88. * our only supported method
  89. */
  90. spin_table_addr_prop = of_get_property(cpunode, "cpu-release-addr",
  91. NULL);
  92. if (spin_table_addr_prop == NULL) {
  93. pr_err("CPU%d: Can't start, missing cpu-release-addr !\n", cpu);
  94. return -ENOENT;
  95. }
  96. /* Assume it's mapped as part of the linear mapping. This is a bit
  97. * fishy but will work fine for now
  98. */
  99. spin_table = (u32 *)__va(*spin_table_addr_prop);
  100. pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table);
  101. spin_table[3] = cpu;
  102. smp_wmb();
  103. spin_table[1] = __pa(start_secondary_47x);
  104. mb();
  105. return 0;
  106. }
  107. static struct smp_ops_t iss_smp_ops = {
  108. .probe = smp_mpic_probe,
  109. .message_pass = smp_mpic_message_pass,
  110. .setup_cpu = smp_iss4xx_setup_cpu,
  111. .kick_cpu = smp_iss4xx_kick_cpu,
  112. .give_timebase = smp_generic_give_timebase,
  113. .take_timebase = smp_generic_take_timebase,
  114. };
  115. static void __init iss4xx_smp_init(void)
  116. {
  117. if (mmu_has_feature(MMU_FTR_TYPE_47x))
  118. smp_ops = &iss_smp_ops;
  119. }
  120. #else /* CONFIG_SMP */
  121. static void __init iss4xx_smp_init(void) { }
  122. #endif /* CONFIG_SMP */
  123. static void __init iss4xx_setup_arch(void)
  124. {
  125. iss4xx_smp_init();
  126. }
  127. /*
  128. * Called very early, MMU is off, device-tree isn't unflattened
  129. */
  130. static int __init iss4xx_probe(void)
  131. {
  132. if (!of_machine_is_compatible("ibm,iss-4xx"))
  133. return 0;
  134. return 1;
  135. }
  136. define_machine(iss4xx) {
  137. .name = "ISS-4xx",
  138. .probe = iss4xx_probe,
  139. .progress = udbg_progress,
  140. .init_IRQ = iss4xx_init_irq,
  141. .setup_arch = iss4xx_setup_arch,
  142. .restart = ppc4xx_reset_system,
  143. .calibrate_decr = generic_calibrate_decr,
  144. };