diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2013-02-11 20:06:04 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-02-20 16:00:56 +1000 |
commit | df3ef6a1091fbdfb57306b0205edef33a1f1dcb4 (patch) | |
tree | 87cbc093d868bbcb499ad91cb5e63300ec05b154 | |
parent | f63740fd580e0645c5123897891b72ec25b396ef (diff) |
drm/nouveau/i2c: handle i2c/aux mux outside of port lookup function
Not quite how I want it yet, but, I'll fix that at some point. For
right now, it's needed because find() won't necessarily be used right
before a transaction anymore.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 41 |
2 files changed, 36 insertions, 21 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c index dc27e794a851..1a428743cf8e 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c @@ -150,15 +150,29 @@ out: return ret; } +static void +auxch_mux(struct nouveau_i2c_port *port) +{ + if (port->dcb & 0x00000100) { + u32 reg = 0x00e500 + (port->drive * 0x50); + /* nfi, but neither auxch or i2c work if it's 1 */ + nv_mask(port->i2c, reg + 0x0c, 0x00000001, 0x00000000); + /* nfi, but switches auxch vs normal i2c */ + nv_mask(port->i2c, reg + 0x00, 0x0000f003, 0x00002002); + } +} + int nv_rdaux(struct nouveau_i2c_port *auxch, u32 addr, u8 *data, u8 size) { + auxch_mux(auxch); return auxch_tx(auxch->i2c, auxch->drive, 9, addr, data, size); } int nv_wraux(struct nouveau_i2c_port *auxch, u32 addr, u8 *data, u8 size) { + auxch_mux(auxch); return auxch_tx(auxch->i2c, auxch->drive, 8, addr, data, size); } @@ -169,6 +183,8 @@ aux_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) struct i2c_msg *msg = msgs; int ret, mcnt = num; + auxch_mux(auxch); + while (mcnt--) { u8 remaining = msg->len; u8 *ptr = msg->buf; diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c index dbfc2abf0cfe..1ee53d3cbd01 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c @@ -103,29 +103,10 @@ nouveau_i2c_find(struct nouveau_i2c *i2c, u8 index) list_for_each_entry(port, &i2c->ports, head) { if (port->index == index) - break; - } - - if (&port->head == &i2c->ports) - return NULL; - - if (nv_device(i2c)->card_type >= NV_50 && (port->dcb & 0x00000100)) { - u32 reg = 0x00e500, val; - if (port->type == 6) { - reg += port->drive * 0x50; - val = 0x2002; - } else { - reg += ((port->dcb & 0x1e00) >> 9) * 0x50; - val = 0xe001; - } - - /* nfi, but neither auxch or i2c work if it's 1 */ - nv_mask(i2c, reg + 0x0c, 0x00000001, 0x00000000); - /* nfi, but switches auxch vs normal i2c */ - nv_mask(i2c, reg + 0x00, 0x0000f003, val); + return port; } - return port; + return NULL; } static int @@ -241,6 +222,23 @@ nouveau_i2c_sense_sda(void *data) return 0; } +static int +nouveau_i2c_pre_xfer(struct i2c_adapter *adap) +{ + struct nouveau_i2c_port *port = (void *)adap; + struct nouveau_i2c *i2c = port->i2c; + + if (nv_device(i2c)->card_type >= NV_50 && (port->dcb & 0x00000100)) { + u32 reg = 0x00e500 + ((port->dcb & 0x1e00) >> 9) * 0x50; + /* nfi, but neither auxch or i2c work if it's 1 */ + nv_mask(i2c, reg + 0x0c, 0x00000001, 0x00000000); + /* nfi, but switches auxch vs normal i2c */ + nv_mask(i2c, reg + 0x00, 0x0000f003, 0x0000e001); + } + + return 0; +} + static const u32 nv50_i2c_port[] = { 0x00e138, 0x00e150, 0x00e168, 0x00e180, 0x00e254, 0x00e274, 0x00e764, 0x00e780, @@ -347,6 +345,7 @@ nouveau_i2c_ctor(struct nouveau_object *parent, struct nouveau_object *engine, port->bit.setscl = nouveau_i2c_drive_scl; port->bit.getsda = nouveau_i2c_sense_sda; port->bit.getscl = nouveau_i2c_sense_scl; + port->bit.pre_xfer = nouveau_i2c_pre_xfer; ret = i2c_bit_add_bus(&port->adapter); } } else { |