omap-hotplug.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * OMAP4 SMP cpu-hotplug support
  3. *
  4. * Copyright (C) 2010 Texas Instruments, Inc.
  5. * Author:
  6. * Santosh Shilimkar <santosh.shilimkar@ti.com>
  7. *
  8. * Platform file needed for the OMAP4 SMP. This file is based on arm
  9. * realview smp platform.
  10. * Copyright (c) 2002 ARM Limited.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/errno.h>
  18. #include <linux/smp.h>
  19. #include <linux/completion.h>
  20. #include <asm/cacheflush.h>
  21. #include <mach/omap4-common.h>
  22. static DECLARE_COMPLETION(cpu_killed);
  23. int platform_cpu_kill(unsigned int cpu)
  24. {
  25. return wait_for_completion_timeout(&cpu_killed, 5000);
  26. }
  27. /*
  28. * platform-specific code to shutdown a CPU
  29. * Called with IRQs disabled
  30. */
  31. void platform_cpu_die(unsigned int cpu)
  32. {
  33. unsigned int this_cpu = hard_smp_processor_id();
  34. if (cpu != this_cpu) {
  35. pr_crit("platform_cpu_die running on %u, should be %u\n",
  36. this_cpu, cpu);
  37. BUG();
  38. }
  39. pr_notice("CPU%u: shutdown\n", cpu);
  40. complete(&cpu_killed);
  41. flush_cache_all();
  42. dsb();
  43. /*
  44. * we're ready for shutdown now, so do it
  45. */
  46. if (omap_modify_auxcoreboot0(0x0, 0x200) != 0x0)
  47. printk(KERN_CRIT "Secure clear status failed\n");
  48. for (;;) {
  49. /*
  50. * Execute WFI
  51. */
  52. do_wfi();
  53. if (omap_read_auxcoreboot0() == cpu) {
  54. /*
  55. * OK, proper wakeup, we're done
  56. */
  57. break;
  58. }
  59. pr_debug("CPU%u: spurious wakeup call\n", cpu);
  60. }
  61. }
  62. int platform_cpu_disable(unsigned int cpu)
  63. {
  64. /*
  65. * we don't allow CPU 0 to be shutdown (it is still too special
  66. * e.g. clock tick interrupts)
  67. */
  68. return cpu == 0 ? -EPERM : 0;
  69. }