drm/dp: Use AUX constants from specification

The current values seem to be defined in a format that's specific to the
i915, gma500 and radeon drivers. To make this more generally useful, use
the values as defined in the specification.

While at it, prefix the constants with DP_ for improved namespacing.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Thierry Reding 2013-12-16 17:01:29 +01:00 committed by Dave Airlie
parent 05f51722a1
commit 6b27f7f0e9
4 changed files with 71 additions and 67 deletions

View File

@ -483,7 +483,7 @@ cdv_intel_dp_aux_native_write(struct gma_encoder *encoder,
if (send_bytes > 16) if (send_bytes > 16)
return -1; return -1;
msg[0] = AUX_NATIVE_WRITE << 4; msg[0] = DP_AUX_NATIVE_WRITE << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address & 0xff; msg[2] = address & 0xff;
msg[3] = send_bytes - 1; msg[3] = send_bytes - 1;
@ -493,9 +493,10 @@ cdv_intel_dp_aux_native_write(struct gma_encoder *encoder,
ret = cdv_intel_dp_aux_ch(encoder, msg, msg_bytes, &ack, 1); ret = cdv_intel_dp_aux_ch(encoder, msg, msg_bytes, &ack, 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) ack >>= 4;
if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
break; break;
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(100); udelay(100);
else else
return -EIO; return -EIO;
@ -523,7 +524,7 @@ cdv_intel_dp_aux_native_read(struct gma_encoder *encoder,
uint8_t ack; uint8_t ack;
int ret; int ret;
msg[0] = AUX_NATIVE_READ << 4; msg[0] = DP_AUX_NATIVE_READ << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address & 0xff; msg[2] = address & 0xff;
msg[3] = recv_bytes - 1; msg[3] = recv_bytes - 1;
@ -538,12 +539,12 @@ cdv_intel_dp_aux_native_read(struct gma_encoder *encoder,
return -EPROTO; return -EPROTO;
if (ret < 0) if (ret < 0)
return ret; return ret;
ack = reply[0]; ack = reply[0] >> 4;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) { if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK) {
memcpy(recv, reply + 1, ret - 1); memcpy(recv, reply + 1, ret - 1);
return ret - 1; return ret - 1;
} }
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(100); udelay(100);
else else
return -EIO; return -EIO;
@ -569,12 +570,12 @@ cdv_intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
/* Set up the command byte */ /* Set up the command byte */
if (mode & MODE_I2C_READ) if (mode & MODE_I2C_READ)
msg[0] = AUX_I2C_READ << 4; msg[0] = DP_AUX_I2C_READ << 4;
else else
msg[0] = AUX_I2C_WRITE << 4; msg[0] = DP_AUX_I2C_WRITE << 4;
if (!(mode & MODE_I2C_STOP)) if (!(mode & MODE_I2C_STOP))
msg[0] |= AUX_I2C_MOT << 4; msg[0] |= DP_AUX_I2C_MOT << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address; msg[2] = address;
@ -606,16 +607,16 @@ cdv_intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
return ret; return ret;
} }
switch (reply[0] & AUX_NATIVE_REPLY_MASK) { switch ((reply[0] >> 4) & DP_AUX_NATIVE_REPLY_MASK) {
case AUX_NATIVE_REPLY_ACK: case DP_AUX_NATIVE_REPLY_ACK:
/* I2C-over-AUX Reply field is only valid /* I2C-over-AUX Reply field is only valid
* when paired with AUX ACK. * when paired with AUX ACK.
*/ */
break; break;
case AUX_NATIVE_REPLY_NACK: case DP_AUX_NATIVE_REPLY_NACK:
DRM_DEBUG_KMS("aux_ch native nack\n"); DRM_DEBUG_KMS("aux_ch native nack\n");
return -EREMOTEIO; return -EREMOTEIO;
case AUX_NATIVE_REPLY_DEFER: case DP_AUX_NATIVE_REPLY_DEFER:
udelay(100); udelay(100);
continue; continue;
default: default:
@ -624,16 +625,16 @@ cdv_intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
return -EREMOTEIO; return -EREMOTEIO;
} }
switch (reply[0] & AUX_I2C_REPLY_MASK) { switch ((reply[0] >> 4) & DP_AUX_I2C_REPLY_MASK) {
case AUX_I2C_REPLY_ACK: case DP_AUX_I2C_REPLY_ACK:
if (mode == MODE_I2C_READ) { if (mode == MODE_I2C_READ) {
*read_byte = reply[1]; *read_byte = reply[1];
} }
return reply_bytes - 1; return reply_bytes - 1;
case AUX_I2C_REPLY_NACK: case DP_AUX_I2C_REPLY_NACK:
DRM_DEBUG_KMS("aux_i2c nack\n"); DRM_DEBUG_KMS("aux_i2c nack\n");
return -EREMOTEIO; return -EREMOTEIO;
case AUX_I2C_REPLY_DEFER: case DP_AUX_I2C_REPLY_DEFER:
DRM_DEBUG_KMS("aux_i2c defer\n"); DRM_DEBUG_KMS("aux_i2c defer\n");
udelay(100); udelay(100);
break; break;

View File

@ -542,7 +542,7 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
return -E2BIG; return -E2BIG;
intel_dp_check_edp(intel_dp); intel_dp_check_edp(intel_dp);
msg[0] = AUX_NATIVE_WRITE << 4; msg[0] = DP_AUX_NATIVE_WRITE << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address & 0xff; msg[2] = address & 0xff;
msg[3] = send_bytes - 1; msg[3] = send_bytes - 1;
@ -552,9 +552,10 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1); ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) ack >>= 4;
if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
break; break;
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(100); udelay(100);
else else
return -EIO; return -EIO;
@ -586,7 +587,7 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
return -E2BIG; return -E2BIG;
intel_dp_check_edp(intel_dp); intel_dp_check_edp(intel_dp);
msg[0] = AUX_NATIVE_READ << 4; msg[0] = DP_AUX_NATIVE_READ << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address & 0xff; msg[2] = address & 0xff;
msg[3] = recv_bytes - 1; msg[3] = recv_bytes - 1;
@ -601,12 +602,12 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
return -EPROTO; return -EPROTO;
if (ret < 0) if (ret < 0)
return ret; return ret;
ack = reply[0]; ack = reply[0] >> 4;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) { if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK) {
memcpy(recv, reply + 1, ret - 1); memcpy(recv, reply + 1, ret - 1);
return ret - 1; return ret - 1;
} }
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(100); udelay(100);
else else
return -EIO; return -EIO;
@ -633,12 +634,12 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
intel_dp_check_edp(intel_dp); intel_dp_check_edp(intel_dp);
/* Set up the command byte */ /* Set up the command byte */
if (mode & MODE_I2C_READ) if (mode & MODE_I2C_READ)
msg[0] = AUX_I2C_READ << 4; msg[0] = DP_AUX_I2C_READ << 4;
else else
msg[0] = AUX_I2C_WRITE << 4; msg[0] = DP_AUX_I2C_WRITE << 4;
if (!(mode & MODE_I2C_STOP)) if (!(mode & MODE_I2C_STOP))
msg[0] |= AUX_I2C_MOT << 4; msg[0] |= DP_AUX_I2C_MOT << 4;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = address; msg[2] = address;
@ -675,17 +676,17 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
goto out; goto out;
} }
switch (reply[0] & AUX_NATIVE_REPLY_MASK) { switch ((reply[0] >> 4) & DP_AUX_NATIVE_REPLY_MASK) {
case AUX_NATIVE_REPLY_ACK: case DP_AUX_NATIVE_REPLY_ACK:
/* I2C-over-AUX Reply field is only valid /* I2C-over-AUX Reply field is only valid
* when paired with AUX ACK. * when paired with AUX ACK.
*/ */
break; break;
case AUX_NATIVE_REPLY_NACK: case DP_AUX_NATIVE_REPLY_NACK:
DRM_DEBUG_KMS("aux_ch native nack\n"); DRM_DEBUG_KMS("aux_ch native nack\n");
ret = -EREMOTEIO; ret = -EREMOTEIO;
goto out; goto out;
case AUX_NATIVE_REPLY_DEFER: case DP_AUX_NATIVE_REPLY_DEFER:
/* /*
* For now, just give more slack to branch devices. We * For now, just give more slack to branch devices. We
* could check the DPCD for I2C bit rate capabilities, * could check the DPCD for I2C bit rate capabilities,
@ -706,18 +707,18 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
goto out; goto out;
} }
switch (reply[0] & AUX_I2C_REPLY_MASK) { switch ((reply[0] >> 4) & DP_AUX_I2C_REPLY_MASK) {
case AUX_I2C_REPLY_ACK: case DP_AUX_I2C_REPLY_ACK:
if (mode == MODE_I2C_READ) { if (mode == MODE_I2C_READ) {
*read_byte = reply[1]; *read_byte = reply[1];
} }
ret = reply_bytes - 1; ret = reply_bytes - 1;
goto out; goto out;
case AUX_I2C_REPLY_NACK: case DP_AUX_I2C_REPLY_NACK:
DRM_DEBUG_KMS("aux_i2c nack\n"); DRM_DEBUG_KMS("aux_i2c nack\n");
ret = -EREMOTEIO; ret = -EREMOTEIO;
goto out; goto out;
case AUX_I2C_REPLY_DEFER: case DP_AUX_I2C_REPLY_DEFER:
DRM_DEBUG_KMS("aux_i2c defer\n"); DRM_DEBUG_KMS("aux_i2c defer\n");
udelay(100); udelay(100);
break; break;

View File

@ -157,7 +157,7 @@ static int radeon_dp_aux_native_write(struct radeon_connector *radeon_connector,
msg[0] = address; msg[0] = address;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = AUX_NATIVE_WRITE << 4; msg[2] = DP_AUX_NATIVE_WRITE << 4;
msg[3] = (msg_bytes << 4) | (send_bytes - 1); msg[3] = (msg_bytes << 4) | (send_bytes - 1);
memcpy(&msg[4], send, send_bytes); memcpy(&msg[4], send, send_bytes);
@ -168,9 +168,10 @@ static int radeon_dp_aux_native_write(struct radeon_connector *radeon_connector,
continue; continue;
else if (ret < 0) else if (ret < 0)
return ret; return ret;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) ack >>= 4;
if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
return send_bytes; return send_bytes;
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(400); udelay(400);
else else
return -EIO; return -EIO;
@ -191,7 +192,7 @@ static int radeon_dp_aux_native_read(struct radeon_connector *radeon_connector,
msg[0] = address; msg[0] = address;
msg[1] = address >> 8; msg[1] = address >> 8;
msg[2] = AUX_NATIVE_READ << 4; msg[2] = DP_AUX_NATIVE_READ << 4;
msg[3] = (msg_bytes << 4) | (recv_bytes - 1); msg[3] = (msg_bytes << 4) | (recv_bytes - 1);
for (retry = 0; retry < 4; retry++) { for (retry = 0; retry < 4; retry++) {
@ -201,9 +202,10 @@ static int radeon_dp_aux_native_read(struct radeon_connector *radeon_connector,
continue; continue;
else if (ret < 0) else if (ret < 0)
return ret; return ret;
if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) ack >>= 4;
if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
return ret; return ret;
else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
udelay(400); udelay(400);
else if (ret == 0) else if (ret == 0)
return -EPROTO; return -EPROTO;
@ -246,12 +248,12 @@ int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
/* Set up the command byte */ /* Set up the command byte */
if (mode & MODE_I2C_READ) if (mode & MODE_I2C_READ)
msg[2] = AUX_I2C_READ << 4; msg[2] = DP_AUX_I2C_READ << 4;
else else
msg[2] = AUX_I2C_WRITE << 4; msg[2] = DP_AUX_I2C_WRITE << 4;
if (!(mode & MODE_I2C_STOP)) if (!(mode & MODE_I2C_STOP))
msg[2] |= AUX_I2C_MOT << 4; msg[2] |= DP_AUX_I2C_MOT << 4;
msg[0] = address; msg[0] = address;
msg[1] = address >> 8; msg[1] = address >> 8;
@ -282,16 +284,16 @@ int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
return ret; return ret;
} }
switch (ack & AUX_NATIVE_REPLY_MASK) { switch ((ack >> 4) & DP_AUX_NATIVE_REPLY_MASK) {
case AUX_NATIVE_REPLY_ACK: case DP_AUX_NATIVE_REPLY_ACK:
/* I2C-over-AUX Reply field is only valid /* I2C-over-AUX Reply field is only valid
* when paired with AUX ACK. * when paired with AUX ACK.
*/ */
break; break;
case AUX_NATIVE_REPLY_NACK: case DP_AUX_NATIVE_REPLY_NACK:
DRM_DEBUG_KMS("aux_ch native nack\n"); DRM_DEBUG_KMS("aux_ch native nack\n");
return -EREMOTEIO; return -EREMOTEIO;
case AUX_NATIVE_REPLY_DEFER: case DP_AUX_NATIVE_REPLY_DEFER:
DRM_DEBUG_KMS("aux_ch native defer\n"); DRM_DEBUG_KMS("aux_ch native defer\n");
udelay(400); udelay(400);
continue; continue;
@ -300,15 +302,15 @@ int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
return -EREMOTEIO; return -EREMOTEIO;
} }
switch (ack & AUX_I2C_REPLY_MASK) { switch ((ack >> 4) & DP_AUX_I2C_REPLY_MASK) {
case AUX_I2C_REPLY_ACK: case DP_AUX_I2C_REPLY_ACK:
if (mode == MODE_I2C_READ) if (mode == MODE_I2C_READ)
*read_byte = reply[0]; *read_byte = reply[0];
return ret; return ret;
case AUX_I2C_REPLY_NACK: case DP_AUX_I2C_REPLY_NACK:
DRM_DEBUG_KMS("aux_i2c nack\n"); DRM_DEBUG_KMS("aux_i2c nack\n");
return -EREMOTEIO; return -EREMOTEIO;
case AUX_I2C_REPLY_DEFER: case DP_AUX_I2C_REPLY_DEFER:
DRM_DEBUG_KMS("aux_i2c defer\n"); DRM_DEBUG_KMS("aux_i2c defer\n");
udelay(400); udelay(400);
break; break;

View File

@ -41,22 +41,22 @@
* 1.2 formally includes both eDP and DPI definitions. * 1.2 formally includes both eDP and DPI definitions.
*/ */
#define AUX_NATIVE_WRITE 0x8 #define DP_AUX_I2C_WRITE 0x0
#define AUX_NATIVE_READ 0x9 #define DP_AUX_I2C_READ 0x1
#define AUX_I2C_WRITE 0x0 #define DP_AUX_I2C_STATUS 0x2
#define AUX_I2C_READ 0x1 #define DP_AUX_I2C_MOT 0x4
#define AUX_I2C_STATUS 0x2 #define DP_AUX_NATIVE_WRITE 0x8
#define AUX_I2C_MOT 0x4 #define DP_AUX_NATIVE_READ 0x9
#define AUX_NATIVE_REPLY_ACK (0x0 << 4) #define DP_AUX_NATIVE_REPLY_ACK (0x0 << 0)
#define AUX_NATIVE_REPLY_NACK (0x1 << 4) #define DP_AUX_NATIVE_REPLY_NACK (0x1 << 0)
#define AUX_NATIVE_REPLY_DEFER (0x2 << 4) #define DP_AUX_NATIVE_REPLY_DEFER (0x2 << 0)
#define AUX_NATIVE_REPLY_MASK (0x3 << 4) #define DP_AUX_NATIVE_REPLY_MASK (0x3 << 0)
#define AUX_I2C_REPLY_ACK (0x0 << 6) #define DP_AUX_I2C_REPLY_ACK (0x0 << 2)
#define AUX_I2C_REPLY_NACK (0x1 << 6) #define DP_AUX_I2C_REPLY_NACK (0x1 << 2)
#define AUX_I2C_REPLY_DEFER (0x2 << 6) #define DP_AUX_I2C_REPLY_DEFER (0x2 << 2)
#define AUX_I2C_REPLY_MASK (0x3 << 6) #define DP_AUX_I2C_REPLY_MASK (0x3 << 2)
/* AUX CH addresses */ /* AUX CH addresses */
/* DPCD */ /* DPCD */