smp.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <sysdev/fsl_soc.h>
  23. extern volatile unsigned long __secondary_hold_acknowledge;
  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. local_irq_save(flags);
  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. /* Map the spin table */
  53. bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY);
  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. iounmap(bptr_vaddr);
  60. local_irq_restore(flags);
  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. /* Clear any pending timer interrupts */
  68. mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
  69. /* Enable decrementer interrupt */
  70. mtspr(SPRN_TCR, TCR_DIE);
  71. }
  72. struct smp_ops_t smp_85xx_ops = {
  73. .message_pass = smp_mpic_message_pass,
  74. .probe = smp_mpic_probe,
  75. .kick_cpu = smp_85xx_kick_cpu,
  76. .setup_cpu = smp_85xx_setup_cpu,
  77. };
  78. void __init
  79. mpc85xx_smp_init(void)
  80. {
  81. smp_ops = &smp_85xx_ops;
  82. }