@@ -649,6 +649,28 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
}
size = PIIX4_BLOCK_DATA;
break;
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ outb_p(command, SMBHSTCMD);
+ if (read_write == I2C_SMBUS_WRITE) {
+ len = data->block[0];
+ if (len == 0 || len > I2C_SMBUS_BLOCK_MAX + 1)
+ return -EINVAL;
+ /* For I2C block write, first byte goes to SMBHSTDAT0 */
+ outb_p(data->block[1], SMBHSTDAT0);
+ inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
+ /* Write remaining bytes to SMBBLKDAT */
+ for (i = 2; i <= len; i++)
+ outb_p(data->block[i], SMBBLKDAT);
+ } else {
+ /* For I2C block read, length is pre-specified by caller */
+ len = data->block[0];
+ if (len == 0 || len > I2C_SMBUS_BLOCK_MAX + 1)
+ return -EINVAL;
+ }
+ size = PIIX4_I2C_BLOCK_DATA;
+ break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
@@ -680,6 +702,18 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
for (i = 1; i <= data->block[0]; i++)
data->block[i] = inb_p(SMBBLKDAT);
break;
+ case PIIX4_I2C_BLOCK_DATA:
+ /* For I2C block read, the length was pre-specified */
+ len = data->block[0];
+ if (len == 0 || len > I2C_SMBUS_BLOCK_MAX + 1)
+ return -EPROTO;
+ /* First byte of data is in SMBHSTDAT0, not a count */
+ data->block[1] = inb_p(SMBHSTDAT0);
+ inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
+ /* Read remaining bytes from SMBBLKDAT */
+ for (i = 2; i <= len; i++)
+ data->block[i] = inb_p(SMBBLKDAT);
+ break;
}
return 0;
}
@@ -819,7 +853,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
* Therefore we need to request the ownership flag during those
* transactions.
*/
- if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc) {
+ if ((size == I2C_SMBUS_BLOCK_DATA ||
+ size == I2C_SMBUS_I2C_BLOCK_DATA) &&
+ adapdata->notify_imc) {
int ret;
ret = piix4_imc_sleep();
@@ -855,7 +891,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
/* Release the semaphore */
outb_p(smbslvcnt | 0x20, SMBSLVCNT);
- if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc)
+ if ((size == I2C_SMBUS_BLOCK_DATA ||
+ size == I2C_SMBUS_I2C_BLOCK_DATA) &&
+ adapdata->notify_imc)
piix4_imc_wakeup();
release:
@@ -867,7 +905,7 @@ static u32 piix4_func(struct i2c_adapter *adapter)
{
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
- I2C_FUNC_SMBUS_BLOCK_DATA;
+ I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_I2C_BLOCK;
}
static const struct i2c_algorithm smbus_algorithm = {
@@ -29,7 +29,8 @@
#define SMBSLVDAT (0x0C + piix4_smba)
/* PIIX4 constants */
-#define PIIX4_BLOCK_DATA 0x14
+#define PIIX4_BLOCK_DATA 0x14
+#define PIIX4_I2C_BLOCK_DATA 0x18
struct sb800_mmio_cfg {
void __iomem *addr;