Skip to content

Commit 26a4463

Browse files
vsyrjalaAndi Shyti
authored andcommitted
drm/i915: Use REG_BIT() & co. for gen9+ timestamp freq registers
Convert the gen9+ timestamo frequency related registers to the modern REG_BIT()/etc. style. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250211231941.22769-12-ville.syrjala@linux.intel.com
1 parent 4cdaba1 commit 26a4463

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ static u32 gen11_get_crystal_clock_freq(struct intel_uncore *uncore,
3535
u32 f24_mhz = 24000000;
3636
u32 f25_mhz = 25000000;
3737
u32 f38_4_mhz = 38400000;
38-
u32 crystal_clock =
39-
(rpm_config_reg & GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >>
40-
GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT;
38+
u32 crystal_clock = rpm_config_reg & GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK;
4139

4240
switch (crystal_clock) {
4341
case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ:
@@ -80,8 +78,7 @@ static u32 gen11_read_clock_frequency(struct intel_uncore *uncore)
8078
* register increments from this frequency (it might
8179
* increment only every few clock cycle).
8280
*/
83-
freq >>= 3 - ((c0 & GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>
84-
GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT);
81+
freq >>= 3 - REG_FIELD_GET(GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK, c0);
8582
}
8683

8784
return freq;
@@ -102,8 +99,7 @@ static u32 gen9_read_clock_frequency(struct intel_uncore *uncore)
10299
* register increments from this frequency (it might
103100
* increment only every few clock cycle).
104101
*/
105-
freq >>= 3 - ((ctc_reg & CTC_SHIFT_PARAMETER_MASK) >>
106-
CTC_SHIFT_PARAMETER_SHIFT);
102+
freq >>= 3 - REG_FIELD_GET(CTC_SHIFT_PARAMETER_MASK, ctc_reg);
107103
}
108104

109105
return freq;

drivers/gpu/drm/i915/gt/intel_gt_regs.h

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,15 @@
3030

3131
/* RPM unit config (Gen8+) */
3232
#define RPM_CONFIG0 _MMIO(0xd00)
33-
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT 3
34-
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK (1 << GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT)
35-
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ 0
36-
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ 1
37-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT 3
38-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK (0x7 << GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT)
39-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ 0
40-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ 1
41-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_38_4_MHZ 2
42-
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_25_MHZ 3
43-
#define GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT 1
44-
#define GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK (0x3 << GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT)
33+
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK REG_BIT(3)
34+
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ REG_FIELD_PREP(GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 0)
35+
#define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ REG_FIELD_PREP(GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 1)
36+
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK REG_GENMASK(5, 3)
37+
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ REG_FIELD_PREP(GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 0)
38+
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ REG_FIELD_PREP(GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 1)
39+
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_38_4_MHZ REG_FIELD_PREP(GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 2)
40+
#define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_25_MHZ REG_FIELD_PREP(GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK, 3)
41+
#define GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK REG_GENMASK(2, 1)
4542

4643
#define RPM_CONFIG1 _MMIO(0xd04)
4744
#define GEN10_GT_NOA_ENABLE (1 << 9)
@@ -882,11 +879,10 @@
882879

883880
/* GPM unit config (Gen9+) */
884881
#define CTC_MODE _MMIO(0xa26c)
885-
#define CTC_SOURCE_PARAMETER_MASK 1
886-
#define CTC_SOURCE_CRYSTAL_CLOCK 0
887-
#define CTC_SOURCE_DIVIDE_LOGIC 1
888-
#define CTC_SHIFT_PARAMETER_SHIFT 1
889-
#define CTC_SHIFT_PARAMETER_MASK (0x3 << CTC_SHIFT_PARAMETER_SHIFT)
882+
#define CTC_SOURCE_PARAMETER_MASK REG_BIT(0)
883+
#define CTC_SOURCE_CRYSTAL_CLOCK REG_FIELD_PREP(CTC_SOURCE_PARAMETER_MASK, 0)
884+
#define CTC_SOURCE_DIVIDE_LOGIC REG_FIELD_PREP(CTC_SOURCE_PARAMETER_MASK, 1)
885+
#define CTC_SHIFT_PARAMETER_MASK REG_GENMASK(2, 1)
890886

891887
/* GPM MSG_IDLE */
892888
#define MSG_IDLE_CS _MMIO(0x8000)

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,15 +1285,12 @@ static void guc_update_engine_gt_clks(struct intel_engine_cs *engine)
12851285
static u32 gpm_timestamp_shift(struct intel_gt *gt)
12861286
{
12871287
intel_wakeref_t wakeref;
1288-
u32 reg, shift;
1288+
u32 reg;
12891289

12901290
with_intel_runtime_pm(gt->uncore->rpm, wakeref)
12911291
reg = intel_uncore_read(gt->uncore, RPM_CONFIG0);
12921292

1293-
shift = (reg & GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>
1294-
GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT;
1295-
1296-
return 3 - shift;
1293+
return 3 - REG_FIELD_GET(GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK, reg);
12971294
}
12981295

12991296
static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)

0 commit comments

Comments
 (0)