aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c62
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c158
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c27
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h16
-rw-r--r--drivers/gpu/drm/radeon/radeon_reg.h12
7 files changed, 166 insertions, 120 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index d1c144be9734..fc5a2df4544b 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -52,7 +52,7 @@ bool radeon_process_aux_ch(struct radeon_i2c_chan *chan, u8 *req_bytes,
52 args.lpAuxRequest = 0; 52 args.lpAuxRequest = 0;
53 args.lpDataOut = 16; 53 args.lpDataOut = 16;
54 args.ucDataOutLen = 0; 54 args.ucDataOutLen = 0;
55 args.ucChannelID = chan->i2c_id; 55 args.ucChannelID = chan->rec.i2c_id;
56 args.ucDelay = delay / 10; 56 args.ucDelay = delay / 10;
57 57
58 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 58 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
@@ -60,7 +60,7 @@ bool radeon_process_aux_ch(struct radeon_i2c_chan *chan, u8 *req_bytes,
60 if (args.ucReplyStatus) { 60 if (args.ucReplyStatus) {
61 DRM_ERROR("failed to get auxch %02x%02x %02x %02x 0x%02x %02x\n", 61 DRM_ERROR("failed to get auxch %02x%02x %02x %02x 0x%02x %02x\n",
62 req_bytes[1], req_bytes[0], req_bytes[2], req_bytes[3], 62 req_bytes[1], req_bytes[0], req_bytes[2], req_bytes[3],
63 chan->i2c_id, args.ucReplyStatus); 63 chan->rec.i2c_id, args.ucReplyStatus);
64 return false; 64 return false;
65 } 65 }
66 66
@@ -102,7 +102,7 @@ int radeon_dp_getsinktype(struct radeon_connector *radeon_connector)
102 struct radeon_device *rdev = dev->dev_private; 102 struct radeon_device *rdev = dev->dev_private;
103 103
104 return radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_GET_SINK_TYPE, 0, 104 return radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_GET_SINK_TYPE, 0,
105 radeon_dig_connector->uc_i2c_id, 0); 105 radeon_dig_connector->dp_i2c_bus->rec.i2c_id, 0);
106} 106}
107 107
108union dig_transmitter_control { 108union dig_transmitter_control {
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index de05ac976472..87bf6b9d10a4 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -47,7 +47,7 @@ radeon_add_atom_connector(struct drm_device *dev,
47 int connector_type, 47 int connector_type,
48 struct radeon_i2c_bus_rec *i2c_bus, 48 struct radeon_i2c_bus_rec *i2c_bus,
49 bool linkb, uint32_t igp_lane_info, 49 bool linkb, uint32_t igp_lane_info,
50 uint16_t connector_object_id, uint8_t uc_i2c_id); 50 uint16_t connector_object_id);
51 51
52/* from radeon_legacy_encoder.c */ 52/* from radeon_legacy_encoder.c */
53extern void 53extern void
@@ -65,7 +65,7 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_gpio(struct drm_device *de
65{ 65{
66 struct radeon_device *rdev = dev->dev_private; 66 struct radeon_device *rdev = dev->dev_private;
67 struct atom_context *ctx = rdev->mode_info.atom_context; 67 struct atom_context *ctx = rdev->mode_info.atom_context;
68 ATOM_GPIO_I2C_ASSIGMENT gpio; 68 ATOM_GPIO_I2C_ASSIGMENT *gpio;
69 struct radeon_i2c_bus_rec i2c; 69 struct radeon_i2c_bus_rec i2c;
70 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info); 70 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
71 struct _ATOM_GPIO_I2C_INFO *i2c_info; 71 struct _ATOM_GPIO_I2C_INFO *i2c_info;
@@ -78,24 +78,37 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_gpio(struct drm_device *de
78 78
79 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); 79 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
80 80
81 gpio = i2c_info->asGPIO_Info[id]; 81 gpio = &i2c_info->asGPIO_Info[id];
82 82
83 i2c.mask_clk_reg = le16_to_cpu(gpio.usClkMaskRegisterIndex) * 4; 83 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
84 i2c.mask_data_reg = le16_to_cpu(gpio.usDataMaskRegisterIndex) * 4; 84 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
85 i2c.en_clk_reg = le16_to_cpu(gpio.usClkEnRegisterIndex) * 4; 85 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
86 i2c.en_data_reg = le16_to_cpu(gpio.usDataEnRegisterIndex) * 4; 86 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
87 i2c.y_clk_reg = le16_to_cpu(gpio.usClkY_RegisterIndex) * 4; 87 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
88 i2c.y_data_reg = le16_to_cpu(gpio.usDataY_RegisterIndex) * 4; 88 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
89 i2c.a_clk_reg = le16_to_cpu(gpio.usClkA_RegisterIndex) * 4; 89 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
90 i2c.a_data_reg = le16_to_cpu(gpio.usDataA_RegisterIndex) * 4; 90 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
91 i2c.mask_clk_mask = (1 << gpio.ucClkMaskShift); 91 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
92 i2c.mask_data_mask = (1 << gpio.ucDataMaskShift); 92 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
93 i2c.en_clk_mask = (1 << gpio.ucClkEnShift); 93 i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
94 i2c.en_data_mask = (1 << gpio.ucDataEnShift); 94 i2c.en_data_mask = (1 << gpio->ucDataEnShift);
95 i2c.y_clk_mask = (1 << gpio.ucClkY_Shift); 95 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
96 i2c.y_data_mask = (1 << gpio.ucDataY_Shift); 96 i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
97 i2c.a_clk_mask = (1 << gpio.ucClkA_Shift); 97 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
98 i2c.a_data_mask = (1 << gpio.ucDataA_Shift); 98 i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
99
100 if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
101 i2c.hw_capable = true;
102 else
103 i2c.hw_capable = false;
104
105 if (gpio->sucI2cId.ucAccess == 0xa0)
106 i2c.mm_i2c = true;
107 else
108 i2c.mm_i2c = false;
109
110 i2c.i2c_id = gpio->sucI2cId.ucAccess;
111
99 i2c.valid = true; 112 i2c.valid = true;
100 113
101 return i2c; 114 return i2c;
@@ -276,7 +289,6 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
276 uint16_t igp_lane_info, conn_id, connector_object_id; 289 uint16_t igp_lane_info, conn_id, connector_object_id;
277 bool linkb; 290 bool linkb;
278 struct radeon_i2c_bus_rec ddc_bus; 291 struct radeon_i2c_bus_rec ddc_bus;
279 ATOM_I2C_ID_CONFIG_ACCESS i2c_id;
280 atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); 292 atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
281 293
282 if (data_offset == 0) 294 if (data_offset == 0)
@@ -302,7 +314,6 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
302 path = (ATOM_DISPLAY_OBJECT_PATH *) addr; 314 path = (ATOM_DISPLAY_OBJECT_PATH *) addr;
303 path_size += le16_to_cpu(path->usSize); 315 path_size += le16_to_cpu(path->usSize);
304 linkb = false; 316 linkb = false;
305 i2c_id.ucAccess = 0;
306 if (device_support & le16_to_cpu(path->usDeviceTag)) { 317 if (device_support & le16_to_cpu(path->usDeviceTag)) {
307 uint8_t con_obj_id, con_obj_num, con_obj_type; 318 uint8_t con_obj_id, con_obj_num, con_obj_type;
308 319
@@ -420,7 +431,7 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
420 asObjects[j]. 431 asObjects[j].
421 usRecordOffset)); 432 usRecordOffset));
422 ATOM_I2C_RECORD *i2c_record; 433 ATOM_I2C_RECORD *i2c_record;
423 434
424 while (record->ucRecordType > 0 435 while (record->ucRecordType > 0
425 && record-> 436 && record->
426 ucRecordType <= 437 ucRecordType <=
@@ -431,7 +442,6 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
431 i2c_record = 442 i2c_record =
432 (ATOM_I2C_RECORD 443 (ATOM_I2C_RECORD
433 *) record; 444 *) record;
434 i2c_id.sbfAccess = i2c_record->sucI2cId;
435 line_mux = 445 line_mux =
436 i2c_record-> 446 i2c_record->
437 sucI2cId. 447 sucI2cId.
@@ -474,7 +484,7 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
474 usDeviceTag), 484 usDeviceTag),
475 connector_type, &ddc_bus, 485 connector_type, &ddc_bus,
476 linkb, igp_lane_info, 486 linkb, igp_lane_info,
477 connector_object_id, i2c_id.ucAccess); 487 connector_object_id);
478 488
479 } 489 }
480 } 490 }
@@ -693,7 +703,7 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
693 connector_type, 703 connector_type,
694 &bios_connectors[i].ddc_bus, 704 &bios_connectors[i].ddc_bus,
695 false, 0, 705 false, 0,
696 connector_object_id, 0); 706 connector_object_id);
697 } 707 }
698 } 708 }
699 709
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 14d3555e4afe..b6761cde1ecb 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -442,29 +442,39 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
442 442
443} 443}
444 444
445struct radeon_i2c_bus_rec combios_setup_i2c_bus(int ddc_line) 445static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
446 int ddc_line)
446{ 447{
447 struct radeon_i2c_bus_rec i2c; 448 struct radeon_i2c_bus_rec i2c;
448 449
449 i2c.mask_clk_mask = RADEON_GPIO_EN_1; 450 if (ddc_line == RADEON_GPIOPAD_MASK) {
450 i2c.mask_data_mask = RADEON_GPIO_EN_0; 451 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
451 i2c.a_clk_mask = RADEON_GPIO_A_1; 452 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
452 i2c.a_data_mask = RADEON_GPIO_A_0; 453 i2c.a_clk_reg = RADEON_GPIOPAD_A;
453 i2c.en_clk_mask = RADEON_GPIO_EN_1; 454 i2c.a_data_reg = RADEON_GPIOPAD_A;
454 i2c.en_data_mask = RADEON_GPIO_EN_0; 455 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
455 i2c.y_clk_mask = RADEON_GPIO_Y_1; 456 i2c.en_data_reg = RADEON_GPIOPAD_EN;
456 i2c.y_data_mask = RADEON_GPIO_Y_0; 457 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
457 if ((ddc_line == RADEON_LCD_GPIO_MASK) || 458 i2c.y_data_reg = RADEON_GPIOPAD_Y;
458 (ddc_line == RADEON_MDGPIO_EN_REG)) { 459 } else if (ddc_line == RADEON_MDGPIO_MASK) {
459 i2c.mask_clk_reg = ddc_line; 460 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
460 i2c.mask_data_reg = ddc_line; 461 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
461 i2c.a_clk_reg = ddc_line; 462 i2c.a_clk_reg = RADEON_MDGPIO_A;
462 i2c.a_data_reg = ddc_line; 463 i2c.a_data_reg = RADEON_MDGPIO_A;
463 i2c.en_clk_reg = ddc_line; 464 i2c.en_clk_reg = RADEON_MDGPIO_EN;
464 i2c.en_data_reg = ddc_line; 465 i2c.en_data_reg = RADEON_MDGPIO_EN;
465 i2c.y_clk_reg = ddc_line + 4; 466 i2c.y_clk_reg = RADEON_MDGPIO_Y;
466 i2c.y_data_reg = ddc_line + 4; 467 i2c.y_data_reg = RADEON_MDGPIO_Y;
467 } else { 468 } else {
469 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
470 i2c.mask_data_mask = RADEON_GPIO_EN_0;
471 i2c.a_clk_mask = RADEON_GPIO_A_1;
472 i2c.a_data_mask = RADEON_GPIO_A_0;
473 i2c.en_clk_mask = RADEON_GPIO_EN_1;
474 i2c.en_data_mask = RADEON_GPIO_EN_0;
475 i2c.y_clk_mask = RADEON_GPIO_Y_1;
476 i2c.y_data_mask = RADEON_GPIO_Y_0;
477
468 i2c.mask_clk_reg = ddc_line; 478 i2c.mask_clk_reg = ddc_line;
469 i2c.mask_data_reg = ddc_line; 479 i2c.mask_data_reg = ddc_line;
470 i2c.a_clk_reg = ddc_line; 480 i2c.a_clk_reg = ddc_line;
@@ -475,6 +485,28 @@ struct radeon_i2c_bus_rec combios_setup_i2c_bus(int ddc_line)
475 i2c.y_data_reg = ddc_line; 485 i2c.y_data_reg = ddc_line;
476 } 486 }
477 487
488 if (rdev->family < CHIP_R200)
489 i2c.hw_capable = false;
490 else {
491 switch (ddc_line) {
492 case RADEON_GPIO_VGA_DDC:
493 case RADEON_GPIO_DVI_DDC:
494 i2c.hw_capable = true;
495 break;
496 case RADEON_GPIO_MONID:
497 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
498 * reliably on some pre-r4xx hardware; not sure why.
499 */
500 i2c.hw_capable = false;
501 break;
502 default:
503 i2c.hw_capable = false;
504 break;
505 }
506 }
507 i2c.mm_i2c = false;
508 i2c.i2c_id = 0;
509
478 if (ddc_line) 510 if (ddc_line)
479 i2c.valid = true; 511 i2c.valid = true;
480 else 512 else
@@ -1077,7 +1109,7 @@ bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1077 struct radeon_i2c_bus_rec i2c_bus; 1109 struct radeon_i2c_bus_rec i2c_bus;
1078 1110
1079 /* default for macs */ 1111 /* default for macs */
1080 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1112 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1081 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1113 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1082 1114
1083 /* XXX some macs have duallink chips */ 1115 /* XXX some macs have duallink chips */
@@ -1153,23 +1185,23 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder
1153 gpio = RBIOS8(offset + 4 + 3); 1185 gpio = RBIOS8(offset + 4 + 3);
1154 switch (gpio) { 1186 switch (gpio) {
1155 case DDC_MONID: 1187 case DDC_MONID:
1156 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1188 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1157 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1189 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1158 break; 1190 break;
1159 case DDC_DVI: 1191 case DDC_DVI:
1160 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1192 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1161 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1193 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1162 break; 1194 break;
1163 case DDC_VGA: 1195 case DDC_VGA:
1164 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1196 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1165 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1197 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1166 break; 1198 break;
1167 case DDC_CRT2: 1199 case DDC_CRT2:
1168 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1200 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1169 if (rdev->family >= CHIP_R300) 1201 if (rdev->family >= CHIP_R300)
1170 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1202 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1171 else 1203 else
1172 i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1204 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1173 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1205 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1174 break; 1206 break;
1175 case DDC_LCD: /* MM i2c */ 1207 case DDC_LCD: /* MM i2c */
@@ -1254,7 +1286,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1254 /* these are the most common settings */ 1286 /* these are the most common settings */
1255 if (rdev->flags & RADEON_SINGLE_CRTC) { 1287 if (rdev->flags & RADEON_SINGLE_CRTC) {
1256 /* VGA - primary dac */ 1288 /* VGA - primary dac */
1257 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1289 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1258 radeon_add_legacy_encoder(dev, 1290 radeon_add_legacy_encoder(dev,
1259 radeon_get_encoder_id(dev, 1291 radeon_get_encoder_id(dev,
1260 ATOM_DEVICE_CRT1_SUPPORT, 1292 ATOM_DEVICE_CRT1_SUPPORT,
@@ -1267,7 +1299,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1267 CONNECTOR_OBJECT_ID_VGA); 1299 CONNECTOR_OBJECT_ID_VGA);
1268 } else if (rdev->flags & RADEON_IS_MOBILITY) { 1300 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1269 /* LVDS */ 1301 /* LVDS */
1270 ddc_i2c = combios_setup_i2c_bus(RADEON_LCD_GPIO_MASK); 1302 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
1271 radeon_add_legacy_encoder(dev, 1303 radeon_add_legacy_encoder(dev,
1272 radeon_get_encoder_id(dev, 1304 radeon_get_encoder_id(dev,
1273 ATOM_DEVICE_LCD1_SUPPORT, 1305 ATOM_DEVICE_LCD1_SUPPORT,
@@ -1280,7 +1312,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1280 CONNECTOR_OBJECT_ID_LVDS); 1312 CONNECTOR_OBJECT_ID_LVDS);
1281 1313
1282 /* VGA - primary dac */ 1314 /* VGA - primary dac */
1283 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1315 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1284 radeon_add_legacy_encoder(dev, 1316 radeon_add_legacy_encoder(dev,
1285 radeon_get_encoder_id(dev, 1317 radeon_get_encoder_id(dev,
1286 ATOM_DEVICE_CRT1_SUPPORT, 1318 ATOM_DEVICE_CRT1_SUPPORT,
@@ -1293,7 +1325,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1293 CONNECTOR_OBJECT_ID_VGA); 1325 CONNECTOR_OBJECT_ID_VGA);
1294 } else { 1326 } else {
1295 /* DVI-I - tv dac, int tmds */ 1327 /* DVI-I - tv dac, int tmds */
1296 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1328 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1297 radeon_add_legacy_encoder(dev, 1329 radeon_add_legacy_encoder(dev,
1298 radeon_get_encoder_id(dev, 1330 radeon_get_encoder_id(dev,
1299 ATOM_DEVICE_DFP1_SUPPORT, 1331 ATOM_DEVICE_DFP1_SUPPORT,
@@ -1312,7 +1344,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1312 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1344 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1313 1345
1314 /* VGA - primary dac */ 1346 /* VGA - primary dac */
1315 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1347 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1316 radeon_add_legacy_encoder(dev, 1348 radeon_add_legacy_encoder(dev,
1317 radeon_get_encoder_id(dev, 1349 radeon_get_encoder_id(dev,
1318 ATOM_DEVICE_CRT1_SUPPORT, 1350 ATOM_DEVICE_CRT1_SUPPORT,
@@ -1343,7 +1375,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1343 DRM_INFO("Connector Table: %d (ibook)\n", 1375 DRM_INFO("Connector Table: %d (ibook)\n",
1344 rdev->mode_info.connector_table); 1376 rdev->mode_info.connector_table);
1345 /* LVDS */ 1377 /* LVDS */
1346 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1378 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1347 radeon_add_legacy_encoder(dev, 1379 radeon_add_legacy_encoder(dev,
1348 radeon_get_encoder_id(dev, 1380 radeon_get_encoder_id(dev,
1349 ATOM_DEVICE_LCD1_SUPPORT, 1381 ATOM_DEVICE_LCD1_SUPPORT,
@@ -1353,7 +1385,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1353 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1385 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1354 CONNECTOR_OBJECT_ID_LVDS); 1386 CONNECTOR_OBJECT_ID_LVDS);
1355 /* VGA - TV DAC */ 1387 /* VGA - TV DAC */
1356 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1388 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1357 radeon_add_legacy_encoder(dev, 1389 radeon_add_legacy_encoder(dev,
1358 radeon_get_encoder_id(dev, 1390 radeon_get_encoder_id(dev,
1359 ATOM_DEVICE_CRT2_SUPPORT, 1391 ATOM_DEVICE_CRT2_SUPPORT,
@@ -1377,7 +1409,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1377 DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1409 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1378 rdev->mode_info.connector_table); 1410 rdev->mode_info.connector_table);
1379 /* LVDS */ 1411 /* LVDS */
1380 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1412 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1381 radeon_add_legacy_encoder(dev, 1413 radeon_add_legacy_encoder(dev,
1382 radeon_get_encoder_id(dev, 1414 radeon_get_encoder_id(dev,
1383 ATOM_DEVICE_LCD1_SUPPORT, 1415 ATOM_DEVICE_LCD1_SUPPORT,
@@ -1387,7 +1419,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1387 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1419 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1388 CONNECTOR_OBJECT_ID_LVDS); 1420 CONNECTOR_OBJECT_ID_LVDS);
1389 /* DVI-I - primary dac, ext tmds */ 1421 /* DVI-I - primary dac, ext tmds */
1390 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1422 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1391 radeon_add_legacy_encoder(dev, 1423 radeon_add_legacy_encoder(dev,
1392 radeon_get_encoder_id(dev, 1424 radeon_get_encoder_id(dev,
1393 ATOM_DEVICE_DFP2_SUPPORT, 1425 ATOM_DEVICE_DFP2_SUPPORT,
@@ -1419,7 +1451,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1419 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1451 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1420 rdev->mode_info.connector_table); 1452 rdev->mode_info.connector_table);
1421 /* LVDS */ 1453 /* LVDS */
1422 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1454 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1423 radeon_add_legacy_encoder(dev, 1455 radeon_add_legacy_encoder(dev,
1424 radeon_get_encoder_id(dev, 1456 radeon_get_encoder_id(dev,
1425 ATOM_DEVICE_LCD1_SUPPORT, 1457 ATOM_DEVICE_LCD1_SUPPORT,
@@ -1429,7 +1461,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1429 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1461 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1430 CONNECTOR_OBJECT_ID_LVDS); 1462 CONNECTOR_OBJECT_ID_LVDS);
1431 /* DVI-I - primary dac, int tmds */ 1463 /* DVI-I - primary dac, int tmds */
1432 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1464 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1433 radeon_add_legacy_encoder(dev, 1465 radeon_add_legacy_encoder(dev,
1434 radeon_get_encoder_id(dev, 1466 radeon_get_encoder_id(dev,
1435 ATOM_DEVICE_DFP1_SUPPORT, 1467 ATOM_DEVICE_DFP1_SUPPORT,
@@ -1460,7 +1492,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1460 DRM_INFO("Connector Table: %d (powerbook vga)\n", 1492 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1461 rdev->mode_info.connector_table); 1493 rdev->mode_info.connector_table);
1462 /* LVDS */ 1494 /* LVDS */
1463 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1495 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1464 radeon_add_legacy_encoder(dev, 1496 radeon_add_legacy_encoder(dev,
1465 radeon_get_encoder_id(dev, 1497 radeon_get_encoder_id(dev,
1466 ATOM_DEVICE_LCD1_SUPPORT, 1498 ATOM_DEVICE_LCD1_SUPPORT,
@@ -1470,7 +1502,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1470 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1502 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1471 CONNECTOR_OBJECT_ID_LVDS); 1503 CONNECTOR_OBJECT_ID_LVDS);
1472 /* VGA - primary dac */ 1504 /* VGA - primary dac */
1473 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1505 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1474 radeon_add_legacy_encoder(dev, 1506 radeon_add_legacy_encoder(dev,
1475 radeon_get_encoder_id(dev, 1507 radeon_get_encoder_id(dev,
1476 ATOM_DEVICE_CRT1_SUPPORT, 1508 ATOM_DEVICE_CRT1_SUPPORT,
@@ -1494,7 +1526,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1494 DRM_INFO("Connector Table: %d (mini external tmds)\n", 1526 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1495 rdev->mode_info.connector_table); 1527 rdev->mode_info.connector_table);
1496 /* DVI-I - tv dac, ext tmds */ 1528 /* DVI-I - tv dac, ext tmds */
1497 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1529 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1498 radeon_add_legacy_encoder(dev, 1530 radeon_add_legacy_encoder(dev,
1499 radeon_get_encoder_id(dev, 1531 radeon_get_encoder_id(dev,
1500 ATOM_DEVICE_DFP2_SUPPORT, 1532 ATOM_DEVICE_DFP2_SUPPORT,
@@ -1526,7 +1558,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1526 DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1558 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1527 rdev->mode_info.connector_table); 1559 rdev->mode_info.connector_table);
1528 /* DVI-I - tv dac, int tmds */ 1560 /* DVI-I - tv dac, int tmds */
1529 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1561 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1530 radeon_add_legacy_encoder(dev, 1562 radeon_add_legacy_encoder(dev,
1531 radeon_get_encoder_id(dev, 1563 radeon_get_encoder_id(dev,
1532 ATOM_DEVICE_DFP1_SUPPORT, 1564 ATOM_DEVICE_DFP1_SUPPORT,
@@ -1557,7 +1589,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1557 DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1589 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1558 rdev->mode_info.connector_table); 1590 rdev->mode_info.connector_table);
1559 /* DVI-D - int tmds */ 1591 /* DVI-D - int tmds */
1560 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1592 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1561 radeon_add_legacy_encoder(dev, 1593 radeon_add_legacy_encoder(dev,
1562 radeon_get_encoder_id(dev, 1594 radeon_get_encoder_id(dev,
1563 ATOM_DEVICE_DFP1_SUPPORT, 1595 ATOM_DEVICE_DFP1_SUPPORT,
@@ -1567,7 +1599,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1567 DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1599 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
1568 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D); 1600 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D);
1569 /* VGA - tv dac */ 1601 /* VGA - tv dac */
1570 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1602 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1571 radeon_add_legacy_encoder(dev, 1603 radeon_add_legacy_encoder(dev,
1572 radeon_get_encoder_id(dev, 1604 radeon_get_encoder_id(dev,
1573 ATOM_DEVICE_CRT2_SUPPORT, 1605 ATOM_DEVICE_CRT2_SUPPORT,
@@ -1591,7 +1623,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1591 DRM_INFO("Connector Table: %d (emac)\n", 1623 DRM_INFO("Connector Table: %d (emac)\n",
1592 rdev->mode_info.connector_table); 1624 rdev->mode_info.connector_table);
1593 /* VGA - primary dac */ 1625 /* VGA - primary dac */
1594 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1626 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1595 radeon_add_legacy_encoder(dev, 1627 radeon_add_legacy_encoder(dev,
1596 radeon_get_encoder_id(dev, 1628 radeon_get_encoder_id(dev,
1597 ATOM_DEVICE_CRT1_SUPPORT, 1629 ATOM_DEVICE_CRT1_SUPPORT,
@@ -1601,7 +1633,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1601 DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1633 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1602 CONNECTOR_OBJECT_ID_VGA); 1634 CONNECTOR_OBJECT_ID_VGA);
1603 /* VGA - tv dac */ 1635 /* VGA - tv dac */
1604 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1636 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1605 radeon_add_legacy_encoder(dev, 1637 radeon_add_legacy_encoder(dev,
1606 radeon_get_encoder_id(dev, 1638 radeon_get_encoder_id(dev,
1607 ATOM_DEVICE_CRT2_SUPPORT, 1639 ATOM_DEVICE_CRT2_SUPPORT,
@@ -1644,11 +1676,11 @@ static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1644 if ((rdev->family == CHIP_RS400 || 1676 if ((rdev->family == CHIP_RS400 ||
1645 rdev->family == CHIP_RS480) && 1677 rdev->family == CHIP_RS480) &&
1646 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1678 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1647 *ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1679 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1648 else if ((rdev->family == CHIP_RS400 || 1680 else if ((rdev->family == CHIP_RS400 ||
1649 rdev->family == CHIP_RS480) && 1681 rdev->family == CHIP_RS480) &&
1650 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { 1682 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
1651 ddc_i2c->valid = true; 1683 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
1652 ddc_i2c->mask_clk_mask = (0x20 << 8); 1684 ddc_i2c->mask_clk_mask = (0x20 << 8);
1653 ddc_i2c->mask_data_mask = 0x80; 1685 ddc_i2c->mask_data_mask = 0x80;
1654 ddc_i2c->a_clk_mask = (0x20 << 8); 1686 ddc_i2c->a_clk_mask = (0x20 << 8);
@@ -1657,20 +1689,12 @@ static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1657 ddc_i2c->en_data_mask = 0x80; 1689 ddc_i2c->en_data_mask = 0x80;
1658 ddc_i2c->y_clk_mask = (0x20 << 8); 1690 ddc_i2c->y_clk_mask = (0x20 << 8);
1659 ddc_i2c->y_data_mask = 0x80; 1691 ddc_i2c->y_data_mask = 0x80;
1660 ddc_i2c->mask_clk_reg = RADEON_GPIOPAD_MASK;
1661 ddc_i2c->mask_data_reg = RADEON_GPIOPAD_MASK;
1662 ddc_i2c->a_clk_reg = RADEON_GPIOPAD_A;
1663 ddc_i2c->a_data_reg = RADEON_GPIOPAD_A;
1664 ddc_i2c->en_clk_reg = RADEON_GPIOPAD_EN;
1665 ddc_i2c->en_data_reg = RADEON_GPIOPAD_EN;
1666 ddc_i2c->y_clk_reg = RADEON_GPIOPAD_Y;
1667 ddc_i2c->y_data_reg = RADEON_GPIOPAD_Y;
1668 } 1692 }
1669 1693
1670 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1694 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1671 if ((rdev->family >= CHIP_R300) && 1695 if ((rdev->family >= CHIP_R300) &&
1672 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1696 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1673 *ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1697 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1674 1698
1675 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 1699 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1676 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 1700 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
@@ -1788,19 +1812,19 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1788 switch (ddc_type) { 1812 switch (ddc_type) {
1789 case DDC_MONID: 1813 case DDC_MONID:
1790 ddc_i2c = 1814 ddc_i2c =
1791 combios_setup_i2c_bus(RADEON_GPIO_MONID); 1815 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1792 break; 1816 break;
1793 case DDC_DVI: 1817 case DDC_DVI:
1794 ddc_i2c = 1818 ddc_i2c =
1795 combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1819 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1796 break; 1820 break;
1797 case DDC_VGA: 1821 case DDC_VGA:
1798 ddc_i2c = 1822 ddc_i2c =
1799 combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1823 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1800 break; 1824 break;
1801 case DDC_CRT2: 1825 case DDC_CRT2:
1802 ddc_i2c = 1826 ddc_i2c =
1803 combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1827 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1804 break; 1828 break;
1805 default: 1829 default:
1806 break; 1830 break;
@@ -1955,7 +1979,7 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1955 0), 1979 0),
1956 ATOM_DEVICE_DFP1_SUPPORT); 1980 ATOM_DEVICE_DFP1_SUPPORT);
1957 1981
1958 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1982 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1959 radeon_add_legacy_connector(dev, 1983 radeon_add_legacy_connector(dev,
1960 0, 1984 0,
1961 ATOM_DEVICE_CRT1_SUPPORT | 1985 ATOM_DEVICE_CRT1_SUPPORT |
@@ -1973,7 +1997,7 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1973 ATOM_DEVICE_CRT1_SUPPORT, 1997 ATOM_DEVICE_CRT1_SUPPORT,
1974 1), 1998 1),
1975 ATOM_DEVICE_CRT1_SUPPORT); 1999 ATOM_DEVICE_CRT1_SUPPORT);
1976 ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 2000 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1977 radeon_add_legacy_connector(dev, 2001 radeon_add_legacy_connector(dev,
1978 0, 2002 0,
1979 ATOM_DEVICE_CRT1_SUPPORT, 2003 ATOM_DEVICE_CRT1_SUPPORT,
@@ -2007,27 +2031,27 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
2007 case DDC_MONID: 2031 case DDC_MONID:
2008 ddc_i2c = 2032 ddc_i2c =
2009 combios_setup_i2c_bus 2033 combios_setup_i2c_bus
2010 (RADEON_GPIO_MONID); 2034 (rdev, RADEON_GPIO_MONID);
2011 break; 2035 break;
2012 case DDC_DVI: 2036 case DDC_DVI:
2013 ddc_i2c = 2037 ddc_i2c =
2014 combios_setup_i2c_bus 2038 combios_setup_i2c_bus
2015 (RADEON_GPIO_DVI_DDC); 2039 (rdev, RADEON_GPIO_DVI_DDC);
2016 break; 2040 break;
2017 case DDC_VGA: 2041 case DDC_VGA:
2018 ddc_i2c = 2042 ddc_i2c =
2019 combios_setup_i2c_bus 2043 combios_setup_i2c_bus
2020 (RADEON_GPIO_VGA_DDC); 2044 (rdev, RADEON_GPIO_VGA_DDC);
2021 break; 2045 break;
2022 case DDC_CRT2: 2046 case DDC_CRT2:
2023 ddc_i2c = 2047 ddc_i2c =
2024 combios_setup_i2c_bus 2048 combios_setup_i2c_bus
2025 (RADEON_GPIO_CRT2_DDC); 2049 (rdev, RADEON_GPIO_CRT2_DDC);
2026 break; 2050 break;
2027 case DDC_LCD: 2051 case DDC_LCD:
2028 ddc_i2c = 2052 ddc_i2c =
2029 combios_setup_i2c_bus 2053 combios_setup_i2c_bus
2030 (RADEON_LCD_GPIO_MASK); 2054 (rdev, RADEON_GPIOPAD_MASK);
2031 ddc_i2c.mask_clk_mask = 2055 ddc_i2c.mask_clk_mask =
2032 RBIOS32(lcd_ddc_info + 3); 2056 RBIOS32(lcd_ddc_info + 3);
2033 ddc_i2c.mask_data_mask = 2057 ddc_i2c.mask_data_mask =
@@ -2048,7 +2072,7 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
2048 case DDC_GPIO: 2072 case DDC_GPIO:
2049 ddc_i2c = 2073 ddc_i2c =
2050 combios_setup_i2c_bus 2074 combios_setup_i2c_bus
2051 (RADEON_MDGPIO_EN_REG); 2075 (rdev, RADEON_MDGPIO_MASK);
2052 ddc_i2c.mask_clk_mask = 2076 ddc_i2c.mask_clk_mask =
2053 RBIOS32(lcd_ddc_info + 3); 2077 RBIOS32(lcd_ddc_info + 3);
2054 ddc_i2c.mask_data_mask = 2078 ddc_i2c.mask_data_mask =
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 4d457bc90141..98634ce5ba10 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -952,7 +952,7 @@ radeon_add_atom_connector(struct drm_device *dev,
952 struct radeon_i2c_bus_rec *i2c_bus, 952 struct radeon_i2c_bus_rec *i2c_bus,
953 bool linkb, 953 bool linkb,
954 uint32_t igp_lane_info, 954 uint32_t igp_lane_info,
955 uint16_t connector_object_id, uint8_t uc_i2c_id) 955 uint16_t connector_object_id)
956{ 956{
957 struct radeon_device *rdev = dev->dev_private; 957 struct radeon_device *rdev = dev->dev_private;
958 struct drm_connector *connector; 958 struct drm_connector *connector;
@@ -1083,8 +1083,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1083 if (ret) 1083 if (ret)
1084 goto failed; 1084 goto failed;
1085 /* add DP i2c bus */ 1085 /* add DP i2c bus */
1086 radeon_dig_connector->uc_i2c_id = uc_i2c_id; 1086 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch");
1087 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, "DP-auxch", true, uc_i2c_id);
1088 if (i2c_bus->valid) { 1087 if (i2c_bus->valid) {
1089 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP"); 1088 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP");
1090 if (!radeon_connector->ddc_bus) 1089 if (!radeon_connector->ddc_bus)
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index f200312dd5df..da3da1e89d00 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -69,13 +69,15 @@ void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state)
69 * holds the i2c port in a bad state - switch hw i2c away before 69 * holds the i2c port in a bad state - switch hw i2c away before
70 * doing DDC - do this for all r200s/r300s/r400s for safety sake 70 * doing DDC - do this for all r200s/r300s/r400s for safety sake
71 */ 71 */
72 if ((rdev->family >= CHIP_R200) && !ASIC_IS_AVIVO(rdev)) { 72 if (rec->hw_capable) {
73 if (rec->a_clk_reg == RADEON_GPIO_MONID) { 73 if ((rdev->family >= CHIP_R200) && !ASIC_IS_AVIVO(rdev)) {
74 WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST | 74 if (rec->a_clk_reg == RADEON_GPIO_MONID) {
75 R200_DVI_I2C_PIN_SEL(R200_SEL_DDC1))); 75 WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
76 } else { 76 R200_DVI_I2C_PIN_SEL(R200_SEL_DDC1)));
77 WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST | 77 } else {
78 R200_DVI_I2C_PIN_SEL(R200_SEL_DDC3))); 78 WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
79 R200_DVI_I2C_PIN_SEL(R200_SEL_DDC3)));
80 }
79 } 81 }
80 } 82 }
81 83
@@ -86,6 +88,12 @@ void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state)
86 temp = RREG32(rec->a_data_reg) & ~rec->a_data_mask; 88 temp = RREG32(rec->a_data_reg) & ~rec->a_data_mask;
87 WREG32(rec->a_data_reg, temp); 89 WREG32(rec->a_data_reg, temp);
88 90
91 /* set the pins to input */
92 temp = RREG32(rec->en_clk_reg) & ~rec->en_clk_mask;
93 WREG32(rec->en_clk_reg, temp);
94
95 temp = RREG32(rec->en_data_reg) & ~rec->en_data_mask;
96 WREG32(rec->en_data_reg, temp);
89 97
90 /* mask the gpio pins for software use */ 98 /* mask the gpio pins for software use */
91 temp = RREG32(rec->mask_clk_reg); 99 temp = RREG32(rec->mask_clk_reg);
@@ -199,7 +207,8 @@ out_free:
199} 207}
200 208
201struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, 209struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
202 const char *name, bool dp, u8 i2c_id) 210 struct radeon_i2c_bus_rec *rec,
211 const char *name)
203{ 212{
204 struct radeon_i2c_chan *i2c; 213 struct radeon_i2c_chan *i2c;
205 int ret; 214 int ret;
@@ -208,7 +217,7 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
208 if (i2c == NULL) 217 if (i2c == NULL)
209 return NULL; 218 return NULL;
210 219
211 i2c->i2c_id = i2c_id; 220 i2c->rec = *rec;
212 i2c->adapter.owner = THIS_MODULE; 221 i2c->adapter.owner = THIS_MODULE;
213 i2c->dev = dev; 222 i2c->dev = dev;
214 i2c_set_adapdata(&i2c->adapter, i2c); 223 i2c_set_adapdata(&i2c->adapter, i2c);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 166f75395f52..1964afb94dbc 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -106,6 +106,13 @@ enum radeon_tv_std {
106 */ 106 */
107struct radeon_i2c_bus_rec { 107struct radeon_i2c_bus_rec {
108 bool valid; 108 bool valid;
109 /* id used by atom */
110 uint8_t i2c_id;
111 /* can be used with hw i2c engine */
112 bool hw_capable;
113 /* uses multi-media i2c engine */
114 bool mm_i2c;
115 /* regs and bits */
109 uint32_t mask_clk_reg; 116 uint32_t mask_clk_reg;
110 uint32_t mask_data_reg; 117 uint32_t mask_data_reg;
111 uint32_t a_clk_reg; 118 uint32_t a_clk_reg;
@@ -172,7 +179,6 @@ struct radeon_i2c_chan {
172 struct i2c_algo_bit_data bit; 179 struct i2c_algo_bit_data bit;
173 } algo; 180 } algo;
174 struct radeon_i2c_bus_rec rec; 181 struct radeon_i2c_bus_rec rec;
175 uint8_t i2c_id;
176}; 182};
177 183
178/* mostly for macs, but really any system without connector tables */ 184/* mostly for macs, but really any system without connector tables */
@@ -333,7 +339,6 @@ struct radeon_encoder {
333struct radeon_connector_atom_dig { 339struct radeon_connector_atom_dig {
334 uint32_t igp_lane_info; 340 uint32_t igp_lane_info;
335 bool linkb; 341 bool linkb;
336 uint16_t uc_i2c_id;
337 struct radeon_i2c_chan *dp_i2c_bus; 342 struct radeon_i2c_chan *dp_i2c_bus;
338 u8 dpcd[8]; 343 u8 dpcd[8];
339}; 344};
@@ -352,8 +357,6 @@ struct radeon_connector {
352 void *con_priv; 357 void *con_priv;
353 bool dac_load_detect; 358 bool dac_load_detect;
354 uint16_t connector_object_id; 359 uint16_t connector_object_id;
355 /* need to keep this for display port */
356//
357}; 360};
358 361
359struct radeon_framebuffer { 362struct radeon_framebuffer {
@@ -362,12 +365,13 @@ struct radeon_framebuffer {
362}; 365};
363 366
364extern int radeon_dp_getsinktype(struct radeon_connector *radeon_connector); 367extern int radeon_dp_getsinktype(struct radeon_connector *radeon_connector);
365extern void radeon_dp_getdpcd(struct radeon_connector *connector); 368extern void radeon_dp_getdpcd(struct radeon_connector *radeon_connector);
366extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, 369extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
367 uint8_t write_byte, uint8_t *read_byte); 370 uint8_t write_byte, uint8_t *read_byte);
368 371
369extern struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, 372extern struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
370 const char *name, bool dp, u8 i2c_id); 373 struct radeon_i2c_bus_rec *rec,
374 const char *name);
371extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, 375extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
372 struct radeon_i2c_bus_rec *rec, 376 struct radeon_i2c_bus_rec *rec,
373 const char *name); 377 const char *name);
diff --git a/drivers/gpu/drm/radeon/radeon_reg.h b/drivers/gpu/drm/radeon/radeon_reg.h
index c4c41c8d908c..b8116401ffae 100644
--- a/drivers/gpu/drm/radeon/radeon_reg.h
+++ b/drivers/gpu/drm/radeon/radeon_reg.h
@@ -1148,16 +1148,16 @@
1148# define RADEON_IO_MCLK_MAX_DYN_STOP_LAT (1 << 13) 1148# define RADEON_IO_MCLK_MAX_DYN_STOP_LAT (1 << 13)
1149# define RADEON_MC_MCLK_DYN_ENABLE (1 << 14) 1149# define RADEON_MC_MCLK_DYN_ENABLE (1 << 14)
1150# define RADEON_IO_MCLK_DYN_ENABLE (1 << 15) 1150# define RADEON_IO_MCLK_DYN_ENABLE (1 << 15)
1151
1151#define RADEON_GPIOPAD_MASK 0x0198 1152#define RADEON_GPIOPAD_MASK 0x0198
1152#define RADEON_GPIOPAD_A 0x019c 1153#define RADEON_GPIOPAD_A 0x019c
1153#define RADEON_GPIOPAD_EN 0x01a0 1154#define RADEON_GPIOPAD_EN 0x01a0
1154#define RADEON_GPIOPAD_Y 0x01a4 1155#define RADEON_GPIOPAD_Y 0x01a4
1155#define RADEON_LCD_GPIO_MASK 0x01a0 1156#define RADEON_MDGPIO_MASK 0x01a8
1156#define RADEON_LCD_GPIO_Y_REG 0x01a4 1157#define RADEON_MDGPIO_A 0x01ac
1157#define RADEON_MDGPIO_A_REG 0x01ac 1158#define RADEON_MDGPIO_EN 0x01b0
1158#define RADEON_MDGPIO_EN_REG 0x01b0 1159#define RADEON_MDGPIO_Y 0x01b4
1159#define RADEON_MDGPIO_MASK 0x0198 1160
1160#define RADEON_MDGPIO_Y_REG 0x01b4
1161#define RADEON_MEM_ADDR_CONFIG 0x0148 1161#define RADEON_MEM_ADDR_CONFIG 0x0148
1162#define RADEON_MEM_BASE 0x0f10 /* PCI */ 1162#define RADEON_MEM_BASE 0x0f10 /* PCI */
1163#define RADEON_MEM_CNTL 0x0140 1163#define RADEON_MEM_CNTL 0x0140