Skip to content

Commit 4904fa6

Browse files
committed
drm/i915: Nuke aux regs from intel_dp
Just store function pointers that give us the correct register offsets instead of storing the register offsets themselves. Slightly less efficient perhaps but saves a few bytes and better matches how we do things elsewhere. v2: Keep a local array of data registers (Chris) Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180222181036.15251-3-ville.syrjala@linux.intel.com
1 parent bdabdb6 commit 4904fa6

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

drivers/gpu/drm/i915/intel_dp.c

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static uint32_t
934934
intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq)
935935
{
936936
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
937-
i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg;
937+
i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg(intel_dp);
938938
uint32_t status;
939939
bool done;
940940

@@ -1068,14 +1068,18 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
10681068
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
10691069
struct drm_i915_private *dev_priv =
10701070
to_i915(intel_dig_port->base.base.dev);
1071-
i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg;
1071+
i915_reg_t ch_ctl, ch_data[5];
10721072
uint32_t aux_clock_divider;
10731073
int i, ret, recv_bytes;
10741074
uint32_t status;
10751075
int try, clock = 0;
10761076
bool has_aux_irq = HAS_AUX_IRQ(dev_priv);
10771077
bool vdd;
10781078

1079+
ch_ctl = intel_dp->aux_ch_ctl_reg(intel_dp);
1080+
for (i = 0; i < ARRAY_SIZE(ch_data); i++)
1081+
ch_data[i] = intel_dp->aux_ch_data_reg(intel_dp, i);
1082+
10791083
pps_lock(intel_dp);
10801084

10811085
/*
@@ -1132,7 +1136,7 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
11321136
for (try = 0; try < 5; try++) {
11331137
/* Load the send data into the aux channel data registers */
11341138
for (i = 0; i < send_bytes; i += 4)
1135-
I915_WRITE(intel_dp->aux_ch_data_reg[i >> 2],
1139+
I915_WRITE(ch_data[i >> 2],
11361140
intel_dp_pack_aux(send + i,
11371141
send_bytes - i));
11381142

@@ -1217,7 +1221,7 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
12171221
recv_bytes = recv_size;
12181222

12191223
for (i = 0; i < recv_bytes; i += 4)
1220-
intel_dp_unpack_aux(I915_READ(intel_dp->aux_ch_data_reg[i >> 2]),
1224+
intel_dp_unpack_aux(I915_READ(ch_data[i >> 2]),
12211225
recv + i, recv_bytes - i);
12221226

12231227
ret = recv_bytes;
@@ -1372,9 +1376,11 @@ intel_aux_power_domain(struct intel_dp *intel_dp)
13721376
}
13731377
}
13741378

1375-
static i915_reg_t g4x_aux_ctl_reg(struct drm_i915_private *dev_priv,
1376-
enum aux_ch aux_ch)
1379+
static i915_reg_t g4x_aux_ctl_reg(struct intel_dp *intel_dp)
13771380
{
1381+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1382+
enum aux_ch aux_ch = intel_dp->aux_ch;
1383+
13781384
switch (aux_ch) {
13791385
case AUX_CH_B:
13801386
case AUX_CH_C:
@@ -1386,9 +1392,11 @@ static i915_reg_t g4x_aux_ctl_reg(struct drm_i915_private *dev_priv,
13861392
}
13871393
}
13881394

1389-
static i915_reg_t g4x_aux_data_reg(struct drm_i915_private *dev_priv,
1390-
enum aux_ch aux_ch, int index)
1395+
static i915_reg_t g4x_aux_data_reg(struct intel_dp *intel_dp, int index)
13911396
{
1397+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1398+
enum aux_ch aux_ch = intel_dp->aux_ch;
1399+
13921400
switch (aux_ch) {
13931401
case AUX_CH_B:
13941402
case AUX_CH_C:
@@ -1400,9 +1408,11 @@ static i915_reg_t g4x_aux_data_reg(struct drm_i915_private *dev_priv,
14001408
}
14011409
}
14021410

1403-
static i915_reg_t ilk_aux_ctl_reg(struct drm_i915_private *dev_priv,
1404-
enum aux_ch aux_ch)
1411+
static i915_reg_t ilk_aux_ctl_reg(struct intel_dp *intel_dp)
14051412
{
1413+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1414+
enum aux_ch aux_ch = intel_dp->aux_ch;
1415+
14061416
switch (aux_ch) {
14071417
case AUX_CH_A:
14081418
return DP_AUX_CH_CTL(aux_ch);
@@ -1416,9 +1426,11 @@ static i915_reg_t ilk_aux_ctl_reg(struct drm_i915_private *dev_priv,
14161426
}
14171427
}
14181428

1419-
static i915_reg_t ilk_aux_data_reg(struct drm_i915_private *dev_priv,
1420-
enum aux_ch aux_ch, int index)
1429+
static i915_reg_t ilk_aux_data_reg(struct intel_dp *intel_dp, int index)
14211430
{
1431+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1432+
enum aux_ch aux_ch = intel_dp->aux_ch;
1433+
14221434
switch (aux_ch) {
14231435
case AUX_CH_A:
14241436
return DP_AUX_CH_DATA(aux_ch, index);
@@ -1432,9 +1444,11 @@ static i915_reg_t ilk_aux_data_reg(struct drm_i915_private *dev_priv,
14321444
}
14331445
}
14341446

1435-
static i915_reg_t skl_aux_ctl_reg(struct drm_i915_private *dev_priv,
1436-
enum aux_ch aux_ch)
1447+
static i915_reg_t skl_aux_ctl_reg(struct intel_dp *intel_dp)
14371448
{
1449+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1450+
enum aux_ch aux_ch = intel_dp->aux_ch;
1451+
14381452
switch (aux_ch) {
14391453
case AUX_CH_A:
14401454
case AUX_CH_B:
@@ -1448,9 +1462,11 @@ static i915_reg_t skl_aux_ctl_reg(struct drm_i915_private *dev_priv,
14481462
}
14491463
}
14501464

1451-
static i915_reg_t skl_aux_data_reg(struct drm_i915_private *dev_priv,
1452-
enum aux_ch aux_ch, int index)
1465+
static i915_reg_t skl_aux_data_reg(struct intel_dp *intel_dp, int index)
14531466
{
1467+
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1468+
enum aux_ch aux_ch = intel_dp->aux_ch;
1469+
14541470
switch (aux_ch) {
14551471
case AUX_CH_A:
14561472
case AUX_CH_B:
@@ -1464,37 +1480,20 @@ static i915_reg_t skl_aux_data_reg(struct drm_i915_private *dev_priv,
14641480
}
14651481
}
14661482

1467-
static i915_reg_t intel_aux_ctl_reg(struct drm_i915_private *dev_priv,
1468-
enum aux_ch aux_ch)
1469-
{
1470-
if (INTEL_GEN(dev_priv) >= 9)
1471-
return skl_aux_ctl_reg(dev_priv, aux_ch);
1472-
else if (HAS_PCH_SPLIT(dev_priv))
1473-
return ilk_aux_ctl_reg(dev_priv, aux_ch);
1474-
else
1475-
return g4x_aux_ctl_reg(dev_priv, aux_ch);
1476-
}
1477-
1478-
static i915_reg_t intel_aux_data_reg(struct drm_i915_private *dev_priv,
1479-
enum aux_ch aux_ch, int index)
1480-
{
1481-
if (INTEL_GEN(dev_priv) >= 9)
1482-
return skl_aux_data_reg(dev_priv, aux_ch, index);
1483-
else if (HAS_PCH_SPLIT(dev_priv))
1484-
return ilk_aux_data_reg(dev_priv, aux_ch, index);
1485-
else
1486-
return g4x_aux_data_reg(dev_priv, aux_ch, index);
1487-
}
1488-
14891483
static void intel_aux_reg_init(struct intel_dp *intel_dp)
14901484
{
14911485
struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
1492-
enum aux_ch aux_ch = intel_dp->aux_ch;
1493-
int i;
14941486

1495-
intel_dp->aux_ch_ctl_reg = intel_aux_ctl_reg(dev_priv, aux_ch);
1496-
for (i = 0; i < ARRAY_SIZE(intel_dp->aux_ch_data_reg); i++)
1497-
intel_dp->aux_ch_data_reg[i] = intel_aux_data_reg(dev_priv, aux_ch, i);
1487+
if (INTEL_GEN(dev_priv) >= 9) {
1488+
intel_dp->aux_ch_ctl_reg = skl_aux_ctl_reg;
1489+
intel_dp->aux_ch_data_reg = skl_aux_data_reg;
1490+
} else if (HAS_PCH_SPLIT(dev_priv)) {
1491+
intel_dp->aux_ch_ctl_reg = ilk_aux_ctl_reg;
1492+
intel_dp->aux_ch_data_reg = ilk_aux_data_reg;
1493+
} else {
1494+
intel_dp->aux_ch_ctl_reg = g4x_aux_ctl_reg;
1495+
intel_dp->aux_ch_data_reg = g4x_aux_data_reg;
1496+
}
14981497
}
14991498

15001499
static void

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,6 @@ struct intel_dp_compliance {
960960

961961
struct intel_dp {
962962
i915_reg_t output_reg;
963-
i915_reg_t aux_ch_ctl_reg;
964-
i915_reg_t aux_ch_data_reg[5];
965963
uint32_t DP;
966964
int link_rate;
967965
uint8_t lane_count;
@@ -1046,6 +1044,9 @@ struct intel_dp {
10461044
int send_bytes,
10471045
uint32_t aux_clock_divider);
10481046

1047+
i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
1048+
i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
1049+
10491050
/* This is called before a link training is starterd */
10501051
void (*prepare_link_retrain)(struct intel_dp *intel_dp);
10511052

0 commit comments

Comments
 (0)