hotplug.c 1.9 KB

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