blob: a5c42b72c9a85616569a9980c646bc4ce82bf12b [file] [log] [blame]
Kerry Sheha3f06072012-02-07 20:32:38 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 - 2012 Advanced Micro Devices, Inc.
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.
Kerry Sheha3f06072012-02-07 20:32:38 +080014 */
15
Kyösti Mälkkief844012013-06-25 23:17:43 +030016// Use simple device model for this file even in ramstage
17#define __SIMPLE_DEVICE__
18
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070019#include <arch/io.h>
Kerry Sheha3f06072012-02-07 20:32:38 +080020#include <reset.h>
Kerry Sheha3f06072012-02-07 20:32:38 +080021
22#define HT_INIT_CONTROL 0x6C
23#define HTIC_BIOSR_Detect (1<<5)
24
Kyösti Mälkki29c3e362014-04-16 16:30:00 +030025#define NODE_PCI(x, fn) (((CONFIG_CDB+x)<32)?(PCI_DEV(CONFIG_CBB,(CONFIG_CDB+x),fn)):(PCI_DEV((CONFIG_CBB-1),(CONFIG_CDB+x-32),fn)))
Kerry Sheha3f06072012-02-07 20:32:38 +080026
27static inline void set_bios_reset(void)
28{
29 u32 nodes;
30 u32 htic;
Kyösti Mälkki3f9a62e2013-06-20 20:25:21 +030031 pci_devfn_t dev;
Kerry Sheha3f06072012-02-07 20:32:38 +080032 int i;
33
34 nodes = ((pci_read_config32(PCI_DEV(CONFIG_CBB, CONFIG_CDB, 0), 0x60) >> 4) & 7) + 1;
Elyes HAOUASba28e8d2016-08-31 19:22:16 +020035 for (i = 0; i < nodes; i++) {
Kerry Sheha3f06072012-02-07 20:32:38 +080036 dev = NODE_PCI(i, 0);
37 htic = pci_read_config32(dev, HT_INIT_CONTROL);
38 htic &= ~HTIC_BIOSR_Detect;
39 pci_write_config32(dev, HT_INIT_CONTROL, htic);
40 }
41}
42
43void hard_reset(void)
44{
45 set_bios_reset();
46 /* Try rebooting through port 0xcf9 */
47 /* Actually it is not a real hard_reset --- it only reset coherent link table, but not reset link freq and width */
48 outb((0 << 3) | (0 << 2) | (1 << 1), 0xcf9);
49 outb((0 << 3) | (1 << 2) | (1 << 1), 0xcf9);
50}
51
52//SbReset();
53void soft_reset(void)
54{
55 set_bios_reset();
56 /* link reset */
57 outb(0x06, 0x0cf9);
58}