iss4xx.c 4.0 KB

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