diff options
| -rw-r--r-- | drivers/gpu/drm/drm_dp_helper.c | 55 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/atombios_dp.c | 140 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/dce6_afmt.c | 14 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_connectors.c | 44 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_display.c | 11 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_drv.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_i2c.c | 60 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_mode.h | 12 | ||||
| -rw-r--r-- | drivers/gpu/drm/tegra/dpaux.c | 44 | ||||
| -rw-r--r-- | drivers/gpu/drm/tegra/dpaux.h | 1 | ||||
| -rw-r--r-- | include/drm/drm_dp_helper.h | 4 |
13 files changed, 152 insertions, 247 deletions
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 27671489477d..4b6e6f3ba0a1 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c | |||
| @@ -577,7 +577,9 @@ static u32 drm_dp_i2c_functionality(struct i2c_adapter *adapter) | |||
| 577 | 577 | ||
| 578 | /* | 578 | /* |
| 579 | * Transfer a single I2C-over-AUX message and handle various error conditions, | 579 | * Transfer a single I2C-over-AUX message and handle various error conditions, |
| 580 | * retrying the transaction as appropriate. | 580 | * retrying the transaction as appropriate. It is assumed that the |
| 581 | * aux->transfer function does not modify anything in the msg other than the | ||
| 582 | * reply field. | ||
| 581 | */ | 583 | */ |
| 582 | static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | 584 | static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) |
| 583 | { | 585 | { |
| @@ -665,11 +667,26 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, | |||
| 665 | { | 667 | { |
| 666 | struct drm_dp_aux *aux = adapter->algo_data; | 668 | struct drm_dp_aux *aux = adapter->algo_data; |
| 667 | unsigned int i, j; | 669 | unsigned int i, j; |
| 670 | struct drm_dp_aux_msg msg; | ||
| 671 | int err = 0; | ||
| 668 | 672 | ||
| 669 | for (i = 0; i < num; i++) { | 673 | memset(&msg, 0, sizeof(msg)); |
| 670 | struct drm_dp_aux_msg msg; | ||
| 671 | int err; | ||
| 672 | 674 | ||
| 675 | for (i = 0; i < num; i++) { | ||
| 676 | msg.address = msgs[i].addr; | ||
| 677 | msg.request = (msgs[i].flags & I2C_M_RD) ? | ||
| 678 | DP_AUX_I2C_READ : | ||
| 679 | DP_AUX_I2C_WRITE; | ||
| 680 | msg.request |= DP_AUX_I2C_MOT; | ||
| 681 | /* Send a bare address packet to start the transaction. | ||
| 682 | * Zero sized messages specify an address only (bare | ||
| 683 | * address) transaction. | ||
| 684 | */ | ||
| 685 | msg.buffer = NULL; | ||
| 686 | msg.size = 0; | ||
| 687 | err = drm_dp_i2c_do_msg(aux, &msg); | ||
| 688 | if (err < 0) | ||
| 689 | break; | ||
| 673 | /* | 690 | /* |
| 674 | * Many hardware implementations support FIFOs larger than a | 691 | * Many hardware implementations support FIFOs larger than a |
| 675 | * single byte, but it has been empirically determined that | 692 | * single byte, but it has been empirically determined that |
| @@ -678,30 +695,28 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, | |||
| 678 | * transferred byte-by-byte. | 695 | * transferred byte-by-byte. |
| 679 | */ | 696 | */ |
| 680 | for (j = 0; j < msgs[i].len; j++) { | 697 | for (j = 0; j < msgs[i].len; j++) { |
| 681 | memset(&msg, 0, sizeof(msg)); | ||
| 682 | msg.address = msgs[i].addr; | ||
| 683 | |||
| 684 | msg.request = (msgs[i].flags & I2C_M_RD) ? | ||
| 685 | DP_AUX_I2C_READ : | ||
| 686 | DP_AUX_I2C_WRITE; | ||
| 687 | |||
| 688 | /* | ||
| 689 | * All messages except the last one are middle-of- | ||
| 690 | * transfer messages. | ||
| 691 | */ | ||
| 692 | if ((i < num - 1) || (j < msgs[i].len - 1)) | ||
| 693 | msg.request |= DP_AUX_I2C_MOT; | ||
| 694 | |||
| 695 | msg.buffer = msgs[i].buf + j; | 698 | msg.buffer = msgs[i].buf + j; |
| 696 | msg.size = 1; | 699 | msg.size = 1; |
| 697 | 700 | ||
| 698 | err = drm_dp_i2c_do_msg(aux, &msg); | 701 | err = drm_dp_i2c_do_msg(aux, &msg); |
| 699 | if (err < 0) | 702 | if (err < 0) |
| 700 | return err; | 703 | break; |
| 701 | } | 704 | } |
| 705 | if (err < 0) | ||
| 706 | break; | ||
| 702 | } | 707 | } |
| 708 | if (err >= 0) | ||
| 709 | err = num; | ||
| 710 | /* Send a bare address packet to close out the transaction. | ||
| 711 | * Zero sized messages specify an address only (bare | ||
| 712 | * address) transaction. | ||
| 713 | */ | ||
| 714 | msg.request &= ~DP_AUX_I2C_MOT; | ||
| 715 | msg.buffer = NULL; | ||
| 716 | msg.size = 0; | ||
| 717 | (void)drm_dp_i2c_do_msg(aux, &msg); | ||
| 703 | 718 | ||
| 704 | return num; | 719 | return err; |
| 705 | } | 720 | } |
| 706 | 721 | ||
| 707 | static const struct i2c_algorithm drm_dp_i2c_algo = { | 722 | static const struct i2c_algorithm drm_dp_i2c_algo = { |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index a0dad1a2f819..d2a55884ad52 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
| @@ -575,7 +575,8 @@ out: | |||
| 575 | return ret; | 575 | return ret; |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | #define HEADER_SIZE 4 | 578 | #define BARE_ADDRESS_SIZE 3 |
| 579 | #define HEADER_SIZE (BARE_ADDRESS_SIZE + 1) | ||
| 579 | static ssize_t | 580 | static ssize_t |
| 580 | intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | 581 | intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) |
| 581 | { | 582 | { |
| @@ -592,7 +593,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 592 | switch (msg->request & ~DP_AUX_I2C_MOT) { | 593 | switch (msg->request & ~DP_AUX_I2C_MOT) { |
| 593 | case DP_AUX_NATIVE_WRITE: | 594 | case DP_AUX_NATIVE_WRITE: |
| 594 | case DP_AUX_I2C_WRITE: | 595 | case DP_AUX_I2C_WRITE: |
| 595 | txsize = HEADER_SIZE + msg->size; | 596 | txsize = msg->size ? HEADER_SIZE + msg->size : BARE_ADDRESS_SIZE; |
| 596 | rxsize = 1; | 597 | rxsize = 1; |
| 597 | 598 | ||
| 598 | if (WARN_ON(txsize > 20)) | 599 | if (WARN_ON(txsize > 20)) |
| @@ -611,7 +612,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 611 | 612 | ||
| 612 | case DP_AUX_NATIVE_READ: | 613 | case DP_AUX_NATIVE_READ: |
| 613 | case DP_AUX_I2C_READ: | 614 | case DP_AUX_I2C_READ: |
| 614 | txsize = HEADER_SIZE; | 615 | txsize = msg->size ? HEADER_SIZE : BARE_ADDRESS_SIZE; |
| 615 | rxsize = msg->size + 1; | 616 | rxsize = msg->size + 1; |
| 616 | 617 | ||
| 617 | if (WARN_ON(rxsize > 20)) | 618 | if (WARN_ON(rxsize > 20)) |
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index 8b0ab170cef9..15936524f226 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c | |||
| @@ -142,7 +142,8 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan, | |||
| 142 | return recv_bytes; | 142 | return recv_bytes; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | #define HEADER_SIZE 4 | 145 | #define BARE_ADDRESS_SIZE 3 |
| 146 | #define HEADER_SIZE (BARE_ADDRESS_SIZE + 1) | ||
| 146 | 147 | ||
| 147 | static ssize_t | 148 | static ssize_t |
| 148 | radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | 149 | radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) |
| @@ -160,13 +161,19 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 160 | tx_buf[0] = msg->address & 0xff; | 161 | tx_buf[0] = msg->address & 0xff; |
| 161 | tx_buf[1] = msg->address >> 8; | 162 | tx_buf[1] = msg->address >> 8; |
| 162 | tx_buf[2] = msg->request << 4; | 163 | tx_buf[2] = msg->request << 4; |
| 163 | tx_buf[3] = msg->size - 1; | 164 | tx_buf[3] = msg->size ? (msg->size - 1) : 0; |
| 164 | 165 | ||
| 165 | switch (msg->request & ~DP_AUX_I2C_MOT) { | 166 | switch (msg->request & ~DP_AUX_I2C_MOT) { |
| 166 | case DP_AUX_NATIVE_WRITE: | 167 | case DP_AUX_NATIVE_WRITE: |
| 167 | case DP_AUX_I2C_WRITE: | 168 | case DP_AUX_I2C_WRITE: |
| 169 | /* tx_size needs to be 4 even for bare address packets since the atom | ||
| 170 | * table needs the info in tx_buf[3]. | ||
| 171 | */ | ||
| 168 | tx_size = HEADER_SIZE + msg->size; | 172 | tx_size = HEADER_SIZE + msg->size; |
| 169 | tx_buf[3] |= tx_size << 4; | 173 | if (msg->size == 0) |
| 174 | tx_buf[3] |= BARE_ADDRESS_SIZE << 4; | ||
| 175 | else | ||
| 176 | tx_buf[3] |= tx_size << 4; | ||
| 170 | memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size); | 177 | memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size); |
| 171 | ret = radeon_process_aux_ch(chan, | 178 | ret = radeon_process_aux_ch(chan, |
| 172 | tx_buf, tx_size, NULL, 0, delay, &ack); | 179 | tx_buf, tx_size, NULL, 0, delay, &ack); |
| @@ -176,8 +183,14 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 176 | break; | 183 | break; |
| 177 | case DP_AUX_NATIVE_READ: | 184 | case DP_AUX_NATIVE_READ: |
| 178 | case DP_AUX_I2C_READ: | 185 | case DP_AUX_I2C_READ: |
| 186 | /* tx_size needs to be 4 even for bare address packets since the atom | ||
| 187 | * table needs the info in tx_buf[3]. | ||
| 188 | */ | ||
| 179 | tx_size = HEADER_SIZE; | 189 | tx_size = HEADER_SIZE; |
| 180 | tx_buf[3] |= tx_size << 4; | 190 | if (msg->size == 0) |
| 191 | tx_buf[3] |= BARE_ADDRESS_SIZE << 4; | ||
| 192 | else | ||
| 193 | tx_buf[3] |= tx_size << 4; | ||
| 181 | ret = radeon_process_aux_ch(chan, | 194 | ret = radeon_process_aux_ch(chan, |
| 182 | tx_buf, tx_size, msg->buffer, msg->size, delay, &ack); | 195 | tx_buf, tx_size, msg->buffer, msg->size, delay, &ack); |
| 183 | break; | 196 | break; |
| @@ -186,7 +199,7 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 186 | break; | 199 | break; |
| 187 | } | 200 | } |
| 188 | 201 | ||
| 189 | if (ret > 0) | 202 | if (ret >= 0) |
| 190 | msg->reply = ack >> 4; | 203 | msg->reply = ack >> 4; |
| 191 | 204 | ||
| 192 | return ret; | 205 | return ret; |
| @@ -194,98 +207,15 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
| 194 | 207 | ||
| 195 | void radeon_dp_aux_init(struct radeon_connector *radeon_connector) | 208 | void radeon_dp_aux_init(struct radeon_connector *radeon_connector) |
| 196 | { | 209 | { |
| 197 | struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; | ||
| 198 | |||
| 199 | dig_connector->dp_i2c_bus->aux.dev = radeon_connector->base.kdev; | ||
| 200 | dig_connector->dp_i2c_bus->aux.transfer = radeon_dp_aux_transfer; | ||
| 201 | } | ||
| 202 | |||
| 203 | int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, | ||
| 204 | u8 write_byte, u8 *read_byte) | ||
| 205 | { | ||
| 206 | struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data; | ||
| 207 | struct radeon_i2c_chan *auxch = i2c_get_adapdata(adapter); | ||
| 208 | u16 address = algo_data->address; | ||
| 209 | u8 msg[5]; | ||
| 210 | u8 reply[2]; | ||
| 211 | unsigned retry; | ||
| 212 | int msg_bytes; | ||
| 213 | int reply_bytes = 1; | ||
| 214 | int ret; | 210 | int ret; |
| 215 | u8 ack; | ||
| 216 | |||
| 217 | /* Set up the address */ | ||
| 218 | msg[0] = address; | ||
| 219 | msg[1] = address >> 8; | ||
| 220 | |||
| 221 | /* Set up the command byte */ | ||
| 222 | if (mode & MODE_I2C_READ) { | ||
| 223 | msg[2] = DP_AUX_I2C_READ << 4; | ||
| 224 | msg_bytes = 4; | ||
| 225 | msg[3] = msg_bytes << 4; | ||
| 226 | } else { | ||
| 227 | msg[2] = DP_AUX_I2C_WRITE << 4; | ||
| 228 | msg_bytes = 5; | ||
| 229 | msg[3] = msg_bytes << 4; | ||
| 230 | msg[4] = write_byte; | ||
| 231 | } | ||
| 232 | |||
| 233 | /* special handling for start/stop */ | ||
| 234 | if (mode & (MODE_I2C_START | MODE_I2C_STOP)) | ||
| 235 | msg[3] = 3 << 4; | ||
| 236 | |||
| 237 | /* Set MOT bit for all but stop */ | ||
| 238 | if ((mode & MODE_I2C_STOP) == 0) | ||
| 239 | msg[2] |= DP_AUX_I2C_MOT << 4; | ||
| 240 | |||
| 241 | for (retry = 0; retry < 7; retry++) { | ||
| 242 | ret = radeon_process_aux_ch(auxch, | ||
| 243 | msg, msg_bytes, reply, reply_bytes, 0, &ack); | ||
| 244 | if (ret == -EBUSY) | ||
| 245 | continue; | ||
| 246 | else if (ret < 0) { | ||
| 247 | DRM_DEBUG_KMS("aux_ch failed %d\n", ret); | ||
| 248 | return ret; | ||
| 249 | } | ||
| 250 | |||
| 251 | switch ((ack >> 4) & DP_AUX_NATIVE_REPLY_MASK) { | ||
| 252 | case DP_AUX_NATIVE_REPLY_ACK: | ||
| 253 | /* I2C-over-AUX Reply field is only valid | ||
| 254 | * when paired with AUX ACK. | ||
| 255 | */ | ||
| 256 | break; | ||
| 257 | case DP_AUX_NATIVE_REPLY_NACK: | ||
| 258 | DRM_DEBUG_KMS("aux_ch native nack\n"); | ||
| 259 | return -EREMOTEIO; | ||
| 260 | case DP_AUX_NATIVE_REPLY_DEFER: | ||
| 261 | DRM_DEBUG_KMS("aux_ch native defer\n"); | ||
| 262 | usleep_range(500, 600); | ||
| 263 | continue; | ||
| 264 | default: | ||
| 265 | DRM_ERROR("aux_ch invalid native reply 0x%02x\n", ack); | ||
| 266 | return -EREMOTEIO; | ||
| 267 | } | ||
| 268 | 211 | ||
| 269 | switch ((ack >> 4) & DP_AUX_I2C_REPLY_MASK) { | 212 | radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; |
| 270 | case DP_AUX_I2C_REPLY_ACK: | 213 | radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; |
| 271 | if (mode == MODE_I2C_READ) | 214 | ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux); |
| 272 | *read_byte = reply[0]; | 215 | if (!ret) |
| 273 | return ret; | 216 | radeon_connector->ddc_bus->has_aux = true; |
| 274 | case DP_AUX_I2C_REPLY_NACK: | ||
| 275 | DRM_DEBUG_KMS("aux_i2c nack\n"); | ||
| 276 | return -EREMOTEIO; | ||
| 277 | case DP_AUX_I2C_REPLY_DEFER: | ||
| 278 | DRM_DEBUG_KMS("aux_i2c defer\n"); | ||
| 279 | usleep_range(400, 500); | ||
| 280 | break; | ||
| 281 | default: | ||
| 282 | DRM_ERROR("aux_i2c invalid reply 0x%02x\n", ack); | ||
| 283 | return -EREMOTEIO; | ||
| 284 | } | ||
| 285 | } | ||
| 286 | 217 | ||
| 287 | DRM_DEBUG_KMS("aux i2c too many retries, giving up\n"); | 218 | WARN(ret, "drm_dp_aux_register_i2c_bus() failed with error %d\n", ret); |
| 288 | return -EREMOTEIO; | ||
| 289 | } | 219 | } |
| 290 | 220 | ||
| 291 | /***** general DP utility functions *****/ | 221 | /***** general DP utility functions *****/ |
| @@ -420,12 +350,11 @@ static u8 radeon_dp_encoder_service(struct radeon_device *rdev, | |||
| 420 | 350 | ||
| 421 | u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector) | 351 | u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector) |
| 422 | { | 352 | { |
| 423 | struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; | ||
| 424 | struct drm_device *dev = radeon_connector->base.dev; | 353 | struct drm_device *dev = radeon_connector->base.dev; |
| 425 | struct radeon_device *rdev = dev->dev_private; | 354 | struct radeon_device *rdev = dev->dev_private; |
| 426 | 355 | ||
| 427 | return radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_GET_SINK_TYPE, 0, | 356 | return radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_GET_SINK_TYPE, 0, |
| 428 | dig_connector->dp_i2c_bus->rec.i2c_id, 0); | 357 | radeon_connector->ddc_bus->rec.i2c_id, 0); |
| 429 | } | 358 | } |
| 430 | 359 | ||
| 431 | static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) | 360 | static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) |
| @@ -436,11 +365,11 @@ static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) | |||
| 436 | if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT)) | 365 | if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT)) |
| 437 | return; | 366 | return; |
| 438 | 367 | ||
| 439 | if (drm_dp_dpcd_read(&dig_connector->dp_i2c_bus->aux, DP_SINK_OUI, buf, 3)) | 368 | if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3)) |
| 440 | DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n", | 369 | DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n", |
| 441 | buf[0], buf[1], buf[2]); | 370 | buf[0], buf[1], buf[2]); |
| 442 | 371 | ||
| 443 | if (drm_dp_dpcd_read(&dig_connector->dp_i2c_bus->aux, DP_BRANCH_OUI, buf, 3)) | 372 | if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3)) |
| 444 | DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n", | 373 | DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n", |
| 445 | buf[0], buf[1], buf[2]); | 374 | buf[0], buf[1], buf[2]); |
| 446 | } | 375 | } |
| @@ -451,7 +380,7 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector) | |||
| 451 | u8 msg[DP_DPCD_SIZE]; | 380 | u8 msg[DP_DPCD_SIZE]; |
| 452 | int ret, i; | 381 | int ret, i; |
| 453 | 382 | ||
| 454 | ret = drm_dp_dpcd_read(&dig_connector->dp_i2c_bus->aux, DP_DPCD_REV, msg, | 383 | ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg, |
| 455 | DP_DPCD_SIZE); | 384 | DP_DPCD_SIZE); |
| 456 | if (ret > 0) { | 385 | if (ret > 0) { |
| 457 | memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); | 386 | memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); |
| @@ -489,7 +418,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder, | |||
| 489 | 418 | ||
| 490 | if (dp_bridge != ENCODER_OBJECT_ID_NONE) { | 419 | if (dp_bridge != ENCODER_OBJECT_ID_NONE) { |
| 491 | /* DP bridge chips */ | 420 | /* DP bridge chips */ |
| 492 | drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux, | 421 | drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, |
| 493 | DP_EDP_CONFIGURATION_CAP, &tmp); | 422 | DP_EDP_CONFIGURATION_CAP, &tmp); |
| 494 | if (tmp & 1) | 423 | if (tmp & 1) |
| 495 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; | 424 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; |
| @@ -500,7 +429,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder, | |||
| 500 | panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE; | 429 | panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE; |
| 501 | } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { | 430 | } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
| 502 | /* eDP */ | 431 | /* eDP */ |
| 503 | drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux, | 432 | drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, |
| 504 | DP_EDP_CONFIGURATION_CAP, &tmp); | 433 | DP_EDP_CONFIGURATION_CAP, &tmp); |
| 505 | if (tmp & 1) | 434 | if (tmp & 1) |
| 506 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; | 435 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; |
| @@ -554,7 +483,8 @@ bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector) | |||
| 554 | u8 link_status[DP_LINK_STATUS_SIZE]; | 483 | u8 link_status[DP_LINK_STATUS_SIZE]; |
| 555 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 484 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; |
| 556 | 485 | ||
| 557 | if (drm_dp_dpcd_read_link_status(&dig->dp_i2c_bus->aux, link_status) <= 0) | 486 | if (drm_dp_dpcd_read_link_status(&radeon_connector->ddc_bus->aux, link_status) |
| 487 | <= 0) | ||
| 558 | return false; | 488 | return false; |
| 559 | if (drm_dp_channel_eq_ok(link_status, dig->dp_lane_count)) | 489 | if (drm_dp_channel_eq_ok(link_status, dig->dp_lane_count)) |
| 560 | return false; | 490 | return false; |
| @@ -574,7 +504,7 @@ void radeon_dp_set_rx_power_state(struct drm_connector *connector, | |||
| 574 | 504 | ||
| 575 | /* power up/down the sink */ | 505 | /* power up/down the sink */ |
| 576 | if (dig_connector->dpcd[0] >= 0x11) { | 506 | if (dig_connector->dpcd[0] >= 0x11) { |
| 577 | drm_dp_dpcd_writeb(&dig_connector->dp_i2c_bus->aux, | 507 | drm_dp_dpcd_writeb(&radeon_connector->ddc_bus->aux, |
| 578 | DP_SET_POWER, power_state); | 508 | DP_SET_POWER, power_state); |
| 579 | usleep_range(1000, 2000); | 509 | usleep_range(1000, 2000); |
| 580 | } | 510 | } |
| @@ -878,7 +808,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder, | |||
| 878 | else | 808 | else |
| 879 | dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A; | 809 | dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A; |
| 880 | 810 | ||
| 881 | drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux, DP_MAX_LANE_COUNT, &tmp); | 811 | drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp); |
| 882 | if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED)) | 812 | if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED)) |
| 883 | dp_info.tp3_supported = true; | 813 | dp_info.tp3_supported = true; |
| 884 | else | 814 | else |
| @@ -890,7 +820,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder, | |||
| 890 | dp_info.connector = connector; | 820 | dp_info.connector = connector; |
| 891 | dp_info.dp_lane_count = dig_connector->dp_lane_count; | 821 | dp_info.dp_lane_count = dig_connector->dp_lane_count; |
| 892 | dp_info.dp_clock = dig_connector->dp_clock; | 822 | dp_info.dp_clock = dig_connector->dp_clock; |
| 893 | dp_info.aux = &dig_connector->dp_i2c_bus->aux; | 823 | dp_info.aux = &radeon_connector->ddc_bus->aux; |
| 894 | 824 | ||
| 895 | if (radeon_dp_link_train_init(&dp_info)) | 825 | if (radeon_dp_link_train_init(&dp_info)) |
| 896 | goto done; | 826 | goto done; |
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c index 94e858751994..0a65dc7e93e7 100644 --- a/drivers/gpu/drm/radeon/dce6_afmt.c +++ b/drivers/gpu/drm/radeon/dce6_afmt.c | |||
| @@ -309,11 +309,17 @@ int dce6_audio_init(struct radeon_device *rdev) | |||
| 309 | 309 | ||
| 310 | rdev->audio.enabled = true; | 310 | rdev->audio.enabled = true; |
| 311 | 311 | ||
| 312 | if (ASIC_IS_DCE8(rdev)) | 312 | if (ASIC_IS_DCE81(rdev)) /* KV: 4 streams, 7 endpoints */ |
| 313 | rdev->audio.num_pins = 7; | ||
| 314 | else if (ASIC_IS_DCE83(rdev)) /* KB: 2 streams, 3 endpoints */ | ||
| 315 | rdev->audio.num_pins = 3; | ||
| 316 | else if (ASIC_IS_DCE8(rdev)) /* BN/HW: 6 streams, 7 endpoints */ | ||
| 317 | rdev->audio.num_pins = 7; | ||
| 318 | else if (ASIC_IS_DCE61(rdev)) /* TN: 4 streams, 6 endpoints */ | ||
| 313 | rdev->audio.num_pins = 6; | 319 | rdev->audio.num_pins = 6; |
| 314 | else if (ASIC_IS_DCE61(rdev)) | 320 | else if (ASIC_IS_DCE64(rdev)) /* OL: 2 streams, 2 endpoints */ |
| 315 | rdev->audio.num_pins = 4; | 321 | rdev->audio.num_pins = 2; |
| 316 | else | 322 | else /* SI: 6 streams, 6 endpoints */ |
| 317 | rdev->audio.num_pins = 6; | 323 | rdev->audio.num_pins = 6; |
| 318 | 324 | ||
| 319 | for (i = 0; i < rdev->audio.num_pins; i++) { | 325 | for (i = 0; i < rdev->audio.num_pins; i++) { |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 7014bdd688ce..b58e1afdda76 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
| @@ -739,7 +739,7 @@ union radeon_irq_stat_regs { | |||
| 739 | struct cik_irq_stat_regs cik; | 739 | struct cik_irq_stat_regs cik; |
| 740 | }; | 740 | }; |
| 741 | 741 | ||
| 742 | #define RADEON_MAX_HPD_PINS 6 | 742 | #define RADEON_MAX_HPD_PINS 7 |
| 743 | #define RADEON_MAX_CRTCS 6 | 743 | #define RADEON_MAX_CRTCS 6 |
| 744 | #define RADEON_MAX_AFMT_BLOCKS 7 | 744 | #define RADEON_MAX_AFMT_BLOCKS 7 |
| 745 | 745 | ||
| @@ -2632,6 +2632,9 @@ void r100_pll_errata_after_index(struct radeon_device *rdev); | |||
| 2632 | #define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND)) | 2632 | #define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND)) |
| 2633 | #define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN)) | 2633 | #define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN)) |
| 2634 | #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE)) | 2634 | #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE)) |
| 2635 | #define ASIC_IS_DCE81(rdev) ((rdev->family == CHIP_KAVERI)) | ||
| 2636 | #define ASIC_IS_DCE82(rdev) ((rdev->family == CHIP_BONAIRE)) | ||
| 2637 | #define ASIC_IS_DCE83(rdev) ((rdev->family == CHIP_KABINI)) | ||
| 2635 | 2638 | ||
| 2636 | #define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \ | 2639 | #define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \ |
| 2637 | (rdev->ddev->pdev->device == 0x6850) || \ | 2640 | (rdev->ddev->pdev->device == 0x6850) || \ |
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index c566b486ca08..ea50e0ae7bf7 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c | |||
| @@ -1261,21 +1261,6 @@ static const struct drm_connector_funcs radeon_dvi_connector_funcs = { | |||
| 1261 | .force = radeon_dvi_force, | 1261 | .force = radeon_dvi_force, |
| 1262 | }; | 1262 | }; |
| 1263 | 1263 | ||
| 1264 | static void radeon_dp_connector_destroy(struct drm_connector *connector) | ||
| 1265 | { | ||
| 1266 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | ||
| 1267 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; | ||
| 1268 | |||
| 1269 | if (radeon_connector->edid) | ||
| 1270 | kfree(radeon_connector->edid); | ||
| 1271 | if (radeon_dig_connector->dp_i2c_bus) | ||
| 1272 | radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus); | ||
| 1273 | kfree(radeon_connector->con_priv); | ||
| 1274 | drm_sysfs_connector_remove(connector); | ||
| 1275 | drm_connector_cleanup(connector); | ||
| 1276 | kfree(connector); | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | static int radeon_dp_get_modes(struct drm_connector *connector) | 1264 | static int radeon_dp_get_modes(struct drm_connector *connector) |
| 1280 | { | 1265 | { |
| 1281 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | 1266 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| @@ -1553,7 +1538,7 @@ static const struct drm_connector_funcs radeon_dp_connector_funcs = { | |||
| 1553 | .detect = radeon_dp_detect, | 1538 | .detect = radeon_dp_detect, |
| 1554 | .fill_modes = drm_helper_probe_single_connector_modes, | 1539 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1555 | .set_property = radeon_connector_set_property, | 1540 | .set_property = radeon_connector_set_property, |
| 1556 | .destroy = radeon_dp_connector_destroy, | 1541 | .destroy = radeon_connector_destroy, |
| 1557 | .force = radeon_dvi_force, | 1542 | .force = radeon_dvi_force, |
| 1558 | }; | 1543 | }; |
| 1559 | 1544 | ||
| @@ -1562,7 +1547,7 @@ static const struct drm_connector_funcs radeon_edp_connector_funcs = { | |||
| 1562 | .detect = radeon_dp_detect, | 1547 | .detect = radeon_dp_detect, |
| 1563 | .fill_modes = drm_helper_probe_single_connector_modes, | 1548 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1564 | .set_property = radeon_lvds_set_property, | 1549 | .set_property = radeon_lvds_set_property, |
| 1565 | .destroy = radeon_dp_connector_destroy, | 1550 | .destroy = radeon_connector_destroy, |
| 1566 | .force = radeon_dvi_force, | 1551 | .force = radeon_dvi_force, |
| 1567 | }; | 1552 | }; |
| 1568 | 1553 | ||
| @@ -1571,7 +1556,7 @@ static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { | |||
| 1571 | .detect = radeon_dp_detect, | 1556 | .detect = radeon_dp_detect, |
| 1572 | .fill_modes = drm_helper_probe_single_connector_modes, | 1557 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1573 | .set_property = radeon_lvds_set_property, | 1558 | .set_property = radeon_lvds_set_property, |
| 1574 | .destroy = radeon_dp_connector_destroy, | 1559 | .destroy = radeon_connector_destroy, |
| 1575 | .force = radeon_dvi_force, | 1560 | .force = radeon_dvi_force, |
| 1576 | }; | 1561 | }; |
| 1577 | 1562 | ||
| @@ -1668,17 +1653,10 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
| 1668 | radeon_dig_connector->igp_lane_info = igp_lane_info; | 1653 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1669 | radeon_connector->con_priv = radeon_dig_connector; | 1654 | radeon_connector->con_priv = radeon_dig_connector; |
| 1670 | if (i2c_bus->valid) { | 1655 | if (i2c_bus->valid) { |
| 1671 | /* add DP i2c bus */ | 1656 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1672 | if (connector_type == DRM_MODE_CONNECTOR_eDP) | 1657 | if (radeon_connector->ddc_bus) |
| 1673 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); | ||
| 1674 | else | ||
| 1675 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); | ||
| 1676 | if (radeon_dig_connector->dp_i2c_bus) | ||
| 1677 | has_aux = true; | 1658 | has_aux = true; |
| 1678 | else | 1659 | else |
| 1679 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | ||
| 1680 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | ||
| 1681 | if (!radeon_connector->ddc_bus) | ||
| 1682 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | 1660 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1683 | } | 1661 | } |
| 1684 | switch (connector_type) { | 1662 | switch (connector_type) { |
| @@ -1893,10 +1871,6 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
| 1893 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); | 1871 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
| 1894 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | 1872 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
| 1895 | if (i2c_bus->valid) { | 1873 | if (i2c_bus->valid) { |
| 1896 | /* add DP i2c bus */ | ||
| 1897 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); | ||
| 1898 | if (!radeon_dig_connector->dp_i2c_bus) | ||
| 1899 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | ||
| 1900 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | 1874 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1901 | if (radeon_connector->ddc_bus) | 1875 | if (radeon_connector->ddc_bus) |
| 1902 | has_aux = true; | 1876 | has_aux = true; |
| @@ -1942,14 +1916,10 @@ radeon_add_atom_connector(struct drm_device *dev, | |||
| 1942 | drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type); | 1916 | drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type); |
| 1943 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | 1917 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
| 1944 | if (i2c_bus->valid) { | 1918 | if (i2c_bus->valid) { |
| 1945 | /* add DP i2c bus */ | 1919 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1946 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); | 1920 | if (radeon_connector->ddc_bus) |
| 1947 | if (radeon_dig_connector->dp_i2c_bus) | ||
| 1948 | has_aux = true; | 1921 | has_aux = true; |
| 1949 | else | 1922 | else |
| 1950 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | ||
| 1951 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | ||
| 1952 | if (!radeon_connector->ddc_bus) | ||
| 1953 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | 1923 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1954 | } | 1924 | } |
| 1955 | drm_object_attach_property(&radeon_connector->base.base, | 1925 | drm_object_attach_property(&radeon_connector->base.base, |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 063d4255137f..2f7cbb901fb1 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
| @@ -759,19 +759,18 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector) | |||
| 759 | 759 | ||
| 760 | if (radeon_connector_encoder_get_dp_bridge_encoder_id(&radeon_connector->base) != | 760 | if (radeon_connector_encoder_get_dp_bridge_encoder_id(&radeon_connector->base) != |
| 761 | ENCODER_OBJECT_ID_NONE) { | 761 | ENCODER_OBJECT_ID_NONE) { |
| 762 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 762 | if (radeon_connector->ddc_bus->has_aux) |
| 763 | |||
| 764 | if (dig->dp_i2c_bus) | ||
| 765 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, | 763 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
| 766 | &dig->dp_i2c_bus->adapter); | 764 | &radeon_connector->ddc_bus->aux.ddc); |
| 767 | } else if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) || | 765 | } else if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) || |
| 768 | (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)) { | 766 | (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)) { |
| 769 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 767 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; |
| 770 | 768 | ||
| 771 | if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT || | 769 | if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT || |
| 772 | dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && dig->dp_i2c_bus) | 770 | dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && |
| 771 | radeon_connector->ddc_bus->has_aux) | ||
| 773 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, | 772 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
| 774 | &dig->dp_i2c_bus->adapter); | 773 | &radeon_connector->ddc_bus->aux.ddc); |
| 775 | else if (radeon_connector->ddc_bus && !radeon_connector->edid) | 774 | else if (radeon_connector->ddc_bus && !radeon_connector->edid) |
| 776 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, | 775 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
| 777 | &radeon_connector->ddc_bus->adapter); | 776 | &radeon_connector->ddc_bus->adapter); |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 25127ba44ed9..c00a2f585185 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
| @@ -185,7 +185,7 @@ module_param_named(dynclks, radeon_dynclks, int, 0444); | |||
| 185 | MODULE_PARM_DESC(r4xx_atom, "Enable ATOMBIOS modesetting for R4xx"); | 185 | MODULE_PARM_DESC(r4xx_atom, "Enable ATOMBIOS modesetting for R4xx"); |
| 186 | module_param_named(r4xx_atom, radeon_r4xx_atom, int, 0444); | 186 | module_param_named(r4xx_atom, radeon_r4xx_atom, int, 0444); |
| 187 | 187 | ||
| 188 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing"); | 188 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); |
| 189 | module_param_named(vramlimit, radeon_vram_limit, int, 0600); | 189 | module_param_named(vramlimit, radeon_vram_limit, int, 0600); |
| 190 | 190 | ||
| 191 | MODULE_PARM_DESC(agpmode, "AGP Mode (-1 == PCI)"); | 191 | MODULE_PARM_DESC(agpmode, "AGP Mode (-1 == PCI)"); |
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c index e24ca6ab96de..7b944142a9fd 100644 --- a/drivers/gpu/drm/radeon/radeon_i2c.c +++ b/drivers/gpu/drm/radeon/radeon_i2c.c | |||
| @@ -64,8 +64,7 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector, bool use_aux) | |||
| 64 | radeon_router_select_ddc_port(radeon_connector); | 64 | radeon_router_select_ddc_port(radeon_connector); |
| 65 | 65 | ||
| 66 | if (use_aux) { | 66 | if (use_aux) { |
| 67 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 67 | ret = i2c_transfer(&radeon_connector->ddc_bus->aux.ddc, msgs, 2); |
| 68 | ret = i2c_transfer(&dig->dp_i2c_bus->adapter, msgs, 2); | ||
| 69 | } else { | 68 | } else { |
| 70 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); | 69 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); |
| 71 | } | 70 | } |
| @@ -950,16 +949,16 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, | |||
| 950 | /* set the radeon bit adapter */ | 949 | /* set the radeon bit adapter */ |
| 951 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), | 950 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
| 952 | "Radeon i2c bit bus %s", name); | 951 | "Radeon i2c bit bus %s", name); |
| 953 | i2c->adapter.algo_data = &i2c->algo.bit; | 952 | i2c->adapter.algo_data = &i2c->bit; |
| 954 | i2c->algo.bit.pre_xfer = pre_xfer; | 953 | i2c->bit.pre_xfer = pre_xfer; |
| 955 | i2c->algo.bit.post_xfer = post_xfer; | 954 | i2c->bit.post_xfer = post_xfer; |
| 956 | i2c->algo.bit.setsda = set_data; | 955 | i2c->bit.setsda = set_data; |
| 957 | i2c->algo.bit.setscl = set_clock; | 956 | i2c->bit.setscl = set_clock; |
| 958 | i2c->algo.bit.getsda = get_data; | 957 | i2c->bit.getsda = get_data; |
| 959 | i2c->algo.bit.getscl = get_clock; | 958 | i2c->bit.getscl = get_clock; |
| 960 | i2c->algo.bit.udelay = 10; | 959 | i2c->bit.udelay = 10; |
| 961 | i2c->algo.bit.timeout = usecs_to_jiffies(2200); /* from VESA */ | 960 | i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ |
| 962 | i2c->algo.bit.data = i2c; | 961 | i2c->bit.data = i2c; |
| 963 | ret = i2c_bit_add_bus(&i2c->adapter); | 962 | ret = i2c_bit_add_bus(&i2c->adapter); |
| 964 | if (ret) { | 963 | if (ret) { |
| 965 | DRM_ERROR("Failed to register bit i2c %s\n", name); | 964 | DRM_ERROR("Failed to register bit i2c %s\n", name); |
| @@ -974,46 +973,13 @@ out_free: | |||
| 974 | 973 | ||
| 975 | } | 974 | } |
| 976 | 975 | ||
| 977 | struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, | ||
| 978 | struct radeon_i2c_bus_rec *rec, | ||
| 979 | const char *name) | ||
| 980 | { | ||
| 981 | struct radeon_i2c_chan *i2c; | ||
| 982 | int ret; | ||
| 983 | |||
| 984 | i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); | ||
| 985 | if (i2c == NULL) | ||
| 986 | return NULL; | ||
| 987 | |||
| 988 | i2c->rec = *rec; | ||
| 989 | i2c->adapter.owner = THIS_MODULE; | ||
| 990 | i2c->adapter.class = I2C_CLASS_DDC; | ||
| 991 | i2c->adapter.dev.parent = &dev->pdev->dev; | ||
| 992 | i2c->dev = dev; | ||
| 993 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), | ||
| 994 | "Radeon aux bus %s", name); | ||
| 995 | i2c_set_adapdata(&i2c->adapter, i2c); | ||
| 996 | i2c->adapter.algo_data = &i2c->algo.dp; | ||
| 997 | i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; | ||
| 998 | i2c->algo.dp.address = 0; | ||
| 999 | ret = i2c_dp_aux_add_bus(&i2c->adapter); | ||
| 1000 | if (ret) { | ||
| 1001 | DRM_INFO("Failed to register i2c %s\n", name); | ||
| 1002 | goto out_free; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | return i2c; | ||
| 1006 | out_free: | ||
| 1007 | kfree(i2c); | ||
| 1008 | return NULL; | ||
| 1009 | |||
| 1010 | } | ||
| 1011 | |||
| 1012 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) | 976 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) |
| 1013 | { | 977 | { |
| 1014 | if (!i2c) | 978 | if (!i2c) |
| 1015 | return; | 979 | return; |
| 1016 | i2c_del_adapter(&i2c->adapter); | 980 | i2c_del_adapter(&i2c->adapter); |
| 981 | if (i2c->has_aux) | ||
| 982 | drm_dp_aux_unregister_i2c_bus(&i2c->aux); | ||
| 1017 | kfree(i2c); | 983 | kfree(i2c); |
| 1018 | } | 984 | } |
| 1019 | 985 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h index 832d9fa1a4c4..6ddf31a2d34e 100644 --- a/drivers/gpu/drm/radeon/radeon_mode.h +++ b/drivers/gpu/drm/radeon/radeon_mode.h | |||
| @@ -187,12 +187,10 @@ struct radeon_pll { | |||
| 187 | struct radeon_i2c_chan { | 187 | struct radeon_i2c_chan { |
| 188 | struct i2c_adapter adapter; | 188 | struct i2c_adapter adapter; |
| 189 | struct drm_device *dev; | 189 | struct drm_device *dev; |
| 190 | union { | 190 | struct i2c_algo_bit_data bit; |
| 191 | struct i2c_algo_bit_data bit; | ||
| 192 | struct i2c_algo_dp_aux_data dp; | ||
| 193 | } algo; | ||
| 194 | struct radeon_i2c_bus_rec rec; | 191 | struct radeon_i2c_bus_rec rec; |
| 195 | struct drm_dp_aux aux; | 192 | struct drm_dp_aux aux; |
| 193 | bool has_aux; | ||
| 196 | }; | 194 | }; |
| 197 | 195 | ||
| 198 | /* mostly for macs, but really any system without connector tables */ | 196 | /* mostly for macs, but really any system without connector tables */ |
| @@ -440,7 +438,6 @@ struct radeon_encoder { | |||
| 440 | struct radeon_connector_atom_dig { | 438 | struct radeon_connector_atom_dig { |
| 441 | uint32_t igp_lane_info; | 439 | uint32_t igp_lane_info; |
| 442 | /* displayport */ | 440 | /* displayport */ |
| 443 | struct radeon_i2c_chan *dp_i2c_bus; | ||
| 444 | u8 dpcd[DP_RECEIVER_CAP_SIZE]; | 441 | u8 dpcd[DP_RECEIVER_CAP_SIZE]; |
| 445 | u8 dp_sink_type; | 442 | u8 dp_sink_type; |
| 446 | int dp_clock; | 443 | int dp_clock; |
| @@ -702,8 +699,6 @@ extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, | |||
| 702 | uint8_t lane_set); | 699 | uint8_t lane_set); |
| 703 | extern void radeon_atom_ext_encoder_setup_ddc(struct drm_encoder *encoder); | 700 | extern void radeon_atom_ext_encoder_setup_ddc(struct drm_encoder *encoder); |
| 704 | extern struct drm_encoder *radeon_get_external_encoder(struct drm_encoder *encoder); | 701 | extern struct drm_encoder *radeon_get_external_encoder(struct drm_encoder *encoder); |
| 705 | extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, | ||
| 706 | u8 write_byte, u8 *read_byte); | ||
| 707 | void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); | 702 | void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); |
| 708 | 703 | ||
| 709 | extern void radeon_i2c_init(struct radeon_device *rdev); | 704 | extern void radeon_i2c_init(struct radeon_device *rdev); |
| @@ -715,9 +710,6 @@ extern void radeon_i2c_add(struct radeon_device *rdev, | |||
| 715 | const char *name); | 710 | const char *name); |
| 716 | extern struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev, | 711 | extern struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev, |
| 717 | struct radeon_i2c_bus_rec *i2c_bus); | 712 | struct radeon_i2c_bus_rec *i2c_bus); |
| 718 | extern struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, | ||
| 719 | struct radeon_i2c_bus_rec *rec, | ||
| 720 | const char *name); | ||
| 721 | extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, | 713 | extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, |
| 722 | struct radeon_i2c_bus_rec *rec, | 714 | struct radeon_i2c_bus_rec *rec, |
| 723 | const char *name); | 715 | const char *name); |
diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index d536ed381fbd..005c19bd92df 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c | |||
| @@ -99,55 +99,73 @@ static void tegra_dpaux_read_fifo(struct tegra_dpaux *dpaux, u8 *buffer, | |||
| 99 | static ssize_t tegra_dpaux_transfer(struct drm_dp_aux *aux, | 99 | static ssize_t tegra_dpaux_transfer(struct drm_dp_aux *aux, |
| 100 | struct drm_dp_aux_msg *msg) | 100 | struct drm_dp_aux_msg *msg) |
| 101 | { | 101 | { |
| 102 | unsigned long value = DPAUX_DP_AUXCTL_TRANSACTREQ; | ||
| 103 | unsigned long timeout = msecs_to_jiffies(250); | 102 | unsigned long timeout = msecs_to_jiffies(250); |
| 104 | struct tegra_dpaux *dpaux = to_dpaux(aux); | 103 | struct tegra_dpaux *dpaux = to_dpaux(aux); |
| 105 | unsigned long status; | 104 | unsigned long status; |
| 106 | ssize_t ret = 0; | 105 | ssize_t ret = 0; |
| 106 | u32 value; | ||
| 107 | 107 | ||
| 108 | if (msg->size < 1 || msg->size > 16) | 108 | /* Tegra has 4x4 byte DP AUX transmit and receive FIFOs. */ |
| 109 | if (msg->size > 16) | ||
| 109 | return -EINVAL; | 110 | return -EINVAL; |
| 110 | 111 | ||
| 111 | tegra_dpaux_writel(dpaux, msg->address, DPAUX_DP_AUXADDR); | 112 | /* |
| 113 | * Allow zero-sized messages only for I2C, in which case they specify | ||
| 114 | * address-only transactions. | ||
| 115 | */ | ||
| 116 | if (msg->size < 1) { | ||
| 117 | switch (msg->request & ~DP_AUX_I2C_MOT) { | ||
| 118 | case DP_AUX_I2C_WRITE: | ||
| 119 | case DP_AUX_I2C_READ: | ||
| 120 | value = DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY; | ||
| 121 | break; | ||
| 122 | |||
| 123 | default: | ||
| 124 | return -EINVAL; | ||
| 125 | } | ||
| 126 | } else { | ||
| 127 | /* For non-zero-sized messages, set the CMDLEN field. */ | ||
| 128 | value = DPAUX_DP_AUXCTL_CMDLEN(msg->size - 1); | ||
| 129 | } | ||
| 112 | 130 | ||
| 113 | switch (msg->request & ~DP_AUX_I2C_MOT) { | 131 | switch (msg->request & ~DP_AUX_I2C_MOT) { |
| 114 | case DP_AUX_I2C_WRITE: | 132 | case DP_AUX_I2C_WRITE: |
| 115 | if (msg->request & DP_AUX_I2C_MOT) | 133 | if (msg->request & DP_AUX_I2C_MOT) |
| 116 | value = DPAUX_DP_AUXCTL_CMD_MOT_WR; | 134 | value |= DPAUX_DP_AUXCTL_CMD_MOT_WR; |
| 117 | else | 135 | else |
| 118 | value = DPAUX_DP_AUXCTL_CMD_I2C_WR; | 136 | value |= DPAUX_DP_AUXCTL_CMD_I2C_WR; |
| 119 | 137 | ||
| 120 | break; | 138 | break; |
| 121 | 139 | ||
| 122 | case DP_AUX_I2C_READ: | 140 | case DP_AUX_I2C_READ: |
| 123 | if (msg->request & DP_AUX_I2C_MOT) | 141 | if (msg->request & DP_AUX_I2C_MOT) |
| 124 | value = DPAUX_DP_AUXCTL_CMD_MOT_RD; | 142 | value |= DPAUX_DP_AUXCTL_CMD_MOT_RD; |
| 125 | else | 143 | else |
| 126 | value = DPAUX_DP_AUXCTL_CMD_I2C_RD; | 144 | value |= DPAUX_DP_AUXCTL_CMD_I2C_RD; |
| 127 | 145 | ||
| 128 | break; | 146 | break; |
| 129 | 147 | ||
| 130 | case DP_AUX_I2C_STATUS: | 148 | case DP_AUX_I2C_STATUS: |
| 131 | if (msg->request & DP_AUX_I2C_MOT) | 149 | if (msg->request & DP_AUX_I2C_MOT) |
| 132 | value = DPAUX_DP_AUXCTL_CMD_MOT_RQ; | 150 | value |= DPAUX_DP_AUXCTL_CMD_MOT_RQ; |
| 133 | else | 151 | else |
| 134 | value = DPAUX_DP_AUXCTL_CMD_I2C_RQ; | 152 | value |= DPAUX_DP_AUXCTL_CMD_I2C_RQ; |
| 135 | 153 | ||
| 136 | break; | 154 | break; |
| 137 | 155 | ||
| 138 | case DP_AUX_NATIVE_WRITE: | 156 | case DP_AUX_NATIVE_WRITE: |
| 139 | value = DPAUX_DP_AUXCTL_CMD_AUX_WR; | 157 | value |= DPAUX_DP_AUXCTL_CMD_AUX_WR; |
| 140 | break; | 158 | break; |
| 141 | 159 | ||
| 142 | case DP_AUX_NATIVE_READ: | 160 | case DP_AUX_NATIVE_READ: |
| 143 | value = DPAUX_DP_AUXCTL_CMD_AUX_RD; | 161 | value |= DPAUX_DP_AUXCTL_CMD_AUX_RD; |
| 144 | break; | 162 | break; |
| 145 | 163 | ||
| 146 | default: | 164 | default: |
| 147 | return -EINVAL; | 165 | return -EINVAL; |
| 148 | } | 166 | } |
| 149 | 167 | ||
| 150 | value |= DPAUX_DP_AUXCTL_CMDLEN(msg->size - 1); | 168 | tegra_dpaux_writel(dpaux, msg->address, DPAUX_DP_AUXADDR); |
| 151 | tegra_dpaux_writel(dpaux, value, DPAUX_DP_AUXCTL); | 169 | tegra_dpaux_writel(dpaux, value, DPAUX_DP_AUXCTL); |
| 152 | 170 | ||
| 153 | if ((msg->request & DP_AUX_I2C_READ) == 0) { | 171 | if ((msg->request & DP_AUX_I2C_READ) == 0) { |
| @@ -198,7 +216,7 @@ static ssize_t tegra_dpaux_transfer(struct drm_dp_aux *aux, | |||
| 198 | break; | 216 | break; |
| 199 | } | 217 | } |
| 200 | 218 | ||
| 201 | if (msg->reply == DP_AUX_NATIVE_REPLY_ACK) { | 219 | if ((msg->size > 0) && (msg->reply == DP_AUX_NATIVE_REPLY_ACK)) { |
| 202 | if (msg->request & DP_AUX_I2C_READ) { | 220 | if (msg->request & DP_AUX_I2C_READ) { |
| 203 | size_t count = value & DPAUX_DP_AUXSTAT_REPLY_MASK; | 221 | size_t count = value & DPAUX_DP_AUXSTAT_REPLY_MASK; |
| 204 | 222 | ||
diff --git a/drivers/gpu/drm/tegra/dpaux.h b/drivers/gpu/drm/tegra/dpaux.h index 4f5bf10fdff9..806e245ca787 100644 --- a/drivers/gpu/drm/tegra/dpaux.h +++ b/drivers/gpu/drm/tegra/dpaux.h | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #define DPAUX_DP_AUXCTL_CMD_I2C_RQ (2 << 12) | 32 | #define DPAUX_DP_AUXCTL_CMD_I2C_RQ (2 << 12) |
| 33 | #define DPAUX_DP_AUXCTL_CMD_I2C_RD (1 << 12) | 33 | #define DPAUX_DP_AUXCTL_CMD_I2C_RD (1 << 12) |
| 34 | #define DPAUX_DP_AUXCTL_CMD_I2C_WR (0 << 12) | 34 | #define DPAUX_DP_AUXCTL_CMD_I2C_WR (0 << 12) |
| 35 | #define DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY (1 << 8) | ||
| 35 | #define DPAUX_DP_AUXCTL_CMDLEN(x) ((x) & 0xff) | 36 | #define DPAUX_DP_AUXCTL_CMDLEN(x) ((x) & 0xff) |
| 36 | 37 | ||
| 37 | #define DPAUX_DP_AUXSTAT 0x31 | 38 | #define DPAUX_DP_AUXSTAT 0x31 |
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index b4f58914bf7d..cfcacec5b89d 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h | |||
| @@ -456,6 +456,10 @@ struct drm_dp_aux_msg { | |||
| 456 | * transactions. The drm_dp_aux_register_i2c_bus() function registers an | 456 | * transactions. The drm_dp_aux_register_i2c_bus() function registers an |
| 457 | * I2C adapter that can be passed to drm_probe_ddc(). Upon removal, drivers | 457 | * I2C adapter that can be passed to drm_probe_ddc(). Upon removal, drivers |
| 458 | * should call drm_dp_aux_unregister_i2c_bus() to remove the I2C adapter. | 458 | * should call drm_dp_aux_unregister_i2c_bus() to remove the I2C adapter. |
| 459 | * | ||
| 460 | * Note that the aux helper code assumes that the .transfer() function | ||
| 461 | * only modifies the reply field of the drm_dp_aux_msg structure. The | ||
| 462 | * retry logic and i2c helpers assume this is the case. | ||
| 459 | */ | 463 | */ |
| 460 | struct drm_dp_aux { | 464 | struct drm_dp_aux { |
| 461 | const char *name; | 465 | const char *name; |
