Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * Copyright (C) 2014 Google Inc. |
| 6 | * Copyright (C) 2015 Intel Corporation. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <arch/hlt.h> |
| 19 | #include <arch/io.h> |
| 20 | #include <reset.h> |
| 21 | |
| 22 | /* Reset control port */ |
| 23 | #define RST_CNT 0xcf9 |
| 24 | #define FULL_RST (1 << 3) |
| 25 | #define RST_CPU (1 << 2) |
| 26 | #define SYS_RST (1 << 1) |
| 27 | |
Andrey Petrov | 6401188 | 2016-07-15 13:31:09 -0700 | [diff] [blame] | 28 | #ifdef __ROMCC__ |
| 29 | #define WEAK |
| 30 | #else |
| 31 | #define WEAK __attribute__((weak)) |
| 32 | #endif |
| 33 | |
| 34 | void WEAK reset_prepare(void) { /* do nothing */ } |
| 35 | |
Lee Leahy | aac31ca | 2016-07-30 10:29:37 -0700 | [diff] [blame] | 36 | #if IS_ENABLED(CONFIG_HAVE_HARD_RESET) |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 37 | void hard_reset(void) |
| 38 | { |
Andrey Petrov | 6401188 | 2016-07-15 13:31:09 -0700 | [diff] [blame] | 39 | reset_prepare(); |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 40 | /* S0->S5->S0 trip. */ |
| 41 | outb(RST_CPU | SYS_RST | FULL_RST, RST_CNT); |
| 42 | while (1) |
| 43 | hlt(); |
| 44 | } |
Lee Leahy | aac31ca | 2016-07-30 10:29:37 -0700 | [diff] [blame] | 45 | #endif |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 46 | |
| 47 | void soft_reset(void) |
| 48 | { |
Andrey Petrov | 6401188 | 2016-07-15 13:31:09 -0700 | [diff] [blame] | 49 | reset_prepare(); |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 50 | /* PMC_PLTRST# asserted. */ |
| 51 | outb(RST_CPU | SYS_RST, RST_CNT); |
| 52 | while (1) |
| 53 | hlt(); |
| 54 | } |
| 55 | |
| 56 | void cpu_reset(void) |
| 57 | { |
Andrey Petrov | 6401188 | 2016-07-15 13:31:09 -0700 | [diff] [blame] | 58 | reset_prepare(); |
Lee Leahy | 14ecb54 | 2015-02-09 21:16:14 -0800 | [diff] [blame] | 59 | /* Sends INIT# to CPU */ |
| 60 | outb(RST_CPU, RST_CNT); |
| 61 | while (1) |
| 62 | hlt(); |
| 63 | } |