[i2c] Can not find sensors since kernel 2.6.18
Wang Xu
gnawux at gmail.com
Tue May 1 02:25:25 CEST 2007
On Sun, Apr 29, 2007 at 11:58:54AM +0800, gnawux wrote:
> I have a ASUS M2Ne Laptop, which has Intel ICH4 (i2c-i801) SMBus.
>
> But under 2.6.18 and 2.6.20 kernel, no sensors could be found,
> I enable the debug option of 2.6.20 kernel, and found the following
> error message of i2c bus:
> | PCI: Unable to reserve I/O region #5:20 at e800 for device 0000:00:1f.3
> | i801_smbus 0000:00:1f.3: Failed to request SMBus region 0xe800-0xe81f
> | i801_smbus: probe of 0000:00:1f.3 failed with error -16
>
It works again!
I reviewed the codes and found they employed different PCI access way
between 2.6.16 and later kernel. I did not know the different the ways,
and had never written kernel modules before.
Anyway, I changed i2c-i801.c codes in 2.6.20 to 2.6.16 ways and the
now the sensor data could be read again! Just the same as under 2.6.16
kernel:
| gnawux at inspiration:~$ sensors
| max6657-i2c-0-4c
| Adapter: SMBus I801 adapter at e800
| M/B Temp: +49°C (low = -55°C, high = +127°C)
| CPU Temp: +48.8°C (low = -54.1°C, high = +51.1°C)
| M/B Crit: +127°C (hyst = +117°C)
| CPU Crit: +127°C (hyst = +117°C)
Could anyone tell the different of the two ways?
And the diff file are attached. (Actually I onle introduced some
2.6.16 codes to 2.6.20)
Thank you!
Wang Xu
-------------- next part --------------
--- i2c-i801.c.bak 2007-04-30 11:31:02.000000000 +0800
+++ i2c-i801.c 2007-05-01 07:49:29.000000000 +0800
@@ -69,6 +69,9 @@
/* PCI Address Constants */
#define SMBBAR 4
#define SMBHSTCFG 0x040
+/* The following 2 lines are from 2.6.16 kernel. --gnawux */
+#define SMBBA 0x020
+#define SMBREV 0x008
/* Host configuration bits for SMBHSTCFG */
#define SMBHSTCFG_HST_EN 1
@@ -97,7 +100,10 @@
static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
int command, int hwpec);
+/* it's short in 2.6.16 kernel. --gnawux
static unsigned long i801_smba;
+*/
+static unsigned short i801_smba;
static struct pci_driver i801_driver;
static struct pci_dev *I801_dev;
static int isich4;
@@ -485,14 +491,33 @@
isich4 = 0;
}
+ pci_read_config_word(I801_dev, SMBBA, &i801_smba);
+ i801_smba &= 0xfff0;
+ if(i801_smba == 0) {
+ dev_err(&dev->dev, "SMB base address uninitialized "
+ "- upgrade BIOS or use force_addr=0xaddr\n");
+ return -ENODEV;
+ }/* above lines are copied from 2.6.16. --gnawux */
+
+ if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) {
+ dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n",
+ i801_smba);
+ err = -EBUSY;
+ goto exit;
+ } /* if section from 2.6.16, with changing END to exit. --gnawux */
+
+/*
err = pci_enable_device(dev);
if (err) {
dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n",
err);
goto exit;
}
+comment out. --gnawux
+*/
/* Determine the address of the SMBus area */
+/*
i801_smba = pci_resource_start(dev, SMBBAR);
if (!i801_smba) {
dev_err(&dev->dev, "SMBus base address uninitialized, "
@@ -500,7 +525,10 @@
err = -ENODEV;
goto exit;
}
+comment out. --gnawux
+*/
+/*
err = pci_request_region(dev, SMBBAR, i801_driver.name);
if (err) {
dev_err(&dev->dev, "Failed to request SMBus region "
@@ -508,6 +536,8 @@
(unsigned long long)pci_resource_end(dev, SMBBAR));
goto exit;
}
+comment out. --gnawux
+*/
pci_read_config_byte(I801_dev, SMBHSTCFG, &temp);
temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */
@@ -526,7 +556,7 @@
i801_adapter.dev.parent = &dev->dev;
snprintf(i801_adapter.name, I2C_NAME_SIZE,
- "SMBus I801 adapter at %04lx", i801_smba);
+ "SMBus I801 adapter at %04x", i801_smba); /* change 04lx to 04x. --gnawux */
err = i2c_add_adapter(&i801_adapter);
if (err) {
dev_err(&dev->dev, "Failed to add SMBus adapter\n");
@@ -543,7 +573,14 @@
static void __devexit i801_remove(struct pci_dev *dev)
{
i2c_del_adapter(&i801_adapter);
+
+ release_region(i801_smba, (isich4 ? 16 : 8));
+ /* the above line is copied from 2.6.16. --gnawux */
+
+/*
pci_release_region(dev, SMBBAR);
+comment out. --gnawux
+*/
/*
* do not call pci_disable_device(dev) since it can cause hard hangs on
* some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)
More information about the i2c
mailing list