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