blob: 561941baeda961c6e6f96bdb6e2c81e8ed69ec3b [file] [log] [blame]
Thomas Gleixner9952f692019-05-28 10:10:04 -07001// SPDX-License-Identifier: GPL-2.0-only
Rob Herring8b61f372011-05-15 12:44:17 -05002/*
3 * Copyright 2011 Calxeda, Inc.
Rob Herring8b61f372011-05-15 12:44:17 -05004 */
5
Rob Herring1ddda1c2012-12-30 10:15:07 -06006#include <linux/cpu_pm.h>
Rob Herring8b61f372011-05-15 12:44:17 -05007#include <linux/init.h>
Mark Rutlandbe120392015-07-31 15:46:19 +01008#include <linux/psci.h>
Rob Herring8b61f372011-05-15 12:44:17 -05009#include <linux/suspend.h>
10
Rob Herring8b61f372011-05-15 12:44:17 -050011#include <asm/suspend.h>
Mark Rutlandbe120392015-07-31 15:46:19 +010012
13#include <uapi/linux/psci.h>
14
15#define HIGHBANK_SUSPEND_PARAM \
16 ((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \
17 (1 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \
18 (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT))
Rob Herring8b61f372011-05-15 12:44:17 -050019
20static int highbank_suspend_finish(unsigned long val)
21{
Mark Rutlandbe120392015-07-31 15:46:19 +010022 return psci_ops.cpu_suspend(HIGHBANK_SUSPEND_PARAM, __pa(cpu_resume));
Rob Herring8b61f372011-05-15 12:44:17 -050023}
24
25static int highbank_pm_enter(suspend_state_t state)
26{
Rob Herring1ddda1c2012-12-30 10:15:07 -060027 cpu_pm_enter();
28 cpu_cluster_pm_enter();
29
Rob Herring8b61f372011-05-15 12:44:17 -050030 cpu_suspend(0, highbank_suspend_finish);
31
Rob Herring1ddda1c2012-12-30 10:15:07 -060032 cpu_cluster_pm_exit();
33 cpu_pm_exit();
34
Rob Herring8b61f372011-05-15 12:44:17 -050035 return 0;
36}
37
38static const struct platform_suspend_ops highbank_pm_ops = {
39 .enter = highbank_pm_enter,
40 .valid = suspend_valid_only_mem,
41};
42
Rob Herringa283580c2012-09-17 09:55:12 -050043void __init highbank_pm_init(void)
Rob Herring8b61f372011-05-15 12:44:17 -050044{
Rob Herringdd68eb02013-09-26 20:02:51 -050045 if (!psci_ops.cpu_suspend)
46 return;
47
Rob Herring8b61f372011-05-15 12:44:17 -050048 suspend_set_ops(&highbank_pm_ops);
Rob Herring8b61f372011-05-15 12:44:17 -050049}