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 | |
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> |
Julius Werner | 80af442 | 2014-10-20 13:18:56 -0700 | [diff] [blame] | 7 | #include <soc/dmc.h> |
8 | #include <soc/power.h> | ||||
9 | #include <soc/setup.h> | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 10 | |
Edward O'Callaghan | 5b63dc1 | 2014-12-23 23:31:30 +1100 | [diff] [blame] | 11 | /* Set the PS-Hold drive value */ |
12 | static void ps_hold_setup(void) | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 13 | { |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 14 | /* Set PS-Hold high */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 15 | setbits32(&exynos_power->ps_hold_ctrl, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 16 | POWER_PS_HOLD_CONTROL_DATA_HIGH); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 17 | } |
18 | |||||
19 | void power_reset(void) | ||||
20 | { | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 21 | /* 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] | 22 | exynos_power->inform1 = 0; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 23 | |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 24 | setbits32(&exynos_power->sw_reset, 1); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 25 | } |
26 | |||||
27 | /* This function never returns */ | ||||
28 | void power_shutdown(void) | ||||
29 | { | ||||
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 30 | clrbits32(&exynos_power->ps_hold_ctrl, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 31 | POWER_PS_HOLD_CONTROL_DATA_HIGH); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 32 | |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 33 | halt(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 34 | } |
35 | |||||
36 | void power_enable_dp_phy(void) | ||||
37 | { | ||||
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 38 | setbits32(&exynos_power->dptx_phy_control, EXYNOS_DP_PHY_ENABLE); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 39 | } |
40 | |||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 41 | void power_enable_hw_thermal_trip(void) |
42 | { | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 43 | /* Enable HW thermal trip */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 44 | setbits32(&exynos_power->ps_hold_ctrl, POWER_ENABLE_HW_TRIP); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 45 | } |
46 | |||||
47 | uint32_t power_read_reset_status(void) | ||||
48 | { | ||||
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 49 | return exynos_power->inform1; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 50 | } |
51 | |||||
52 | void power_exit_wakeup(void) | ||||
53 | { | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 54 | typedef void (*resume_func)(void); |
55 | |||||
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 56 | ((resume_func)exynos_power->inform0)(); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 57 | } |
58 | |||||
59 | int power_init(void) | ||||
60 | { | ||||
61 | ps_hold_setup(); | ||||
62 | return 0; | ||||
63 | } | ||||
64 | |||||
65 | void power_enable_xclkout(void) | ||||
66 | { | ||||
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 67 | /* use xxti for xclk out */ |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 68 | clrsetbits32(&exynos_power->pmu_debug, PMU_DEBUG_CLKOUT_SEL_MASK, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 69 | PMU_DEBUG_XXTI); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 70 | } |
Hung-Te Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 71 | |
72 | void power_release_uart_retention(void) | ||||
73 | { | ||||
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 74 | write32(&exynos_power->padret_uart_opt, 1 << 28); |
Hung-Te Lin | 12b121f | 2013-09-24 15:51:05 +0800 | [diff] [blame] | 75 | } |