Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 08dc357 | 2013-05-14 16:57:50 -0700 | [diff] [blame] | 4 | * Copyright 2013 Google Inc. |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 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. |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 17 | #include <soc/power.h> |
| 18 | #include <soc/wakeup.h> |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 19 | |
| 20 | void 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 Reinauer | 9125d88 | 2013-09-10 10:58:28 -0700 | [diff] [blame] | 27 | /* Should never return. If we do, reset. */ |
| 28 | power_reset(); |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | int 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 Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 47 | |
| 48 | void wakeup_enable_uart(void) |
| 49 | { |
| 50 | power_release_uart_retention(); |
| 51 | } |