hotplug.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) STMicroelectronics 2009
  3. * Copyright (C) ST-Ericsson SA 2010
  4. *
  5. * License Terms: GNU General Public License v2
  6. * Based on ARM realview platform
  7. *
  8. * Author: Sundar Iyer <sundar.iyer@stericsson.com>
  9. *
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/smp.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/smp_plat.h>
  16. extern volatile int pen_release;
  17. static inline void platform_do_lowpower(unsigned int cpu)
  18. {
  19. flush_cache_all();
  20. /* we put the platform to just WFI */
  21. for (;;) {
  22. __asm__ __volatile__("dsb\n\t" "wfi\n\t"
  23. : : : "memory");
  24. if (pen_release == cpu_logical_map(cpu)) {
  25. /*
  26. * OK, proper wakeup, we're done
  27. */
  28. break;
  29. }
  30. }
  31. }
  32. int platform_cpu_kill(unsigned int cpu)
  33. {
  34. return 1;
  35. }
  36. /*
  37. * platform-specific code to shutdown a CPU
  38. *
  39. * Called with IRQs disabled
  40. */
  41. void platform_cpu_die(unsigned int cpu)
  42. {
  43. /* directly enter low power state, skipping secure registers */
  44. platform_do_lowpower(cpu);
  45. }
  46. int platform_cpu_disable(unsigned int cpu)
  47. {
  48. /*
  49. * we don't allow CPU 0 to be shutdown (it is still too special
  50. * e.g. clock tick interrupts)
  51. */
  52. return cpu == 0 ? -EPERM : 0;
  53. }