sysreset.h 1.9 KB

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