Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 1 | /* |
| 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 Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
Gabe Black | ee4bfbf | 2013-08-13 21:05:43 -0700 | [diff] [blame] | 16 | #include <arch/cache.h> |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 17 | #include <console/console.h> |
Julius Werner | 80af442 | 2014-10-20 13:18:56 -0700 | [diff] [blame] | 18 | #include <soc/power.h> |
| 19 | #include <soc/wakeup.h> |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 20 | |
| 21 | void wakeup(void) |
| 22 | { |
| 23 | if (wakeup_need_reset()) |
| 24 | power_reset(); |
| 25 | |
| 26 | power_init(); /* Ensure ps_hold_setup() for early wakeup. */ |
Gabe Black | ee4bfbf | 2013-08-13 21:05:43 -0700 | [diff] [blame] | 27 | dcache_mmu_disable(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 28 | power_exit_wakeup(); |
Stefan Reinauer | 9125d88 | 2013-09-10 10:58:28 -0700 | [diff] [blame] | 29 | /* Should never return. If we do, reset. */ |
| 30 | power_reset(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | int 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 Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 49 | |
| 50 | void wakeup_enable_uart(void) |
| 51 | { |
| 52 | power_release_uart_retention(); |
| 53 | } |