Lines Matching +full:static +full:- +full:enable
37 static void ih_v6_1_set_interrupt_funcs(struct amdgpu_device *adev);
40 * ih_v6_1_init_register_offset - Initialize register offset for ih rings
46 static void ih_v6_1_init_register_offset(struct amdgpu_device *adev) in ih_v6_1_init_register_offset()
52 if (adev->irq.ih.ring_size) { in ih_v6_1_init_register_offset()
53 ih_regs = &adev->irq.ih.ih_regs; in ih_v6_1_init_register_offset()
54 ih_regs->ih_rb_base = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_BASE); in ih_v6_1_init_register_offset()
55 ih_regs->ih_rb_base_hi = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_BASE_HI); in ih_v6_1_init_register_offset()
56 ih_regs->ih_rb_cntl = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_CNTL); in ih_v6_1_init_register_offset()
57 ih_regs->ih_rb_wptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_WPTR); in ih_v6_1_init_register_offset()
58 ih_regs->ih_rb_rptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_RPTR); in ih_v6_1_init_register_offset()
59 ih_regs->ih_doorbell_rptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_DOORBELL_RPTR); in ih_v6_1_init_register_offset()
60 ih_regs->ih_rb_wptr_addr_lo = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_WPTR_ADDR_LO); in ih_v6_1_init_register_offset()
61 ih_regs->ih_rb_wptr_addr_hi = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_WPTR_ADDR_HI); in ih_v6_1_init_register_offset()
62 ih_regs->psp_reg_id = PSP_REG_IH_RB_CNTL; in ih_v6_1_init_register_offset()
65 if (adev->irq.ih1.ring_size) { in ih_v6_1_init_register_offset()
66 ih_regs = &adev->irq.ih1.ih_regs; in ih_v6_1_init_register_offset()
67 ih_regs->ih_rb_base = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_BASE_RING1); in ih_v6_1_init_register_offset()
68 ih_regs->ih_rb_base_hi = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_BASE_HI_RING1); in ih_v6_1_init_register_offset()
69 ih_regs->ih_rb_cntl = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_CNTL_RING1); in ih_v6_1_init_register_offset()
70 ih_regs->ih_rb_wptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_WPTR_RING1); in ih_v6_1_init_register_offset()
71 ih_regs->ih_rb_rptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_RB_RPTR_RING1); in ih_v6_1_init_register_offset()
72 ih_regs->ih_doorbell_rptr = SOC15_REG_OFFSET(OSSSYS, 0, regIH_DOORBELL_RPTR_RING1); in ih_v6_1_init_register_offset()
73 ih_regs->psp_reg_id = PSP_REG_IH_RB_CNTL_RING1; in ih_v6_1_init_register_offset()
78 * force_update_wptr_for_self_int - Force update the wptr for self interrupt
83 * @enabled: Enable/disable timeout flush mechanism
92 static void
109 if (psp_reg_program(&adev->psp, PSP_REG_IH_RB_CNTL_RING1, ih_rb_cntl)) in force_update_wptr_for_self_int()
119 * ih_v6_1_toggle_ring_interrupts - toggle the interrupt ring buffer
123 * @enable: true - enable the interrupts, false - disable the interrupts
127 static int ih_v6_1_toggle_ring_interrupts(struct amdgpu_device *adev, in ih_v6_1_toggle_ring_interrupts()
129 bool enable) in ih_v6_1_toggle_ring_interrupts() argument
134 ih_regs = &ih->ih_regs; in ih_v6_1_toggle_ring_interrupts()
136 tmp = RREG32(ih_regs->ih_rb_cntl); in ih_v6_1_toggle_ring_interrupts()
137 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, RB_ENABLE, (enable ? 1 : 0)); in ih_v6_1_toggle_ring_interrupts()
139 if (ih == &adev->irq.ih) in ih_v6_1_toggle_ring_interrupts()
140 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, ENABLE_INTR, (enable ? 1 : 0)); in ih_v6_1_toggle_ring_interrupts()
143 if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp)) in ih_v6_1_toggle_ring_interrupts()
144 return -ETIMEDOUT; in ih_v6_1_toggle_ring_interrupts()
146 WREG32(ih_regs->ih_rb_cntl, tmp); in ih_v6_1_toggle_ring_interrupts()
149 if (enable) { in ih_v6_1_toggle_ring_interrupts()
150 ih->enabled = true; in ih_v6_1_toggle_ring_interrupts()
153 WREG32(ih_regs->ih_rb_rptr, 0); in ih_v6_1_toggle_ring_interrupts()
154 WREG32(ih_regs->ih_rb_wptr, 0); in ih_v6_1_toggle_ring_interrupts()
155 ih->enabled = false; in ih_v6_1_toggle_ring_interrupts()
156 ih->rptr = 0; in ih_v6_1_toggle_ring_interrupts()
163 * ih_v6_1_toggle_interrupts - Toggle all the available interrupt ring buffers
166 * @enable: enable or disable interrupt ring buffers
170 static int ih_v6_1_toggle_interrupts(struct amdgpu_device *adev, bool enable) in ih_v6_1_toggle_interrupts() argument
172 struct amdgpu_ih_ring *ih[] = {&adev->irq.ih, &adev->irq.ih1}; in ih_v6_1_toggle_interrupts()
177 if (ih[i]->ring_size) { in ih_v6_1_toggle_interrupts()
178 r = ih_v6_1_toggle_ring_interrupts(adev, ih[i], enable); in ih_v6_1_toggle_interrupts()
187 static uint32_t ih_v6_1_rb_cntl(struct amdgpu_ih_ring *ih, uint32_t ih_rb_cntl) in ih_v6_1_rb_cntl()
189 int rb_bufsz = order_base_2(ih->ring_size / 4); in ih_v6_1_rb_cntl()
192 MC_SPACE, ih->use_bus_addr ? 2 : 4); in ih_v6_1_rb_cntl()
210 static uint32_t ih_v6_1_doorbell_rptr(struct amdgpu_ih_ring *ih) in ih_v6_1_doorbell_rptr()
214 if (ih->use_doorbell) { in ih_v6_1_doorbell_rptr()
217 ih->doorbell_index); in ih_v6_1_doorbell_rptr()
220 ENABLE, 1); in ih_v6_1_doorbell_rptr()
224 ENABLE, 0); in ih_v6_1_doorbell_rptr()
230 * ih_v6_1_enable_ring - enable an ih ring buffer
235 * Enable an ih ring buffer (IH_V6_0)
237 static int ih_v6_1_enable_ring(struct amdgpu_device *adev, in ih_v6_1_enable_ring()
243 ih_regs = &ih->ih_regs; in ih_v6_1_enable_ring()
245 /* Ring Buffer base. [39:8] of 40-bit address of the beginning of the ring buffer*/ in ih_v6_1_enable_ring()
246 WREG32(ih_regs->ih_rb_base, ih->gpu_addr >> 8); in ih_v6_1_enable_ring()
247 WREG32(ih_regs->ih_rb_base_hi, (ih->gpu_addr >> 40) & 0xff); in ih_v6_1_enable_ring()
249 tmp = RREG32(ih_regs->ih_rb_cntl); in ih_v6_1_enable_ring()
251 if (ih == &adev->irq.ih) in ih_v6_1_enable_ring()
252 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, RPTR_REARM, !!adev->irq.msi_enabled); in ih_v6_1_enable_ring()
253 if (ih == &adev->irq.ih1) { in ih_v6_1_enable_ring()
259 if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp)) { in ih_v6_1_enable_ring()
261 return -ETIMEDOUT; in ih_v6_1_enable_ring()
264 WREG32(ih_regs->ih_rb_cntl, tmp); in ih_v6_1_enable_ring()
267 if (ih == &adev->irq.ih) { in ih_v6_1_enable_ring()
269 WREG32(ih_regs->ih_rb_wptr_addr_lo, lower_32_bits(ih->wptr_addr)); in ih_v6_1_enable_ring()
270 WREG32(ih_regs->ih_rb_wptr_addr_hi, upper_32_bits(ih->wptr_addr) & 0xFFFF); in ih_v6_1_enable_ring()
274 WREG32(ih_regs->ih_rb_wptr, 0); in ih_v6_1_enable_ring()
275 WREG32(ih_regs->ih_rb_rptr, 0); in ih_v6_1_enable_ring()
277 WREG32(ih_regs->ih_doorbell_rptr, ih_v6_1_doorbell_rptr(ih)); in ih_v6_1_enable_ring()
283 * ih_v6_1_irq_init - init and enable the interrupt ring
288 * enable the RLC, disable interrupts, enable the IH
289 * ring buffer and enable it.
293 static int ih_v6_1_irq_init(struct amdgpu_device *adev) in ih_v6_1_irq_init()
295 struct amdgpu_ih_ring *ih[] = {&adev->irq.ih, &adev->irq.ih1}; in ih_v6_1_irq_init()
306 adev->nbio.funcs->ih_control(adev); in ih_v6_1_irq_init()
308 if (unlikely((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) || in ih_v6_1_irq_init()
309 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO))) { in ih_v6_1_irq_init()
310 if (ih[0]->use_bus_addr) { in ih_v6_1_irq_init()
319 if (ih[i]->ring_size) { in ih_v6_1_irq_init()
327 adev->nbio.funcs->ih_doorbell_range(adev, ih[0]->use_doorbell, in ih_v6_1_irq_init()
328 ih[0]->doorbell_index); in ih_v6_1_irq_init()
350 if (adev->irq.ih1.ring_size) { in ih_v6_1_irq_init()
364 pci_set_master(adev->pdev); in ih_v6_1_irq_init()
366 /* enable interrupts */ in ih_v6_1_irq_init()
370 /* enable wptr force update for self int */ in ih_v6_1_irq_init()
373 if (adev->irq.ih_soft.ring_size) in ih_v6_1_irq_init()
374 adev->irq.ih_soft.enabled = true; in ih_v6_1_irq_init()
380 * ih_v6_1_irq_disable - disable interrupts
386 static void ih_v6_1_irq_disable(struct amdgpu_device *adev) in ih_v6_1_irq_disable()
396 * ih_v6_1_get_wptr - get the IH ring buffer wptr
406 static u32 ih_v6_1_get_wptr(struct amdgpu_device *adev, in ih_v6_1_get_wptr()
412 wptr = le32_to_cpu(*ih->wptr_cpu); in ih_v6_1_get_wptr()
413 ih_regs = &ih->ih_regs; in ih_v6_1_get_wptr()
418 wptr = RREG32_NO_KIQ(ih_regs->ih_rb_wptr); in ih_v6_1_get_wptr()
427 tmp = (wptr + 32) & ih->ptr_mask; in ih_v6_1_get_wptr()
428 dev_warn(adev->dev, "IH ring buffer overflow " in ih_v6_1_get_wptr()
430 wptr, ih->rptr, tmp); in ih_v6_1_get_wptr()
431 ih->rptr = tmp; in ih_v6_1_get_wptr()
433 tmp = RREG32_NO_KIQ(ih_regs->ih_rb_cntl); in ih_v6_1_get_wptr()
435 WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); in ih_v6_1_get_wptr()
441 WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); in ih_v6_1_get_wptr()
444 return (wptr & ih->ptr_mask); in ih_v6_1_get_wptr()
448 * ih_v6_1_irq_rearm - rearm IRQ if lost
454 static void ih_v6_1_irq_rearm(struct amdgpu_device *adev, in ih_v6_1_irq_rearm()
461 ih_regs = &ih->ih_regs; in ih_v6_1_irq_rearm()
463 /* Rearm IRQ / re-write doorbell if doorbell write is lost */ in ih_v6_1_irq_rearm()
465 v = RREG32_NO_KIQ(ih_regs->ih_rb_rptr); in ih_v6_1_irq_rearm()
466 if ((v < ih->ring_size) && (v != ih->rptr)) in ih_v6_1_irq_rearm()
467 WDOORBELL32(ih->doorbell_index, ih->rptr); in ih_v6_1_irq_rearm()
474 * ih_v6_1_set_rptr - set the IH ring buffer rptr
481 static void ih_v6_1_set_rptr(struct amdgpu_device *adev, in ih_v6_1_set_rptr()
486 if (ih->use_doorbell) { in ih_v6_1_set_rptr()
488 *ih->rptr_cpu = ih->rptr; in ih_v6_1_set_rptr()
489 WDOORBELL32(ih->doorbell_index, ih->rptr); in ih_v6_1_set_rptr()
494 ih_regs = &ih->ih_regs; in ih_v6_1_set_rptr()
495 WREG32(ih_regs->ih_rb_rptr, ih->rptr); in ih_v6_1_set_rptr()
500 * ih_v6_1_self_irq - dispatch work for ring 1
508 static int ih_v6_1_self_irq(struct amdgpu_device *adev, in ih_v6_1_self_irq()
512 uint32_t wptr = cpu_to_le32(entry->src_data[0]); in ih_v6_1_self_irq()
514 switch (entry->ring_id) { in ih_v6_1_self_irq()
516 *adev->irq.ih1.wptr_cpu = wptr; in ih_v6_1_self_irq()
517 schedule_work(&adev->irq.ih1_work); in ih_v6_1_self_irq()
525 static const struct amdgpu_irq_src_funcs ih_v6_1_self_irq_funcs = {
529 static void ih_v6_1_set_self_irq_funcs(struct amdgpu_device *adev) in ih_v6_1_set_self_irq_funcs()
531 adev->irq.self_irq.num_types = 0; in ih_v6_1_set_self_irq_funcs()
532 adev->irq.self_irq.funcs = &ih_v6_1_self_irq_funcs; in ih_v6_1_set_self_irq_funcs()
535 static int ih_v6_1_early_init(void *handle) in ih_v6_1_early_init()
550 static int ih_v6_1_sw_init(void *handle) in ih_v6_1_sw_init()
557 &adev->irq.self_irq); in ih_v6_1_sw_init()
566 (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) ? false : true; in ih_v6_1_sw_init()
567 r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 256 * 1024, use_bus_addr); in ih_v6_1_sw_init()
571 adev->irq.ih.use_doorbell = true; in ih_v6_1_sw_init()
572 adev->irq.ih.doorbell_index = adev->doorbell_index.ih << 1; in ih_v6_1_sw_init()
574 if (!(adev->flags & AMD_IS_APU)) { in ih_v6_1_sw_init()
575 r = amdgpu_ih_ring_init(adev, &adev->irq.ih1, IH_RING_SIZE, in ih_v6_1_sw_init()
580 adev->irq.ih1.use_doorbell = true; in ih_v6_1_sw_init()
581 adev->irq.ih1.doorbell_index = (adev->doorbell_index.ih + 1) << 1; in ih_v6_1_sw_init()
587 r = amdgpu_ih_ring_init(adev, &adev->irq.ih_soft, PAGE_SIZE, true); in ih_v6_1_sw_init()
596 static int ih_v6_1_sw_fini(void *handle) in ih_v6_1_sw_fini()
605 static int ih_v6_1_hw_init(void *handle) in ih_v6_1_hw_init()
617 static int ih_v6_1_hw_fini(void *handle) in ih_v6_1_hw_fini()
626 static int ih_v6_1_suspend(void *handle) in ih_v6_1_suspend()
633 static int ih_v6_1_resume(void *handle) in ih_v6_1_resume()
640 static bool ih_v6_1_is_idle(void *handle) in ih_v6_1_is_idle()
646 static int ih_v6_1_wait_for_idle(void *handle) in ih_v6_1_wait_for_idle()
649 return -ETIMEDOUT; in ih_v6_1_wait_for_idle()
652 static int ih_v6_1_soft_reset(void *handle) in ih_v6_1_soft_reset()
658 static void ih_v6_1_update_clockgating_state(struct amdgpu_device *adev, in ih_v6_1_update_clockgating_state()
659 bool enable) in ih_v6_1_update_clockgating_state() argument
663 if (adev->cg_flags & AMD_CG_SUPPORT_IH_CG) { in ih_v6_1_update_clockgating_state()
665 field_val = enable ? 0 : 1; in ih_v6_1_update_clockgating_state()
683 static int ih_v6_1_set_clockgating_state(void *handle, in ih_v6_1_set_clockgating_state()
693 static void ih_v6_1_update_ih_mem_power_gating(struct amdgpu_device *adev, in ih_v6_1_update_ih_mem_power_gating()
694 bool enable) in ih_v6_1_update_ih_mem_power_gating() argument
705 if (enable) { in ih_v6_1_update_ih_mem_power_gating()
720 /* re-enable power cntl */ in ih_v6_1_update_ih_mem_power_gating()
738 /* re-enable power cntl*/ in ih_v6_1_update_ih_mem_power_gating()
746 static int ih_v6_1_set_powergating_state(void *handle, in ih_v6_1_set_powergating_state()
750 bool enable = (state == AMD_PG_STATE_GATE); in ih_v6_1_set_powergating_state() local
752 if (adev->pg_flags & AMD_PG_SUPPORT_IH_SRAM_PG) in ih_v6_1_set_powergating_state()
753 ih_v6_1_update_ih_mem_power_gating(adev, enable); in ih_v6_1_set_powergating_state()
758 static void ih_v6_1_get_clockgating_state(void *handle, u64 *flags) in ih_v6_1_get_clockgating_state()
768 static const struct amd_ip_funcs ih_v6_1_ip_funcs = {
788 static const struct amdgpu_ih_funcs ih_v6_1_funcs = {
795 static void ih_v6_1_set_interrupt_funcs(struct amdgpu_device *adev) in ih_v6_1_set_interrupt_funcs()
797 adev->irq.ih_funcs = &ih_v6_1_funcs; in ih_v6_1_set_interrupt_funcs()