blob: af29a11142a67d817292a7bb10cb3d337f8acbab [file] [log] [blame]
Caesar Wangb4003742016-10-12 08:10:12 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Caesar Wangb4003742016-10-12 08:10:12 +08005 */
6
Xing Zhengb4bcc1d2017-02-24 16:26:11 +08007#include <pmu_regs.h>
Xing Zheng93280b72016-10-26 21:25:26 +08008#include "rk3399_mcu.h"
Caesar Wangb4003742016-10-12 08:10:12 +08009
Xing Zheng93280b72016-10-26 21:25:26 +080010#define M0_SCR 0xe000ed10 /* System Control Register (SCR) */
11
12#define SCR_SLEEPDEEP_SHIFT (1 << 2)
13
14void handle_suspend(void)
15{
16 unsigned int status_value;
17
18 while (1) {
19 status_value = mmio_read_32(PMU_BASE + PMU_POWER_ST);
20 if (status_value) {
21 mmio_clrbits_32(PMU_BASE + PMU_PWRMODE_CON, 0x01);
22 return;
23 }
Caesar Wangb4003742016-10-12 08:10:12 +080024 }
25
Xing Zheng93280b72016-10-26 21:25:26 +080026 /* m0 enter deep sleep mode */
27 mmio_setbits_32(M0_SCR, SCR_SLEEPDEEP_SHIFT);
Caesar Wangb4003742016-10-12 08:10:12 +080028}