sysreset.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2015 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #ifndef __SYSRESET_H
  7. #define __SYSRESET_H
  8. enum sysreset_t {
  9. SYSRESET_WARM, /* Reset CPU, keep GPIOs active */
  10. SYSRESET_COLD, /* Reset CPU and GPIOs */
  11. SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
  12. SYSRESET_COUNT,
  13. };
  14. struct sysreset_ops {
  15. /**
  16. * request() - request a sysreset of the given type
  17. *
  18. * Note that this function may return before the reset takes effect.
  19. *
  20. * @type: Reset type to request
  21. * @return -EINPROGRESS if the reset has been started and
  22. * will complete soon, -EPROTONOSUPPORT if not supported
  23. * by this device, 0 if the reset has already happened
  24. * (in which case this method will not actually return)
  25. */
  26. int (*request)(struct udevice *dev, enum sysreset_t type);
  27. };
  28. #define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops)
  29. /**
  30. * sysreset_request() - request a sysreset
  31. *
  32. * @type: Reset type to request
  33. * @return 0 if OK, -EPROTONOSUPPORT if not supported by this device
  34. */
  35. int sysreset_request(struct udevice *dev, enum sysreset_t type);
  36. /**
  37. * sysreset_walk() - cause a system reset
  38. *
  39. * This works through the available sysreset devices until it finds one that can
  40. * perform a reset. If the provided sysreset type is not available, the next one
  41. * will be tried.
  42. *
  43. * If this function fails to reset, it will display a message and halt
  44. *
  45. * @type: Reset type to request
  46. * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
  47. */
  48. int sysreset_walk(enum sysreset_t type);
  49. /**
  50. * sysreset_walk_halt() - try to reset, otherwise halt
  51. *
  52. * This calls sysreset_walk(). If it returns, indicating that reset is not
  53. * supported, it prints a message and halts.
  54. */
  55. void sysreset_walk_halt(enum sysreset_t type);
  56. /**
  57. * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
  58. */
  59. void reset_cpu(ulong addr);
  60. #endif