drv_hardlock.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are met:
  5. * 1. Redistributions of source code must retain the above copyright
  6. * notice, this list of conditions and the following disclaimer.
  7. * 2. Redistributions in binary form must reproduce the above copyright
  8. * notice, this list of conditions and the following disclaimer in the
  9. * documentation and/or other materials provided with the distribution.
  10. *
  11. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  12. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  13. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  16. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  18. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  22. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef DRV_HARDLOCK_H__
  26. #define DRV_HARDLOCK_H__
  27. #include <rtdef.h>
  28. typedef enum k230_hardlock_type
  29. {
  30. HARDLOCK_GPIO = 0,
  31. HARDLOCK_KPU = 1,
  32. HARDLOCK_TS = 2,
  33. HARDLOCK_DISP = 3,
  34. HARDLOCK_DISP_CPU0 = 4,
  35. HARDLOCK_DISP_CPU1 = 5,
  36. HARDLOCK_HASH = 6,
  37. HARDLOCK_AES = 7,
  38. HARDLOCK_SM4 = 8,
  39. HARDLOCK_PDMA = 9,
  40. HARDLOCK_MAX = 128
  41. } hardlock_type;
  42. #ifdef BSP_USING_HARDLOCK
  43. extern int kd_hardlock_lock(hardlock_type num);
  44. extern void kd_hardlock_unlock(hardlock_type num);
  45. extern int kd_request_lock(hardlock_type num);
  46. #else
  47. rt_inline int kd_hardlock_lock(hardlock_type num)
  48. { return 0; }
  49. rt_inline void kd_hardlock_unlock(hardlock_type num)
  50. {}
  51. rt_inline int kd_request_lock(hardlock_type num)
  52. { return num; }
  53. #endif
  54. #endif