UPSTREAM: drm/i915/intel_i2c: use WAIT cycle, not STOP
authorDaniel Kurtz <djkurtz@chromium.org>
Fri, 30 Mar 2012 11:46:39 +0000 (19:46 +0800)
committerGrant Grundler <grundler@google.com>
Thu, 24 May 2012 22:13:19 +0000 (15:13 -0700)
commit957bd4d8154eaabb440f9d33da4ea71014a15393
tree2bef03a0af8baf7967eb419a7d4f41fc15f5287c
parent4e31e5ecbbcbb30d0f4c769c9e88555f28eac1b6
UPSTREAM: drm/i915/intel_i2c: use WAIT cycle, not STOP

The i915 is only able to generate a STOP cycle (i.e. finalize an i2c
transaction) during a DATA or WAIT phase.  In other words, the
controller rejects a STOP requested as part of the first transaction in a
sequence.

Thus, for the first transaction we must always use a WAIT cycle, detect
when the device has finished (and is in a WAIT phase), and then either
start the next transaction, or, if there are no more transactions,
generate a STOP cycle.

Note: Theoretically, the last transaction of a multi-transaction sequence
could initiate a STOP cycle.  However, this slight optimization is left
for another patch.  We return -ETIMEDOUT if the hardware doesn't
deactivate after the STOP cycle.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
[danvet: added comment to the code that gmbus can't generate STOP on
the very first cycle.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 72d66afd1461effb143784a0f6cde2a9f9908b70)

Change-Id: Idf84c86090b12b0c10a78497ff41330dabcf5ebe
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
drivers/gpu/drm/i915/intel_i2c.c