Commit 09a3943b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] i2c i2c-ali15x3.c: fix up formatting and whitespace issues.

parent b6afc392
...@@ -131,34 +131,31 @@ MODULE_PARM(force_addr, "i"); ...@@ -131,34 +131,31 @@ MODULE_PARM(force_addr, "i");
MODULE_PARM_DESC(force_addr, MODULE_PARM_DESC(force_addr,
"Initialize the base address of the i2c controller"); "Initialize the base address of the i2c controller");
static void ali15x3_do_pause(unsigned int amount);
static unsigned short ali15x3_smba = 0; static unsigned short ali15x3_smba = 0;
int ali15x3_setup(struct pci_dev *ALI15X3_dev) static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
{ {
u16 a; u16 a;
unsigned char temp; unsigned char temp;
/* Check the following things: /* Check the following things:
- SMB I/O address is initialized - SMB I/O address is initialized
- Device is enabled - Device is enabled
- We can use the addresses - We can use the addresses
*/ */
/* Unlock the register. /* Unlock the register.
The data sheet says that the address registers are read-only The data sheet says that the address registers are read-only
if the lock bits are 1, but in fact the address registers if the lock bits are 1, but in fact the address registers
are zero unless you clear the lock bits. are zero unless you clear the lock bits.
*/ */
pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp); pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp);
if (temp & ALI15X3_LOCK) { if (temp & ALI15X3_LOCK) {
temp &= ~ALI15X3_LOCK; temp &= ~ALI15X3_LOCK;
pci_write_config_byte(ALI15X3_dev, SMBATPC, temp); pci_write_config_byte(ALI15X3_dev, SMBATPC, temp);
} }
/* Determine the address of the SMBus area */ /* Determine the address of the SMBus area */
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) {
...@@ -193,30 +190,30 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -193,30 +190,30 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
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) {
dev_info(&ALI15X3_dev->dev, "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) {
dev_info(&ALI15X3_dev->dev, "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);
} }
/* set SMB clock to 74KHz as recommended in data sheet */ /* set SMB clock to 74KHz as recommended in data sheet */
pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20); pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20);
/* /*
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)
dev_dbg(&ALI15X3_dev->dev, "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);
dev_dbg(&ALI15X3_dev->dev, "SMBREV = 0x%X\n", temp); dev_dbg(&ALI15X3_dev->dev, "SMBREV = 0x%X\n", temp);
dev_dbg(&ALI15X3_dev->dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba); dev_dbg(&ALI15X3_dev->dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba);
...@@ -224,9 +221,8 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev) ...@@ -224,9 +221,8 @@ int ali15x3_setup(struct pci_dev *ALI15X3_dev)
return 0; return 0;
} }
/* Internally used pause function */ /* Internally used pause function */
void ali15x3_do_pause(unsigned int amount) static void ali15x3_do_pause(unsigned int amount)
{ {
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount); schedule_timeout(amount);
...@@ -250,33 +246,32 @@ static int ali15x3_transaction(struct i2c_adapter *adap) ...@@ -250,33 +246,32 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
/* Make sure the SMBus host is ready to start transmitting */ /* Make sure the SMBus host is ready to start transmitting */
/* Check the busy bit first */ /* Check the busy bit first */
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
resulting in a "SMBus Timeout" Dev. previous transaction, 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
2. Reset the controller and the other SMBus devices with a T_OUT command. device is hung)
(this clears the host busy bit if an external device is hung, 2. Reset the controller and the other SMBus devices with a
but it comes back upon a new access to a device) T_OUT command. (this clears the host busy bit if an
external device is hung, but it comes back upon a new access
to a device)
3. Disable and reenable the controller in SMBHSTCFG 3. Disable and reenable the controller in SMBHSTCFG
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 */
/* /*
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.
*/ */
dev_info(&adap->dev, "Resetting entire SMB Bus to " dev_info(&adap->dev, "Resetting entire SMB Bus to "
"clear busy condition (%02x)\n", temp); "clear busy condition (%02x)\n", temp);
outb_p(ALI15X3_T_OUT, SMBHSTCNT); outb_p(ALI15X3_T_OUT, SMBHSTCNT);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} }
/*
}
*/
/* now check the error bits and the busy bit */ /* now check the error bits and the busy bit */
if (temp & (ALI15X3_STS_ERR | ALI15X3_STS_BUSY)) { if (temp & (ALI15X3_STS_ERR | ALI15X3_STS_BUSY)) {
...@@ -321,12 +316,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap) ...@@ -321,12 +316,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
} }
/* /*
Unfortunately the ALI SMB controller maps "no response" and "bus collision" Unfortunately the ALI SMB controller maps "no response" and "bus
into a single bit. No reponse is the usual case so don't collision" into a single bit. No reponse is the usual case so don't
do a printk. do a printk.
This means that bus collisions go unreported. This means that bus collisions go unreported.
*/ */
if (temp & ALI15X3_STS_COLL) { if (temp & ALI15X3_STS_COLL) {
result = -1; result = -1;
dev_dbg(&adap->dev, dev_dbg(&adap->dev,
...@@ -334,7 +329,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) ...@@ -334,7 +329,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
inb_p(SMBHSTADD)); inb_p(SMBHSTADD));
} }
/* haven't ever seen this */ /* haven't ever seen this */
if (temp & ALI15X3_STS_DEV) { if (temp & ALI15X3_STS_DEV) {
result = -1; result = -1;
dev_err(&adap->dev, "Error: device error\n"); dev_err(&adap->dev, "Error: device error\n");
...@@ -347,7 +342,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) ...@@ -347,7 +342,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
} }
/* Return -1 on error. */ /* Return -1 on error. */
s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
unsigned short flags, char read_write, u8 command, unsigned short flags, char read_write, u8 command,
int size, union i2c_smbus_data * data) int size, union i2c_smbus_data * data)
{ {
...@@ -355,9 +350,9 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -355,9 +350,9 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
int temp; int temp;
int timeout; int timeout;
/* clear all the bits (clear-on-write) */ /* clear all the bits (clear-on-write) */
outb_p(0xFF, SMBHSTSTS); outb_p(0xFF, SMBHSTSTS);
/* make sure SMBus is idle */ /* make sure SMBus is idle */
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
for (timeout = 0; for (timeout = 0;
(timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE);
...@@ -418,7 +413,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -418,7 +413,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
data->block[0] = len; data->block[0] = len;
} }
outb_p(len, SMBHSTDAT0); outb_p(len, SMBHSTDAT0);
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */ /* Reset SMBBLKDAT */
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);
for (i = 1; i <= len; i++) for (i = 1; i <= len; i++)
outb_p(data->block[i], SMBBLKDAT); outb_p(data->block[i], SMBBLKDAT);
} }
...@@ -450,7 +446,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -450,7 +446,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
if (len > 32) if (len > 32)
len = 32; len = 32;
data->block[0] = len; data->block[0] = len;
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */ /* Reset SMBBLKDAT */
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);
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);
dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n", dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n",
...@@ -461,8 +458,7 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -461,8 +458,7 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
return 0; return 0;
} }
static u32 ali15x3_func(struct i2c_adapter *adapter)
u32 ali15x3_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
...@@ -483,8 +479,6 @@ static struct i2c_adapter ali15x3_adapter = { ...@@ -483,8 +479,6 @@ static struct i2c_adapter ali15x3_adapter = {
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
}; };
static struct pci_device_id ali15x3_ids[] __devinitdata = { static struct pci_device_id ali15x3_ids[] __devinitdata = {
{ {
.vendor = PCI_VENDOR_ID_AL, .vendor = PCI_VENDOR_ID_AL,
...@@ -529,17 +523,15 @@ static int __init i2c_ali15x3_init(void) ...@@ -529,17 +523,15 @@ static int __init i2c_ali15x3_init(void)
return pci_module_init(&ali15x3_driver); return pci_module_init(&ali15x3_driver);
} }
static void __exit i2c_ali15x3_exit(void) static void __exit i2c_ali15x3_exit(void)
{ {
pci_unregister_driver(&ali15x3_driver); pci_unregister_driver(&ali15x3_driver);
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE); release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
} }
MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, "
"Philip Edelbrock <phil@netroedge.com>, "
MODULE_AUTHOR "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
MODULE_DESCRIPTION("ALI15X3 SMBus driver"); MODULE_DESCRIPTION("ALI15X3 SMBus driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
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