blob: dd0c7878f21d50fd37427f7c35a786b61eb20d14 [file] [log] [blame]
Gabe Black607c0b62013-05-16 05:45:57 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2013 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Gabe Black607c0b62013-05-16 05:45:57 -070014 */
15
Gabe Blackee4bfbf2013-08-13 21:05:43 -070016#include <arch/cache.h>
Gabe Black607c0b62013-05-16 05:45:57 -070017#include <console/console.h>
Julius Werner80af4422014-10-20 13:18:56 -070018#include <soc/power.h>
19#include <soc/wakeup.h>
Gabe Black607c0b62013-05-16 05:45:57 -070020
21void wakeup(void)
22{
23 if (wakeup_need_reset())
24 power_reset();
25
26 power_init(); /* Ensure ps_hold_setup() for early wakeup. */
Gabe Blackee4bfbf2013-08-13 21:05:43 -070027 dcache_mmu_disable();
Gabe Black607c0b62013-05-16 05:45:57 -070028 power_exit_wakeup();
Stefan Reinauer9125d882013-09-10 10:58:28 -070029 /* Should never return. If we do, reset. */
30 power_reset();
Gabe Black607c0b62013-05-16 05:45:57 -070031}
32
33int get_wakeup_state(void)
34{
35 uint32_t status = power_read_reset_status();
36
37 /* DIDLE/LPA can be resumed without clock reset (ex, bootblock),
38 * and SLEEP requires resetting clock (should be done in ROM stage).
39 */
40
41 if (status == S5P_CHECK_DIDLE || status == S5P_CHECK_LPA)
42 return WAKEUP_DIRECT;
43
44 if (status == S5P_CHECK_SLEEP)
45 return WAKEUP_NEED_CLOCK_RESET;
46
47 return IS_NOT_WAKEUP;
48}
Hung-Te Lin12b121f2013-09-24 15:51:05 +080049
50void wakeup_enable_uart(void)
51{
52 power_release_uart_retention();
53}