Skip to contentSkip to conversation

Fix for i2c-piix4 with on some boards

PATCH New Tom Rini 3 participants 12 messages May 19, 2005

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

Hello all. On some boards with an Intel PIIX4 the BIOS (such as the one found on a Force CPCI-735) will incorrectly configure the chipset, and leaves a register in an undefined state causing i2c to behave strangley. The following patches (first vs lm_sensors-2.8.0 and then vs 2.6.0-test3) fixes the issue.

kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +9 -0
@@ -180,6 +180,15 @@
 	}
 
 	pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);
+
+	/* Some BIOS will set up the chipset incorrectly and leave a register
+	   in an undefined state (causing I2C to act very strangely). */
+	if (temp & 0x02) {
+		printk("Fixed I2C problem on Force CPCI735\n");
+		temp = temp & 0xfd;
+		pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp);
+	}
+
 /* If force_addr is set, we program the new address here. Just to make
    sure, we disable the PIIX4 first. */
 	if (force_addr) {

=== i2c-piix4.c 1.13 vs edited ==--- 1.13/drivers/i2c/busses/i2c-piix4.c Fri Aug 8 16:15:03 2003
+++ edited/drivers/i2c/busses/i2c-piix4.c Mon Aug 11 10:57:39 2003
@@ -160,6 +160,15 @@
}

pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);
+
+ /* Some BIOS will set up the chipset incorrectly and leave a register
+ in an undefined state (causing I2C to act very strangely). */
+ if (temp & 0x02) {
+ printk("Fixed I2C problem on Force CPCI735\n");
+ temp = temp & 0xfd;
+ pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp);
+ }
+
/* If force_addr is set, we program the new address here. Just to make
sure, we disable the PIIX4 first. */
if (force_addr) {

Signature · 9 lines
Tom Rini
http://gate.crashing.org/~trini/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20030811/b97c52f5/attachment.bin
#1 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

Hi Tom,

We would need a bit more details about your patch before we can apply it.

1* What is the register that cause the problems? How did you come to it, starting from the problem you encountered on that motherboard?

2* What are these values 0x02 and 0xFD you are using? Why do you say that having 0x02 in that register is an "unknown" state?

3* How well-tested is your patch? Did you test it on a "standard" piix4 chipset?

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#2 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini

kernel/bussses/i2c-piix4.c line 187

Quoted 1 line · Tom Rini
kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +1 -0
+		printk("Fixed I2C problem on Force CPCI735\n");

Shame on adding a printk() without a proper level value. I'll convert this to a dev_info() message and apply it (the 2.6 patch, not the cvs patch.)

thanks,

greg k-h

author
#3 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 6 lines · Greg KH

kernel/bussses/i2c-piix4.c line 187

Quoted 1 line · Tom Rini
kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +1 -0
+		printk("Fixed I2C problem on Force CPCI735\n");

Shame on adding a printk() without a proper level value. I'll convert this to a dev_info() message and apply it (the 2.6 patch, not the cvs patch.)

D'oh. I actually forgot to change the printk to not be Force CPCI735-centric. Would you mind chaning it to something more generic? Thanks.

Signature · 9 lines
Tom Rini
http://gate.crashing.org/~trini/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20030811/c7b333f2/attachment.bin
#4 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 11 lines · Tom Rini
Quoted 6 lines · Greg KH

kernel/bussses/i2c-piix4.c line 187

Quoted 1 line · Tom Rini
kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +1 -0
+		printk("Fixed I2C problem on Force CPCI735\n");

Shame on adding a printk() without a proper level value. I'll convert this to a dev_info() message and apply it (the 2.6 patch, not the cvs patch.)

D'oh. I actually forgot to change the printk to not be Force CPCI735-centric. Would you mind chaning it to something more generic?

What should I change it to exactly?

thanks,

greg k-h

author
#5 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 10 lines · Greg KH
Quoted 9 lines · Tom Rini
Quoted 6 lines · Greg KH

kernel/bussses/i2c-piix4.c line 187

Quoted 1 line · Tom Rini
kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +1 -0
+		printk("Fixed I2C problem on Force CPCI735\n");

Shame on adding a printk() without a proper level value. I'll convert this to a dev_info() message and apply it (the 2.6 patch, not the cvs patch.)

Quoted 4 lines
Quoted 2 lines

D'oh. I actually forgot to change the printk to not be Force CPCI735-centric. Would you mind chaning it to something more generic?

What should I change it to exactly?

Is:
"Worked around buggy BIOS (I2C)\n"
alright?

Signature · 9 lines
Tom Rini
http://gate.crashing.org/~trini/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20030811/18fd4ceb/attachment.bin
author
#6 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 8 lines · Jean Delvare

Hi Tom,

We would need a bit more details about your patch before we can apply it.

1* What is the register that cause the problems? How did you come to it, starting from the problem you encountered on that motherboard?

I must admit I'm working as a bit of a middle man here, but:
This is the SMBus Host Configuration Register (PCI space, function 0, offset 0xd2). I was trying to get I2C working, and it was just doing bizarre things. I finally looked at every register that had anything to do with I2C. This was the only thing I had to change to make it work.

Quoted 2 lines

2* What are these values 0x02 and 0xFD you are using? Why do you say that having 0x02 in that register is an "unknown" state?

In this register, bit 0 is an enable, bits 1-3 assign the interrupt, and bits 4-7 are reserved. The only valid values for the interrupt are 000b (SMI#) and 100b (IRQ9). All other values are reserved. Thus bit 1 should never be set in the register.

Quoted 2 lines

3* How well-tested is your patch? Did you test it on a "standard" piix4 chipset?

Yes, this has been tested on a "standard" piix4 chipsets. <hat type="montavista employee">
This was also shipped in MVL 2.1 (just the CPCI-735 used the i2c-piix.c code) and MVL 3.0 (as well as MVL CGE 3.0, and the CPCI-735 as well as a Motorola board that did not need the workaround).
Sadly the fix fell through the cracks until now.
</hat>

Signature · 9 lines
Tom Rini
http://gate.crashing.org/~trini/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20030811/de4f2cd3/attachment.bin
#7 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini

Greg,

Can you send me your patch after applying it? I'd like to commit a patch that is as similar as possible to our repository (better keep both trees as close as possible).

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#8 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 11 lines · Tom Rini
Quoted 10 lines · Greg KH
Quoted 9 lines · Tom Rini
Quoted 6 lines · Greg KH

kernel/bussses/i2c-piix4.c line 187

Quoted 1 line · Tom Rini
kernel/bussses/i2c-piix4.c renamed from kernel/busses/i2c-piix4.c.orig +1 -0
+		printk("Fixed I2C problem on Force CPCI735\n");

Shame on adding a printk() without a proper level value. I'll convert this to a dev_info() message and apply it (the 2.6 patch, not the cvs patch.)

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

D'oh. I actually forgot to change the printk to not be Force CPCI735-centric. Would you mind chaning it to something more generic?

What should I change it to exactly?

Is:
"Worked around buggy BIOS (I2C)\n"
alright?

Sounds good, I've made that change.

thanks,

greg k-h

#9 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 6 lines · Jean Delvare

Greg,

Can you send me your patch after applying it? I'd like to commit a patch that is as similar as possible to our repository (better keep both trees as close as possible).

Take Tom's original patch and then change the wording to what he just said. My patch will not apply to 2.4 due to the dev_info() change I have made.

thanks,

greg k-h

#10 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 4 lines

Take Tom's original patch and then change the wording to what he just said. My patch will not apply to 2.4 due to the dev_info() change I have made.

OK, patch commited. I took the liberty to change "temp = temp & 0xfd" into "temp &= 0xfd".

I'll test it on my piix4 chipsets tomorrow (no time left tonight).

Thanks Tom for the patch!

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#11 lore raw

PATCH 1/1 Fix for i2c-piix4 with on some boards

In reply to Tom Rini
Quoted 5 lines

OK, patch commited. I took the liberty to change "temp = temp & 0xfd" into "temp &= 0xfd".

I'll test it on my piix4 chipsets tomorrow (no time left tonight).

OK, tested on three different machines, which were not needing the patch (so no wonder they worked and still do).

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/