Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 357895
b: refs/heads/master
c: 2c438c0
h: refs/heads/master
i:
  357893: b5a3616
  357891: 6d17814
  357887: 39060d6
v: v3
  • Loading branch information
Daniel Vetter committed Dec 6, 2012
1 parent c62096f commit 2feb939
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 28c70f162a315bdcfbe0bf940a740ef8bfb918d6
refs/heads/master: 2c438c0273b76d6cb158f8bdd0aa3ebf66e48a28
32 changes: 28 additions & 4 deletions trunk/drivers/gpu/drm/i915/intel_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ intel_gpio_setup(struct intel_gmbus *bus, u32 pin)
algo->data = bus;
}

#define HAS_GMBUS_IRQ(dev) (INTEL_INFO(dev)->gen >= 4)
static int
gmbus_wait_hw_status(struct drm_i915_private *dev_priv,
u32 gmbus2_status,
Expand Down Expand Up @@ -239,6 +240,31 @@ gmbus_wait_hw_status(struct drm_i915_private *dev_priv,
return -ETIMEDOUT;
}

static int
gmbus_wait_idle(struct drm_i915_private *dev_priv)
{
int ret;
int reg_offset = dev_priv->gpio_mmio_base;

#define C ((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0)

if (!HAS_GMBUS_IRQ(dev_priv->dev))
return wait_for(C, 10);

/* Important: The hw handles only the first bit, so set only one! */
I915_WRITE(GMBUS4 + reg_offset, GMBUS_IDLE_EN);

ret = wait_event_timeout(dev_priv->gmbus_wait_queue, C, 10);

I915_WRITE(GMBUS4 + reg_offset, 0);

if (ret)
return 0;
else
return -ETIMEDOUT;
#undef C
}

static int
gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
u32 gmbus1_index)
Expand Down Expand Up @@ -406,8 +432,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
* We will re-enable it at the start of the next xfer,
* till then let it sleep.
*/
if (wait_for((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0,
10)) {
if (gmbus_wait_idle(dev_priv)) {
DRM_DEBUG_KMS("GMBUS [%s] timed out waiting for idle\n",
adapter->name);
ret = -ETIMEDOUT;
Expand All @@ -431,8 +456,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
* it's slow responding and only answers on the 2nd retry.
*/
ret = -ENXIO;
if (wait_for((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0,
10)) {
if (gmbus_wait_idle(dev_priv)) {
DRM_DEBUG_KMS("GMBUS [%s] timed out after NAK\n",
adapter->name);
ret = -ETIMEDOUT;
Expand Down

0 comments on commit 2feb939

Please sign in to comment.