blob: a168355f14475c3433943e90820d600132a8ab9e [file] [log] [blame]
Gabe Black607c0b62013-05-16 05:45:57 -07001/*
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 Black607c0b62013-05-16 05:45:57 -070014 */
15
16/* Power setup code for EXYNOS5 */
17
Gabe Black607c0b62013-05-16 05:45:57 -070018#include <arch/io.h>
Julius Wernerfa938c72013-08-29 14:17:36 -070019#include <console/console.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010020#include <halt.h>
Julius Werner80af4422014-10-20 13:18:56 -070021#include <soc/dmc.h>
22#include <soc/power.h>
23#include <soc/setup.h>
Gabe Black607c0b62013-05-16 05:45:57 -070024
Edward O'Callaghan5b63dc12014-12-23 23:31:30 +110025/* Set the PS-Hold drive value */
26static void ps_hold_setup(void)
Gabe Black607c0b62013-05-16 05:45:57 -070027{
Gabe Black607c0b62013-05-16 05:45:57 -070028 /* Set PS-Hold high */
Julius Wernerfa938c72013-08-29 14:17:36 -070029 setbits_le32(&exynos_power->ps_hold_ctrl,
30 POWER_PS_HOLD_CONTROL_DATA_HIGH);
Gabe Black607c0b62013-05-16 05:45:57 -070031}
32
33void power_reset(void)
34{
Gabe Black607c0b62013-05-16 05:45:57 -070035 /* Clear inform1 so there's no change we think we've got a wake reset */
Julius Wernerfa938c72013-08-29 14:17:36 -070036 exynos_power->inform1 = 0;
Gabe Black607c0b62013-05-16 05:45:57 -070037
Julius Wernerfa938c72013-08-29 14:17:36 -070038 setbits_le32(&exynos_power->sw_reset, 1);
Gabe Black607c0b62013-05-16 05:45:57 -070039}
40
41/* This function never returns */
42void power_shutdown(void)
43{
Julius Wernerfa938c72013-08-29 14:17:36 -070044 clrbits_le32(&exynos_power->ps_hold_ctrl,
45 POWER_PS_HOLD_CONTROL_DATA_HIGH);
Gabe Black607c0b62013-05-16 05:45:57 -070046
Patrick Georgi546953c2014-11-29 10:38:17 +010047 halt();
Gabe Black607c0b62013-05-16 05:45:57 -070048}
49
50void power_enable_dp_phy(void)
51{
Julius Wernerfa938c72013-08-29 14:17:36 -070052 setbits_le32(&exynos_power->dptx_phy_control, EXYNOS_DP_PHY_ENABLE);
Gabe Black607c0b62013-05-16 05:45:57 -070053}
54
Gabe Black607c0b62013-05-16 05:45:57 -070055void power_enable_hw_thermal_trip(void)
56{
Gabe Black607c0b62013-05-16 05:45:57 -070057 /* Enable HW thermal trip */
Julius Wernerfa938c72013-08-29 14:17:36 -070058 setbits_le32(&exynos_power->ps_hold_ctrl, POWER_ENABLE_HW_TRIP);
Gabe Black607c0b62013-05-16 05:45:57 -070059}
60
61uint32_t power_read_reset_status(void)
62{
Julius Wernerfa938c72013-08-29 14:17:36 -070063 return exynos_power->inform1;
Gabe Black607c0b62013-05-16 05:45:57 -070064}
65
66void power_exit_wakeup(void)
67{
Gabe Black607c0b62013-05-16 05:45:57 -070068 typedef void (*resume_func)(void);
69
Julius Wernerfa938c72013-08-29 14:17:36 -070070 ((resume_func)exynos_power->inform0)();
Gabe Black607c0b62013-05-16 05:45:57 -070071}
72
73int power_init(void)
74{
75 ps_hold_setup();
76 return 0;
77}
78
79void power_enable_xclkout(void)
80{
Gabe Black607c0b62013-05-16 05:45:57 -070081 /* use xxti for xclk out */
Julius Wernerfa938c72013-08-29 14:17:36 -070082 clrsetbits_le32(&exynos_power->pmu_debug, PMU_DEBUG_CLKOUT_SEL_MASK,
83 PMU_DEBUG_XXTI);
Gabe Black607c0b62013-05-16 05:45:57 -070084}
Hung-Te Lin12b121f2013-09-24 15:51:05 +080085
86void power_release_uart_retention(void)
87{
Julius Werner2f37bd62015-02-19 14:51:15 -080088 write32(&exynos_power->padret_uart_opt, 1 << 28);
Hung-Te Lin12b121f2013-09-24 15:51:05 +080089}