mt_psci.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/smp.h>
  16. #include <asm/cpu_ops.h>
  17. #include <asm/psci.h>
  18. #include <mach/mt_spm_mtcmos.h>
  19. #include "mt_cpu_psci_ops.h"
  20. #ifdef CONFIG_SMP
  21. static int __init mt_psci_cpu_init(struct device_node *dn, unsigned int cpu)
  22. {
  23. return 0;
  24. }
  25. static int __init mt_psci_cpu_prepare(unsigned int cpu)
  26. {
  27. if (cpu == 1)
  28. spm_mtcmos_cpu_init();
  29. return cpu_psci_ops.cpu_prepare(cpu);
  30. }
  31. static int mt_psci_cpu_boot(unsigned int cpu)
  32. {
  33. int ret;
  34. ret = cpu_psci_ops.cpu_boot(cpu);
  35. if (ret < 0)
  36. return ret;
  37. return spm_mtcmos_ctrl_cpu(cpu, STA_POWER_ON, 1);
  38. }
  39. #ifdef CONFIG_HOTPLUG_CPU
  40. static int mt_psci_cpu_disable(unsigned int cpu)
  41. {
  42. return cpu_psci_ops.cpu_disable(cpu);
  43. }
  44. static void mt_psci_cpu_die(unsigned int cpu)
  45. {
  46. cpu_psci_ops.cpu_die(cpu);
  47. }
  48. static int mt_psci_cpu_kill(unsigned int cpu)
  49. {
  50. int ret;
  51. ret = cpu_psci_ops.cpu_kill(cpu);
  52. if (!ret)
  53. pr_warn("CPU%d may not have shut down cleanly\n", cpu);
  54. return !spm_mtcmos_ctrl_cpu(cpu, STA_POWER_DOWN, 1);
  55. }
  56. #endif
  57. #ifdef CONFIG_CPU_IDLE
  58. static int mt_psci_cpu_init_idle(struct device_node *cpu_node,
  59. unsigned int cpu)
  60. {
  61. return cpu_psci_ops.cpu_init_idle(cpu_node, cpu);
  62. }
  63. static int mt_psci_cpu_suspend(unsigned long index)
  64. {
  65. return cpu_psci_ops.cpu_suspend(index);
  66. }
  67. #endif
  68. const struct cpu_operations mt_cpu_psci_ops = {
  69. .name = "mt-boot",
  70. #ifdef CONFIG_CPU_IDLE
  71. .cpu_init_idle = mt_psci_cpu_init_idle,
  72. .cpu_suspend = mt_psci_cpu_suspend,
  73. #endif
  74. .cpu_init = mt_psci_cpu_init,
  75. .cpu_prepare = mt_psci_cpu_prepare,
  76. .cpu_boot = mt_psci_cpu_boot,
  77. #ifdef CONFIG_HOTPLUG_CPU
  78. .cpu_disable = mt_psci_cpu_disable,
  79. .cpu_die = mt_psci_cpu_die,
  80. .cpu_kill = mt_psci_cpu_kill,
  81. #endif
  82. };
  83. #endif