pm.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2011 Calxeda, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/cpu_pm.h>
  17. #include <linux/init.h>
  18. #include <linux/psci.h>
  19. #include <linux/suspend.h>
  20. #include <asm/suspend.h>
  21. #include <uapi/linux/psci.h>
  22. #define HIGHBANK_SUSPEND_PARAM \
  23. ((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \
  24. (1 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \
  25. (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT))
  26. static int highbank_suspend_finish(unsigned long val)
  27. {
  28. return psci_ops.cpu_suspend(HIGHBANK_SUSPEND_PARAM, __pa(cpu_resume));
  29. }
  30. static int highbank_pm_enter(suspend_state_t state)
  31. {
  32. cpu_pm_enter();
  33. cpu_cluster_pm_enter();
  34. cpu_suspend(0, highbank_suspend_finish);
  35. cpu_cluster_pm_exit();
  36. cpu_pm_exit();
  37. return 0;
  38. }
  39. static const struct platform_suspend_ops highbank_pm_ops = {
  40. .enter = highbank_pm_enter,
  41. .valid = suspend_valid_only_mem,
  42. };
  43. void __init highbank_pm_init(void)
  44. {
  45. if (!psci_ops.cpu_suspend)
  46. return;
  47. suspend_set_ops(&highbank_pm_ops);
  48. }