WIP FPC-III support
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gt / intel_gt_pm_irq.c
blobbabe866126d7c4edf559ab2c5ed85f73c92a925a
1 /*
2 * SPDX-License-Identifier: MIT
4 * Copyright © 2019 Intel Corporation
5 */
7 #include "i915_drv.h"
8 #include "i915_reg.h"
9 #include "intel_gt.h"
10 #include "intel_gt_irq.h"
11 #include "intel_gt_pm_irq.h"
13 static void write_pm_imr(struct intel_gt *gt)
15 struct drm_i915_private *i915 = gt->i915;
16 struct intel_uncore *uncore = gt->uncore;
17 u32 mask = gt->pm_imr;
18 i915_reg_t reg;
20 if (INTEL_GEN(i915) >= 11) {
21 reg = GEN11_GPM_WGBOXPERF_INTR_MASK;
22 mask <<= 16; /* pm is in upper half */
23 } else if (INTEL_GEN(i915) >= 8) {
24 reg = GEN8_GT_IMR(2);
25 } else {
26 reg = GEN6_PMIMR;
29 intel_uncore_write(uncore, reg, mask);
32 static void gen6_gt_pm_update_irq(struct intel_gt *gt,
33 u32 interrupt_mask,
34 u32 enabled_irq_mask)
36 u32 new_val;
38 WARN_ON(enabled_irq_mask & ~interrupt_mask);
40 lockdep_assert_held(&gt->irq_lock);
42 new_val = gt->pm_imr;
43 new_val &= ~interrupt_mask;
44 new_val |= ~enabled_irq_mask & interrupt_mask;
46 if (new_val != gt->pm_imr) {
47 gt->pm_imr = new_val;
48 write_pm_imr(gt);
52 void gen6_gt_pm_unmask_irq(struct intel_gt *gt, u32 mask)
54 gen6_gt_pm_update_irq(gt, mask, mask);
57 void gen6_gt_pm_mask_irq(struct intel_gt *gt, u32 mask)
59 gen6_gt_pm_update_irq(gt, mask, 0);
62 void gen6_gt_pm_reset_iir(struct intel_gt *gt, u32 reset_mask)
64 struct intel_uncore *uncore = gt->uncore;
65 i915_reg_t reg = INTEL_GEN(gt->i915) >= 8 ? GEN8_GT_IIR(2) : GEN6_PMIIR;
67 lockdep_assert_held(&gt->irq_lock);
69 intel_uncore_write(uncore, reg, reset_mask);
70 intel_uncore_write(uncore, reg, reset_mask);
71 intel_uncore_posting_read(uncore, reg);
74 static void write_pm_ier(struct intel_gt *gt)
76 struct drm_i915_private *i915 = gt->i915;
77 struct intel_uncore *uncore = gt->uncore;
78 u32 mask = gt->pm_ier;
79 i915_reg_t reg;
81 if (INTEL_GEN(i915) >= 11) {
82 reg = GEN11_GPM_WGBOXPERF_INTR_ENABLE;
83 mask <<= 16; /* pm is in upper half */
84 } else if (INTEL_GEN(i915) >= 8) {
85 reg = GEN8_GT_IER(2);
86 } else {
87 reg = GEN6_PMIER;
90 intel_uncore_write(uncore, reg, mask);
93 void gen6_gt_pm_enable_irq(struct intel_gt *gt, u32 enable_mask)
95 lockdep_assert_held(&gt->irq_lock);
97 gt->pm_ier |= enable_mask;
98 write_pm_ier(gt);
99 gen6_gt_pm_unmask_irq(gt, enable_mask);
102 void gen6_gt_pm_disable_irq(struct intel_gt *gt, u32 disable_mask)
104 lockdep_assert_held(&gt->irq_lock);
106 gt->pm_ier &= ~disable_mask;
107 gen6_gt_pm_mask_irq(gt, disable_mask);
108 write_pm_ier(gt);