1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2020-2023 Intel Corporation
12 int (*info_init)(struct ivpu_device *vdev);
13 int (*power_up)(struct ivpu_device *vdev);
14 int (*boot_fw)(struct ivpu_device *vdev);
15 int (*power_down)(struct ivpu_device *vdev);
16 int (*reset)(struct ivpu_device *vdev);
17 bool (*is_idle)(struct ivpu_device *vdev);
18 int (*wait_for_idle)(struct ivpu_device *vdev);
19 void (*wdt_disable)(struct ivpu_device *vdev);
20 void (*diagnose_failure)(struct ivpu_device *vdev);
21 u32 (*profiling_freq_get)(struct ivpu_device *vdev);
22 void (*profiling_freq_drive)(struct ivpu_device *vdev, bool enable);
23 u32 (*reg_pll_freq_get)(struct ivpu_device *vdev);
24 u32 (*ratio_to_freq)(struct ivpu_device *vdev, u32 ratio);
25 u32 (*reg_telemetry_offset_get)(struct ivpu_device *vdev);
26 u32 (*reg_telemetry_size_get)(struct ivpu_device *vdev);
27 u32 (*reg_telemetry_enable_get)(struct ivpu_device *vdev);
28 void (*reg_db_set)(struct ivpu_device *vdev, u32 db_id);
29 u32 (*reg_ipc_rx_addr_get)(struct ivpu_device *vdev);
30 u32 (*reg_ipc_rx_count_get)(struct ivpu_device *vdev);
31 void (*reg_ipc_tx_set)(struct ivpu_device *vdev, u32 vpu_addr);
32 void (*irq_clear)(struct ivpu_device *vdev);
33 void (*irq_enable)(struct ivpu_device *vdev);
34 void (*irq_disable)(struct ivpu_device *vdev);
35 irqreturn_t (*irq_handler)(int irq, void *ptr);
38 struct ivpu_addr_range {
39 resource_size_t start;
44 const struct ivpu_hw_ops *ops;
46 struct ivpu_addr_range global;
47 struct ivpu_addr_range user;
48 struct ivpu_addr_range shave;
49 struct ivpu_addr_range dma;
55 * Pll ratio for the efficiency frequency. The VPU has optimum
56 * performance to power ratio at this frequency.
65 ktime_t d0i3_entry_host_ts;
66 u64 d0i3_entry_vpu_ts;
69 extern const struct ivpu_hw_ops ivpu_hw_37xx_ops;
70 extern const struct ivpu_hw_ops ivpu_hw_40xx_ops;
72 static inline int ivpu_hw_info_init(struct ivpu_device *vdev)
74 return vdev->hw->ops->info_init(vdev);
77 static inline int ivpu_hw_power_up(struct ivpu_device *vdev)
79 ivpu_dbg(vdev, PM, "HW power up\n");
81 return vdev->hw->ops->power_up(vdev);
84 static inline int ivpu_hw_boot_fw(struct ivpu_device *vdev)
86 return vdev->hw->ops->boot_fw(vdev);
89 static inline bool ivpu_hw_is_idle(struct ivpu_device *vdev)
91 return vdev->hw->ops->is_idle(vdev);
94 static inline int ivpu_hw_wait_for_idle(struct ivpu_device *vdev)
96 return vdev->hw->ops->wait_for_idle(vdev);
99 static inline int ivpu_hw_power_down(struct ivpu_device *vdev)
101 ivpu_dbg(vdev, PM, "HW power down\n");
103 return vdev->hw->ops->power_down(vdev);
106 static inline int ivpu_hw_reset(struct ivpu_device *vdev)
108 ivpu_dbg(vdev, PM, "HW reset\n");
110 return vdev->hw->ops->reset(vdev);
113 static inline void ivpu_hw_wdt_disable(struct ivpu_device *vdev)
115 vdev->hw->ops->wdt_disable(vdev);
118 static inline u32 ivpu_hw_profiling_freq_get(struct ivpu_device *vdev)
120 return vdev->hw->ops->profiling_freq_get(vdev);
123 static inline void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable)
125 return vdev->hw->ops->profiling_freq_drive(vdev, enable);
128 /* Register indirect accesses */
129 static inline u32 ivpu_hw_reg_pll_freq_get(struct ivpu_device *vdev)
131 return vdev->hw->ops->reg_pll_freq_get(vdev);
134 static inline u32 ivpu_hw_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
136 return vdev->hw->ops->ratio_to_freq(vdev, ratio);
139 static inline u32 ivpu_hw_reg_telemetry_offset_get(struct ivpu_device *vdev)
141 return vdev->hw->ops->reg_telemetry_offset_get(vdev);
144 static inline u32 ivpu_hw_reg_telemetry_size_get(struct ivpu_device *vdev)
146 return vdev->hw->ops->reg_telemetry_size_get(vdev);
149 static inline u32 ivpu_hw_reg_telemetry_enable_get(struct ivpu_device *vdev)
151 return vdev->hw->ops->reg_telemetry_enable_get(vdev);
154 static inline void ivpu_hw_reg_db_set(struct ivpu_device *vdev, u32 db_id)
156 vdev->hw->ops->reg_db_set(vdev, db_id);
159 static inline u32 ivpu_hw_reg_ipc_rx_addr_get(struct ivpu_device *vdev)
161 return vdev->hw->ops->reg_ipc_rx_addr_get(vdev);
164 static inline u32 ivpu_hw_reg_ipc_rx_count_get(struct ivpu_device *vdev)
166 return vdev->hw->ops->reg_ipc_rx_count_get(vdev);
169 static inline void ivpu_hw_reg_ipc_tx_set(struct ivpu_device *vdev, u32 vpu_addr)
171 vdev->hw->ops->reg_ipc_tx_set(vdev, vpu_addr);
174 static inline void ivpu_hw_irq_clear(struct ivpu_device *vdev)
176 vdev->hw->ops->irq_clear(vdev);
179 static inline void ivpu_hw_irq_enable(struct ivpu_device *vdev)
181 vdev->hw->ops->irq_enable(vdev);
184 static inline void ivpu_hw_irq_disable(struct ivpu_device *vdev)
186 vdev->hw->ops->irq_disable(vdev);
189 static inline void ivpu_hw_init_range(struct ivpu_addr_range *range, u64 start, u64 size)
191 range->start = start;
192 range->end = start + size;
195 static inline u64 ivpu_hw_range_size(const struct ivpu_addr_range *range)
197 return range->end - range->start;
200 static inline void ivpu_hw_diagnose_failure(struct ivpu_device *vdev)
202 vdev->hw->ops->diagnose_failure(vdev);
205 #endif /* __IVPU_HW_H__ */