Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 4 | * Copyright (C) 2010 - 2011 Advanced Micro Devices, Inc. |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 20 | // Use simple device model for this file even in ramstage |
| 21 | #define __SIMPLE_DEVICE__ |
| 22 | |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 23 | #include <arch/io.h> |
| 24 | #include <reset.h> |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 25 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 26 | #define HT_INIT_CONTROL 0x6C |
| 27 | #define HTIC_BIOSR_Detect (1<<5) |
| 28 | |
| 29 | #if CONFIG_MAX_PHYSICAL_CPUS > 32 |
| 30 | #define NODE_PCI(x, fn) ((x<32)?(PCI_DEV(CONFIG_CBB,(CONFIG_CDB+x),fn)):(PCI_DEV((CONFIG_CBB-1),(CONFIG_CDB+x-32),fn))) |
| 31 | #else |
| 32 | #define NODE_PCI(x, fn) PCI_DEV(CONFIG_CBB,(CONFIG_CDB+x),fn) |
| 33 | #endif |
| 34 | |
| 35 | static void set_bios_reset(void) |
| 36 | { |
| 37 | u32 nodes; |
| 38 | u32 htic; |
Kyösti Mälkki | 3f9a62e | 2013-06-20 20:25:21 +0300 | [diff] [blame] | 39 | pci_devfn_t dev; |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 40 | int i; |
| 41 | |
| 42 | nodes = ((pci_read_config32(PCI_DEV(CONFIG_CBB, CONFIG_CDB, 0), 0x60) >> 4) & 7) + 1; |
| 43 | for(i = 0; i < nodes; i++) { |
| 44 | dev = NODE_PCI(i, 0); |
| 45 | htic = pci_read_config32(dev, HT_INIT_CONTROL); |
| 46 | htic &= ~HTIC_BIOSR_Detect; |
| 47 | pci_write_config32(dev, HT_INIT_CONTROL, htic); |
| 48 | } |
| 49 | } |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 50 | |
| 51 | void hard_reset(void) |
| 52 | { |
| 53 | set_bios_reset(); |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 54 | |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 55 | /* Try rebooting through port 0xcf9 */ |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 56 | /* Actually it is not a real hard_reset |
| 57 | * --- it only reset coherent link table, but not reset link freq and width |
| 58 | */ |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 59 | outb((0 << 3) | (0 << 2) | (1 << 1), 0xcf9); |
| 60 | outb((0 << 3) | (1 << 2) | (1 << 1), 0xcf9); |
| 61 | } |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 62 | |
| 63 | void soft_reset(void) |
| 64 | { |
| 65 | set_bios_reset(); |
| 66 | /* link reset */ |
| 67 | outb(0x06, 0x0cf9); |
| 68 | } |