mpc86xx_smp.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Author: Xianghua Xiao <x.xiao@freescale.com>
  3. * Zhang Wei <wei.zhang@freescale.com>
  4. *
  5. * Copyright 2006 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 <asm/pgtable.h>
  17. #include <asm/page.h>
  18. #include <asm/pci-bridge.h>
  19. #include <asm-powerpc/mpic.h>
  20. #include <asm/mpc86xx.h>
  21. #include <asm/cacheflush.h>
  22. #include <sysdev/fsl_soc.h>
  23. #include "mpc86xx.h"
  24. extern void __secondary_start_mpc86xx(void);
  25. extern unsigned long __secondary_hold_acknowledge;
  26. static void __init
  27. smp_86xx_release_core(int nr)
  28. {
  29. __be32 __iomem *mcm_vaddr;
  30. unsigned long pcr;
  31. if (nr < 0 || nr >= NR_CPUS)
  32. return;
  33. /*
  34. * Startup Core #nr.
  35. */
  36. mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,
  37. MPC86xx_MCM_SIZE);
  38. pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));
  39. pcr |= 1 << (nr + 24);
  40. out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);
  41. }
  42. static void __init
  43. smp_86xx_kick_cpu(int nr)
  44. {
  45. unsigned int save_vector;
  46. unsigned long target, flags;
  47. int n = 0;
  48. volatile unsigned int *vector
  49. = (volatile unsigned int *)(KERNELBASE + 0x100);
  50. if (nr < 0 || nr >= NR_CPUS)
  51. return;
  52. pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);
  53. local_irq_save(flags);
  54. /* Save reset vector */
  55. save_vector = *vector;
  56. /* Setup fake reset vector to call __secondary_start_mpc86xx. */
  57. target = (unsigned long) __secondary_start_mpc86xx;
  58. create_branch((unsigned long)vector, target, BRANCH_SET_LINK);
  59. /* Kick that CPU */
  60. smp_86xx_release_core(nr);
  61. /* Wait a bit for the CPU to take the exception. */
  62. while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
  63. mdelay(1);
  64. /* Restore the exception vector */
  65. *vector = save_vector;
  66. flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
  67. local_irq_restore(flags);
  68. pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
  69. }
  70. static void __init
  71. smp_86xx_setup_cpu(int cpu_nr)
  72. {
  73. mpic_setup_this_cpu();
  74. }
  75. struct smp_ops_t smp_86xx_ops = {
  76. .message_pass = smp_mpic_message_pass,
  77. .probe = smp_mpic_probe,
  78. .kick_cpu = smp_86xx_kick_cpu,
  79. .setup_cpu = smp_86xx_setup_cpu,
  80. .take_timebase = smp_generic_take_timebase,
  81. .give_timebase = smp_generic_give_timebase,
  82. };
  83. void __init
  84. mpc86xx_smp_init(void)
  85. {
  86. smp_ops = &smp_86xx_ops;
  87. }