ivpu_hw.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2020-2024 Intel Corporation
  4. */
  5. #ifndef __IVPU_HW_H__
  6. #define __IVPU_HW_H__
  7. #include <linux/kfifo.h>
  8. #include "ivpu_drv.h"
  9. #include "ivpu_hw_btrs.h"
  10. #include "ivpu_hw_ip.h"
  11. #define IVPU_HW_IRQ_FIFO_LENGTH 1024
  12. #define IVPU_HW_IRQ_SRC_IPC 1
  13. #define IVPU_HW_IRQ_SRC_MMU_EVTQ 2
  14. #define IVPU_HW_IRQ_SRC_DCT 3
  15. struct ivpu_addr_range {
  16. resource_size_t start;
  17. resource_size_t end;
  18. };
  19. struct ivpu_hw_info {
  20. struct {
  21. bool (*btrs_irq_handler)(struct ivpu_device *vdev, int irq);
  22. bool (*ip_irq_handler)(struct ivpu_device *vdev, int irq);
  23. DECLARE_KFIFO(fifo, u8, IVPU_HW_IRQ_FIFO_LENGTH);
  24. } irq;
  25. struct {
  26. struct ivpu_addr_range global;
  27. struct ivpu_addr_range user;
  28. struct ivpu_addr_range shave;
  29. struct ivpu_addr_range dma;
  30. } ranges;
  31. struct {
  32. u8 min_ratio;
  33. u8 max_ratio;
  34. /*
  35. * Pll ratio for the efficiency frequency. The VPU has optimum
  36. * performance to power ratio at this frequency.
  37. */
  38. u8 pn_ratio;
  39. u32 profiling_freq;
  40. } pll;
  41. u32 tile_fuse;
  42. u32 sched_mode;
  43. u32 sku;
  44. u16 config;
  45. int dma_bits;
  46. ktime_t d0i3_entry_host_ts;
  47. u64 d0i3_entry_vpu_ts;
  48. atomic_t firewall_irq_counter;
  49. };
  50. int ivpu_hw_init(struct ivpu_device *vdev);
  51. int ivpu_hw_power_up(struct ivpu_device *vdev);
  52. int ivpu_hw_power_down(struct ivpu_device *vdev);
  53. int ivpu_hw_reset(struct ivpu_device *vdev);
  54. int ivpu_hw_boot_fw(struct ivpu_device *vdev);
  55. void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable);
  56. void ivpu_irq_handlers_init(struct ivpu_device *vdev);
  57. void ivpu_hw_irq_enable(struct ivpu_device *vdev);
  58. void ivpu_hw_irq_disable(struct ivpu_device *vdev);
  59. irqreturn_t ivpu_hw_irq_handler(int irq, void *ptr);
  60. static inline u32 ivpu_hw_btrs_irq_handler(struct ivpu_device *vdev, int irq)
  61. {
  62. return vdev->hw->irq.btrs_irq_handler(vdev, irq);
  63. }
  64. static inline u32 ivpu_hw_ip_irq_handler(struct ivpu_device *vdev, int irq)
  65. {
  66. return vdev->hw->irq.ip_irq_handler(vdev, irq);
  67. }
  68. static inline void ivpu_hw_range_init(struct ivpu_addr_range *range, u64 start, u64 size)
  69. {
  70. range->start = start;
  71. range->end = start + size;
  72. }
  73. static inline u64 ivpu_hw_range_size(const struct ivpu_addr_range *range)
  74. {
  75. return range->end - range->start;
  76. }
  77. static inline u32 ivpu_hw_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
  78. {
  79. return ivpu_hw_btrs_ratio_to_freq(vdev, ratio);
  80. }
  81. static inline void ivpu_hw_irq_clear(struct ivpu_device *vdev)
  82. {
  83. ivpu_hw_ip_irq_clear(vdev);
  84. }
  85. static inline u32 ivpu_hw_pll_freq_get(struct ivpu_device *vdev)
  86. {
  87. return ivpu_hw_btrs_pll_freq_get(vdev);
  88. }
  89. static inline u32 ivpu_hw_profiling_freq_get(struct ivpu_device *vdev)
  90. {
  91. return vdev->hw->pll.profiling_freq;
  92. }
  93. static inline void ivpu_hw_diagnose_failure(struct ivpu_device *vdev)
  94. {
  95. ivpu_hw_ip_diagnose_failure(vdev);
  96. ivpu_hw_btrs_diagnose_failure(vdev);
  97. }
  98. static inline u32 ivpu_hw_telemetry_offset_get(struct ivpu_device *vdev)
  99. {
  100. return ivpu_hw_btrs_telemetry_offset_get(vdev);
  101. }
  102. static inline u32 ivpu_hw_telemetry_size_get(struct ivpu_device *vdev)
  103. {
  104. return ivpu_hw_btrs_telemetry_size_get(vdev);
  105. }
  106. static inline u32 ivpu_hw_telemetry_enable_get(struct ivpu_device *vdev)
  107. {
  108. return ivpu_hw_btrs_telemetry_enable_get(vdev);
  109. }
  110. static inline bool ivpu_hw_is_idle(struct ivpu_device *vdev)
  111. {
  112. return ivpu_hw_btrs_is_idle(vdev);
  113. }
  114. static inline int ivpu_hw_wait_for_idle(struct ivpu_device *vdev)
  115. {
  116. return ivpu_hw_btrs_wait_for_idle(vdev);
  117. }
  118. static inline void ivpu_hw_ipc_tx_set(struct ivpu_device *vdev, u32 vpu_addr)
  119. {
  120. ivpu_hw_ip_ipc_tx_set(vdev, vpu_addr);
  121. }
  122. static inline void ivpu_hw_db_set(struct ivpu_device *vdev, u32 db_id)
  123. {
  124. ivpu_hw_ip_db_set(vdev, db_id);
  125. }
  126. static inline u32 ivpu_hw_ipc_rx_addr_get(struct ivpu_device *vdev)
  127. {
  128. return ivpu_hw_ip_ipc_rx_addr_get(vdev);
  129. }
  130. static inline u32 ivpu_hw_ipc_rx_count_get(struct ivpu_device *vdev)
  131. {
  132. return ivpu_hw_ip_ipc_rx_count_get(vdev);
  133. }
  134. #endif /* __IVPU_HW_H__ */