summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/suspend_ops.c
blob: 0b1e64b7bffe14abbe53e04773d2617da0b9c96a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * arch/arm/mach-tegra/suspend_ops.c
 *
 * Suspend Operation API implementation
 *
 * Copyright (c) 2010, NVIDIA Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <linux/suspend.h>
#include "nvcommon.h"
#include "nvodm_query.h"
#include <linux/wakelock.h>
#include <linux/cpu.h>

extern void cpu_ap20_do_lp0(void);
extern void cpu_ap20_do_lp1(void);

int tegra_state_valid(suspend_state_t state)
{
	if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX)
		return 1;
	return 0;
}

int tegra_state_enter(suspend_state_t state)
{
	const NvOdmSocPowerStateInfo *LPStateInfo;

	LPStateInfo = NvOdmQueryLowestSocPowerState();
	if (LPStateInfo->LowestPowerState == NvOdmSocPowerState_DeepSleep) {
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
		/* do AP20 LP0 */
		cpu_ap20_do_lp0();
#endif
	}
	else if (LPStateInfo->LowestPowerState == NvOdmSocPowerState_Suspend) {
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
		/* do AP20 LP1 */
		cpu_ap20_do_lp1();
#endif
	}
	return 0;
}

static struct platform_suspend_ops tegra_suspend_ops =
{
	.valid   = tegra_state_valid,
	.enter   = tegra_state_enter,
};

void tegra_set_suspend_ops(void)
{
	suspend_set_ops(&tegra_suspend_ops);
}