Angel Pons | 1ddb894 | 2020-04-04 18:51:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 2 | |
Gabe Black | ee4bfbf | 2013-08-13 21:05:43 -0700 | [diff] [blame] | 3 | #include <arch/cache.h> |
Julius Werner | 80af442 | 2014-10-20 13:18:56 -0700 | [diff] [blame] | 4 | #include <soc/power.h> |
| 5 | #include <soc/wakeup.h> |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 6 | |
| 7 | void wakeup(void) |
| 8 | { |
| 9 | if (wakeup_need_reset()) |
| 10 | power_reset(); |
| 11 | |
| 12 | power_init(); /* Ensure ps_hold_setup() for early wakeup. */ |
Gabe Black | ee4bfbf | 2013-08-13 21:05:43 -0700 | [diff] [blame] | 13 | dcache_mmu_disable(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 14 | power_exit_wakeup(); |
Stefan Reinauer | 9125d88 | 2013-09-10 10:58:28 -0700 | [diff] [blame] | 15 | /* Should never return. If we do, reset. */ |
| 16 | power_reset(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | int get_wakeup_state(void) |
| 20 | { |
| 21 | uint32_t status = power_read_reset_status(); |
| 22 | |
| 23 | /* DIDLE/LPA can be resumed without clock reset (ex, bootblock), |
| 24 | * and SLEEP requires resetting clock (should be done in ROM stage). |
| 25 | */ |
| 26 | |
| 27 | if (status == S5P_CHECK_DIDLE || status == S5P_CHECK_LPA) |
| 28 | return WAKEUP_DIRECT; |
| 29 | |
| 30 | if (status == S5P_CHECK_SLEEP) |
| 31 | return WAKEUP_NEED_CLOCK_RESET; |
| 32 | |
| 33 | return IS_NOT_WAKEUP; |
| 34 | } |
Hung-Te Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 35 | |
| 36 | void wakeup_enable_uart(void) |
| 37 | { |
| 38 | power_release_uart_retention(); |
| 39 | } |