blob: e9be1855b032fef6d0f72a81bcbd68de0646aae7 [file] [log] [blame]
Lee Leahy14ecb542015-02-09 21:16:14 -08001/*
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 Leahy14ecb542015-02-09 21:16:14 -080016 */
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 Petrov64011882016-07-15 13:31:09 -070028#ifdef __ROMCC__
29#define WEAK
30#else
31#define WEAK __attribute__((weak))
32#endif
33
34void WEAK reset_prepare(void) { /* do nothing */ }
35
Lee Leahyaac31ca2016-07-30 10:29:37 -070036#if IS_ENABLED(CONFIG_HAVE_HARD_RESET)
Lee Leahy14ecb542015-02-09 21:16:14 -080037void hard_reset(void)
38{
Andrey Petrov64011882016-07-15 13:31:09 -070039 reset_prepare();
Lee Leahy14ecb542015-02-09 21:16:14 -080040 /* S0->S5->S0 trip. */
41 outb(RST_CPU | SYS_RST | FULL_RST, RST_CNT);
42 while (1)
43 hlt();
44}
Lee Leahyaac31ca2016-07-30 10:29:37 -070045#endif
Lee Leahy14ecb542015-02-09 21:16:14 -080046
47void soft_reset(void)
48{
Andrey Petrov64011882016-07-15 13:31:09 -070049 reset_prepare();
Lee Leahy14ecb542015-02-09 21:16:14 -080050 /* PMC_PLTRST# asserted. */
51 outb(RST_CPU | SYS_RST, RST_CNT);
52 while (1)
53 hlt();
54}
55
56void cpu_reset(void)
57{
Andrey Petrov64011882016-07-15 13:31:09 -070058 reset_prepare();
Lee Leahy14ecb542015-02-09 21:16:14 -080059 /* Sends INIT# to CPU */
60 outb(RST_CPU, RST_CNT);
61 while (1)
62 hlt();
63}