aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2012-07-24 08:13:57 -0400
committerJean Delvare <khali@endymion.delvare>2012-07-24 08:13:57 -0400
commitefa3cb15ad8ba40bd08b05df87ef0ca6680ef762 (patch)
treeaffbc114b7f751f8308a834b39b8d34972191ac1 /drivers
parentfda2f4af37ccc80d655a5b4538288d461539b574 (diff)
i2c-i801: Refactor use of LAST_BYTE in i801_block_transaction_byte_by_byte
As a slight optimization, pull some logic out of the polling loop during byte-by-byte transactions by just setting the I801_LAST_BYTE bit, as defined in the i801 (PCH) datasheet, when reading the last byte of a byte-by-byte I2C_SMBUS_READ. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-i801.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index ae2945a5e00..51e11eb64ab 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -117,8 +117,7 @@
117#define I801_PROC_CALL 0x10 /* unimplemented */ 117#define I801_PROC_CALL 0x10 /* unimplemented */
118#define I801_BLOCK_DATA 0x14 118#define I801_BLOCK_DATA 0x14
119#define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */ 119#define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */
120#define I801_BLOCK_LAST 0x34 120#define I801_LAST_BYTE 0x20
121#define I801_I2C_BLOCK_LAST 0x38 /* ICH5 and later */
122#define I801_START 0x40 121#define I801_START 0x40
123#define I801_PEC_EN 0x80 /* ICH3 and later */ 122#define I801_PEC_EN 0x80 /* ICH3 and later */
124 123
@@ -338,6 +337,11 @@ static int i801_block_transaction_by_block(struct i801_priv *priv,
338 return 0; 337 return 0;
339} 338}
340 339
340/*
341 * For "byte-by-byte" block transactions:
342 * I2C write uses cmd=I801_BLOCK_DATA, I2C_EN=1
343 * I2C read uses cmd=I801_I2C_BLOCK_DATA
344 */
341static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, 345static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
342 union i2c_smbus_data *data, 346 union i2c_smbus_data *data,
343 char read_write, int command, 347 char read_write, int command,
@@ -360,19 +364,15 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
360 outb_p(data->block[1], SMBBLKDAT(priv)); 364 outb_p(data->block[1], SMBBLKDAT(priv));
361 } 365 }
362 366
367 if (command == I2C_SMBUS_I2C_BLOCK_DATA &&
368 read_write == I2C_SMBUS_READ)
369 smbcmd = I801_I2C_BLOCK_DATA;
370 else
371 smbcmd = I801_BLOCK_DATA;
372
363 for (i = 1; i <= len; i++) { 373 for (i = 1; i <= len; i++) {
364 if (i == len && read_write == I2C_SMBUS_READ) { 374 if (i == len && read_write == I2C_SMBUS_READ)
365 if (command == I2C_SMBUS_I2C_BLOCK_DATA) 375 smbcmd |= I801_LAST_BYTE;
366 smbcmd = I801_I2C_BLOCK_LAST;
367 else
368 smbcmd = I801_BLOCK_LAST;
369 } else {
370 if (command == I2C_SMBUS_I2C_BLOCK_DATA
371 && read_write == I2C_SMBUS_READ)
372 smbcmd = I801_I2C_BLOCK_DATA;
373 else
374 smbcmd = I801_BLOCK_DATA;
375 }
376 outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); 376 outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv));
377 377
378 if (i == 1) 378 if (i == 1)