mt_spm.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef MT_SPM_H
  7. #define MT_SPM_H
  8. #include <lib/bakery_lock.h>
  9. #include <lib/spinlock.h>
  10. #include <plat_mtk_lpm.h>
  11. /*
  12. * ARM v8.2, the cache will turn off automatically when cpu
  13. * power down. Therefore, there is no doubt to use the spin_lock here.
  14. */
  15. #if !HW_ASSISTED_COHERENCY
  16. #define MT_SPM_USING_BAKERY_LOCK
  17. #endif
  18. #ifdef MT_SPM_USING_BAKERY_LOCK
  19. DECLARE_BAKERY_LOCK(spm_lock);
  20. #define plat_spm_lock() bakery_lock_get(&spm_lock)
  21. #define plat_spm_unlock() bakery_lock_release(&spm_lock)
  22. #else
  23. extern spinlock_t spm_lock;
  24. #define plat_spm_lock() spin_lock(&spm_lock)
  25. #define plat_spm_unlock() spin_unlock(&spm_lock)
  26. #endif
  27. #define MT_SPM_USING_SRCLKEN_RC
  28. /* spm extern operand definition */
  29. #define MT_SPM_EX_OP_CLR_26M_RECORD BIT(0)
  30. #define MT_SPM_EX_OP_SET_WDT BIT(1)
  31. #define MT_SPM_EX_OP_NON_GENERIC_RESOURCE_REQ BIT(2)
  32. #define MT_SPM_EX_OP_SET_SUSPEND_MODE BIT(3)
  33. #define MT_SPM_EX_OP_SET_IS_ADSP BIT(4)
  34. #define MT_SPM_EX_OP_SRCLKEN_RC_BBLPM BIT(5)
  35. #define MT_SPM_EX_OP_HW_S1_DETECT BIT(6)
  36. #define MT_SPM_EX_OP_TRACE_LP BIT(7)
  37. #define MT_SPM_EX_OP_TRACE_SUSPEND BIT(8)
  38. #define MT_SPM_EX_OP_TRACE_TIMESTAMP_EN BIT(9)
  39. #define MT_SPM_EX_OP_TIME_CHECK BIT(10)
  40. #define MT_SPM_EX_OP_TIME_OBS BIT(11)
  41. typedef enum {
  42. WR_NONE = 0,
  43. WR_UART_BUSY = 1,
  44. WR_ABORT = 2,
  45. WR_PCM_TIMER = 3,
  46. WR_WAKE_SRC = 4,
  47. WR_DVFSRC = 5,
  48. WR_TWAM = 6,
  49. WR_PMSR = 7,
  50. WR_SPM_ACK_CHK = 8,
  51. WR_UNKNOWN = 9,
  52. } wake_reason_t;
  53. /* for suspend vol. bin settings */
  54. enum MT_PLAT_SUSPEND_VCORE {
  55. SPM_SUSPEND_VCORE_5500 = 0,
  56. SPM_SUSPEND_VCORE_5250 = 1,
  57. SPM_SUSPEND_VCORE_5000 = 2,
  58. };
  59. extern void spm_boot_init(void);
  60. static inline void spm_lock_get(void)
  61. {
  62. plat_spm_lock();
  63. }
  64. static inline void spm_lock_release(void)
  65. {
  66. plat_spm_unlock();
  67. }
  68. unsigned int spm_get_suspend_vcore_voltage_idx(void);
  69. #endif /* MT_SPM_H */