hotplug.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2002 ARM Ltd.
  3. * All Rights Reserved
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/smp.h>
  12. #include <asm/cacheflush.h>
  13. extern volatile int pen_release;
  14. static inline void cpu_enter_lowpower(void)
  15. {
  16. /* Just flush the cache. Changing the coherency is not yet
  17. * available on msm. */
  18. flush_cache_all();
  19. }
  20. static inline void cpu_leave_lowpower(void)
  21. {
  22. }
  23. static inline void platform_do_lowpower(unsigned int cpu)
  24. {
  25. /* Just enter wfi for now. TODO: Properly shut off the cpu. */
  26. for (;;) {
  27. /*
  28. * here's the WFI
  29. */
  30. asm("wfi"
  31. :
  32. :
  33. : "memory", "cc");
  34. if (pen_release == cpu) {
  35. /*
  36. * OK, proper wakeup, we're done
  37. */
  38. break;
  39. }
  40. /*
  41. * getting here, means that we have come out of WFI without
  42. * having been woken up - this shouldn't happen
  43. *
  44. * The trouble is, letting people know about this is not really
  45. * possible, since we are currently running incoherently, and
  46. * therefore cannot safely call printk() or anything else
  47. */
  48. pr_debug("CPU%u: spurious wakeup call\n", cpu);
  49. }
  50. }
  51. int platform_cpu_kill(unsigned int cpu)
  52. {
  53. return 1;
  54. }
  55. /*
  56. * platform-specific code to shutdown a CPU
  57. *
  58. * Called with IRQs disabled
  59. */
  60. void platform_cpu_die(unsigned int cpu)
  61. {
  62. /*
  63. * we're ready for shutdown now, so do it
  64. */
  65. cpu_enter_lowpower();
  66. platform_do_lowpower(cpu);
  67. /*
  68. * bring this CPU back into the world of cache
  69. * coherency, and then restore interrupts
  70. */
  71. cpu_leave_lowpower();
  72. }
  73. int platform_cpu_disable(unsigned int cpu)
  74. {
  75. /*
  76. * we don't allow CPU 0 to be shutdown (it is still too special
  77. * e.g. clock tick interrupts)
  78. */
  79. return cpu == 0 ? -EPERM : 0;
  80. }