blob: d6092050284980b1cd2b64332c529f3a10ef547c [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marc Jones24484842017-05-04 21:17:45 -06002
Marc Jones24484842017-05-04 21:17:45 -06003#include <arch/io.h>
Felix Held3fe1ad12020-12-09 15:47:59 +01004#include <cf9_reset.h>
Marc Jones24484842017-05-04 21:17:45 -06005#include <reset.h>
Martin Roth48e44ee2017-11-12 14:54:09 -07006#include <soc/northbridge.h>
7#include <soc/pci_devs.h>
Patrick Rudolphe56189c2018-04-18 10:11:59 +02008#include <device/pci_ops.h>
Marc Jonesdfeb1c42017-08-07 19:08:24 -06009#include <soc/southbridge.h>
Marshall Dawson69486ca2019-05-02 12:03:45 -060010#include <amdblocks/acpimmio.h>
Nico Huber73c11192018-10-06 18:20:47 +020011#include <amdblocks/reset.h>
Marc Jones24484842017-05-04 21:17:45 -060012
Marshall Dawson2e49cf122018-08-03 17:05:22 -060013void set_warm_reset_flag(void)
14{
15 u32 htic;
16 htic = pci_read_config32(SOC_HT_DEV, HT_INIT_CONTROL);
17 htic |= HTIC_COLD_RST_DET;
18 pci_write_config32(SOC_HT_DEV, HT_INIT_CONTROL, htic);
19}
20
21int is_warm_reset(void)
22{
23 u32 htic;
24 htic = pci_read_config32(SOC_HT_DEV, HT_INIT_CONTROL);
25 return !!(htic & HTIC_COLD_RST_DET);
26}
27
Martin Roth48e44ee2017-11-12 14:54:09 -070028/* Clear bits 5, 9 & 10, used to signal the reset type */
29static void clear_bios_reset(void)
Marc Jones24484842017-05-04 21:17:45 -060030{
31 u32 htic;
Martin Roth48e44ee2017-11-12 14:54:09 -070032 htic = pci_read_config32(SOC_HT_DEV, HT_INIT_CONTROL);
33 htic &= ~HTIC_BIOSR_DETECT;
34 pci_write_config32(SOC_HT_DEV, HT_INIT_CONTROL, htic);
Marc Jones24484842017-05-04 21:17:45 -060035}
36
Nico Huber73c11192018-10-06 18:20:47 +020037void do_cold_reset(void)
Marc Jones24484842017-05-04 21:17:45 -060038{
Martin Roth48e44ee2017-11-12 14:54:09 -070039 clear_bios_reset();
40
41 /* De-assert and then assert all PwrGood signals on CF9 reset. */
42 pm_write16(PWR_RESET_CFG, pm_read16(PWR_RESET_CFG) |
43 TOGGLE_ALL_PWR_GOOD);
Felix Held3fe1ad12020-12-09 15:47:59 +010044 outb(RST_CPU | SYS_RST, RST_CNT);
Martin Roth48e44ee2017-11-12 14:54:09 -070045}
46
Nico Huber73c11192018-10-06 18:20:47 +020047void do_warm_reset(void)
Martin Roth48e44ee2017-11-12 14:54:09 -070048{
Marshall Dawson2e49cf122018-08-03 17:05:22 -060049 set_warm_reset_flag();
Martin Roth48e44ee2017-11-12 14:54:09 -070050 clear_bios_reset();
51
52 /* Assert reset signals only. */
Felix Held3fe1ad12020-12-09 15:47:59 +010053 outb(RST_CPU | SYS_RST, RST_CNT);
Marc Jones24484842017-05-04 21:17:45 -060054}
Nico Huber73c11192018-10-06 18:20:47 +020055
56void do_board_reset(void)
57{
58 /* TODO: Would a warm_reset() suffice? */
59 do_cold_reset();
60}