hotplug.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * SMP support for R-Mobile / SH-Mobile
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. *
  6. * Based on realview, Copyright (C) 2002 ARM Ltd, All Rights Reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/errno.h>
  14. #include <linux/smp.h>
  15. #include <linux/cpumask.h>
  16. #include <linux/delay.h>
  17. #include <mach/common.h>
  18. #include <asm/cacheflush.h>
  19. static cpumask_t dead_cpus;
  20. void shmobile_cpu_die(unsigned int cpu)
  21. {
  22. /* hardware shutdown code running on the CPU that is being offlined */
  23. flush_cache_all();
  24. dsb();
  25. /* notify platform_cpu_kill() that hardware shutdown is finished */
  26. cpumask_set_cpu(cpu, &dead_cpus);
  27. /* wait for SoC code in platform_cpu_kill() to shut off CPU core
  28. * power. CPU bring up starts from the reset vector.
  29. */
  30. while (1) {
  31. /*
  32. * here's the WFI
  33. */
  34. asm(".word 0xe320f003\n"
  35. :
  36. :
  37. : "memory", "cc");
  38. }
  39. }
  40. int shmobile_cpu_disable(unsigned int cpu)
  41. {
  42. cpumask_clear_cpu(cpu, &dead_cpus);
  43. /*
  44. * we don't allow CPU 0 to be shutdown (it is still too special
  45. * e.g. clock tick interrupts)
  46. */
  47. return cpu == 0 ? -EPERM : 0;
  48. }
  49. int shmobile_cpu_disable_any(unsigned int cpu)
  50. {
  51. cpumask_clear_cpu(cpu, &dead_cpus);
  52. return 0;
  53. }
  54. int shmobile_cpu_is_dead(unsigned int cpu)
  55. {
  56. return cpumask_test_cpu(cpu, &dead_cpus);
  57. }