hal_hwspinlock.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _HAL_HWSPINLOCK_H_
  13. #define _HAL_HWSPINLOCK_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #include "hal_config.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * HW spinlock ID for ADI bus access
  23. */
  24. #define HAL_HWSPINLOCK_ID_ADIBUS 0
  25. /**
  26. * HW spinlock ID for CP sleep
  27. *
  28. * It is not a typical spinlock. CP will acquire the spinlock during normal
  29. * mode. It will only release spinlock when cp is ready for sleep. Also,
  30. * after WFI, cp will acquire spinlock before go forward. AP can use the
  31. * spinlock to prevent CP go forward when shared resources (such as PSRAM)
  32. * is unavailable.
  33. *
  34. * CP sleep protocol is through IPC bit10. This spinlock can be used for
  35. * double checking.
  36. */
  37. #define HAL_HWSPINLOCK_ID_CPSLEEP 5
  38. /**
  39. * HW spinlock ID for EFUSE access
  40. */
  41. #define HAL_HWSPINLOCK_ID_EFUSE 8
  42. /**
  43. * HW spinlock ID for IPC
  44. */
  45. #define HAL_HWSPINLOCK_ID_IPC 9
  46. /**
  47. * @brief acquire HW spinlock and enter critical
  48. *
  49. * @param id HW spinlock id
  50. * @return critical flag
  51. */
  52. uint32_t halHwspinlockAcquire(uint32_t id);
  53. /**
  54. * @brief release HW spinlock and exit critical
  55. *
  56. * @param critical critical flag
  57. * @param id HW spinlock id
  58. */
  59. void halHwspinlockRelease(uint32_t critical, uint32_t id);
  60. /**
  61. * @brief try acquire HW spinlock inside critical section
  62. *
  63. * @param id HW spinlock id
  64. * @return
  65. * - true if HW spinlock is acquired
  66. * - false if HW spinlock is busy
  67. */
  68. bool halHwspinlockTryAcquireInCritical(uint32_t id);
  69. #ifdef CONFIG_SOC_8910
  70. /**
  71. * @brief acquire HW spinlock inside critical section
  72. *
  73. * @param id HW spinlock id
  74. * @return
  75. * - true if HW spinlock is acquired
  76. * - false if HW spinlock is busy
  77. */
  78. bool halHwspinlockAcquireInCritical(uint32_t id);
  79. #else
  80. /**
  81. * @brief acquire HW spinlock inside critical section
  82. *
  83. * @param id HW spinlock id
  84. */
  85. void halHwspinlockAcquireInCritical(uint32_t id);
  86. #endif
  87. /**
  88. * @brief release HW spinlock inside critical section
  89. *
  90. * @param id HW spinlock id
  91. */
  92. void halHwspinlockReleaseInCritical(uint32_t id);
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif