Skip to content

Commit ba9ad2a

Browse files
jdelvareWolfram Sang
authored andcommitted
i2c: i801: Fix I2C Block Read on 8-Series/C220 and later
Starting with the 8-Series/C220 PCH (Lynx Point), the SMBus controller includes a SPD EEPROM protection mechanism. Once the SPD Write Disable bit is set, only reads are allowed to slave addresses 0x50-0x57. However the legacy implementation of I2C Block Read since the ICH5 looks like a write, and is therefore blocked by the SPD protection mechanism. This causes the eeprom and at24 drivers to fail. So assume that I2C Block Read is implemented as an actual read on these chipsets. I tested it on my Q87 chipset and it seems to work just fine. Signed-off-by: Jean Delvare <jdelvare@suse.de> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> [wsa: rebased to v4.9-rc2] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 6036160 commit ba9ad2a

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

drivers/i2c/busses/i2c-i801.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
#define SMBHSTCFG_HST_EN 1
147147
#define SMBHSTCFG_SMB_SMI_EN 2
148148
#define SMBHSTCFG_I2C_EN 4
149+
#define SMBHSTCFG_SPD_WD 0x10
149150

150151
/* TCO configuration bits for TCOCTL */
151152
#define TCOCTL_EN 0x0100
@@ -865,9 +866,16 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
865866
block = 1;
866867
break;
867868
case I2C_SMBUS_I2C_BLOCK_DATA:
868-
/* NB: page 240 of ICH5 datasheet shows that the R/#W
869-
* bit should be cleared here, even when reading */
870-
outb_p((addr & 0x7f) << 1, SMBHSTADD(priv));
869+
/*
870+
* NB: page 240 of ICH5 datasheet shows that the R/#W
871+
* bit should be cleared here, even when reading.
872+
* However if SPD Write Disable is set (Lynx Point and later),
873+
* the read will fail if we don't set the R/#W bit.
874+
*/
875+
outb_p(((addr & 0x7f) << 1) |
876+
((priv->original_hstcfg & SMBHSTCFG_SPD_WD) ?
877+
(read_write & 0x01) : 0),
878+
SMBHSTADD(priv));
871879
if (read_write == I2C_SMBUS_READ) {
872880
/* NB: page 240 of ICH5 datasheet also shows
873881
* that DATA1 is the cmd field when reading */
@@ -1573,6 +1581,8 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
15731581
/* Disable SMBus interrupt feature if SMBus using SMI# */
15741582
priv->features &= ~FEATURE_IRQ;
15751583
}
1584+
if (temp & SMBHSTCFG_SPD_WD)
1585+
dev_info(&dev->dev, "SPD Write Disable is set\n");
15761586

15771587
/* Clear special mode bits */
15781588
if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER))

0 commit comments

Comments
 (0)