hotplug.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <linux/of.h>
  18. #include <mach/common.h>
  19. #include <mach/r8a7779.h>
  20. #include <mach/emev2.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/mach-types.h>
  23. static cpumask_t dead_cpus;
  24. void shmobile_cpu_die(unsigned int cpu)
  25. {
  26. /* hardware shutdown code running on the CPU that is being offlined */
  27. flush_cache_all();
  28. dsb();
  29. /* notify platform_cpu_kill() that hardware shutdown is finished */
  30. cpumask_set_cpu(cpu, &dead_cpus);
  31. /* wait for SoC code in platform_cpu_kill() to shut off CPU core
  32. * power. CPU bring up starts from the reset vector.
  33. */
  34. while (1) {
  35. /*
  36. * here's the WFI
  37. */
  38. asm(".word 0xe320f003\n"
  39. :
  40. :
  41. : "memory", "cc");
  42. }
  43. }
  44. int shmobile_cpu_disable(unsigned int cpu)
  45. {
  46. cpumask_clear_cpu(cpu, &dead_cpus);
  47. /*
  48. * we don't allow CPU 0 to be shutdown (it is still too special
  49. * e.g. clock tick interrupts)
  50. */
  51. return cpu == 0 ? -EPERM : 0;
  52. }
  53. int shmobile_cpu_disable_any(unsigned int cpu)
  54. {
  55. cpumask_clear_cpu(cpu, &dead_cpus);
  56. return 0;
  57. }
  58. int shmobile_cpu_is_dead(unsigned int cpu)
  59. {
  60. return cpumask_test_cpu(cpu, &dead_cpus);
  61. }