mpc86xx_smp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. void *mcm_vaddr;
  30. unsigned long vaddr, 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. vaddr = (unsigned long)mcm_vaddr + MCM_PORT_CONFIG_OFFSET;
  39. pcr = in_be32((volatile unsigned *)vaddr);
  40. pcr |= 1 << (nr + 24);
  41. out_be32((volatile unsigned *)vaddr, pcr);
  42. }
  43. static void __init
  44. smp_86xx_kick_cpu(int nr)
  45. {
  46. unsigned int save_vector;
  47. unsigned long target, flags;
  48. int n = 0;
  49. volatile unsigned int *vector
  50. = (volatile unsigned int *)(KERNELBASE + 0x100);
  51. if (nr < 0 || nr >= NR_CPUS)
  52. return;
  53. pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);
  54. local_irq_save(flags);
  55. local_irq_disable();
  56. /* Save reset vector */
  57. save_vector = *vector;
  58. /* Setup fake reset vector to call __secondary_start_mpc86xx. */
  59. target = (unsigned long) __secondary_start_mpc86xx;
  60. create_branch((unsigned long)vector, target, BRANCH_SET_LINK);
  61. /* Kick that CPU */
  62. smp_86xx_release_core(nr);
  63. /* Wait a bit for the CPU to take the exception. */
  64. while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
  65. mdelay(1);
  66. /* Restore the exception vector */
  67. *vector = save_vector;
  68. flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
  69. local_irq_restore(flags);
  70. pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
  71. }
  72. static void __init
  73. smp_86xx_setup_cpu(int cpu_nr)
  74. {
  75. mpic_setup_this_cpu();
  76. }
  77. struct smp_ops_t smp_86xx_ops = {
  78. .message_pass = smp_mpic_message_pass,
  79. .probe = smp_mpic_probe,
  80. .kick_cpu = smp_86xx_kick_cpu,
  81. .setup_cpu = smp_86xx_setup_cpu,
  82. .take_timebase = smp_generic_take_timebase,
  83. .give_timebase = smp_generic_give_timebase,
  84. };
  85. void __init
  86. mpc86xx_smp_init(void)
  87. {
  88. smp_ops = &smp_86xx_ops;
  89. }