Commit 91bd9569 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] i2c i2c-ali15x3.c: remove #ifdefs and fix all printk() to use dev_*().

parent 18e7e540
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
/* Note: we assume there can only be one ALI15X3, with one SMBus interface */ /* Note: we assume there can only be one ALI15X3, with one SMBus interface */
/* #define DEBUG 1 */
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -131,7 +133,6 @@ MODULE_PARM_DESC(force_addr, ...@@ -131,7 +133,6 @@ MODULE_PARM_DESC(force_addr,
static void ali15x3_do_pause(unsigned int amount); static void ali15x3_do_pause(unsigned int amount);
static int ali15x3_transaction(void);
static unsigned short ali15x3_smba = 0; static unsigned short ali15x3_smba = 0;
...@@ -161,8 +162,8 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -161,8 +162,8 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba); pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba);
ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1)); ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1));
if (ali15x3_smba == 0 && force_addr == 0) { if (ali15x3_smba == 0 && force_addr == 0) {
printk dev_err(&ALI15X3_dev->dev, "ALI15X3_smb region uninitialized "
("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); "- upgrade BIOS or use force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
...@@ -170,14 +171,15 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -170,14 +171,15 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) { if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) {
printk dev_err(&ALI15X3_dev->dev,
("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n", "ALI15X3_smb region 0x%x already in use!\n",
ali15x3_smba); ali15x3_smba);
return -ENODEV; return -ENODEV;
} }
if(force_addr) { if(force_addr) {
printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba); dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n",
ali15x3_smba);
if (PCIBIOS_SUCCESSFUL != if (PCIBIOS_SUCCESSFUL !=
pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba)) pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba))
return -ENODEV; return -ENODEV;
...@@ -186,21 +188,22 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -186,21 +188,22 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
return -ENODEV; return -ENODEV;
if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
/* make sure it works */ /* make sure it works */
printk("i2c-ali15x3.o: force address failed - not supported?\n"); dev_err(&ALI15X3_dev->dev,
"force address failed - not supported?\n");
return -ENODEV; return -ENODEV;
} }
} }
/* check if whole device is enabled */ /* check if whole device is enabled */
pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp); pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp);
if ((temp & 1) == 0) { if ((temp & 1) == 0) {
printk("i2c-ali15x3: enabling SMBus device\n"); dev_info(&ALI15X3_dev->dev, "enabling SMBus device\n");
pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01); pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01);
} }
/* Is SMB Host controller enabled? */ /* Is SMB Host controller enabled? */
pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp); pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp);
if ((temp & 1) == 0) { if ((temp & 1) == 0) {
printk("i2c-ali15x3: enabling SMBus controller\n"); dev_info(&ALI15X3_dev->dev, "enabling SMBus controller\n");
pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01); pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01);
} }
...@@ -210,18 +213,16 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -210,18 +213,16 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
/* Everything is happy, let's grab the memory and set things up. */ /* Everything is happy, let's grab the memory and set things up. */
request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb"); request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb");
#ifdef DEBUG
/* /*
The interrupt routing for SMB is set up in register 0x77 in the The interrupt routing for SMB is set up in register 0x77 in the
1533 ISA Bridge device, NOT in the 7101 device. 1533 ISA Bridge device, NOT in the 7101 device.
Don't bother with finding the 1533 device and reading the register. Don't bother with finding the 1533 device and reading the register.
if ((....... & 0x0F) == 1) if ((....... & 0x0F) == 1)
printk("i2c-ali15x3.o: ALI15X3 using Interrupt 9 for SMBus.\n"); dev_dbg(&ALI15X3_dev->dev, "ALI15X3 using Interrupt 9 for SMBus.\n");
*/ */
pci_read_config_byte(ALI15X3_dev, SMBREV, &temp); pci_read_config_byte(ALI15X3_dev, SMBREV, &temp);
printk("i2c-ali15x3.o: SMBREV = 0x%X\n", temp); dev_dbg(&ALI15X3_dev->dev, "SMBREV = 0x%X\n", temp);
printk("i2c-ali15x3.o: ALI15X3_smba = 0x%X\n", ali15x3_smba); dev_dbg(&ALI15X3_dev->dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba);
#endif /* DEBUG */
return 0; return 0;
} }
...@@ -235,19 +236,16 @@ void ali15x3_do_pause(unsigned int amount) ...@@ -235,19 +236,16 @@ void ali15x3_do_pause(unsigned int amount)
} }
/* Another internally used function */ /* Another internally used function */
int ali15x3_transaction(void) static int ali15x3_transaction(struct i2c_adapter *adap)
{ {
int temp; int temp;
int result = 0; int result = 0;
int timeout = 0; int timeout = 0;
#ifdef DEBUG dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, "
printk "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
("i2c-ali15x3.o: Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
"DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
inb_p(SMBHSTDAT1));
#endif
/* get status */ /* get status */
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
...@@ -257,7 +255,7 @@ int ali15x3_transaction(void) ...@@ -257,7 +255,7 @@ int ali15x3_transaction(void)
if (temp & ALI15X3_STS_BUSY) { if (temp & ALI15X3_STS_BUSY) {
/* /*
If the host controller is still busy, it may have timed out in the previous transaction, If the host controller is still busy, it may have timed out in the previous transaction,
resulting in a "SMBus Timeout" printk. resulting in a "SMBus Timeout" Dev.
I've tried the following to reset a stuck busy bit. I've tried the following to reset a stuck busy bit.
1. Reset the controller with an ABORT command. 1. Reset the controller with an ABORT command.
(this doesn't seem to clear the controller if an external device is hung) (this doesn't seem to clear the controller if an external device is hung)
...@@ -268,24 +266,14 @@ int ali15x3_transaction(void) ...@@ -268,24 +266,14 @@ int ali15x3_transaction(void)
Worst case, nothing seems to work except power reset. Worst case, nothing seems to work except power reset.
*/ */
/* Abort - reset the host controller */ /* Abort - reset the host controller */
/*
#ifdef DEBUG
printk("i2c-ali15x3.o: Resetting host controller to clear busy condition\n",temp);
#endif
outb_p(ALI15X3_ABORT, SMBHSTCNT);
temp = inb_p(SMBHSTSTS);
if (temp & ALI15X3_STS_BUSY) {
*/
/* /*
Try resetting entire SMB bus, including other devices - Try resetting entire SMB bus, including other devices -
This may not work either - it clears the BUSY bit but This may not work either - it clears the BUSY bit but
then the BUSY bit may come back on when you try and use the chip again. then the BUSY bit may come back on when you try and use the chip again.
If that's the case you are stuck. If that's the case you are stuck.
*/ */
printk dev_info(&adap->dev, "Resetting entire SMB Bus to "
("i2c-ali15x3.o: Resetting entire SMB Bus to clear busy condition (%02x)\n", "clear busy condition (%02x)\n", temp);
temp);
outb_p(ALI15X3_T_OUT, SMBHSTCNT); outb_p(ALI15X3_T_OUT, SMBHSTCNT);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} }
...@@ -302,9 +290,9 @@ int ali15x3_transaction(void) ...@@ -302,9 +290,9 @@ int ali15x3_transaction(void)
/* this is probably going to be correctable only by a power reset /* this is probably going to be correctable only by a power reset
as one of the bits now appears to be stuck */ as one of the bits now appears to be stuck */
/* This may be a bus or device with electrical problems. */ /* This may be a bus or device with electrical problems. */
printk dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - "
("i2c-ali15x3.o: SMBus reset failed! (0x%02x) - controller or device on bus is probably hung\n", "controller or device on bus is probably hung\n",
temp); temp);
return -1; return -1;
} }
} else { } else {
...@@ -328,14 +316,12 @@ int ali15x3_transaction(void) ...@@ -328,14 +316,12 @@ int ali15x3_transaction(void)
/* If the SMBus is still busy, we give up */ /* If the SMBus is still busy, we give up */
if (timeout >= MAX_TIMEOUT) { if (timeout >= MAX_TIMEOUT) {
result = -1; result = -1;
printk("i2c-ali15x3.o: SMBus Timeout!\n"); dev_err(&adap->dev, "SMBus Timeout!\n");
} }
if (temp & ALI15X3_STS_TERM) { if (temp & ALI15X3_STS_TERM) {
result = -1; result = -1;
#ifdef DEBUG dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
printk("i2c-ali15x3.o: Error: Failed bus transaction\n");
#endif
} }
/* /*
...@@ -346,25 +332,20 @@ int ali15x3_transaction(void) ...@@ -346,25 +332,20 @@ int ali15x3_transaction(void)
*/ */
if (temp & ALI15X3_STS_COLL) { if (temp & ALI15X3_STS_COLL) {
result = -1; result = -1;
#ifdef DEBUG dev_dbg(&adap->dev,
printk "Error: no response or bus collision ADD=%02x\n",
("i2c-ali15x3.o: Error: no response or bus collision ADD=%02x\n", inb_p(SMBHSTADD));
inb_p(SMBHSTADD));
#endif
} }
/* haven't ever seen this */ /* haven't ever seen this */
if (temp & ALI15X3_STS_DEV) { if (temp & ALI15X3_STS_DEV) {
result = -1; result = -1;
printk("i2c-ali15x3.o: Error: device error\n"); dev_err(&adap->dev, "Error: device error\n");
} }
#ifdef DEBUG dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
printk "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
("i2c-ali15x3.o: Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, " inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
"DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
inb_p(SMBHSTDAT1));
#endif
return result; return result;
} }
...@@ -388,14 +369,12 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -388,14 +369,12 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} }
if (timeout >= MAX_TIMEOUT) { if (timeout >= MAX_TIMEOUT) {
printk("i2c-ali15x3.o: Idle wait Timeout! STS=0x%02x\n", dev_err(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp);
temp);
} }
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
("i2c-ali15x3.o: I2C_SMBUS_PROC_CALL not supported!\n");
return -1; return -1;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
...@@ -452,7 +431,7 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -452,7 +431,7 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
outb_p(size, SMBHSTCNT); /* output command */ outb_p(size, SMBHSTCNT); /* output command */
if (ali15x3_transaction()) /* Error in transaction */ if (ali15x3_transaction(adap)) /* Error in transaction */
return -1; return -1;
if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
...@@ -477,11 +456,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -477,11 +456,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */ outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */
for (i = 1; i <= data->block[0]; i++) { for (i = 1; i <= data->block[0]; i++) {
data->block[i] = inb_p(SMBBLKDAT); data->block[i] = inb_p(SMBBLKDAT);
#ifdef DEBUG dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n",
printk len, i, data->block[i]);
("i2c-ali15x3.o: Blk: len=%d, i=%d, data=%02x\n",
len, i, data->block[i]);
#endif /* DEBUG */
} }
break; break;
} }
...@@ -525,9 +501,8 @@ static struct pci_device_id ali15x3_ids[] __devinitdata = { ...@@ -525,9 +501,8 @@ static struct pci_device_id ali15x3_ids[] __devinitdata = {
static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id) static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
{ {
if (ali15x3_setup(dev)) { if (ali15x3_setup(dev)) {
printk dev_err(&dev->dev,
("i2c-ali15x3.o: ALI15X3 not detected, module not inserted.\n"); "ALI15X3 not detected, module not inserted.\n");
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment