summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-07-02 18:15:39 -0600
committerSimon Glass <sjg@chromium.org>2015-08-05 20:57:51 -0600
commit7d7db2225c5e63a389ee04d63919f012e7ba880d (patch)
tree66f8381e57291bc502753c87f1461dbe4a05b325 /drivers/i2c
parentd82ba4c0b457f0cb30da7bbee935aad7793e5fac (diff)
downloadu-boot-imx-7d7db2225c5e63a389ee04d63919f012e7ba880d.zip
u-boot-imx-7d7db2225c5e63a389ee04d63919f012e7ba880d.tar.gz
u-boot-imx-7d7db2225c5e63a389ee04d63919f012e7ba880d.tar.bz2
dm: i2c: Add a message debug function
Add a way to dump the contents of an I2C message for debugging purposes. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-uclass.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index eaba965..42d6e89 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -18,6 +18,22 @@ DECLARE_GLOBAL_DATA_PTR;
#define I2C_MAX_OFFSET_LEN 4
+/* Useful debugging function */
+void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs)
+{
+ int i;
+
+ for (i = 0; i < nmsgs; i++) {
+ struct i2c_msg *m = &msg[i];
+
+ printf(" %s %x len=%x", m->flags & I2C_M_RD ? "R" : "W",
+ msg->addr, msg->len);
+ if (!(m->flags & I2C_M_RD))
+ printf(": %x", m->buf[0]);
+ printf("\n");
+ }
+}
+
/**
* i2c_setup_offset() - Set up a new message with a chip offset
*