Merge tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6.git] / arch / arm / mach-kirkwood / pm.c
blob8783a7184e733ffcc3cfea0b4fd0d286dc898875
1 /*
2 * Power Management driver for Marvell Kirkwood SoCs
4 * Copyright (C) 2013 Ezequiel Garcia <ezequiel@free-electrons.com>
5 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License,
9 * version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <linux/kernel.h>
18 #include <linux/suspend.h>
19 #include <linux/io.h>
20 #include <mach/bridge-regs.h>
22 static void __iomem *ddr_operation_base;
24 static void kirkwood_low_power(void)
26 u32 mem_pm_ctrl;
28 mem_pm_ctrl = readl(MEMORY_PM_CTRL);
30 /* Set peripherals to low-power mode */
31 writel_relaxed(~0, MEMORY_PM_CTRL);
33 /* Set DDR in self-refresh */
34 writel_relaxed(0x7, ddr_operation_base);
37 * Set CPU in wait-for-interrupt state.
38 * This disables the CPU core clocks,
39 * the array clocks, and also the L2 controller.
41 cpu_do_idle();
43 writel_relaxed(mem_pm_ctrl, MEMORY_PM_CTRL);
46 static int kirkwood_suspend_enter(suspend_state_t state)
48 switch (state) {
49 case PM_SUSPEND_STANDBY:
50 kirkwood_low_power();
51 break;
52 default:
53 return -EINVAL;
55 return 0;
58 static int kirkwood_pm_valid_standby(suspend_state_t state)
60 return state == PM_SUSPEND_STANDBY;
63 static const struct platform_suspend_ops kirkwood_suspend_ops = {
64 .enter = kirkwood_suspend_enter,
65 .valid = kirkwood_pm_valid_standby,
68 int __init kirkwood_pm_init(void)
70 ddr_operation_base = ioremap(DDR_OPERATION_BASE, 4);
71 suspend_set_ops(&kirkwood_suspend_ops);
72 return 0;