diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-ali1535.c')
| -rw-r--r-- | drivers/i2c/busses/i2c-ali1535.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index f14372ac2fc5..9cead9b9458e 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | i2c-ali1535.c - Part of lm_sensors, Linux kernel modules for hardware | ||
| 3 | monitoring | ||
| 4 | Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>, | 2 | Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>, |
| 5 | Philip Edelbrock <phil@netroedge.com>, | 3 | Philip Edelbrock <phil@netroedge.com>, |
| 6 | Mark D. Studebaker <mdsxyz123@yahoo.com>, | 4 | Mark D. Studebaker <mdsxyz123@yahoo.com>, |
| @@ -61,6 +59,7 @@ | |||
| 61 | #include <linux/ioport.h> | 59 | #include <linux/ioport.h> |
| 62 | #include <linux/i2c.h> | 60 | #include <linux/i2c.h> |
| 63 | #include <linux/init.h> | 61 | #include <linux/init.h> |
| 62 | #include <linux/acpi.h> | ||
| 64 | #include <asm/io.h> | 63 | #include <asm/io.h> |
| 65 | 64 | ||
| 66 | 65 | ||
| @@ -159,6 +158,11 @@ static int ali1535_setup(struct pci_dev *dev) | |||
| 159 | goto exit; | 158 | goto exit; |
| 160 | } | 159 | } |
| 161 | 160 | ||
| 161 | retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE, | ||
| 162 | ali1535_driver.name); | ||
| 163 | if (retval) | ||
| 164 | goto exit; | ||
| 165 | |||
| 162 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, | 166 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, |
| 163 | ali1535_driver.name)) { | 167 | ali1535_driver.name)) { |
| 164 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", | 168 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", |
| @@ -259,7 +263,7 @@ static int ali1535_transaction(struct i2c_adapter *adap) | |||
| 259 | dev_err(&adap->dev, | 263 | dev_err(&adap->dev, |
| 260 | "SMBus reset failed! (0x%02x) - controller or " | 264 | "SMBus reset failed! (0x%02x) - controller or " |
| 261 | "device on bus is probably hung\n", temp); | 265 | "device on bus is probably hung\n", temp); |
| 262 | return -1; | 266 | return -EBUSY; |
| 263 | } | 267 | } |
| 264 | } else { | 268 | } else { |
| 265 | /* check and clear done bit */ | 269 | /* check and clear done bit */ |
| @@ -281,12 +285,12 @@ static int ali1535_transaction(struct i2c_adapter *adap) | |||
| 281 | 285 | ||
| 282 | /* If the SMBus is still busy, we give up */ | 286 | /* If the SMBus is still busy, we give up */ |
| 283 | if (timeout >= MAX_TIMEOUT) { | 287 | if (timeout >= MAX_TIMEOUT) { |
| 284 | result = -1; | 288 | result = -ETIMEDOUT; |
| 285 | dev_err(&adap->dev, "SMBus Timeout!\n"); | 289 | dev_err(&adap->dev, "SMBus Timeout!\n"); |
| 286 | } | 290 | } |
| 287 | 291 | ||
| 288 | if (temp & ALI1535_STS_FAIL) { | 292 | if (temp & ALI1535_STS_FAIL) { |
| 289 | result = -1; | 293 | result = -EIO; |
| 290 | dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); | 294 | dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); |
| 291 | } | 295 | } |
| 292 | 296 | ||
| @@ -295,7 +299,7 @@ static int ali1535_transaction(struct i2c_adapter *adap) | |||
| 295 | * do a printk. This means that bus collisions go unreported. | 299 | * do a printk. This means that bus collisions go unreported. |
| 296 | */ | 300 | */ |
| 297 | if (temp & ALI1535_STS_BUSERR) { | 301 | if (temp & ALI1535_STS_BUSERR) { |
| 298 | result = -1; | 302 | result = -ENXIO; |
| 299 | dev_dbg(&adap->dev, | 303 | dev_dbg(&adap->dev, |
| 300 | "Error: no response or bus collision ADD=%02x\n", | 304 | "Error: no response or bus collision ADD=%02x\n", |
| 301 | inb_p(SMBHSTADD)); | 305 | inb_p(SMBHSTADD)); |
| @@ -303,13 +307,13 @@ static int ali1535_transaction(struct i2c_adapter *adap) | |||
| 303 | 307 | ||
| 304 | /* haven't ever seen this */ | 308 | /* haven't ever seen this */ |
| 305 | if (temp & ALI1535_STS_DEV) { | 309 | if (temp & ALI1535_STS_DEV) { |
| 306 | result = -1; | 310 | result = -EIO; |
| 307 | dev_err(&adap->dev, "Error: device error\n"); | 311 | dev_err(&adap->dev, "Error: device error\n"); |
| 308 | } | 312 | } |
| 309 | 313 | ||
| 310 | /* check to see if the "command complete" indication is set */ | 314 | /* check to see if the "command complete" indication is set */ |
| 311 | if (!(temp & ALI1535_STS_DONE)) { | 315 | if (!(temp & ALI1535_STS_DONE)) { |
| 312 | result = -1; | 316 | result = -ETIMEDOUT; |
| 313 | dev_err(&adap->dev, "Error: command never completed\n"); | 317 | dev_err(&adap->dev, "Error: command never completed\n"); |
| 314 | } | 318 | } |
| 315 | 319 | ||
| @@ -332,7 +336,7 @@ static int ali1535_transaction(struct i2c_adapter *adap) | |||
| 332 | return result; | 336 | return result; |
| 333 | } | 337 | } |
| 334 | 338 | ||
| 335 | /* Return -1 on error. */ | 339 | /* Return negative errno on error. */ |
| 336 | static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | 340 | static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, |
| 337 | unsigned short flags, char read_write, u8 command, | 341 | unsigned short flags, char read_write, u8 command, |
| 338 | int size, union i2c_smbus_data *data) | 342 | int size, union i2c_smbus_data *data) |
| @@ -357,10 +361,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
| 357 | outb_p(0xFF, SMBHSTSTS); | 361 | outb_p(0xFF, SMBHSTSTS); |
| 358 | 362 | ||
| 359 | switch (size) { | 363 | switch (size) { |
| 360 | case I2C_SMBUS_PROC_CALL: | ||
| 361 | dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); | ||
| 362 | result = -1; | ||
| 363 | goto EXIT; | ||
| 364 | case I2C_SMBUS_QUICK: | 364 | case I2C_SMBUS_QUICK: |
| 365 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | 365 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), |
| 366 | SMBHSTADD); | 366 | SMBHSTADD); |
| @@ -418,13 +418,15 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
| 418 | outb_p(data->block[i], SMBBLKDAT); | 418 | outb_p(data->block[i], SMBBLKDAT); |
| 419 | } | 419 | } |
| 420 | break; | 420 | break; |
| 421 | default: | ||
| 422 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); | ||
| 423 | result = -EOPNOTSUPP; | ||
| 424 | goto EXIT; | ||
| 421 | } | 425 | } |
| 422 | 426 | ||
| 423 | if (ali1535_transaction(adap)) { | 427 | result = ali1535_transaction(adap); |
| 424 | /* Error in transaction */ | 428 | if (result) |
| 425 | result = -1; | ||
| 426 | goto EXIT; | 429 | goto EXIT; |
| 427 | } | ||
| 428 | 430 | ||
| 429 | if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) { | 431 | if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) { |
| 430 | result = 0; | 432 | result = 0; |
| @@ -475,7 +477,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
| 475 | static struct i2c_adapter ali1535_adapter = { | 477 | static struct i2c_adapter ali1535_adapter = { |
| 476 | .owner = THIS_MODULE, | 478 | .owner = THIS_MODULE, |
| 477 | .id = I2C_HW_SMBUS_ALI1535, | 479 | .id = I2C_HW_SMBUS_ALI1535, |
| 478 | .class = I2C_CLASS_HWMON, | 480 | .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, |
| 479 | .algo = &smbus_algorithm, | 481 | .algo = &smbus_algorithm, |
| 480 | }; | 482 | }; |
| 481 | 483 | ||
