Skip to content

Commit a42892e

Browse files
committed
Merge branch 'drm-next-3.15-wip' of git://people.freedesktop.org/~deathsimple/linux into drm-next
Some i2c fixes over DisplayPort. * 'drm-next-3.15-wip' of git://people.freedesktop.org/~deathsimple/linux: drm/radeon: Improve vramlimit module param documentation drm/radeon: fix audio pin counts for DCE6+ (v2) drm/radeon/dp: switch to the common i2c over aux code drm/dp/i2c: Update comments about common i2c over dp assumptions (v3) drm/dp/i2c: send bare addresses to properly reset i2c connections (v4) drm/radeon/dp: handle zero sized i2c over aux transactions (v2) drm/i915: support address only i2c-over-aux transactions drm/tegra: dp: Support address-only I2C-over-AUX transactions
2 parents c044330 + 8902e6f commit a42892e

File tree

13 files changed

+152
-247
lines changed

13 files changed

+152
-247
lines changed

drivers/gpu/drm/drm_dp_helper.c

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,9 @@ static u32 drm_dp_i2c_functionality(struct i2c_adapter *adapter)
577577

578578
/*
579579
* 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.
581583
*/
582584
static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
583585
{
@@ -665,11 +667,26 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
665667
{
666668
struct drm_dp_aux *aux = adapter->algo_data;
667669
unsigned int i, j;
670+
struct drm_dp_aux_msg msg;
671+
int err = 0;
668672

669-
for (i = 0; i < num; i++) {
670-
struct drm_dp_aux_msg msg;
671-
int err;
673+
memset(&msg, 0, sizeof(msg));
672674

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;
673690
/*
674691
* Many hardware implementations support FIFOs larger than a
675692
* 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,
678695
* transferred byte-by-byte.
679696
*/
680697
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-
695698
msg.buffer = msgs[i].buf + j;
696699
msg.size = 1;
697700

698701
err = drm_dp_i2c_do_msg(aux, &msg);
699702
if (err < 0)
700-
return err;
703+
break;
701704
}
705+
if (err < 0)
706+
break;
702707
}
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);
703718

704-
return num;
719+
return err;
705720
}
706721

707722
static const struct i2c_algorithm drm_dp_i2c_algo = {

drivers/gpu/drm/i915/intel_dp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
575575
return ret;
576576
}
577577

578-
#define HEADER_SIZE 4
578+
#define BARE_ADDRESS_SIZE 3
579+
#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)
579580
static ssize_t
580581
intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
581582
{
@@ -592,7 +593,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
592593
switch (msg->request & ~DP_AUX_I2C_MOT) {
593594
case DP_AUX_NATIVE_WRITE:
594595
case DP_AUX_I2C_WRITE:
595-
txsize = HEADER_SIZE + msg->size;
596+
txsize = msg->size ? HEADER_SIZE + msg->size : BARE_ADDRESS_SIZE;
596597
rxsize = 1;
597598

598599
if (WARN_ON(txsize > 20))
@@ -611,7 +612,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
611612

612613
case DP_AUX_NATIVE_READ:
613614
case DP_AUX_I2C_READ:
614-
txsize = HEADER_SIZE;
615+
txsize = msg->size ? HEADER_SIZE : BARE_ADDRESS_SIZE;
615616
rxsize = msg->size + 1;
616617

617618
if (WARN_ON(rxsize > 20))

drivers/gpu/drm/radeon/atombios_dp.c

Lines changed: 35 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
142142
return recv_bytes;
143143
}
144144

145-
#define HEADER_SIZE 4
145+
#define BARE_ADDRESS_SIZE 3
146+
#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)
146147

147148
static ssize_t
148149
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)
160161
tx_buf[0] = msg->address & 0xff;
161162
tx_buf[1] = msg->address >> 8;
162163
tx_buf[2] = msg->request << 4;
163-
tx_buf[3] = msg->size - 1;
164+
tx_buf[3] = msg->size ? (msg->size - 1) : 0;
164165

165166
switch (msg->request & ~DP_AUX_I2C_MOT) {
166167
case DP_AUX_NATIVE_WRITE:
167168
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+
*/
168172
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;
170177
memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size);
171178
ret = radeon_process_aux_ch(chan,
172179
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)
176183
break;
177184
case DP_AUX_NATIVE_READ:
178185
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+
*/
179189
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;
181194
ret = radeon_process_aux_ch(chan,
182195
tx_buf, tx_size, msg->buffer, msg->size, delay, &ack);
183196
break;
@@ -186,106 +199,23 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
186199
break;
187200
}
188201

