1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
5 * Generic reset driver for x86 processor
12 #include <asm/processor.h>
13 #include <efi_loader.h>
15 static int x86_sysreset_request(struct udevice *dev, enum sysreset_t type)
21 value = SYS_RST | RST_CPU;
24 value = SYS_RST | RST_CPU | FULL_RST;
30 outb(value, IO_PORT_RESET);
35 #ifdef CONFIG_EFI_LOADER
36 void __efi_runtime EFIAPI efi_reset_system(
37 enum efi_reset_type reset_type,
38 efi_status_t reset_status,
39 unsigned long data_size, void *reset_data)
44 * inline this code since we are not caused in the context of a
45 * udevice and passing NULL to x86_sysreset_request() is too horrible.
47 if (reset_type == EFI_RESET_COLD ||
48 reset_type == EFI_RESET_PLATFORM_SPECIFIC)
49 value = SYS_RST | RST_CPU | FULL_RST;
50 else /* assume EFI_RESET_WARM since we cannot return an error */
51 value = SYS_RST | RST_CPU;
52 outb(value, IO_PORT_RESET);
54 /* TODO EFI_RESET_SHUTDOWN */
61 static const struct udevice_id x86_sysreset_ids[] = {
62 { .compatible = "x86,reset" },
66 static struct sysreset_ops x86_sysreset_ops = {
67 .request = x86_sysreset_request,
70 U_BOOT_DRIVER(x86_sysreset) = {
71 .name = "x86-sysreset",
72 .id = UCLASS_SYSRESET,
73 .of_match = x86_sysreset_ids,
74 .ops = &x86_sysreset_ops,