Linux 5.6.13
[linux/fpc-iii.git] / arch / arm / mach-mvebu / kirkwood-pm.c
blob7c65ea2a87c097fe067b6724a63e206945f64764
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Power Management driver for Marvell Kirkwood SoCs
5 * Copyright (C) 2013 Ezequiel Garcia <ezequiel@free-electrons.com>
6 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
7 */
9 #include <linux/kernel.h>
10 #include <linux/suspend.h>
11 #include <linux/io.h>
12 #include "kirkwood.h"
13 #include "kirkwood-pm.h"
15 static void __iomem *ddr_operation_base;
16 static void __iomem *memory_pm_ctrl;
18 static void kirkwood_low_power(void)
20 u32 mem_pm_ctrl;
22 mem_pm_ctrl = readl(memory_pm_ctrl);
24 /* Set peripherals to low-power mode */
25 writel_relaxed(~0, memory_pm_ctrl);
27 /* Set DDR in self-refresh */
28 writel_relaxed(0x7, ddr_operation_base);
31 * Set CPU in wait-for-interrupt state.
32 * This disables the CPU core clocks,
33 * the array clocks, and also the L2 controller.
35 cpu_do_idle();
37 writel_relaxed(mem_pm_ctrl, memory_pm_ctrl);
40 static int kirkwood_suspend_enter(suspend_state_t state)
42 switch (state) {
43 case PM_SUSPEND_STANDBY:
44 kirkwood_low_power();
45 break;
46 default:
47 return -EINVAL;
49 return 0;
52 static int kirkwood_pm_valid_standby(suspend_state_t state)
54 return state == PM_SUSPEND_STANDBY;
57 static const struct platform_suspend_ops kirkwood_suspend_ops = {
58 .enter = kirkwood_suspend_enter,
59 .valid = kirkwood_pm_valid_standby,
62 void __init kirkwood_pm_init(void)
64 ddr_operation_base = ioremap(DDR_OPERATION_BASE, 4);
65 memory_pm_ctrl = ioremap(MEMORY_PM_CTRL_PHYS, 4);
67 suspend_set_ops(&kirkwood_suspend_ops);