Commit a8ed0b16 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Tidy dvo_ch7017 and print out which chip we detect

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent b8232e90
...@@ -165,56 +165,35 @@ struct ch7017_priv { ...@@ -165,56 +165,35 @@ struct ch7017_priv {
static void ch7017_dump_regs(struct intel_dvo_device *dvo); static void ch7017_dump_regs(struct intel_dvo_device *dvo);
static void ch7017_dpms(struct intel_dvo_device *dvo, int mode); static void ch7017_dpms(struct intel_dvo_device *dvo, int mode);
static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val) static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val)
{ {
struct i2c_adapter *adapter = dvo->i2c_bus;
u8 out_buf[2];
u8 in_buf[2];
struct i2c_msg msgs[] = { struct i2c_msg msgs[] = {
{ {
.addr = dvo->slave_addr, .addr = dvo->slave_addr,
.flags = 0, .flags = 0,
.len = 1, .len = 1,
.buf = out_buf, .buf = &addr,
}, },
{ {
.addr = dvo->slave_addr, .addr = dvo->slave_addr,
.flags = I2C_M_RD, .flags = I2C_M_RD,
.len = 1, .len = 1,
.buf = in_buf, .buf = val,
} }
}; };
return i2c_transfer(dvo->i2c_bus, msgs, 2) == 2;
out_buf[0] = addr;
out_buf[1] = 0;
if (i2c_transfer(adapter, msgs, 2) == 2) {
*val= in_buf[0];
return true;
};
return false;
} }
static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val) static bool ch7017_write(struct intel_dvo_device *dvo, u8 addr, u8 val)
{ {
struct i2c_adapter *adapter = dvo->i2c_bus; uint8_t buf[2] = { addr, val };
uint8_t out_buf[2];
struct i2c_msg msg = { struct i2c_msg msg = {
.addr = dvo->slave_addr, .addr = dvo->slave_addr,
.flags = 0, .flags = 0,
.len = 2, .len = 2,
.buf = out_buf, .buf = buf,
}; };
return i2c_transfer(dvo->i2c_bus, &msg, 1) == 1;
out_buf[0] = addr;
out_buf[1] = val;
if (i2c_transfer(adapter, &msg, 1) == 1)
return true;
return false;
} }
/** Probes for a CH7017 on the given bus and slave address. */ /** Probes for a CH7017 on the given bus and slave address. */
...@@ -222,7 +201,8 @@ static bool ch7017_init(struct intel_dvo_device *dvo, ...@@ -222,7 +201,8 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
struct i2c_adapter *adapter) struct i2c_adapter *adapter)
{ {
struct ch7017_priv *priv; struct ch7017_priv *priv;
uint8_t val; const char *str;
u8 val;
priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL); priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL);
if (priv == NULL) if (priv == NULL)
...@@ -234,16 +214,27 @@ static bool ch7017_init(struct intel_dvo_device *dvo, ...@@ -234,16 +214,27 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val)) if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val))
goto fail; goto fail;
if (val != CH7017_DEVICE_ID_VALUE && switch (val) {
val != CH7018_DEVICE_ID_VALUE && case CH7017_DEVICE_ID_VALUE:
val != CH7019_DEVICE_ID_VALUE) { str = "ch7017";
break;
case CH7018_DEVICE_ID_VALUE:
str = "ch7018";
break;
case CH7019_DEVICE_ID_VALUE:
str = "ch7019";
break;
default:
DRM_DEBUG_KMS("ch701x not detected, got %d: from %s " DRM_DEBUG_KMS("ch701x not detected, got %d: from %s "
"Slave %d.\n", "slave %d.\n",
val, adapter->name,dvo->slave_addr); val, adapter->name,dvo->slave_addr);
goto fail; goto fail;
} }
DRM_DEBUG_KMS("%s detected on %s, addr %d\n",
str, adapter->name, dvo->slave_addr);
return true; return true;
fail: fail:
kfree(priv); kfree(priv);
return false; return false;
...@@ -365,7 +356,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -365,7 +356,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode)
} }
/* XXX: Should actually wait for update power status somehow */ /* XXX: Should actually wait for update power status somehow */
udelay(20000); msleep(20);
} }
static void ch7017_dump_regs(struct intel_dvo_device *dvo) static void ch7017_dump_regs(struct intel_dvo_device *dvo)
......
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