sbi_system.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __SBI_SYSTEM_H__
  10. #define __SBI_SYSTEM_H__
  11. #include <sbi/sbi_types.h>
  12. #include <sbi/sbi_list.h>
  13. /** System reset hardware device */
  14. struct sbi_system_reset_device {
  15. /** Name of the system reset device */
  16. char name[32];
  17. /* Check whether reset type and reason supported by the device */
  18. int (*system_reset_check)(u32 reset_type, u32 reset_reason);
  19. /** Reset the system */
  20. void (*system_reset)(u32 reset_type, u32 reset_reason);
  21. /** List */
  22. struct sbi_dlist node;
  23. };
  24. static inline struct sbi_system_reset_device *to_system_reset_device(
  25. struct sbi_dlist *node)
  26. {
  27. return container_of(node, struct sbi_system_reset_device, node);
  28. }
  29. const struct sbi_system_reset_device *sbi_system_reset_get_device(
  30. u32 reset_type, u32 reset_reason);
  31. void sbi_system_reset_add_device(struct sbi_system_reset_device *dev);
  32. bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason);
  33. void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason);
  34. /** System suspend device */
  35. struct sbi_system_suspend_device {
  36. /** Name of the system suspend device */
  37. char name[32];
  38. /* Check whether sleep type is supported by the device */
  39. int (*system_suspend_check)(u32 sleep_type);
  40. /**
  41. * Suspend the system
  42. *
  43. * @sleep_type: The sleep type identifier passed to the SBI call.
  44. * @mmode_resume_addr:
  45. * This is the same as sbi_scratch.warmboot_addr. Some platforms
  46. * may not be able to return from system_suspend(), so they will
  47. * jump directly to this address instead. Platforms which can
  48. * return from system_suspend() may ignore this parameter.
  49. */
  50. int (*system_suspend)(u32 sleep_type, unsigned long mmode_resume_addr);
  51. };
  52. const struct sbi_system_suspend_device *sbi_system_suspend_get_device(void);
  53. void sbi_system_suspend_set_device(struct sbi_system_suspend_device *dev);
  54. void sbi_system_suspend_test_enable(void);
  55. bool sbi_system_suspend_supported(u32 sleep_type);
  56. int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque);
  57. #endif