sysreset_x86.c 895 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  4. *
  5. * Generic reset driver for x86 processor
  6. */
  7. #include <common.h>
  8. #include <dm.h>
  9. #include <sysreset.h>
  10. #include <asm/io.h>
  11. #include <asm/processor.h>
  12. static int x86_sysreset_request(struct udevice *dev, enum sysreset_t type)
  13. {
  14. int value;
  15. switch (type) {
  16. case SYSRESET_WARM:
  17. value = SYS_RST | RST_CPU;
  18. break;
  19. case SYSRESET_COLD:
  20. value = SYS_RST | RST_CPU | FULL_RST;
  21. break;
  22. default:
  23. return -ENOSYS;
  24. }
  25. outb(value, IO_PORT_RESET);
  26. return -EINPROGRESS;
  27. }
  28. static const struct udevice_id x86_sysreset_ids[] = {
  29. { .compatible = "x86,reset" },
  30. { }
  31. };
  32. static struct sysreset_ops x86_sysreset_ops = {
  33. .request = x86_sysreset_request,
  34. };
  35. U_BOOT_DRIVER(x86_sysreset) = {
  36. .name = "x86-sysreset",
  37. .id = UCLASS_SYSRESET,
  38. .of_match = x86_sysreset_ids,
  39. .ops = &x86_sysreset_ops,
  40. };