aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-ali15x3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-ali15x3.c')
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 93bf87d7096..234fdde7d40 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 ali15x3.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> and 3 Philip Edelbrock <phil@netroedge.com> and
6 Mark D. Studebaker <mdsxyz123@yahoo.com> 4 Mark D. Studebaker <mdsxyz123@yahoo.com>
@@ -68,6 +66,7 @@
68#include <linux/delay.h> 66#include <linux/delay.h>
69#include <linux/i2c.h> 67#include <linux/i2c.h>
70#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/acpi.h>
71#include <asm/io.h> 70#include <asm/io.h>
72 71
73/* ALI15X3 SMBus address offsets */ 72/* ALI15X3 SMBus address offsets */
@@ -166,6 +165,10 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
166 if(force_addr) 165 if(force_addr)
167 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); 166 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
168 167
168 if (acpi_check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
169 ali15x3_driver.name))
170 return -EBUSY;
171
169 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, 172 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
170 ali15x3_driver.name)) { 173 ali15x3_driver.name)) {
171 dev_err(&ALI15X3_dev->dev, 174 dev_err(&ALI15X3_dev->dev,
@@ -282,7 +285,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
282 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " 285 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - "
283 "controller or device on bus is probably hung\n", 286 "controller or device on bus is probably hung\n",
284 temp); 287 temp);
285 return -1; 288 return -EBUSY;
286 } 289 }
287 } else { 290 } else {
288 /* check and clear done bit */ 291 /* check and clear done bit */
@@ -304,12 +307,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
304 307
305 /* If the SMBus is still busy, we give up */ 308 /* If the SMBus is still busy, we give up */
306 if (timeout >= MAX_TIMEOUT) { 309 if (timeout >= MAX_TIMEOUT) {
307 result = -1; 310 result = -ETIMEDOUT;
308 dev_err(&adap->dev, "SMBus Timeout!\n"); 311 dev_err(&adap->dev, "SMBus Timeout!\n");
309 } 312 }
310 313
311 if (temp & ALI15X3_STS_TERM) { 314 if (temp & ALI15X3_STS_TERM) {
312 result = -1; 315 result = -EIO;
313 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 316 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
314 } 317 }
315 318
@@ -320,7 +323,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
320 This means that bus collisions go unreported. 323 This means that bus collisions go unreported.
321 */ 324 */
322 if (temp & ALI15X3_STS_COLL) { 325 if (temp & ALI15X3_STS_COLL) {
323 result = -1; 326 result = -ENXIO;
324 dev_dbg(&adap->dev, 327 dev_dbg(&adap->dev,
325 "Error: no response or bus collision ADD=%02x\n", 328 "Error: no response or bus collision ADD=%02x\n",
326 inb_p(SMBHSTADD)); 329 inb_p(SMBHSTADD));
@@ -328,7 +331,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
328 331
329 /* haven't ever seen this */ 332 /* haven't ever seen this */
330 if (temp & ALI15X3_STS_DEV) { 333 if (temp & ALI15X3_STS_DEV) {
331 result = -1; 334 result = -EIO;
332 dev_err(&adap->dev, "Error: device error\n"); 335 dev_err(&adap->dev, "Error: device error\n");
333 } 336 }
334 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " 337 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
@@ -338,7 +341,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
338 return result; 341 return result;
339} 342}
340 343
341/* Return -1 on error. */ 344/* Return negative errno on error. */
342static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, 345static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
343 unsigned short flags, char read_write, u8 command, 346 unsigned short flags, char read_write, u8 command,
344 int size, union i2c_smbus_data * data) 347 int size, union i2c_smbus_data * data)
@@ -362,9 +365,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
362 } 365 }
363 366
364 switch (size) { 367 switch (size) {
365 case I2C_SMBUS_PROC_CALL:
366 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
367 return -1;
368 case I2C_SMBUS_QUICK: 368 case I2C_SMBUS_QUICK:
369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
370 SMBHSTADD); 370 SMBHSTADD);
@@ -417,12 +417,16 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
417 } 417 }
418 size = ALI15X3_BLOCK_DATA; 418 size = ALI15X3_BLOCK_DATA;
419 break; 419 break;
420 default:
421 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
422 return -EOPNOTSUPP;
420 } 423 }
421 424
422 outb_p(size, SMBHSTCNT); /* output command */ 425 outb_p(size, SMBHSTCNT); /* output command */
423 426
424 if (ali15x3_transaction(adap)) /* Error in transaction */ 427 temp = ali15x3_transaction(adap);
425 return -1; 428 if (temp)
429 return temp;
426 430
427 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) 431 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
428 return 0; 432 return 0;
@@ -470,7 +474,7 @@ static const struct i2c_algorithm smbus_algorithm = {
470static struct i2c_adapter ali15x3_adapter = { 474static struct i2c_adapter ali15x3_adapter = {
471 .owner = THIS_MODULE, 475 .owner = THIS_MODULE,
472 .id = I2C_HW_SMBUS_ALI15X3, 476 .id = I2C_HW_SMBUS_ALI15X3,
473 .class = I2C_CLASS_HWMON, 477 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
474 .algo = &smbus_algorithm, 478 .algo = &smbus_algorithm,
475}; 479};
476 480