Commit 1cb57d25 authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/i2c: switch to subdev printk macros



Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 3ecd329b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@ struct anx9805_i2c_port {
static int
anx9805_train(struct nvkm_i2c_port *port, int link_nr, int link_bw, bool enh)
{
	struct nvkm_i2c *i2c = nvkm_i2c(port);
	struct nvkm_subdev *subdev = &i2c->subdev;
	struct anx9805_i2c_port *chan = (void *)port;
	struct nvkm_i2c_port *mast = (void *)nv_object(chan)->parent;
	u8 tmp, i;

	DBG("ANX9805 train %d 0x%02x %d\n", link_nr, link_bw, enh);
	DBG("ANX9805 train %d %02x %d\n", link_nr, link_bw, enh);

	nv_wri2cr(mast, chan->addr, 0xa0, link_bw);
	nv_wri2cr(mast, chan->addr, 0xa1, link_nr | (enh ? 0x80 : 0x00));
@@ -47,13 +49,13 @@ anx9805_train(struct nvkm_i2c_port *port, int link_nr, int link_bw, bool enh)
	while ((tmp = nv_rdi2cr(mast, chan->addr, 0xa8)) & 0x01) {
		mdelay(5);
		if (i++ == 100) {
			nv_error(port, "link training timed out\n");
			nvkm_error(subdev, "link training timed out\n");
			return -ETIMEDOUT;
		}
	}

	if (tmp & 0x70) {
		nv_error(port, "link training failed: 0x%02x\n", tmp);
		nvkm_error(subdev, "link training failed: %02x\n", tmp);
		return -EIO;
	}

+10 −7
Original line number Diff line number Diff line
@@ -282,22 +282,25 @@ nvkm_i2c_identify(struct nvkm_i2c *i2c, int index, const char *what,
		  bool (*match)(struct nvkm_i2c_port *,
				struct i2c_board_info *, void *), void *data)
{
	struct nvkm_subdev *subdev = &i2c->subdev;
	struct nvkm_i2c_port *port = nvkm_i2c_find(i2c, index);
	int i;

	if (!port) {
		nv_debug(i2c, "no bus when probing %s on %d\n", what, index);
		nvkm_debug(subdev, "no bus when probing %s on %d\n",
			   what, index);
		return -ENODEV;
	}

	nv_debug(i2c, "probing %ss on bus: %d\n", what, port->index);
	nvkm_debug(subdev, "probing %ss on bus: %d\n", what, port->index);
	for (i = 0; info[i].dev.addr; i++) {
		u8 orig_udelay = 0;

		if ((port->adapter.algo == &i2c_bit_algo) &&
		    (info[i].udelay != 0)) {
			struct i2c_algo_bit_data *algo = port->adapter.algo_data;
			nv_debug(i2c, "using custom udelay %d instead of %d\n",
			nvkm_debug(subdev,
				   "using custom udelay %d instead of %d\n",
				   info[i].udelay, algo->udelay);
			orig_udelay = algo->udelay;
			algo->udelay = info[i].udelay;
@@ -305,7 +308,7 @@ nvkm_i2c_identify(struct nvkm_i2c *i2c, int index, const char *what,

		if (nv_probe_i2c(port, info[i].dev.addr) &&
		    (!match || match(port, &info[i].dev, data))) {
			nv_info(i2c, "detected %s: %s\n", what,
			nvkm_info(subdev, "detected %s: %s\n", what,
				  info[i].dev.type);
			return i;
		}
@@ -316,7 +319,7 @@ nvkm_i2c_identify(struct nvkm_i2c *i2c, int index, const char *what,
		}
	}

	nv_debug(i2c, "no devices found.\n");
	nvkm_debug(subdev, "no devices found.\n");
	return -ENODEV;
}

+11 −9
Original line number Diff line number Diff line
@@ -55,8 +55,10 @@ g94_aux_mask(struct nvkm_i2c *i2c, u32 type, u32 mask, u32 data)
	nvkm_wr32(device, 0x00e068, temp);
}

#define AUX_DBG(fmt, args...) nv_debug(i2c, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_ERR(fmt, args...) nv_error(i2c, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_DBG(fmt, args...)                                                  \
	nvkm_debug(&i2c->subdev, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_ERR(fmt, args...)                                                  \
	nvkm_error(&i2c->subdev, "AUXCH(%d): " fmt, ch, ##args)

static void
auxch_fini(struct nvkm_i2c *i2c, int ch)
@@ -80,7 +82,7 @@ auxch_init(struct nvkm_i2c *i2c, int ch)
		ctrl = nvkm_rd32(device, 0x00e4e4 + (ch * 0x50));
		udelay(1);
		if (!timeout--) {
			AUX_ERR("begin idle timeout 0x%08x\n", ctrl);
			AUX_ERR("begin idle timeout %08x\n", ctrl);
			return -EBUSY;
		}
	} while (ctrl & 0x03010000);
@@ -92,7 +94,7 @@ auxch_init(struct nvkm_i2c *i2c, int ch)
		ctrl = nvkm_rd32(device, 0x00e4e4 + (ch * 0x50));
		udelay(1);
		if (!timeout--) {
			AUX_ERR("magic wait 0x%08x\n", ctrl);
			AUX_ERR("magic wait %08x\n", ctrl);
			auxch_fini(i2c, ch);
			return -EBUSY;
		}
@@ -113,7 +115,7 @@ g94_aux(struct nvkm_i2c_port *base, bool retry,
	int ch = port->addr;
	int ret, i;

	AUX_DBG("%d: 0x%08x %d\n", type, addr, size);
	AUX_DBG("%d: %08x %d\n", type, addr, size);

	ret = auxch_init(i2c, ch);
	if (ret < 0)
@@ -129,7 +131,7 @@ g94_aux(struct nvkm_i2c_port *base, bool retry,
	if (!(type & 1)) {
		memcpy(xbuf, data, size);
		for (i = 0; i < 16; i += 4) {
			AUX_DBG("wr 0x%08x\n", xbuf[i / 4]);
			AUX_DBG("wr %08x\n", xbuf[i / 4]);
			nvkm_wr32(device, 0x00e4c0 + (ch * 0x50) + i, xbuf[i / 4]);
		}
	}
@@ -156,7 +158,7 @@ g94_aux(struct nvkm_i2c_port *base, bool retry,
			ctrl = nvkm_rd32(device, 0x00e4e4 + (ch * 0x50));
			udelay(1);
			if (!timeout--) {
				AUX_ERR("tx req timeout 0x%08x\n", ctrl);
				AUX_ERR("tx req timeout %08x\n", ctrl);
				ret = -EIO;
				goto out;
			}
@@ -173,13 +175,13 @@ g94_aux(struct nvkm_i2c_port *base, bool retry,
		if ((stat & 0x00000e00))
			ret = -EIO;

		AUX_DBG("%02d 0x%08x 0x%08x\n", retries, ctrl, stat);
		AUX_DBG("%02d %08x %08x\n", retries, ctrl, stat);
	}

	if (type & 1) {
		for (i = 0; i < 16; i += 4) {
			xbuf[i / 4] = nvkm_rd32(device, 0x00e4d0 + (ch * 0x50) + i);
			AUX_DBG("rd 0x%08x\n", xbuf[i / 4]);
			AUX_DBG("rd %08x\n", xbuf[i / 4]);
		}
		memcpy(data, xbuf, size);
	}
+11 −9
Original line number Diff line number Diff line
@@ -23,8 +23,10 @@
 */
#include "nv50.h"

#define AUX_DBG(fmt, args...) nv_debug(i2c, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_ERR(fmt, args...) nv_error(i2c, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_DBG(fmt, args...)                                                  \
	nvkm_debug(&i2c->subdev, "AUXCH(%d): " fmt, ch, ##args)
#define AUX_ERR(fmt, args...)                                                  \
	nvkm_error(&i2c->subdev, "AUXCH(%d): " fmt, ch, ##args)

static void
auxch_fini(struct nvkm_i2c *i2c, int ch)
@@ -48,7 +50,7 @@ auxch_init(struct nvkm_i2c *i2c, int ch)
		ctrl = nvkm_rd32(device, 0x00d954 + (ch * 0x50));
		udelay(1);
		if (!timeout--) {
			AUX_ERR("begin idle timeout 0x%08x\n", ctrl);
			AUX_ERR("begin idle timeout %08x\n", ctrl);
			return -EBUSY;
		}
	} while (ctrl & 0x03010000);
@@ -60,7 +62,7 @@ auxch_init(struct nvkm_i2c *i2c, int ch)
		ctrl = nvkm_rd32(device, 0x00d954 + (ch * 0x50));
		udelay(1);
		if (!timeout--) {
			AUX_ERR("magic wait 0x%08x\n", ctrl);
			AUX_ERR("magic wait %08x\n", ctrl);
			auxch_fini(i2c, ch);
			return -EBUSY;
		}
@@ -81,7 +83,7 @@ gm204_aux(struct nvkm_i2c_port *base, bool retry,
	int ch = port->addr;
	int ret, i;

	AUX_DBG("%d: 0x%08x %d\n", type, addr, size);
	AUX_DBG("%d: %08x %d\n", type, addr, size);

	ret = auxch_init(i2c, ch);
	if (ret < 0)
@@ -97,7 +99,7 @@ gm204_aux(struct nvkm_i2c_port *base, bool retry,
	if (!(type & 1)) {
		memcpy(xbuf, data, size);
		for (i = 0; i < 16; i += 4) {
			AUX_DBG("wr 0x%08x\n", xbuf[i / 4]);
			AUX_DBG("wr %08x\n", xbuf[i / 4]);
			nvkm_wr32(device, 0x00d930 + (ch * 0x50) + i, xbuf[i / 4]);
		}
	}
@@ -124,7 +126,7 @@ gm204_aux(struct nvkm_i2c_port *base, bool retry,
			ctrl = nvkm_rd32(device, 0x00d954 + (ch * 0x50));
			udelay(1);
			if (!timeout--) {
				AUX_ERR("tx req timeout 0x%08x\n", ctrl);
				AUX_ERR("tx req timeout %08x\n", ctrl);
				ret = -EIO;
				goto out;
			}
@@ -141,13 +143,13 @@ gm204_aux(struct nvkm_i2c_port *base, bool retry,
		if ((stat & 0x00000e00))
			ret = -EIO;

		AUX_DBG("%02d 0x%08x 0x%08x\n", retries, ctrl, stat);
		AUX_DBG("%02d %08x %08x\n", retries, ctrl, stat);
	}

	if (type & 1) {
		for (i = 0; i < 16; i += 4) {
			xbuf[i / 4] = nvkm_rd32(device, 0x00d940 + (ch * 0x50) + i);
			AUX_DBG("rd 0x%08x\n", xbuf[i / 4]);
			AUX_DBG("rd %08x\n", xbuf[i / 4]);
		}
		memcpy(data, xbuf, size);
	}
+5 −3
Original line number Diff line number Diff line
@@ -46,9 +46,11 @@ int _nvkm_i2c_pad_fini(struct nvkm_object *, bool);
#ifndef MSG
#define MSG(l,f,a...) do {                                                     \
	struct nvkm_i2c_pad *_pad = (void *)pad;                               \
	nv_##l(_pad, "PAD:%c:%02x: "f,                                         \
	struct nvkm_i2c *_i2c = nvkm_i2c(_pad);                                \
	nvkm_##l(&_i2c->subdev, "PAD:%c:%02x: "f,                              \
		 _pad->index >= 0x100 ? 'X' : 'S',                             \
	       _pad->index >= 0x100 ? _pad->index - 0x100 : _pad->index, ##a); \
		 _pad->index >= 0x100 ?                                        \
		 _pad->index - 0x100 : _pad->index, ##a);                      \
} while(0)
#define DBG(f,a...) MSG(debug, f, ##a)
#define ERR(f,a...) MSG(error, f, ##a)
Loading