smp.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Author: Andy Fleming <afleming@freescale.com>
  3. * Kumar Gala <galak@kernel.crashing.org>
  4. *
  5. * Copyright 2006-2008 Freescale Semiconductor Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/stddef.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/delay.h>
  16. #include <linux/of.h>
  17. #include <asm/machdep.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/page.h>
  20. #include <asm/mpic.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/dbell.h>
  23. #include <sysdev/fsl_soc.h>
  24. extern void __early_start(void);
  25. #define BOOT_ENTRY_ADDR_UPPER 0
  26. #define BOOT_ENTRY_ADDR_LOWER 1
  27. #define BOOT_ENTRY_R3_UPPER 2
  28. #define BOOT_ENTRY_R3_LOWER 3
  29. #define BOOT_ENTRY_RESV 4
  30. #define BOOT_ENTRY_PIR 5
  31. #define BOOT_ENTRY_R6_UPPER 6
  32. #define BOOT_ENTRY_R6_LOWER 7
  33. #define NUM_BOOT_ENTRY 8
  34. #define SIZE_BOOT_ENTRY (NUM_BOOT_ENTRY * sizeof(u32))
  35. static void __init
  36. smp_85xx_kick_cpu(int nr)
  37. {
  38. unsigned long flags;
  39. const u64 *cpu_rel_addr;
  40. __iomem u32 *bptr_vaddr;
  41. struct device_node *np;
  42. int n = 0;
  43. int ioremappable;
  44. WARN_ON (nr < 0 || nr >= NR_CPUS);
  45. pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr);
  46. np = of_get_cpu_node(nr, NULL);
  47. cpu_rel_addr = of_get_property(np, "cpu-release-addr", NULL);
  48. if (cpu_rel_addr == NULL) {
  49. printk(KERN_ERR "No cpu-release-addr for cpu %d\n", nr);
  50. return;
  51. }
  52. /*
  53. * A secondary core could be in a spinloop in the bootpage
  54. * (0xfffff000), somewhere in highmem, or somewhere in lowmem.
  55. * The bootpage and highmem can be accessed via ioremap(), but
  56. * we need to directly access the spinloop if its in lowmem.
  57. */
  58. ioremappable = *cpu_rel_addr > virt_to_phys(high_memory);
  59. /* Map the spin table */
  60. if (ioremappable)
  61. bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY);
  62. else
  63. bptr_vaddr = phys_to_virt(*cpu_rel_addr);
  64. local_irq_save(flags);
  65. out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr);
  66. out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start));
  67. if (!ioremappable)
  68. flush_dcache_range((ulong)bptr_vaddr,
  69. (ulong)(bptr_vaddr + SIZE_BOOT_ENTRY));
  70. /* Wait a bit for the CPU to ack. */
  71. while ((__secondary_hold_acknowledge != nr) && (++n < 1000))
  72. mdelay(1);
  73. local_irq_restore(flags);
  74. if (ioremappable)
  75. iounmap(bptr_vaddr);
  76. pr_debug("waited %d msecs for CPU #%d.\n", n, nr);
  77. }
  78. static void __init
  79. smp_85xx_setup_cpu(int cpu_nr)
  80. {
  81. mpic_setup_this_cpu();
  82. }
  83. struct smp_ops_t smp_85xx_ops = {
  84. .kick_cpu = smp_85xx_kick_cpu,
  85. };
  86. void __init mpc85xx_smp_init(void)
  87. {
  88. struct device_node *np;
  89. np = of_find_node_by_type(NULL, "open-pic");
  90. if (np) {
  91. smp_85xx_ops.probe = smp_mpic_probe;
  92. smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu;
  93. smp_85xx_ops.message_pass = smp_mpic_message_pass;
  94. }
  95. if (cpu_has_feature(CPU_FTR_DBELL))
  96. smp_85xx_ops.message_pass = smp_dbell_message_pass;
  97. BUG_ON(!smp_85xx_ops.message_pass);
  98. smp_ops = &smp_85xx_ops;
  99. }