Commit 789505b0 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "Two fixes from Intel, one a regression, one because I merged an early
  version of a fix.

  Also the nouveau revert of the i2c code that was tested on the list."

* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
  drm/nouveau/i2c: resume use of i2c-algo-bit, rather than custom stack
  drm/i915: Do no set Stencil Cache eviction LRA w/a on gen7+
  drm/i915: disable sdvo hotplug on i945g/gm
parents 4ed6cede ec9b3a9d
...@@ -398,10 +398,8 @@ static int init_render_ring(struct intel_ring_buffer *ring) ...@@ -398,10 +398,8 @@ static int init_render_ring(struct intel_ring_buffer *ring)
return ret; return ret;
} }
if (INTEL_INFO(dev)->gen >= 6) {
I915_WRITE(INSTPM,
INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING);
if (IS_GEN6(dev)) {
/* From the Sandybridge PRM, volume 1 part 3, page 24: /* From the Sandybridge PRM, volume 1 part 3, page 24:
* "If this bit is set, STCunit will have LRA as replacement * "If this bit is set, STCunit will have LRA as replacement
* policy. [...] This bit must be reset. LRA replacement * policy. [...] This bit must be reset. LRA replacement
...@@ -411,6 +409,11 @@ static int init_render_ring(struct intel_ring_buffer *ring) ...@@ -411,6 +409,11 @@ static int init_render_ring(struct intel_ring_buffer *ring)
CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT); CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT);
} }
if (INTEL_INFO(dev)->gen >= 6) {
I915_WRITE(INSTPM,
INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING);
}
return ret; return ret;
} }
......
...@@ -1220,8 +1220,14 @@ static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in ...@@ -1220,8 +1220,14 @@ static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in
static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo) static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo)
{ {
struct drm_device *dev = intel_sdvo->base.base.dev;
u8 response[2]; u8 response[2];
/* HW Erratum: SDVO Hotplug is broken on all i945G chips, there's noise
* on the line. */
if (IS_I945G(dev) || IS_I945GM(dev))
return false;
return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
&response, 2) && response[0]; &response, 2) && response[0];
} }
......
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#include "nouveau_i2c.h" #include "nouveau_i2c.h"
#include "nouveau_hw.h" #include "nouveau_hw.h"
#define T_TIMEOUT 2200000
#define T_RISEFALL 1000
#define T_HOLD 5000
static void static void
i2c_drive_scl(void *data, int state) i2c_drive_scl(void *data, int state)
{ {
...@@ -113,175 +109,6 @@ i2c_sense_sda(void *data) ...@@ -113,175 +109,6 @@ i2c_sense_sda(void *data)
return 0; return 0;
} }
static void
i2c_delay(struct nouveau_i2c_chan *port, u32 nsec)
{
udelay((nsec + 500) / 1000);
}
static bool
i2c_raise_scl(struct nouveau_i2c_chan *port)
{
u32 timeout = T_TIMEOUT / T_RISEFALL;
i2c_drive_scl(port, 1);
do {
i2c_delay(port, T_RISEFALL);
} while (!i2c_sense_scl(port) && --timeout);
return timeout != 0;
}
static int
i2c_start(struct nouveau_i2c_chan *port)
{
int ret = 0;
port->state = i2c_sense_scl(port);
port->state |= i2c_sense_sda(port) << 1;
if (port->state != 3) {
i2c_drive_scl(port, 0);
i2c_drive_sda(port, 1);
if (!i2c_raise_scl(port))
ret = -EBUSY;
}
i2c_drive_sda(port, 0);
i2c_delay(port, T_HOLD);
i2c_drive_scl(port, 0);
i2c_delay(port, T_HOLD);
return ret;
}
static void
i2c_stop(struct nouveau_i2c_chan *port)
{
i2c_drive_scl(port, 0);
i2c_drive_sda(port, 0);
i2c_delay(port, T_RISEFALL);
i2c_drive_scl(port, 1);
i2c_delay(port, T_HOLD);
i2c_drive_sda(port, 1);
i2c_delay(port, T_HOLD);
}
static int
i2c_bitw(struct nouveau_i2c_chan *port, int sda)
{
i2c_drive_sda(port, sda);
i2c_delay(port, T_RISEFALL);
if (!i2c_raise_scl(port))
return -ETIMEDOUT;
i2c_delay(port, T_HOLD);
i2c_drive_scl(port, 0);
i2c_delay(port, T_HOLD);
return 0;
}
static int
i2c_bitr(struct nouveau_i2c_chan *port)
{
int sda;
i2c_drive_sda(port, 1);
i2c_delay(port, T_RISEFALL);
if (!i2c_raise_scl(port))
return -ETIMEDOUT;
i2c_delay(port, T_HOLD);
sda = i2c_sense_sda(port);
i2c_drive_scl(port, 0);
i2c_delay(port, T_HOLD);
return sda;
}
static int
i2c_get_byte(struct nouveau_i2c_chan *port, u8 *byte, bool last)
{
int i, bit;
*byte = 0;
for (i = 7; i >= 0; i--) {
bit = i2c_bitr(port);
if (bit < 0)
return bit;
*byte |= bit << i;
}
return i2c_bitw(port, last ? 1 : 0);
}
static int
i2c_put_byte(struct nouveau_i2c_chan *port, u8 byte)
{
int i, ret;
for (i = 7; i >= 0; i--) {
ret = i2c_bitw(port, !!(byte & (1 << i)));
if (ret < 0)
return ret;
}
ret = i2c_bitr(port);
if (ret == 1) /* nack */
ret = -EIO;
return ret;
}
static int
i2c_addr(struct nouveau_i2c_chan *port, struct i2c_msg *msg)
{
u32 addr = msg->addr << 1;
if (msg->flags & I2C_M_RD)
addr |= 1;
return i2c_put_byte(port, addr);
}
static int
i2c_bit_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
struct nouveau_i2c_chan *port = (struct nouveau_i2c_chan *)adap;
struct i2c_msg *msg = msgs;
int ret = 0, mcnt = num;
while (!ret && mcnt--) {
u8 remaining = msg->len;
u8 *ptr = msg->buf;
ret = i2c_start(port);
if (ret == 0)
ret = i2c_addr(port, msg);
if (msg->flags & I2C_M_RD) {
while (!ret && remaining--)
ret = i2c_get_byte(port, ptr++, !remaining);
} else {
while (!ret && remaining--)
ret = i2c_put_byte(port, *ptr++);
}
msg++;
}
i2c_stop(port);
return (ret < 0) ? ret : num;
}
static u32
i2c_bit_func(struct i2c_adapter *adap)
{
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
}
const struct i2c_algorithm nouveau_i2c_bit_algo = {
.master_xfer = i2c_bit_xfer,
.functionality = i2c_bit_func
};
static const uint32_t nv50_i2c_port[] = { static const uint32_t nv50_i2c_port[] = {
0x00e138, 0x00e150, 0x00e168, 0x00e180, 0x00e138, 0x00e150, 0x00e168, 0x00e180,
0x00e254, 0x00e274, 0x00e764, 0x00e780, 0x00e254, 0x00e274, 0x00e764, 0x00e780,
...@@ -384,12 +211,10 @@ nouveau_i2c_init(struct drm_device *dev) ...@@ -384,12 +211,10 @@ nouveau_i2c_init(struct drm_device *dev)
case 0: /* NV04:NV50 */ case 0: /* NV04:NV50 */
port->drive = entry[0]; port->drive = entry[0];
port->sense = entry[1]; port->sense = entry[1];
port->adapter.algo = &nouveau_i2c_bit_algo;
break; break;
case 4: /* NV4E */ case 4: /* NV4E */
port->drive = 0x600800 + entry[1]; port->drive = 0x600800 + entry[1];
port->sense = port->drive; port->sense = port->drive;
port->adapter.algo = &nouveau_i2c_bit_algo;
break; break;
case 5: /* NV50- */ case 5: /* NV50- */
port->drive = entry[0] & 0x0f; port->drive = entry[0] & 0x0f;
...@@ -402,7 +227,6 @@ nouveau_i2c_init(struct drm_device *dev) ...@@ -402,7 +227,6 @@ nouveau_i2c_init(struct drm_device *dev)
port->drive = 0x00d014 + (port->drive * 0x20); port->drive = 0x00d014 + (port->drive * 0x20);
port->sense = port->drive; port->sense = port->drive;
} }
port->adapter.algo = &nouveau_i2c_bit_algo;
break; break;
case 6: /* NV50- DP AUX */ case 6: /* NV50- DP AUX */
port->drive = entry[0]; port->drive = entry[0];
...@@ -413,7 +237,7 @@ nouveau_i2c_init(struct drm_device *dev) ...@@ -413,7 +237,7 @@ nouveau_i2c_init(struct drm_device *dev)
break; break;
} }
if (!port->adapter.algo) { if (!port->adapter.algo && !port->drive) {
NV_ERROR(dev, "I2C%d: type %d index %x/%x unknown\n", NV_ERROR(dev, "I2C%d: type %d index %x/%x unknown\n",
i, port->type, port->drive, port->sense); i, port->type, port->drive, port->sense);
kfree(port); kfree(port);
...@@ -429,7 +253,26 @@ nouveau_i2c_init(struct drm_device *dev) ...@@ -429,7 +253,26 @@ nouveau_i2c_init(struct drm_device *dev)
port->dcb = ROM32(entry[0]); port->dcb = ROM32(entry[0]);
i2c_set_adapdata(&port->adapter, i2c); i2c_set_adapdata(&port->adapter, i2c);
if (port->adapter.algo != &nouveau_dp_i2c_algo) {
port->adapter.algo_data = &port->bit;
port->bit.udelay = 10;
port->bit.timeout = usecs_to_jiffies(2200);
port->bit.data = port;
port->bit.setsda = i2c_drive_sda;
port->bit.setscl = i2c_drive_scl;
port->bit.getsda = i2c_sense_sda;
port->bit.getscl = i2c_sense_scl;
i2c_drive_scl(port, 0);
i2c_drive_sda(port, 1);
i2c_drive_scl(port, 1);
ret = i2c_bit_add_bus(&port->adapter);
} else {
port->adapter.algo = &nouveau_dp_i2c_algo;
ret = i2c_add_adapter(&port->adapter); ret = i2c_add_adapter(&port->adapter);
}
if (ret) { if (ret) {
NV_ERROR(dev, "I2C%d: failed register: %d\n", i, ret); NV_ERROR(dev, "I2C%d: failed register: %d\n", i, ret);
kfree(port); kfree(port);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
struct nouveau_i2c_chan { struct nouveau_i2c_chan {
struct i2c_adapter adapter; struct i2c_adapter adapter;
struct drm_device *dev; struct drm_device *dev;
struct i2c_algo_bit_data bit;
struct list_head head; struct list_head head;
u8 index; u8 index;
u8 type; u8 type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment