mpc86xx_smp.c 2.6 KB

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