mpc86xx_smp.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. local_irq_disable();
  55. /* Save reset vector */
  56. save_vector = *vector;
  57. /* Setup fake reset vector to call __secondary_start_mpc86xx. */
  58. target = (unsigned long) __secondary_start_mpc86xx;
  59. create_branch((unsigned long)vector, target, BRANCH_SET_LINK);
  60. /* Kick that CPU */
  61. smp_86xx_release_core(nr);
  62. /* Wait a bit for the CPU to take the exception. */
  63. while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
  64. mdelay(1);
  65. /* Restore the exception vector */
  66. *vector = save_vector;
  67. flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
  68. local_irq_restore(flags);
  69. pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
  70. }
  71. static void __init
  72. smp_86xx_setup_cpu(int cpu_nr)
  73. {
  74. mpic_setup_this_cpu();
  75. }
  76. struct smp_ops_t smp_86xx_ops = {
  77. .message_pass = smp_mpic_message_pass,
  78. .probe = smp_mpic_probe,
  79. .kick_cpu = smp_86xx_kick_cpu,
  80. .setup_cpu = smp_86xx_setup_cpu,
  81. .take_timebase = smp_generic_take_timebase,
  82. .give_timebase = smp_generic_give_timebase,
  83. };
  84. void __init
  85. mpc86xx_smp_init(void)
  86. {
  87. smp_ops = &smp_86xx_ops;
  88. }