Lines Matching full:vdev

45 static void platform_init(struct ivpu_device *vdev)  in platform_init()  argument
48 vdev->platform = IVPU_PLATFORM_SIMICS; in platform_init()
50 vdev->platform = IVPU_PLATFORM_SILICON; in platform_init()
52 ivpu_dbg(vdev, MISC, "Platform type: %s (%d)\n", in platform_init()
53 platform_to_str(vdev->platform), vdev->platform); in platform_init()
56 static void wa_init(struct ivpu_device *vdev) in wa_init() argument
58 vdev->wa.punit_disabled = ivpu_is_fpga(vdev); in wa_init()
59 vdev->wa.clear_runtime_mem = false; in wa_init()
61 if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_MTL) in wa_init()
62 vdev->wa.interrupt_clear_with_0 = ivpu_hw_btrs_irqs_clear_with_0_mtl(vdev); in wa_init()
64 if (ivpu_device_id(vdev) == PCI_DEVICE_ID_LNL && in wa_init()
65 ivpu_revision(vdev) < IVPU_HW_IP_REV_LNL_B0) in wa_init()
66 vdev->wa.disable_clock_relinquish = true; in wa_init()
68 if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) in wa_init()
69 vdev->wa.wp0_during_power_up = true; in wa_init()
78 static void timeouts_init(struct ivpu_device *vdev) in timeouts_init() argument
81 vdev->timeout.boot = -1; in timeouts_init()
82 vdev->timeout.jsm = -1; in timeouts_init()
83 vdev->timeout.tdr = -1; in timeouts_init()
84 vdev->timeout.autosuspend = -1; in timeouts_init()
85 vdev->timeout.d0i3_entry_msg = -1; in timeouts_init()
86 } else if (ivpu_is_fpga(vdev)) { in timeouts_init()
87 vdev->timeout.boot = 100000; in timeouts_init()
88 vdev->timeout.jsm = 50000; in timeouts_init()
89 vdev->timeout.tdr = 2000000; in timeouts_init()
90 vdev->timeout.autosuspend = -1; in timeouts_init()
91 vdev->timeout.d0i3_entry_msg = 500; in timeouts_init()
92 } else if (ivpu_is_simics(vdev)) { in timeouts_init()
93 vdev->timeout.boot = 50; in timeouts_init()
94 vdev->timeout.jsm = 500; in timeouts_init()
95 vdev->timeout.tdr = 10000; in timeouts_init()
96 vdev->timeout.autosuspend = -1; in timeouts_init()
97 vdev->timeout.d0i3_entry_msg = 100; in timeouts_init()
99 vdev->timeout.boot = 1000; in timeouts_init()
100 vdev->timeout.jsm = 500; in timeouts_init()
101 vdev->timeout.tdr = 2000; in timeouts_init()
102 if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) in timeouts_init()
103 vdev->timeout.autosuspend = 10; in timeouts_init()
105 vdev->timeout.autosuspend = 100; in timeouts_init()
106 vdev->timeout.d0i3_entry_msg = 5; in timeouts_init()
110 static void memory_ranges_init(struct ivpu_device *vdev) in memory_ranges_init() argument
112 if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) { in memory_ranges_init()
113 ivpu_hw_range_init(&vdev->hw->ranges.global, 0x80000000, SZ_512M); in memory_ranges_init()
114 ivpu_hw_range_init(&vdev->hw->ranges.user, 0xc0000000, 255 * SZ_1M); in memory_ranges_init()
115 ivpu_hw_range_init(&vdev->hw->ranges.shave, 0x180000000, SZ_2G); in memory_ranges_init()
116 ivpu_hw_range_init(&vdev->hw->ranges.dma, 0x200000000, SZ_8G); in memory_ranges_init()
118 ivpu_hw_range_init(&vdev->hw->ranges.global, 0x80000000, SZ_512M); in memory_ranges_init()
119 ivpu_hw_range_init(&vdev->hw->ranges.user, 0x80000000, SZ_256M); in memory_ranges_init()
120 ivpu_hw_range_init(&vdev->hw->ranges.shave, 0x80000000 + SZ_256M, SZ_2G - SZ_256M); in memory_ranges_init()
121 ivpu_hw_range_init(&vdev->hw->ranges.dma, 0x200000000, SZ_8G); in memory_ranges_init()
125 static int wp_enable(struct ivpu_device *vdev) in wp_enable() argument
127 return ivpu_hw_btrs_wp_drive(vdev, true); in wp_enable()
130 static int wp_disable(struct ivpu_device *vdev) in wp_disable() argument
132 return ivpu_hw_btrs_wp_drive(vdev, false); in wp_disable()
135 int ivpu_hw_power_up(struct ivpu_device *vdev) in ivpu_hw_power_up() argument
141 ret = wp_disable(vdev); in ivpu_hw_power_up()
143 ivpu_warn(vdev, "Failed to disable workpoint: %d\n", ret); in ivpu_hw_power_up()
146 ret = ivpu_hw_btrs_d0i3_disable(vdev); in ivpu_hw_power_up()
148 ivpu_warn(vdev, "Failed to disable D0I3: %d\n", ret); in ivpu_hw_power_up()
150 ret = wp_enable(vdev); in ivpu_hw_power_up()
152 ivpu_err(vdev, "Failed to enable workpoint: %d\n", ret); in ivpu_hw_power_up()
156 if (ivpu_hw_btrs_gen(vdev) >= IVPU_HW_BTRS_LNL) { in ivpu_hw_power_up()
158 ivpu_hw_btrs_clock_relinquish_disable_lnl(vdev); in ivpu_hw_power_up()
159 ivpu_hw_btrs_profiling_freq_reg_set_lnl(vdev); in ivpu_hw_power_up()
160 ivpu_hw_btrs_ats_print_lnl(vdev); in ivpu_hw_power_up()
163 ret = ivpu_hw_ip_host_ss_configure(vdev); in ivpu_hw_power_up()
165 ivpu_err(vdev, "Failed to configure host SS: %d\n", ret); in ivpu_hw_power_up()
169 ivpu_hw_ip_idle_gen_disable(vdev); in ivpu_hw_power_up()
171 ret = ivpu_hw_btrs_wait_for_clock_res_own_ack(vdev); in ivpu_hw_power_up()
173 ivpu_err(vdev, "Timed out waiting for clock resource own ACK\n"); in ivpu_hw_power_up()
177 ret = ivpu_hw_ip_pwr_domain_enable(vdev); in ivpu_hw_power_up()
179 ivpu_err(vdev, "Failed to enable power domain: %d\n", ret); in ivpu_hw_power_up()
183 ret = ivpu_hw_ip_host_ss_axi_enable(vdev); in ivpu_hw_power_up()
185 ivpu_err(vdev, "Failed to enable AXI: %d\n", ret); in ivpu_hw_power_up()
189 if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_LNL) in ivpu_hw_power_up()
190 ivpu_hw_btrs_set_port_arbitration_weights_lnl(vdev); in ivpu_hw_power_up()
192 ret = ivpu_hw_ip_top_noc_enable(vdev); in ivpu_hw_power_up()
194 ivpu_err(vdev, "Failed to enable TOP NOC: %d\n", ret); in ivpu_hw_power_up()
199 static void save_d0i3_entry_timestamp(struct ivpu_device *vdev) in save_d0i3_entry_timestamp() argument
201 vdev->hw->d0i3_entry_host_ts = ktime_get_boottime(); in save_d0i3_entry_timestamp()
202 vdev->hw->d0i3_entry_vpu_ts = ivpu_hw_ip_read_perf_timer_counter(vdev); in save_d0i3_entry_timestamp()
205 int ivpu_hw_reset(struct ivpu_device *vdev) in ivpu_hw_reset() argument
209 if (ivpu_hw_btrs_ip_reset(vdev)) { in ivpu_hw_reset()
210 ivpu_err(vdev, "Failed to reset NPU IP\n"); in ivpu_hw_reset()
214 if (wp_disable(vdev)) { in ivpu_hw_reset()
215 ivpu_err(vdev, "Failed to disable workpoint\n"); in ivpu_hw_reset()
222 int ivpu_hw_power_down(struct ivpu_device *vdev) in ivpu_hw_power_down() argument
226 save_d0i3_entry_timestamp(vdev); in ivpu_hw_power_down()
228 if (!ivpu_hw_is_idle(vdev)) in ivpu_hw_power_down()
229 ivpu_warn(vdev, "NPU not idle during power down\n"); in ivpu_hw_power_down()
231 if (ivpu_hw_reset(vdev)) { in ivpu_hw_power_down()
232 ivpu_err(vdev, "Failed to reset NPU\n"); in ivpu_hw_power_down()
236 if (ivpu_hw_btrs_d0i3_enable(vdev)) { in ivpu_hw_power_down()
237 ivpu_err(vdev, "Failed to enter D0I3\n"); in ivpu_hw_power_down()
244 int ivpu_hw_init(struct ivpu_device *vdev) in ivpu_hw_init() argument
246 ivpu_hw_btrs_info_init(vdev); in ivpu_hw_init()
247 ivpu_hw_btrs_freq_ratios_init(vdev); in ivpu_hw_init()
248 memory_ranges_init(vdev); in ivpu_hw_init()
249 platform_init(vdev); in ivpu_hw_init()
250 wa_init(vdev); in ivpu_hw_init()
251 timeouts_init(vdev); in ivpu_hw_init()
252 atomic_set(&vdev->hw->firewall_irq_counter, 0); in ivpu_hw_init()
257 int ivpu_hw_boot_fw(struct ivpu_device *vdev) in ivpu_hw_boot_fw() argument
261 ivpu_hw_ip_snoop_disable(vdev); in ivpu_hw_boot_fw()
262 ivpu_hw_ip_tbu_mmu_enable(vdev); in ivpu_hw_boot_fw()
263 ret = ivpu_hw_ip_soc_cpu_boot(vdev); in ivpu_hw_boot_fw()
265 ivpu_err(vdev, "Failed to boot SOC CPU: %d\n", ret); in ivpu_hw_boot_fw()
270 void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable) in ivpu_hw_profiling_freq_drive() argument
272 if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) { in ivpu_hw_profiling_freq_drive()
273 vdev->hw->pll.profiling_freq = PLL_PROFILING_FREQ_DEFAULT; in ivpu_hw_profiling_freq_drive()
278 vdev->hw->pll.profiling_freq = PLL_PROFILING_FREQ_HIGH; in ivpu_hw_profiling_freq_drive()
280 vdev->hw->pll.profiling_freq = PLL_PROFILING_FREQ_DEFAULT; in ivpu_hw_profiling_freq_drive()
283 void ivpu_irq_handlers_init(struct ivpu_device *vdev) in ivpu_irq_handlers_init() argument
285 INIT_KFIFO(vdev->hw->irq.fifo); in ivpu_irq_handlers_init()
287 if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) in ivpu_irq_handlers_init()
288 vdev->hw->irq.ip_irq_handler = ivpu_hw_ip_irq_handler_37xx; in ivpu_irq_handlers_init()
290 vdev->hw->irq.ip_irq_handler = ivpu_hw_ip_irq_handler_40xx; in ivpu_irq_handlers_init()
292 if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_MTL) in ivpu_irq_handlers_init()
293 vdev->hw->irq.btrs_irq_handler = ivpu_hw_btrs_irq_handler_mtl; in ivpu_irq_handlers_init()
295 vdev->hw->irq.btrs_irq_handler = ivpu_hw_btrs_irq_handler_lnl; in ivpu_irq_handlers_init()
298 void ivpu_hw_irq_enable(struct ivpu_device *vdev) in ivpu_hw_irq_enable() argument
300 kfifo_reset(&vdev->hw->irq.fifo); in ivpu_hw_irq_enable()
301 ivpu_hw_ip_irq_enable(vdev); in ivpu_hw_irq_enable()
302 ivpu_hw_btrs_irq_enable(vdev); in ivpu_hw_irq_enable()
305 void ivpu_hw_irq_disable(struct ivpu_device *vdev) in ivpu_hw_irq_disable() argument
307 ivpu_hw_btrs_irq_disable(vdev); in ivpu_hw_irq_disable()
308 ivpu_hw_ip_irq_disable(vdev); in ivpu_hw_irq_disable()
313 struct ivpu_device *vdev = ptr; in ivpu_hw_irq_handler() local
316 ivpu_hw_btrs_global_int_disable(vdev); in ivpu_hw_irq_handler()
318 btrs_handled = ivpu_hw_btrs_irq_handler(vdev, irq); in ivpu_hw_irq_handler()
319 if (!ivpu_hw_is_idle((vdev)) || !btrs_handled) in ivpu_hw_irq_handler()
320 ip_handled = ivpu_hw_ip_irq_handler(vdev, irq); in ivpu_hw_irq_handler()
325 ivpu_hw_btrs_global_int_enable(vdev); in ivpu_hw_irq_handler()
327 if (!kfifo_is_empty(&vdev->hw->irq.fifo)) in ivpu_hw_irq_handler()