All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] i2c: i801: Fix I2C Block Read on 8-Series/C220 and later
@ 2016-05-23  9:47 Jean Delvare
  2016-05-24  7:00 ` Jarkko Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2016-05-23  9:47 UTC (permalink / raw)
  To: Linux I2C; +Cc: Jarkko Nikula, Mika Westerberg, Wolfram Sang

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>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
---
Jarkko, Mika, that's what I'm using on my machine now. It works, but
obviously I'd prefer to have confirmation from Intel hardware people
that this is the right thing to do before it goes upstream.

 drivers/i2c/busses/i2c-i801.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

--- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c	2016-05-23 10:39:56.423505663 +0200
+++ linux-4.5/drivers/i2c/busses/i2c-i801.c	2016-05-23 11:25:09.862853791 +0200
@@ -137,9 +137,10 @@
 #define SMBPCICTL_INTDIS	0x0400
 
 /* Host configuration bits for SMBHSTCFG */
-#define SMBHSTCFG_HST_EN	1
-#define SMBHSTCFG_SMB_SMI_EN	2
-#define SMBHSTCFG_I2C_EN	4
+#define SMBHSTCFG_HST_EN	0x01
+#define SMBHSTCFG_SMB_SMI_EN	0x02
+#define SMBHSTCFG_I2C_EN	0x04
+#define SMBHSTCFG_SPD_WD	0x10
 
 /* TCO configuration bits for TCOCTL */
 #define TCOCTL_EN		0x0100
@@ -775,9 +776,16 @@ static s32 i801_access(struct i2c_adapte
 		block = 1;
 		break;
 	case I2C_SMBUS_I2C_BLOCK_DATA:
-		/* NB: page 240 of ICH5 datasheet shows that the R/#W
-		 * bit should be cleared here, even when reading */
-		outb_p((addr & 0x7f) << 1, SMBHSTADD(priv));
+		/*
+		 * NB: page 240 of ICH5 datasheet shows that the R/#W
+		 * bit should be cleared here, even when reading.
+		 * However if SPD Write Disable is set (Lynx Point and later),
+		 * the read will fail if we don't set the R/#W bit.
+		 */
+		outb_p(((addr & 0x7f) << 1) |
+		       ((priv->original_hstcfg & SMBHSTCFG_SPD_WD) ?
+			(read_write & 0x01) : 0),
+		       SMBHSTADD(priv));
 		if (read_write == I2C_SMBUS_READ) {
 			/* NB: page 240 of ICH5 datasheet also shows
 			 * that DATA1 is the cmd field when reading */
@@ -1456,6 +1464,8 @@ static int i801_probe(struct pci_dev *de
 		/* Disable SMBus interrupt feature if SMBus using SMI# */
 		priv->features &= ~FEATURE_IRQ;
 	}
+	if (temp & SMBHSTCFG_SPD_WD)
+		dev_info(&dev->dev, "SPD Write Disable is set\n");
 
 	/* Clear special mode bits */
 	if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER))


-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] i2c: i801: Fix I2C Block Read on 8-Series/C220 and later
  2016-05-23  9:47 [RFC PATCH] i2c: i801: Fix I2C Block Read on 8-Series/C220 and later Jean Delvare
@ 2016-05-24  7:00 ` Jarkko Nikula
  2016-06-19 17:09   ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Nikula @ 2016-05-24  7:00 UTC (permalink / raw)
  To: Jean Delvare, Linux I2C; +Cc: Mika Westerberg, Wolfram Sang

Hi

On 05/23/2016 12:47 PM, Jean Delvare wrote:
> 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>
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> ---
> Jarkko, Mika, that's what I'm using on my machine now. It works, but
> obviously I'd prefer to have confirmation from Intel hardware people
> that this is the right thing to do before it goes upstream.
>
I haven't yet found the contact but search is on going.

-- 
Jarkko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] i2c: i801: Fix I2C Block Read on 8-Series/C220 and later
  2016-05-24  7:00 ` Jarkko Nikula
@ 2016-06-19 17:09   ` Wolfram Sang
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2016-06-19 17:09 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: Jean Delvare, Linux I2C, Mika Westerberg

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]


> >Jarkko, Mika, that's what I'm using on my machine now. It works, but
> >obviously I'd prefer to have confirmation from Intel hardware people
> >that this is the right thing to do before it goes upstream.
> >
> I haven't yet found the contact but search is on going.

Is there a plan B if no further information shows up?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-19 17:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23  9:47 [RFC PATCH] i2c: i801: Fix I2C Block Read on 8-Series/C220 and later Jean Delvare
2016-05-24  7:00 ` Jarkko Nikula
2016-06-19 17:09   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.