blob: f7580b9a166d1766e9d56b626eb66c31ea6696ea [file] [log] [blame]
Stefan Reinauer043eb0e2013-05-10 16:21:58 -07001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauer08dc3572013-05-14 16:57:50 -07004 * Copyright 2013 Google Inc.
Stefan Reinauer043eb0e2013-05-10 16:21:58 -07005 *
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.
Stefan Reinauer043eb0e2013-05-10 16:21:58 -070014 */
15
16#include <console/console.h>
Julius Werner1ed0c8c2014-10-20 13:16:29 -070017#include <soc/power.h>
18#include <soc/wakeup.h>
Stefan Reinauer043eb0e2013-05-10 16:21:58 -070019
20void wakeup(void)
21{
22 if (wakeup_need_reset())
23 power_reset();
24
25 power_init(); /* Ensure ps_hold_setup() for early wakeup. */
26 power_exit_wakeup();
Stefan Reinauer9125d882013-09-10 10:58:28 -070027 /* Should never return. If we do, reset. */
28 power_reset();
Stefan Reinauer043eb0e2013-05-10 16:21:58 -070029}
30
31int get_wakeup_state(void)
32{
33 uint32_t status = power_read_reset_status();
34
35 /* DIDLE/LPA can be resumed without clock reset (ex, bootblock),
36 * and SLEEP requires resetting clock (should be done in ROM stage).
37 */
38
39 if (status == S5P_CHECK_DIDLE || status == S5P_CHECK_LPA)
40 return WAKEUP_DIRECT;
41
42 if (status == S5P_CHECK_SLEEP)
43 return WAKEUP_NEED_CLOCK_RESET;
44
45 return IS_NOT_WAKEUP;
46}
Hung-Te Lin12b121f2013-09-24 15:51:05 +080047
48void wakeup_enable_uart(void)
49{
50 power_release_uart_retention();
51}