drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / drivers / accel / ivpu / ivpu_hw.h
blobfbef9816b9d0cd185d2e54fdfa0506595f67c964
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2020-2024 Intel Corporation
4 */
6 #ifndef __IVPU_HW_H__
7 #define __IVPU_HW_H__
9 #include "ivpu_drv.h"
10 #include "ivpu_hw_btrs.h"
11 #include "ivpu_hw_ip.h"
13 struct ivpu_addr_range {
14 resource_size_t start;
15 resource_size_t end;
18 struct ivpu_hw_info {
19 struct {
20 bool (*btrs_irq_handler)(struct ivpu_device *vdev, int irq);
21 bool (*ip_irq_handler)(struct ivpu_device *vdev, int irq);
22 } irq;
23 struct {
24 struct ivpu_addr_range global;
25 struct ivpu_addr_range user;
26 struct ivpu_addr_range shave;
27 struct ivpu_addr_range dma;
28 } ranges;
29 struct {
30 u8 min_ratio;
31 u8 max_ratio;
33 * Pll ratio for the efficiency frequency. The VPU has optimum
34 * performance to power ratio at this frequency.
36 u8 pn_ratio;
37 u32 profiling_freq;
38 } pll;
39 u32 tile_fuse;
40 u32 sku;
41 u16 config;
42 int dma_bits;
43 ktime_t d0i3_entry_host_ts;
44 u64 d0i3_entry_vpu_ts;
45 atomic_t firewall_irq_counter;
48 int ivpu_hw_init(struct ivpu_device *vdev);
49 int ivpu_hw_power_up(struct ivpu_device *vdev);
50 int ivpu_hw_power_down(struct ivpu_device *vdev);
51 int ivpu_hw_reset(struct ivpu_device *vdev);
52 int ivpu_hw_boot_fw(struct ivpu_device *vdev);
53 void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable);
54 void ivpu_irq_handlers_init(struct ivpu_device *vdev);
55 void ivpu_hw_irq_enable(struct ivpu_device *vdev);
56 void ivpu_hw_irq_disable(struct ivpu_device *vdev);
57 irqreturn_t ivpu_hw_irq_handler(int irq, void *ptr);
59 static inline u32 ivpu_hw_btrs_irq_handler(struct ivpu_device *vdev, int irq)
61 return vdev->hw->irq.btrs_irq_handler(vdev, irq);
64 static inline u32 ivpu_hw_ip_irq_handler(struct ivpu_device *vdev, int irq)
66 return vdev->hw->irq.ip_irq_handler(vdev, irq);
69 static inline void ivpu_hw_range_init(struct ivpu_addr_range *range, u64 start, u64 size)
71 range->start = start;
72 range->end = start + size;
75 static inline u64 ivpu_hw_range_size(const struct ivpu_addr_range *range)
77 return range->end - range->start;
80 static inline u32 ivpu_hw_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
82 return ivpu_hw_btrs_ratio_to_freq(vdev, ratio);
85 static inline void ivpu_hw_irq_clear(struct ivpu_device *vdev)
87 ivpu_hw_ip_irq_clear(vdev);
90 static inline u32 ivpu_hw_pll_freq_get(struct ivpu_device *vdev)
92 return ivpu_hw_btrs_pll_freq_get(vdev);
95 static inline u32 ivpu_hw_profiling_freq_get(struct ivpu_device *vdev)
97 return vdev->hw->pll.profiling_freq;
100 static inline void ivpu_hw_diagnose_failure(struct ivpu_device *vdev)
102 ivpu_hw_ip_diagnose_failure(vdev);
103 ivpu_hw_btrs_diagnose_failure(vdev);
106 static inline u32 ivpu_hw_telemetry_offset_get(struct ivpu_device *vdev)
108 return ivpu_hw_btrs_telemetry_offset_get(vdev);
111 static inline u32 ivpu_hw_telemetry_size_get(struct ivpu_device *vdev)
113 return ivpu_hw_btrs_telemetry_size_get(vdev);
116 static inline u32 ivpu_hw_telemetry_enable_get(struct ivpu_device *vdev)
118 return ivpu_hw_btrs_telemetry_enable_get(vdev);
121 static inline bool ivpu_hw_is_idle(struct ivpu_device *vdev)
123 return ivpu_hw_btrs_is_idle(vdev);
126 static inline int ivpu_hw_wait_for_idle(struct ivpu_device *vdev)
128 return ivpu_hw_btrs_wait_for_idle(vdev);
131 static inline void ivpu_hw_ipc_tx_set(struct ivpu_device *vdev, u32 vpu_addr)
133 ivpu_hw_ip_ipc_tx_set(vdev, vpu_addr);
136 static inline void ivpu_hw_db_set(struct ivpu_device *vdev, u32 db_id)
138 ivpu_hw_ip_db_set(vdev, db_id);
141 static inline u32 ivpu_hw_ipc_rx_addr_get(struct ivpu_device *vdev)
143 return ivpu_hw_ip_ipc_rx_addr_get(vdev);
146 static inline u32 ivpu_hw_ipc_rx_count_get(struct ivpu_device *vdev)
148 return ivpu_hw_ip_ipc_rx_count_get(vdev);
151 #endif /* __IVPU_HW_H__ */