diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-i801.c')
-rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 299b918455a3..f4b21f2bb8ed 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -138,6 +138,17 @@ static struct pci_dev *I801_dev; | |||
138 | #define FEATURE_I2C_BLOCK_READ (1 << 3) | 138 | #define FEATURE_I2C_BLOCK_READ (1 << 3) |
139 | static unsigned int i801_features; | 139 | static unsigned int i801_features; |
140 | 140 | ||
141 | static const char *i801_feature_names[] = { | ||
142 | "SMBus PEC", | ||
143 | "Block buffer", | ||
144 | "Block process call", | ||
145 | "I2C block read", | ||
146 | }; | ||
147 | |||
148 | static unsigned int disable_features; | ||
149 | module_param(disable_features, uint, S_IRUGO | S_IWUSR); | ||
150 | MODULE_PARM_DESC(disable_features, "Disable selected driver features"); | ||
151 | |||
141 | /* Make sure the SMBus host is ready to start transmitting. | 152 | /* Make sure the SMBus host is ready to start transmitting. |
142 | Return 0 if it is, -EBUSY if it is not. */ | 153 | Return 0 if it is, -EBUSY if it is not. */ |
143 | static int i801_check_pre(void) | 154 | static int i801_check_pre(void) |
@@ -341,9 +352,8 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data, | |||
341 | do { | 352 | do { |
342 | msleep(1); | 353 | msleep(1); |
343 | status = inb_p(SMBHSTSTS); | 354 | status = inb_p(SMBHSTSTS); |
344 | } | 355 | } while ((!(status & SMBHSTSTS_BYTE_DONE)) |
345 | while ((!(status & SMBHSTSTS_BYTE_DONE)) | 356 | && (timeout++ < MAX_TIMEOUT)); |
346 | && (timeout++ < MAX_TIMEOUT)); | ||
347 | 357 | ||
348 | result = i801_check_post(status, timeout > MAX_TIMEOUT); | 358 | result = i801_check_post(status, timeout > MAX_TIMEOUT); |
349 | if (result < 0) | 359 | if (result < 0) |
@@ -440,9 +450,9 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
440 | } | 450 | } |
441 | 451 | ||
442 | /* Return negative errno on error. */ | 452 | /* Return negative errno on error. */ |
443 | static s32 i801_access(struct i2c_adapter * adap, u16 addr, | 453 | static s32 i801_access(struct i2c_adapter *adap, u16 addr, |
444 | unsigned short flags, char read_write, u8 command, | 454 | unsigned short flags, char read_write, u8 command, |
445 | int size, union i2c_smbus_data * data) | 455 | int size, union i2c_smbus_data *data) |
446 | { | 456 | { |
447 | int hwpec; | 457 | int hwpec; |
448 | int block = 0; | 458 | int block = 0; |
@@ -511,7 +521,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
511 | else | 521 | else |
512 | outb_p(inb_p(SMBAUXCTL) & (~SMBAUXCTL_CRC), SMBAUXCTL); | 522 | outb_p(inb_p(SMBAUXCTL) & (~SMBAUXCTL_CRC), SMBAUXCTL); |
513 | 523 | ||
514 | if(block) | 524 | if (block) |
515 | ret = i801_block_transaction(data, read_write, size, hwpec); | 525 | ret = i801_block_transaction(data, read_write, size, hwpec); |
516 | else | 526 | else |
517 | ret = i801_transaction(xact | ENABLE_INT9); | 527 | ret = i801_transaction(xact | ENABLE_INT9); |
@@ -523,9 +533,9 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
523 | outb_p(inb_p(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), | 533 | outb_p(inb_p(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), |
524 | SMBAUXCTL); | 534 | SMBAUXCTL); |
525 | 535 | ||
526 | if(block) | 536 | if (block) |
527 | return ret; | 537 | return ret; |
528 | if(ret) | 538 | if (ret) |
529 | return ret; | 539 | return ret; |
530 | if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) | 540 | if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) |
531 | return 0; | 541 | return 0; |
@@ -585,7 +595,7 @@ static const struct pci_device_id i801_ids[] = { | |||
585 | { 0, } | 595 | { 0, } |
586 | }; | 596 | }; |
587 | 597 | ||
588 | MODULE_DEVICE_TABLE (pci, i801_ids); | 598 | MODULE_DEVICE_TABLE(pci, i801_ids); |
589 | 599 | ||
590 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE | 600 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE |
591 | static unsigned char apanel_addr; | 601 | static unsigned char apanel_addr; |
@@ -689,10 +699,11 @@ static void __devinit dmi_check_onboard_devices(const struct dmi_header *dm, | |||
689 | } | 699 | } |
690 | #endif | 700 | #endif |
691 | 701 | ||
692 | static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) | 702 | static int __devinit i801_probe(struct pci_dev *dev, |
703 | const struct pci_device_id *id) | ||
693 | { | 704 | { |
694 | unsigned char temp; | 705 | unsigned char temp; |
695 | int err; | 706 | int err, i; |
696 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE | 707 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE |
697 | const char *vendor; | 708 | const char *vendor; |
698 | #endif | 709 | #endif |
@@ -700,26 +711,28 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id | |||
700 | I801_dev = dev; | 711 | I801_dev = dev; |
701 | i801_features = 0; | 712 | i801_features = 0; |
702 | switch (dev->device) { | 713 | switch (dev->device) { |
703 | case PCI_DEVICE_ID_INTEL_82801EB_3: | 714 | default: |
704 | case PCI_DEVICE_ID_INTEL_ESB_4: | ||
705 | case PCI_DEVICE_ID_INTEL_ICH6_16: | ||
706 | case PCI_DEVICE_ID_INTEL_ICH7_17: | ||
707 | case PCI_DEVICE_ID_INTEL_ESB2_17: | ||
708 | case PCI_DEVICE_ID_INTEL_ICH8_5: | ||
709 | case PCI_DEVICE_ID_INTEL_ICH9_6: | ||
710 | case PCI_DEVICE_ID_INTEL_TOLAPAI_1: | ||
711 | case PCI_DEVICE_ID_INTEL_ICH10_4: | ||
712 | case PCI_DEVICE_ID_INTEL_ICH10_5: | ||
713 | case PCI_DEVICE_ID_INTEL_PCH_SMBUS: | ||
714 | case PCI_DEVICE_ID_INTEL_CPT_SMBUS: | ||
715 | i801_features |= FEATURE_I2C_BLOCK_READ; | 715 | i801_features |= FEATURE_I2C_BLOCK_READ; |
716 | /* fall through */ | 716 | /* fall through */ |
717 | case PCI_DEVICE_ID_INTEL_82801DB_3: | 717 | case PCI_DEVICE_ID_INTEL_82801DB_3: |
718 | i801_features |= FEATURE_SMBUS_PEC; | 718 | i801_features |= FEATURE_SMBUS_PEC; |
719 | i801_features |= FEATURE_BLOCK_BUFFER; | 719 | i801_features |= FEATURE_BLOCK_BUFFER; |
720 | /* fall through */ | ||
721 | case PCI_DEVICE_ID_INTEL_82801CA_3: | ||
722 | case PCI_DEVICE_ID_INTEL_82801BA_2: | ||
723 | case PCI_DEVICE_ID_INTEL_82801AB_3: | ||
724 | case PCI_DEVICE_ID_INTEL_82801AA_3: | ||
720 | break; | 725 | break; |
721 | } | 726 | } |
722 | 727 | ||
728 | /* Disable features on user request */ | ||
729 | for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) { | ||
730 | if (i801_features & disable_features & (1 << i)) | ||
731 | dev_notice(&dev->dev, "%s disabled by user\n", | ||
732 | i801_feature_names[i]); | ||
733 | } | ||
734 | i801_features &= ~disable_features; | ||
735 | |||
723 | err = pci_enable_device(dev); | 736 | err = pci_enable_device(dev); |
724 | if (err) { | 737 | if (err) { |
725 | dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", | 738 | dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", |