Angel Pons | 1ddb894 | 2020-04-04 18:51:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 2 | |
Stefan Reinauer | 08dc357 | 2013-05-14 16:57:50 -0700 | [diff] [blame] | 3 | /* Power setup code for EXYNOS5 */ |
4 | |||||
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 5 | #include <device/mmio.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 6 | #include <halt.h> |
Stefan Reinauer | 747d0f8 | 2015-12-14 17:09:49 -0800 | [diff] [blame] | 7 | #include <reset.h> |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 8 | #include <soc/dmc.h> |
9 | #include <soc/power.h> | ||||
10 | #include <soc/setup.h> | ||||
David Hendricks | 27094b0 | 2013-01-09 17:42:02 -0800 | [diff] [blame] | 11 | |
Edward O'Callaghan | 5b63dc1 | 2014-12-23 23:31:30 +1100 | [diff] [blame] | 12 | /* Set the PS-Hold drive value */ |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 13 | static void ps_hold_setup(void) |
14 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 15 | /* Set PS-Hold high */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 16 | setbits32(&exynos_power->ps_hold_ctrl, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 17 | POWER_PS_HOLD_CONTROL_DATA_HIGH); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 18 | } |
19 | |||||
20 | void power_reset(void) | ||||
21 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 22 | /* Clear inform1 so there's no change we think we've got a wake reset */ |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 23 | exynos_power->inform1 = 0; |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 24 | |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 25 | setbits32(&exynos_power->sw_reset, 1); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 26 | } |
27 | |||||
Nico Huber | 8ba7023 | 2018-10-06 19:16:40 +0200 | [diff] [blame] | 28 | void do_board_reset(void) |
Stefan Reinauer | 747d0f8 | 2015-12-14 17:09:49 -0800 | [diff] [blame] | 29 | { |
30 | power_reset(); | ||||
31 | } | ||||
32 | |||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 33 | /* This function never returns */ |
34 | void power_shutdown(void) | ||||
35 | { | ||||
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 36 | clrbits32(&exynos_power->ps_hold_ctrl, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 37 | POWER_PS_HOLD_CONTROL_DATA_HIGH); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 38 | |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 39 | halt(); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 40 | } |
41 | |||||
42 | void power_enable_dp_phy(void) | ||||
43 | { | ||||
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 44 | setbits32(&exynos_power->dptx_phy_control, EXYNOS_DP_PHY_ENABLE); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 45 | } |
46 | |||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 47 | void power_enable_hw_thermal_trip(void) |
48 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 49 | /* Enable HW thermal trip */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 50 | setbits32(&exynos_power->ps_hold_ctrl, POWER_ENABLE_HW_TRIP); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 51 | } |
52 | |||||
53 | uint32_t power_read_reset_status(void) | ||||
54 | { | ||||
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 55 | return exynos_power->inform1; |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 56 | } |
57 | |||||
58 | void power_exit_wakeup(void) | ||||
59 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 60 | typedef void (*resume_func)(void); |
61 | |||||
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 62 | ((resume_func)exynos_power->inform0)(); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 63 | } |
64 | |||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 65 | int power_init(void) |
66 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 67 | ps_hold_setup(); |
David Hendricks | db9eaf4 | 2013-04-05 15:38:12 -0700 | [diff] [blame] | 68 | return 0; |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 69 | } |
70 | |||||
71 | void power_enable_xclkout(void) | ||||
72 | { | ||||
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 73 | /* use xxti for xclk out */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 74 | clrsetbits32(&exynos_power->pmu_debug, PMU_DEBUG_CLKOUT_SEL_MASK, |
Edward O'Callaghan | f679cfe | 2014-12-23 23:48:01 +1100 | [diff] [blame] | 75 | PMU_DEBUG_XXTI); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 76 | } |
Hung-Te Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 77 | |
78 | void power_release_uart_retention(void) | ||||
79 | { | ||||
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 80 | write32(&exynos_power->padret_uart_opt, 1 << 28); |
Hung-Te Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 81 | } |