diff options
author | Alex Deucher <alexdeucher@gmail.com> | 2014-04-07 10:33:46 -0400 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2014-04-08 10:12:40 -0400 |
commit | 379dfc25e257ffe10eb53b86d2375f7c0f4f33ef (patch) | |
tree | 72a09e2fd8d1aca2f3a47c849c631e9078e5cff3 | |
parent | 732d50b431dca2f3f78fc21ba9b7ed9d06bb01ce (diff) |
drm/radeon/dp: switch to the common i2c over aux code
Provides a nice cleanup in radeon.
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
-rw-r--r-- | drivers/gpu/drm/radeon/atombios_dp.c | 117 | ||||
-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_i2c.c | 60 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_mode.h | 12 |
5 files changed, 44 insertions, 200 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index e4483042aee0..15936524f226 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c | |||
@@ -207,98 +207,15 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) | |||
207 | 207 | ||
208 | void radeon_dp_aux_init(struct radeon_connector *radeon_connector) | 208 | void radeon_dp_aux_init(struct radeon_connector *radeon_connector) |
209 | { | 209 | { |
210 | struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; | ||
211 | |||
212 | dig_connector->dp_i2c_bus->aux.dev = radeon_connector->base.kdev; | ||
213 | dig_connector->dp_i2c_bus->aux.transfer = radeon_dp_aux_transfer; | ||
214 | } | ||
215 | |||
216 | int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, | ||
217 | u8 write_byte, u8 *read_byte) | ||
218 | { | ||
219 | struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data; | ||
220 | struct radeon_i2c_chan *auxch = i2c_get_adapdata(adapter); | ||
221 | u16 address = algo_data->address; | ||
222 | u8 msg[5]; | ||
223 | u8 reply[2]; | ||
224 | unsigned retry; | ||
225 | int msg_bytes; | ||
226 | int reply_bytes = 1; | ||
227 | int ret; | 210 | int ret; |
228 | u8 ack; | ||
229 | |||
230 | /* Set up the address */ | ||
231 | msg[0] = address; | ||
232 | msg[1] = address >> 8; | ||
233 | |||
234 | /* Set up the command byte */ | ||
235 | if (mode & MODE_I2C_READ) { | ||
236 | msg[2] = DP_AUX_I2C_READ << 4; | ||
237 | msg_bytes = 4; | ||
238 | msg[3] = msg_bytes << 4; | ||
239 | } else { | ||
240 | msg[2] = DP_AUX_I2C_WRITE << 4; | ||
241 | msg_bytes = 5; | ||
242 | msg[3] = msg_bytes << 4; | ||
243 | msg[4] = write_byte; | ||
244 | } | ||
245 | 211 | ||
246 | /* special handling for start/stop */ | 212 | radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; |
247 | if (mode & (MODE_I2C_START | MODE_I2C_STOP)) | 213 | radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; |
248 | msg[3] = 3 << 4; | 214 | ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux); |
249 | 215 | if (!ret) | |
250 | /* Set MOT bit for all but stop */ | 216 | radeon_connector->ddc_bus->has_aux = true; |
251 | if ((mode & MODE_I2C_STOP) == 0) | ||
252 | msg[2] |= DP_AUX_I2C_MOT << 4; | ||
253 | |||
254 | for (retry = 0; retry < 7; retry++) { | ||
255 | ret = radeon_process_aux_ch(auxch, | ||
256 | msg, msg_bytes, reply, reply_bytes, 0, &ack); | ||
257 | if (ret == -EBUSY) | ||
258 | continue; | ||
259 | else if (ret < 0) { | ||
260 | DRM_DEBUG_KMS("aux_ch failed %d\n", ret); | ||
261 | return ret; | ||
262 | } | ||
263 | 217 | ||
264 | switch ((ack >> 4) & DP_AUX_NATIVE_REPLY_MASK) { | 218 | WARN(ret, "drm_dp_aux_register_i2c_bus() failed with error %d\n", ret); |
265 | case DP_AUX_NATIVE_REPLY_ACK: | ||
266 | /* I2C-over-AUX Reply field is only valid | ||
267 | * when paired with AUX ACK. | ||
268 | */ | ||
269 | break; | ||
270 | case DP_AUX_NATIVE_REPLY_NACK: | ||
271 | DRM_DEBUG_KMS("aux_ch native nack\n"); | ||
272 | return -EREMOTEIO; | ||
273 | case DP_AUX_NATIVE_REPLY_DEFER: | ||
274 | DRM_DEBUG_KMS("aux_ch native defer\n"); | ||
275 | usleep_range(500, 600); | ||
276 | continue; | ||
277 | default: | ||
278 | DRM_ERROR("aux_ch invalid native reply 0x%02x\n", ack); | ||
279 | return -EREMOTEIO; | ||
280 | } | ||
281 | |||
282 | switch ((ack >> 4) & DP_AUX_I2C_REPLY_MASK) { | ||
283 | case DP_AUX_I2C_REPLY_ACK: | ||
284 | if (mode == MODE_I2C_READ) | ||
285 | *read_byte = reply[0]; | ||
286 | return ret; | ||
287 | case DP_AUX_I2C_REPLY_NACK: | ||
288 | DRM_DEBUG_KMS("aux_i2c nack\n"); | ||
289 | return -EREMOTEIO; | ||
290 | case DP_AUX_I2C_REPLY_DEFER: | ||
291 | DRM_DEBUG_KMS("aux_i2c defer\n"); | ||
292 | usleep_range(400, 500); | ||
293 | break; | ||
294 | default: | ||
295 | DRM_ERROR("aux_i2c invalid reply 0x%02x\n", ack); | ||
296 | return -EREMOTEIO; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | DRM_DEBUG_KMS("aux i2c too many retries, giving up\n"); | ||
301 | return -EREMOTEIO; | ||
302 | } | 219 | } |
303 | 220 | ||
304 | /***** general DP utility functions *****/ | 221 | /***** general DP utility functions *****/ |
@@ -433,12 +350,11 @@ static u8 radeon_dp_encoder_service(struct radeon_device *rdev, | |||
433 | 350 | ||
434 | u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector) | 351 | u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector) |
435 | { | 352 | { |
436 | struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; | ||
437 | struct drm_device *dev = radeon_connector->base.dev; | 353 | struct drm_device *dev = radeon_connector->base.dev; |
438 | struct radeon_device *rdev = dev->dev_private; | 354 | struct radeon_device *rdev = dev->dev_private; |
439 | 355 | ||
440 | 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, |
441 | dig_connector->dp_i2c_bus->rec.i2c_id, 0); | 357 | radeon_connector->ddc_bus->rec.i2c_id, 0); |
442 | } | 358 | } |
443 | 359 | ||
444 | static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) | 360 | static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) |
@@ -449,11 +365,11 @@ static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector) | |||
449 | 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)) |
450 | return; | 366 | return; |
451 | 367 | ||
452 | 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)) |
453 | DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n", | 369 | DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n", |
454 | buf[0], buf[1], buf[2]); | 370 | buf[0], buf[1], buf[2]); |
455 | 371 | ||
456 | 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)) |
457 | DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n", | 373 | DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n", |
458 | buf[0], buf[1], buf[2]); | 374 | buf[0], buf[1], buf[2]); |
459 | } | 375 | } |
@@ -464,7 +380,7 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector) | |||
464 | u8 msg[DP_DPCD_SIZE]; | 380 | u8 msg[DP_DPCD_SIZE]; |
465 | int ret, i; | 381 | int ret, i; |
466 | 382 | ||
467 | 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, |
468 | DP_DPCD_SIZE); | 384 | DP_DPCD_SIZE); |
469 | if (ret > 0) { | 385 | if (ret > 0) { |
470 | memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); | 386 | memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); |
@@ -502,7 +418,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder, | |||
502 | 418 | ||
503 | if (dp_bridge != ENCODER_OBJECT_ID_NONE) { | 419 | if (dp_bridge != ENCODER_OBJECT_ID_NONE) { |
504 | /* DP bridge chips */ | 420 | /* DP bridge chips */ |
505 | drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux, | 421 | drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, |
506 | DP_EDP_CONFIGURATION_CAP, &tmp); | 422 | DP_EDP_CONFIGURATION_CAP, &tmp); |
507 | if (tmp & 1) | 423 | if (tmp & 1) |
508 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; | 424 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; |
@@ -513,7 +429,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder, | |||
513 | panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE; | 429 | panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE; |
514 | } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { | 430 | } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
515 | /* eDP */ | 431 | /* eDP */ |
516 | drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux, | 432 | drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, |
517 | DP_EDP_CONFIGURATION_CAP, &tmp); | 433 | DP_EDP_CONFIGURATION_CAP, &tmp); |
518 | if (tmp & 1) | 434 | if (tmp & 1) |
519 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; | 435 | panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; |
@@ -567,7 +483,8 @@ bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector) | |||
567 | u8 link_status[DP_LINK_STATUS_SIZE]; | 483 | u8 link_status[DP_LINK_STATUS_SIZE]; |
568 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 484 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; |
569 | 485 | ||
570 | 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) | ||
571 | return false; | 488 | return false; |
572 | 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)) |
573 | return false; | 490 | return false; |
@@ -587,7 +504,7 @@ void radeon_dp_set_rx_power_state(struct drm_connector *connector, | |||
587 | 504 | ||
588 | /* power up/down the sink */ | 505 | /* power up/down the sink */ |
589 | if (dig_connector->dpcd[0] >= 0x11) { | 506 | if (dig_connector->dpcd[0] >= 0x11) { |
590 | drm_dp_dpcd_writeb(&dig_connector->dp_i2c_bus->aux, | 507 | drm_dp_dpcd_writeb(&radeon_connector->ddc_bus->aux, |
591 | DP_SET_POWER, power_state); | 508 | DP_SET_POWER, power_state); |
592 | usleep_range(1000, 2000); | 509 | usleep_range(1000, 2000); |
593 | } | 510 | } |
@@ -891,7 +808,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder, | |||
891 | else | 808 | else |
892 | dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A; | 809 | dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A; |
893 | 810 | ||
894 | 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); |
895 | if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED)) | 812 | if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED)) |
896 | dp_info.tp3_supported = true; | 813 | dp_info.tp3_supported = true; |
897 | else | 814 | else |
@@ -903,7 +820,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder, | |||
903 | dp_info.connector = connector; | 820 | dp_info.connector = connector; |
904 | dp_info.dp_lane_count = dig_connector->dp_lane_count; | 821 | dp_info.dp_lane_count = dig_connector->dp_lane_count; |
905 | dp_info.dp_clock = dig_connector->dp_clock; | 822 | dp_info.dp_clock = dig_connector->dp_clock; |
906 | dp_info.aux = &dig_connector->dp_i2c_bus->aux; | 823 | dp_info.aux = &radeon_connector->ddc_bus->aux; |
907 | 824 | ||
908 | if (radeon_dp_link_train_init(&dp_info)) | 825 | if (radeon_dp_link_train_init(&dp_info)) |
909 | goto done; | 826 | goto done; |
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 386cfa4c194d..776e03d6ac81 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_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); |