sysreset_psci.c 710 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <sysreset.h>
  8. #include <linux/errno.h>
  9. #include <linux/psci.h>
  10. static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type)
  11. {
  12. switch (type) {
  13. case SYSRESET_WARM:
  14. case SYSRESET_COLD:
  15. psci_sys_reset(type);
  16. break;
  17. case SYSRESET_POWER_OFF:
  18. psci_sys_poweroff();
  19. break;
  20. default:
  21. return -ENOSYS;
  22. }
  23. return -EINPROGRESS;
  24. }
  25. static struct sysreset_ops psci_sysreset_ops = {
  26. .request = psci_sysreset_request,
  27. };
  28. U_BOOT_DRIVER(psci_sysreset) = {
  29. .name = "psci-sysreset",
  30. .id = UCLASS_SYSRESET,
  31. .ops = &psci_sysreset_ops,
  32. };