189-
if (ret > 0)
202+
if (ret >= 0)
190203
msg->reply = ack >> 4;
191204

192205
return ret;
193206
}
194207

195208
void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
196209
{
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;
214210
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-
}
268211

269-
switch ((ack >> 4) & DP_AUX_I2C_REPLY_MASK) {
270-
case DP_AUX_I2C_REPLY_ACK:
271-
if (mode == MODE_I2C_READ)
272-
*read_byte = reply[0];
273-
return ret;
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-
}
212+
radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
213+
radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer;
214+
ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux);
215+
if (!ret)
216+
radeon_connector->ddc_bus->has_aux = true;
286217

287-
DRM_DEBUG_KMS("aux i2c too many retries, giving up\n");
288-
return -EREMOTEIO;
218+
WARN(ret, "drm_dp_aux_register_i2c_bus() failed with error %d\n", ret);
289219
}
290220

291221
/***** general DP utility functions *****/
@@ -420,12 +350,11 @@ static u8 radeon_dp_encoder_service(struct radeon_device *rdev,
420350

421351
u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector)
422352
{
423-
struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv;
424353
struct drm_device *dev = radeon_connector->base.dev;
425354
struct radeon_device *rdev = dev->dev_private;
426355

427356
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);
429358
}
430359

431360
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)
436365
if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
437366
return;
438367

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))
440369
DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
441370
buf[0], buf[1], buf[2]);
442371

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))
444373
DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
445374
buf[0], buf[1], buf[2]);
446375
}
@@ -451,7 +380,7 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector)
451380
u8 msg[DP_DPCD_SIZE];
452381
int ret, i;
453382

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,
455384
DP_DPCD_SIZE);
456385
if (ret > 0) {
457386
memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
@@ -489,7 +418,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
489418

490419
if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
491420
/* DP bridge chips */
492-
drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux,
421+
drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
493422
DP_EDP_CONFIGURATION_CAP, &tmp);
494423
if (tmp & 1)
495424
panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
@@ -500,7 +429,7 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
500429
panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
501430
} else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
502431
/* eDP */
503-
drm_dp_dpcd_readb(&dig_connector->dp_i2c_bus->aux,
432+
drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
504433
DP_EDP_CONFIGURATION_CAP, &tmp);
505434
if (tmp & 1)
506435
panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
@@ -554,7 +483,8 @@ bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector)
554483
u8 link_status[DP_LINK_STATUS_SIZE];
555484
struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
556485

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)
558488
return false;
559489
if (drm_dp_channel_eq_ok(link_status, dig->dp_lane_count))
560490
return false;
@@ -574,7 +504,7 @@ void radeon_dp_set_rx_power_state(struct drm_connector *connector,
574504

575505
/* power up/down the sink */
576506
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,
578508
DP_SET_POWER, power_state);
579509
usleep_range(1000, 2000);
580510
}
@@ -878,7 +808,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
878808
else
879809
dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A;
880810

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);
882812
if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
883813
dp_info.tp3_supported = true;
884814
else
@@ -890,7 +820,7 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
890820
dp_info.connector = connector;
891821
dp_info.dp_lane_count = dig_connector->dp_lane_count;
892822
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;
894824

895825
if (radeon_dp_link_train_init(&dp_info))
896826
goto done;

drivers/gpu/drm/radeon/dce6_afmt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,17 @@ int dce6_audio_init(struct radeon_device *rdev)
309309

310310
rdev->audio.enabled = true;
311311

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 */
313319
rdev->audio.num_pins = 6;
314-
else if (ASIC_IS_DCE61(rdev))
315-
rdev->audio.num_pins = 4;
316-
else
320+
else if (ASIC_IS_DCE64(rdev)) /* OL: 2 streams, 2 endpoints */
321+
rdev->audio.num_pins = 2;
322+
else /* SI: 6 streams, 6 endpoints */
317323
rdev->audio.num_pins = 6;
318324

319325
for (i = 0; i < rdev->audio.num_pins; i++) {

0 commit comments

Comments
 (0)