aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-viapro.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index a89a21264d37..c1c9eb1d714f 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -104,6 +104,30 @@ static struct i2c_adapter vt596_adapter;
104#define FEATURE_I2CBLOCK (1<<0) 104#define FEATURE_I2CBLOCK (1<<0)
105static unsigned int vt596_features; 105static unsigned int vt596_features;
106 106
107#ifdef DEBUG
108static void vt596_dump_regs(const char *msg, u8 size)
109{
110 dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x "
111 "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT),
112 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
113 inb_p(SMBHSTDAT1));
114
115 if (size == VT596_BLOCK_DATA
116 || size == VT596_I2C_BLOCK_DATA) {
117 int i;
118
119 dev_dbg(&vt596_adapter.dev, "BLK=");
120 for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++)
121 printk("%02x,", inb_p(SMBBLKDAT));
122 printk("\n");
123 dev_dbg(&vt596_adapter.dev, " ");
124 for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++)
125 printk("%02x,", inb_p(SMBBLKDAT));
126 printk("%02x\n", inb_p(SMBBLKDAT));
127 }
128}
129#endif
130
107/* Return -1 on error, 0 on success */ 131/* Return -1 on error, 0 on success */
108static int vt596_transaction(u8 size) 132static int vt596_transaction(u8 size)
109{ 133{
@@ -111,10 +135,9 @@ static int vt596_transaction(u8 size)
111 int result = 0; 135 int result = 0;
112 int timeout = 0; 136 int timeout = 0;
113 137
114 dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " 138#ifdef DEBUG
115 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 139 vt596_dump_regs("Transaction (pre)", size);
116 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 140#endif
117 inb_p(SMBHSTDAT1));
118 141
119 /* Make sure the SMBus host is ready to start transmitting */ 142 /* Make sure the SMBus host is ready to start transmitting */
120 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 143 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
@@ -169,10 +192,9 @@ static int vt596_transaction(u8 size)
169 if (temp & 0x1F) 192 if (temp & 0x1F)
170 outb_p(temp, SMBHSTSTS); 193 outb_p(temp, SMBHSTSTS);
171 194
172 dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " 195#ifdef DEBUG
173 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 196 vt596_dump_regs("Transaction (post)", size);
174 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 197#endif
175 inb_p(SMBHSTDAT1));
176 198
177 return result; 199 return result;
178} 200}