smp.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. WARN_ON (nr < 0 || nr >= NR_CPUS);
  44. pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr);
  45. np = of_get_cpu_node(nr, NULL);
  46. cpu_rel_addr = of_get_property(np, "cpu-release-addr", NULL);
  47. if (cpu_rel_addr == NULL) {
  48. printk(KERN_ERR "No cpu-release-addr for cpu %d\n", nr);
  49. return;
  50. }
  51. /* Map the spin table */
  52. bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY);
  53. local_irq_save(flags);
  54. out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr);
  55. out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start));
  56. /* Wait a bit for the CPU to ack. */
  57. while ((__secondary_hold_acknowledge != nr) && (++n < 1000))
  58. mdelay(1);
  59. local_irq_restore(flags);
  60. iounmap(bptr_vaddr);
  61. pr_debug("waited %d msecs for CPU #%d.\n", n, nr);
  62. }
  63. static void __init
  64. smp_85xx_setup_cpu(int cpu_nr)
  65. {
  66. mpic_setup_this_cpu();
  67. }
  68. struct smp_ops_t smp_85xx_ops = {
  69. .kick_cpu = smp_85xx_kick_cpu,
  70. };
  71. void __init mpc85xx_smp_init(void)
  72. {
  73. struct device_node *np;
  74. np = of_find_node_by_type(NULL, "open-pic");
  75. if (np) {
  76. smp_85xx_ops.probe = smp_mpic_probe;
  77. smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu;
  78. smp_85xx_ops.message_pass = smp_mpic_message_pass;
  79. }
  80. if (cpu_has_feature(CPU_FTR_DBELL))
  81. smp_85xx_ops.message_pass = smp_dbell_message_pass;
  82. BUG_ON(!smp_85xx_ops.message_pass);
  83. smp_ops = &smp_85xx_ops;
  84. }