Skip to content

Commit 80e49db

Browse files
committed
drm/i915/power: convert {SKL, ICL}_PW_CTL_IDX_TO_PG() macros to a function
Add pw_ctl_idx_to_pg() helper function to deduplicate the open-coded usage of the {SKL,ICL}_PW_CTL_IDX_TO_PG() macros. Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://lore.kernel.org/r/3aa74825db0b900f93b94aa89d0242a354929b85.1750855148.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent ca09800 commit 80e49db

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/gpu/drm/i915/display/intel_display_power_well.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@
3636

3737
/*
3838
* PG0 is HW controlled, so doesn't have a corresponding power well control knob
39-
* SKL_DISP_PW1_IDX..SKL_DISP_PW2_IDX -> PG1..PG2
40-
*/
41-
#define SKL_PW_CTL_IDX_TO_PG(pw_idx) \
42-
((pw_idx) - SKL_PW_CTL_IDX_PW_1 + SKL_PG1)
43-
/*
44-
* PG0 is HW controlled, so doesn't have a corresponding power well control knob
45-
* ICL_DISP_PW1_IDX..ICL_DISP_PW4_IDX -> PG1..PG4
39+
*
40+
* {ICL,SKL}_DISP_PW1_IDX..{ICL,SKL}_DISP_PW4_IDX -> PG1..PG4
4641
*/
47-
#define ICL_PW_CTL_IDX_TO_PG(pw_idx) \
48-
((pw_idx) - ICL_PW_CTL_IDX_PW_1 + SKL_PG1)
42+
static enum skl_power_gate pw_idx_to_pg(struct intel_display *display, int pw_idx)
43+
{
44+
int pw1_idx = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_PW_1 : SKL_PW_CTL_IDX_PW_1;
45+
46+
return pw_idx - pw1_idx + SKL_PG1;
47+
}
4948

5049
struct i915_power_well_regs {
5150
i915_reg_t bios;
@@ -363,8 +362,7 @@ static void hsw_power_well_enable(struct intel_display *display,
363362
if (power_well->desc->has_fuses) {
364363
enum skl_power_gate pg;
365364

366-
pg = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_TO_PG(pw_idx) :
367-
SKL_PW_CTL_IDX_TO_PG(pw_idx);
365+
pg = pw_idx_to_pg(display, pw_idx);
368366

369367
/* Wa_16013190616:adlp */
370368
if (display->platform.alderlake_p && pg == SKL_PG1)
@@ -388,8 +386,8 @@ static void hsw_power_well_enable(struct intel_display *display,
388386
if (power_well->desc->has_fuses) {
389387
enum skl_power_gate pg;
390388

391-
pg = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_TO_PG(pw_idx) :
392-
SKL_PW_CTL_IDX_TO_PG(pw_idx);
389+
pg = pw_idx_to_pg(display, pw_idx);
390+
393391
gen9_wait_for_power_well_fuses(display, pg);
394392
}
395393

0 commit comments

Comments
 (0)