1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2020-2024 Intel Corporation
9 #include <linux/kfifo.h>
12 #include "ivpu_hw_btrs.h"
13 #include "ivpu_hw_ip.h"
15 #define IVPU_HW_IRQ_FIFO_LENGTH 1024
17 #define IVPU_HW_IRQ_SRC_IPC 1
18 #define IVPU_HW_IRQ_SRC_MMU_EVTQ 2
19 #define IVPU_HW_IRQ_SRC_DCT 3
21 struct ivpu_addr_range
{
22 resource_size_t start
;
28 bool (*btrs_irq_handler
)(struct ivpu_device
*vdev
, int irq
);
29 bool (*ip_irq_handler
)(struct ivpu_device
*vdev
, int irq
);
30 DECLARE_KFIFO(fifo
, u8
, IVPU_HW_IRQ_FIFO_LENGTH
);
33 struct ivpu_addr_range global
;
34 struct ivpu_addr_range user
;
35 struct ivpu_addr_range shave
;
36 struct ivpu_addr_range dma
;
42 * Pll ratio for the efficiency frequency. The VPU has optimum
43 * performance to power ratio at this frequency.
52 ktime_t d0i3_entry_host_ts
;
53 u64 d0i3_entry_vpu_ts
;
54 atomic_t firewall_irq_counter
;
57 int ivpu_hw_init(struct ivpu_device
*vdev
);
58 int ivpu_hw_power_up(struct ivpu_device
*vdev
);
59 int ivpu_hw_power_down(struct ivpu_device
*vdev
);
60 int ivpu_hw_reset(struct ivpu_device
*vdev
);
61 int ivpu_hw_boot_fw(struct ivpu_device
*vdev
);
62 void ivpu_hw_profiling_freq_drive(struct ivpu_device
*vdev
, bool enable
);
63 void ivpu_irq_handlers_init(struct ivpu_device
*vdev
);
64 void ivpu_hw_irq_enable(struct ivpu_device
*vdev
);
65 void ivpu_hw_irq_disable(struct ivpu_device
*vdev
);
66 irqreturn_t
ivpu_hw_irq_handler(int irq
, void *ptr
);
68 static inline u32
ivpu_hw_btrs_irq_handler(struct ivpu_device
*vdev
, int irq
)
70 return vdev
->hw
->irq
.btrs_irq_handler(vdev
, irq
);
73 static inline u32
ivpu_hw_ip_irq_handler(struct ivpu_device
*vdev
, int irq
)
75 return vdev
->hw
->irq
.ip_irq_handler(vdev
, irq
);
78 static inline void ivpu_hw_range_init(struct ivpu_addr_range
*range
, u64 start
, u64 size
)
81 range
->end
= start
+ size
;
84 static inline u64
ivpu_hw_range_size(const struct ivpu_addr_range
*range
)
86 return range
->end
- range
->start
;
89 static inline u32
ivpu_hw_ratio_to_freq(struct ivpu_device
*vdev
, u32 ratio
)
91 return ivpu_hw_btrs_ratio_to_freq(vdev
, ratio
);
94 static inline void ivpu_hw_irq_clear(struct ivpu_device
*vdev
)
96 ivpu_hw_ip_irq_clear(vdev
);
99 static inline u32
ivpu_hw_pll_freq_get(struct ivpu_device
*vdev
)
101 return ivpu_hw_btrs_pll_freq_get(vdev
);
104 static inline u32
ivpu_hw_profiling_freq_get(struct ivpu_device
*vdev
)
106 return vdev
->hw
->pll
.profiling_freq
;
109 static inline void ivpu_hw_diagnose_failure(struct ivpu_device
*vdev
)
111 ivpu_hw_ip_diagnose_failure(vdev
);
112 ivpu_hw_btrs_diagnose_failure(vdev
);
115 static inline u32
ivpu_hw_telemetry_offset_get(struct ivpu_device
*vdev
)
117 return ivpu_hw_btrs_telemetry_offset_get(vdev
);
120 static inline u32
ivpu_hw_telemetry_size_get(struct ivpu_device
*vdev
)
122 return ivpu_hw_btrs_telemetry_size_get(vdev
);
125 static inline u32
ivpu_hw_telemetry_enable_get(struct ivpu_device
*vdev
)
127 return ivpu_hw_btrs_telemetry_enable_get(vdev
);
130 static inline bool ivpu_hw_is_idle(struct ivpu_device
*vdev
)
132 return ivpu_hw_btrs_is_idle(vdev
);
135 static inline int ivpu_hw_wait_for_idle(struct ivpu_device
*vdev
)
137 return ivpu_hw_btrs_wait_for_idle(vdev
);
140 static inline void ivpu_hw_ipc_tx_set(struct ivpu_device
*vdev
, u32 vpu_addr
)
142 ivpu_hw_ip_ipc_tx_set(vdev
, vpu_addr
);
145 static inline void ivpu_hw_db_set(struct ivpu_device
*vdev
, u32 db_id
)
147 ivpu_hw_ip_db_set(vdev
, db_id
);
150 static inline u32
ivpu_hw_ipc_rx_addr_get(struct ivpu_device
*vdev
)
152 return ivpu_hw_ip_ipc_rx_addr_get(vdev
);
155 static inline u32
ivpu_hw_ipc_rx_count_get(struct ivpu_device
*vdev
)
157 return ivpu_hw_ip_ipc_rx_count_get(vdev
);
160 #endif /* __IVPU_HW_H__ */