Skip to content

Commit 7f58aab

Browse files
committed
drm/i915: Reset GMBUS controller after NAK
Once a NAK has been asserted by the slave, we need to reset the GMBUS controller in order to continue. This is done by asserting the Software Clear Interrupt bit and then clearing it again to restore operations. If we don't clear the NAK, then all future GMBUS xfers will fail, including DDC probes and EDID retrieval. v2: Add some comments as suggested by Keith Packard. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=35781 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Jesse Barnes <jbarnes@virtuousgeek.org> Tested-by: "Mengmeng Meng" <mengmeng.meng@intel.com>
1 parent 9f01b25 commit 7f58aab

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

drivers/gpu/drm/i915/intel_i2c.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
259259
if (wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_RDY), 50))
260260
goto timeout;
261261
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
262-
return 0;
262+
goto clear_err;
263263

264264
val = I915_READ(GMBUS3 + reg_offset);
265265
do {
@@ -287,7 +287,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
287287
if (wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_RDY), 50))
288288
goto timeout;
289289
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
290-
return 0;
290+
goto clear_err;
291291

292292
val = loop = 0;
293293
do {
@@ -302,14 +302,31 @@ gmbus_xfer(struct i2c_adapter *adapter,
302302
if (i + 1 < num && wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_WAIT_PHASE), 50))
303303
goto timeout;
304304
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
305-
return 0;
305+
goto clear_err;
306306
}
307307

308-
return num;
308+
goto done;
309+
310+
clear_err:
311+
/* Toggle the Software Clear Interrupt bit. This has the effect
312+
* of resetting the GMBUS controller and so clearing the
313+
* BUS_ERROR raised by the slave's NAK.
314+
*/
315+
I915_WRITE(GMBUS1 + reg_offset, GMBUS_SW_CLR_INT);
316+
I915_WRITE(GMBUS1 + reg_offset, 0);
317+
318+
done:
319+
/* Mark the GMBUS interface as disabled. We will re-enable it at the
320+
* start of the next xfer, till then let it sleep.
321+
*/
322+
I915_WRITE(GMBUS0 + reg_offset, 0);
323+
return i;
309324

310325
timeout:
311326
DRM_INFO("GMBUS timed out, falling back to bit banging on pin %d [%s]\n",
312327
bus->reg0 & 0xff, bus->adapter.name);
328+
I915_WRITE(GMBUS0 + reg_offset, 0);
329+
313330
/* Hardware may not support GMBUS over these pins? Try GPIO bitbanging instead. */
314331
bus->force_bit = intel_gpio_create(dev_priv, bus->reg0 & 0xff);
315332
if (!bus->force_bit)

0 commit comments

Comments
 (0)