[coreboot-gerrit] Change in coreboot[master]: arch/x86: Implement common CF9 reset

Nico Huber (Code Review) gerrit at coreboot.org
Fri Oct 12 00:06:35 CEST 2018


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/29054


Change subject: arch/x86: Implement common CF9 reset
......................................................................

arch/x86: Implement common CF9 reset

It's very common across many x86 silicon vendors, so place it in
`arch/x86/`.

Use the "system reset" as board_reset().

Change-Id: I06c27afa31e5eecfdb7093c02f703bdaabf0594c
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
M src/arch/x86/Kconfig
M src/arch/x86/Makefile.inc
A src/arch/x86/cf9_reset.c
A src/arch/x86/include/cf9_reset.h
4 files changed, 109 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/29054/1

diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig
index 46e0c2d..ff26a15 100644
--- a/src/arch/x86/Kconfig
+++ b/src/arch/x86/Kconfig
@@ -315,3 +315,10 @@
 	bool
 	default n
 	depends on ARCH_X86
+
+config HAVE_CF9_RESET
+	bool
+
+config HAVE_CF9_RESET_PREPARE
+	bool
+	depends on HAVE_CF9_RESET
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 7f85b6a..730bc83 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -43,6 +43,12 @@
 pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
 pci$(stripped_vgabios_id).rom-type := optionrom
 
+verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
+bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
+romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
+ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
+postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
+
 ###############################################################################
 # common support for early assembly includes
 ###############################################################################
diff --git a/src/arch/x86/cf9_reset.c b/src/arch/x86/cf9_reset.c
new file mode 100644
index 0000000..6f903c9
--- /dev/null
+++ b/src/arch/x86/cf9_reset.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2017 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/io.h>
+#include <arch/cache.h>
+#include <cf9_reset.h>
+#include <console/console.h>
+#include <halt.h>
+#include <reset.h>
+
+void do_system_reset(void)
+{
+	outb(SYS_RST, RST_CNT);
+	outb(RST_CPU | SYS_RST, RST_CNT);
+}
+
+void do_full_reset(void)
+{
+	outb(FULL_RST | SYS_RST, RST_CNT);
+	outb(FULL_RST | RST_CPU | SYS_RST, RST_CNT);
+}
+
+void system_reset(void)
+{
+	printk(BIOS_INFO, "%s() called!\n", __func__);
+	cf9_reset_prepare();
+	dcache_clean_all();
+	do_system_reset();
+	halt();
+}
+
+void full_reset(void)
+{
+	printk(BIOS_INFO, "%s() called!\n", __func__);
+	cf9_reset_prepare();
+	dcache_clean_all();
+	do_full_reset();
+	halt();
+}
+
+void do_board_reset(void)
+{
+	system_reset();
+}
diff --git a/src/arch/x86/include/cf9_reset.h b/src/arch/x86/include/cf9_reset.h
new file mode 100644
index 0000000..c0dcc92
--- /dev/null
+++ b/src/arch/x86/include/cf9_reset.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Intel Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef X86_CF9_RESET_H
+#define X86_CF9_RESET_H
+
+/* Reset control port */
+#define RST_CNT			0xcf9
+#define FULL_RST		(1 << 3)
+#define RST_CPU			(1 << 2)
+#define SYS_RST			(1 << 1)
+
+/* Implement the bare reset, i.e. write to cf9. */
+void do_system_reset(void);
+void do_full_reset(void);
+
+/* Called by functions below before reset. */
+#if IS_ENABLED(CONFIG_HAVE_CF9_RESET_PREPARE)
+void cf9_reset_prepare(void);
+#else
+static inline void cf9_reset_prepare(void) {}
+#endif
+
+/* Prepare for reset, run do_*_reset(), halt. */
+__noreturn void system_reset(void);
+__noreturn void full_reset(void);
+
+#endif	/* X86_CF9_RESET_H */

-- 
To view, visit https://review.coreboot.org/29054
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06c27afa31e5eecfdb7093c02f703bdaabf0594c
Gerrit-Change-Number: 29054
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181011/2547b3d1/attachment-0001.html>


More information about the coreboot-gerrit mailing list