sbi_hsm.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Atish Patra <atish.patra@wdc.com>
  8. */
  9. #ifndef __SBI_HSM_H__
  10. #define __SBI_HSM_H__
  11. #include <sbi/sbi_types.h>
  12. /** Hart state managment device */
  13. struct sbi_hsm_device {
  14. /** Name of the hart state managment device */
  15. char name[32];
  16. /** Start (or power-up) the given hart */
  17. int (*hart_start)(u32 hartid, ulong saddr);
  18. /**
  19. * Stop (or power-down) the current hart from running.
  20. *
  21. * Return SBI_ENOTSUPP if the hart does not support platform-specific
  22. * stop actions.
  23. *
  24. * For successful stop, the call won't return.
  25. */
  26. int (*hart_stop)(void);
  27. /**
  28. * Put the current hart in platform specific suspend (or low-power)
  29. * state.
  30. *
  31. * For successful retentive suspend, the call will return 0 when
  32. * the hart resumes normal execution.
  33. *
  34. * For successful non-retentive suspend, the hart will resume from
  35. * the warm boot entry point.
  36. */
  37. int (*hart_suspend)(u32 suspend_type);
  38. /**
  39. * Perform platform-specific actions to resume from a suspended state.
  40. *
  41. * This includes restoring any platform state that was lost during
  42. * non-retentive suspend.
  43. */
  44. void (*hart_resume)(void);
  45. };
  46. struct sbi_domain;
  47. struct sbi_scratch;
  48. const struct sbi_hsm_device *sbi_hsm_get_device(void);
  49. void sbi_hsm_set_device(const struct sbi_hsm_device *dev);
  50. int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot);
  51. void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch);
  52. int sbi_hsm_hart_start(struct sbi_scratch *scratch,
  53. const struct sbi_domain *dom,
  54. u32 hartid, ulong saddr, ulong smode, ulong arg1);
  55. int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow);
  56. void sbi_hsm_hart_resume_start(struct sbi_scratch *scratch);
  57. void __noreturn sbi_hsm_hart_resume_finish(struct sbi_scratch *scratch,
  58. u32 hartid);
  59. int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
  60. ulong raddr, ulong rmode, ulong arg1);
  61. bool sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate,
  62. long newstate);
  63. int __sbi_hsm_hart_get_state(u32 hartid);
  64. int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid);
  65. int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
  66. ulong hbase, ulong *out_hmask);
  67. void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch);
  68. void __noreturn sbi_hsm_hart_start_finish(struct sbi_scratch *scratch,
  69. u32 hartid);
  70. #endif