Show
Ignore:
Timestamp:
06/06/03 03:49:49 (10 years ago)
Author:
mds
Message:

backport from kernel 2.5.69. untested.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/busses/i2c-i801.c

    r1708 r1763  
    5050#include <asm/io.h> 
    5151#include "version.h" 
    52  
    53 MODULE_LICENSE("GPL"); 
     52#include "sensors_compat.h" 
    5453 
    5554#ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC 
     
    5756#endif 
    5857 
    59 #ifndef PCI_DEVICE_ID_INTEL_82801CA_SMBUS 
    60 #define PCI_DEVICE_ID_INTEL_82801CA_SMBUS       0x2483 
    61 #endif 
    62  
    63 #ifndef PCI_DEVICE_ID_INTEL_82801DB_SMBUS 
    64 #define PCI_DEVICE_ID_INTEL_82801DB_SMBUS       0x24C3 
    65 #endif 
    66  
    67 static int supported[] = {PCI_DEVICE_ID_INTEL_82801AA_3, 
    68                           PCI_DEVICE_ID_INTEL_82801AB_3, 
    69                           PCI_DEVICE_ID_INTEL_82801BA_2, 
    70                           PCI_DEVICE_ID_INTEL_82801CA_SMBUS, 
    71                           PCI_DEVICE_ID_INTEL_82801DB_SMBUS, 
    72                           0 }; 
    73  
    7458/* I801 SMBus address offsets */ 
    75 #define SMBHSTSTS (0 + i801_smba) 
    76 #define SMBHSTCNT (2 + i801_smba) 
    77 #define SMBHSTCMD (3 + i801_smba) 
    78 #define SMBHSTADD (4 + i801_smba) 
    79 #define SMBHSTDAT0 (5 + i801_smba) 
    80 #define SMBHSTDAT1 (6 + i801_smba) 
    81 #define SMBBLKDAT (7 + i801_smba) 
    82 #define SMBPEC    (8 + i801_smba)       /* ICH4 only */ 
    83 #define SMBAUXSTS (12 + i801_smba)      /* ICH4 only */ 
    84 #define SMBAUXCTL (13 + i801_smba)      /* ICH4 only */ 
     59#define SMBHSTSTS       (0 + i801_smba) 
     60#define SMBHSTCNT       (2 + i801_smba) 
     61#define SMBHSTCMD       (3 + i801_smba) 
     62#define SMBHSTADD       (4 + i801_smba) 
     63#define SMBHSTDAT0      (5 + i801_smba) 
     64#define SMBHSTDAT1      (6 + i801_smba) 
     65#define SMBBLKDAT       (7 + i801_smba) 
     66#define SMBPEC          (8 + i801_smba) /* ICH4 only */ 
     67#define SMBAUXSTS       (12 + i801_smba)        /* ICH4 only */ 
     68#define SMBAUXCTL       (13 + i801_smba)        /* ICH4 only */ 
    8569 
    8670/* PCI Address Constants */ 
    87 #define SMBBA     0x020 
    88 #define SMBHSTCFG 0x040 
    89 #define SMBREV    0x008 
     71#define SMBBA           0x020 
     72#define SMBHSTCFG       0x040 
     73#define SMBREV          0x008 
    9074 
    9175/* Host configuration bits for SMBHSTCFG */ 
    92 #define SMBHSTCFG_HST_EN      1 
    93 #define SMBHSTCFG_SMB_SMI_EN  2 
    94 #define SMBHSTCFG_I2C_EN      4 
     76#define SMBHSTCFG_HST_EN        1 
     77#define SMBHSTCFG_SMB_SMI_EN    2 
     78#define SMBHSTCFG_I2C_EN        4 
    9579 
    9680/* Other settings */ 
    97 #define MAX_TIMEOUT 100 
    98 #define ENABLE_INT9 0   /* set to 0x01 to enable - untested */ 
     81#define MAX_TIMEOUT             100 
     82#define ENABLE_INT9             0       /* set to 0x01 to enable - untested */ 
    9983 
    10084/* I801 command constants */ 
    101 #define I801_QUICK          0x00 
    102 #define I801_BYTE           0x04 
    103 #define I801_BYTE_DATA      0x08 
    104 #define I801_WORD_DATA      0x0C 
    105 #define I801_PROC_CALL      0x10        /* later chips only, unimplemented */ 
    106 #define I801_BLOCK_DATA     0x14 
    107 #define I801_I2C_BLOCK_DATA 0x18        /* unimplemented */ 
    108 #define I801_BLOCK_LAST     0x34 
    109 #define I801_I2C_BLOCK_LAST 0x38        /* unimplemented */ 
    110 #define I801_START          0x40 
    111 #define I801_PEC_EN         0x80        /* ICH4 only */ 
     85#define I801_QUICK              0x00 
     86#define I801_BYTE               0x04 
     87#define I801_BYTE_DATA          0x08 
     88#define I801_WORD_DATA          0x0C 
     89#define I801_PROC_CALL          0x10    /* later chips only, unimplemented */ 
     90#define I801_BLOCK_DATA         0x14 
     91#define I801_I2C_BLOCK_DATA     0x18    /* unimplemented */ 
     92#define I801_BLOCK_LAST         0x34 
     93#define I801_I2C_BLOCK_LAST     0x38    /* unimplemented */ 
     94#define I801_START              0x40 
     95#define I801_PEC_EN             0x80    /* ICH4 only */ 
    11296 
    11397/* insmod parameters */ 
     
    121105                 "EXTREMELY DANGEROUS!"); 
    122106 
    123  
    124  
    125  
    126  
    127107static void i801_do_pause(unsigned int amount); 
    128108static int i801_transaction(void); 
     
    130110                                  char read_write, int command); 
    131111 
    132  
    133  
    134  
    135 static unsigned short i801_smba = 0; 
    136 static struct pci_dev *I801_dev = NULL; 
    137 static int isich4 = 0; 
    138  
    139 /* Detect whether a I801 can be found, and initialize it, where necessary. 
    140    Note the differences between kernels with the old PCI BIOS interface and 
    141    newer kernels with the real PCI interface. In compat.h some things are 
    142    defined to make the transition easier. */ 
    143 int i801_setup(void) 
     112static unsigned short i801_smba; 
     113static struct pci_dev *I801_dev; 
     114static int isich4; 
     115 
     116static int i801_setup(struct pci_dev *dev) 
    144117{ 
    145118        int error_return = 0; 
    146         int *num = supported; 
    147119        unsigned char temp; 
    148120 
    149         /* First check whether we can access PCI at all */ 
    150         if (pci_present() == 0) { 
    151                 printk(KERN_WARNING "i2c-i801.o: Error: No PCI-bus found!\n"); 
    152                 error_return = -ENODEV; 
    153                 goto END; 
    154         } 
    155  
    156         /* Look for each chip */ 
    157121        /* Note: we keep on searching until we have found 'function 3' */ 
    158         I801_dev = NULL; 
    159         do { 
    160                 if((I801_dev = pci_find_device(PCI_VENDOR_ID_INTEL, 
    161                                               *num, I801_dev))) { 
    162                         if(PCI_FUNC(I801_dev->devfn) != 3) 
    163                                 continue; 
    164                         break; 
    165                 } 
    166                 num++; 
    167         } while (*num != 0); 
    168  
    169         if (I801_dev == NULL) { 
    170                 printk 
    171                     (KERN_WARNING "i2c-i801.o: Error: Can't detect I801, function 3!\n"); 
    172                 error_return = -ENODEV; 
    173                 goto END; 
    174         } 
    175         isich4 = *num == PCI_DEVICE_ID_INTEL_82801DB_SMBUS; 
    176  
    177 /* Determine the address of the SMBus areas */ 
     122        if(PCI_FUNC(dev->devfn) != 3) 
     123                return -ENODEV; 
     124 
     125        I801_dev = dev; 
     126        if (dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) 
     127                isich4 = 1; 
     128        else 
     129                isich4 = 0; 
     130 
     131        /* Determine the address of the SMBus areas */ 
    178132        if (force_addr) { 
    179133                i801_smba = force_addr & 0xfff0; 
     
    182136                i801_smba &= 0xfff0; 
    183137                if(i801_smba == 0) { 
    184                         printk(KERN_ERR "i2c-i801.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); 
     138                        dev_err(dev, "SMB base address uninitialized" 
     139                                "- upgrade BIOS or use force_addr=0xaddr\n"); 
    185140                        return -ENODEV; 
    186141                } 
    187142        } 
    188143 
    189         if (check_region(i801_smba, (isich4 ? 16 : 8))) { 
    190                 printk 
    191                     (KERN_ERR "i2c-i801.o: I801_smb region 0x%x already in use!\n", 
    192                      i801_smba); 
    193                 error_return = -ENODEV; 
     144        if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { 
     145                dev_err(dev, "I801_smb region 0x%x already in use!\n", 
     146                        i801_smba); 
     147                error_return = -EBUSY; 
    194148                goto END; 
    195149        } 
     
    198152        temp &= ~SMBHSTCFG_I2C_EN;      /* SMBus timing */ 
    199153        pci_write_config_byte(I801_dev, SMBHSTCFG, temp); 
    200 /* If force_addr is set, we program the new address here. Just to make 
    201    sure, we disable the device first. */ 
     154 
     155        /* If force_addr is set, we program the new address here. Just to make 
     156           sure, we disable the device first. */ 
    202157        if (force_addr) { 
    203158                pci_write_config_byte(I801_dev, SMBHSTCFG, temp & 0xfe); 
    204159                pci_write_config_word(I801_dev, SMBBA, i801_smba); 
    205160                pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 0x01); 
    206                 printk 
    207                     (KERN_WARNING "i2c-i801.o: WARNING: I801 SMBus interface set to new " 
    208                      "address %04x!\n", i801_smba); 
     161                dev_warn(dev, "WARNING: I801 SMBus interface set to " 
     162                        "new address %04x!\n", i801_smba); 
    209163        } else if ((temp & 1) == 0) { 
    210164                pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1); 
    211                 printk(KERN_WARNING "i2c-i801.o: enabling SMBus device\n"); 
    212         } 
    213  
    214         request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus"); 
    215  
    216 #ifdef DEBUG 
     165                dev_warn(dev, "enabling SMBus device\n"); 
     166        } 
     167 
    217168        if (temp & 0x02) 
    218                 printk 
    219                     (KERN_DEBUG "i2c-i801.o: I801 using Interrupt SMI# for SMBus.\n"); 
     169                dev_dbg(dev, "I801 using Interrupt SMI# for SMBus.\n"); 
    220170        else 
    221                 printk 
    222                     (KERN_DEBUG "i2c-i801.o: I801 using PCI Interrupt for SMBus.\n"); 
     171                dev_dbg(dev, "I801 using PCI Interrupt for SMBus.\n"); 
    223172 
    224173        pci_read_config_byte(I801_dev, SMBREV, &temp); 
    225         printk(KERN_DEBUG "i2c-i801.o: SMBREV = 0x%X\n", temp); 
    226         printk(KERN_DEBUG "i2c-i801.o: I801_smba = 0x%X\n", i801_smba); 
    227 #endif                          /* DEBUG */ 
    228  
    229       END: 
     174        dev_dbg(dev, "SMBREV = 0x%X\n", temp); 
     175        dev_dbg(dev, "I801_smba = 0x%X\n", i801_smba); 
     176 
     177END: 
    230178        return error_return; 
    231179} 
    232180 
    233181 
    234 void i801_do_pause(unsigned int amount) 
     182static void i801_do_pause(unsigned int amount) 
    235183{ 
    236184        current->state = TASK_INTERRUPTIBLE; 
     
    238186} 
    239187 
    240 int i801_transaction(void) 
     188static int i801_transaction(void) 
    241189{ 
    242190        int temp; 
     
    244192        int timeout = 0; 
    245193 
    246 #ifdef DEBUG 
    247         printk 
    248             (KERN_DEBUG "i2c-i801.o: Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " 
    249              "DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), 
    250              inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); 
    251 #endif 
     194        dev_dbg(I801_dev, "Transaction (pre): CNT=%02x, CMD=%02x," 
     195                "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 
     196                inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
     197                inb_p(SMBHSTDAT1)); 
    252198 
    253199        /* Make sure the SMBus host is ready to start transmitting */ 
    254200        /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ 
    255201        if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 
    256 #ifdef DEBUG 
    257                 printk(KERN_DEBUG "i2c-i801.o: SMBus busy (%02x). Resetting... \n", 
    258                        temp); 
    259 #endif 
     202                dev_dbg(I801_dev, "SMBus busy (%02x). Resetting... \n", 
     203                        temp); 
    260204                outb_p(temp, SMBHSTSTS); 
    261205                if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 
    262 #ifdef DEBUG 
    263                         printk(KERN_DEBUG "i2c-i801.o: Failed! (%02x)\n", temp); 
    264 #endif 
     206                        dev_dbg(I801_dev, "Failed! (%02x)\n", temp); 
    265207                        return -1; 
    266208                } else { 
    267 #ifdef DEBUG 
    268                         printk(KERN_DEBUG "i2c-i801.o: Successfull!\n"); 
    269 #endif 
     209                        dev_dbg(I801_dev, "Successfull!\n"); 
    270210                } 
    271211        } 
     
    281221        /* If the SMBus is still busy, we give up */ 
    282222        if (timeout >= MAX_TIMEOUT) { 
    283 #ifdef DEBUG 
    284                 printk(KERN_DEBUG "i2c-i801.o: SMBus Timeout!\n"); 
     223                dev_dbg(I801_dev, "SMBus Timeout!\n"); 
    285224                result = -1; 
    286 #endif 
    287225        } 
    288226 
    289227        if (temp & 0x10) { 
    290228                result = -1; 
    291 #ifdef DEBUG 
    292                 printk(KERN_DEBUG "i2c-i801.o: Error: Failed bus transaction\n"); 
    293 #endif 
     229                dev_dbg(I801_dev, "Error: Failed bus transaction\n"); 
    294230        } 
    295231 
    296232        if (temp & 0x08) { 
    297233                result = -1; 
    298                 printk 
    299                     (KERN_ERR "i2c-i801.o: Bus collision! SMBus may be locked until next hard\n" 
    300                      "reset. (sorry!)\n"); 
     234                dev_err(I801_dev, "Bus collision! SMBus may be locked " 
     235                        "until next hard reset. (sorry!)\n"); 
    301236                /* Clock stops and slave is stuck in mid-transmission */ 
    302237        } 
     
    304239        if (temp & 0x04) { 
    305240                result = -1; 
    306 #ifdef DEBUG 
    307                 printk(KERN_DEBUG "i2c-i801.o: Error: no response!\n"); 
    308 #endif 
     241                dev_dbg(I801_dev, "Error: no response!\n"); 
    309242        } 
    310243 
     
    313246 
    314247        if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 
    315 #ifdef DEBUG 
    316                 printk 
    317                     (KERN_DEBUG "i2c-i801.o: Failed reset at end of transaction (%02x)\n", 
    318                      temp); 
    319 #endif 
    320         } 
    321 #ifdef DEBUG 
    322         printk 
    323             (KERN_DEBUG "i2c-i801.o: Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, " 
    324              "DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), 
    325              inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); 
    326 #endif 
     248                dev_dbg(I801_dev, "Failed reset at end of transaction" 
     249                        "(%02x)\n", temp); 
     250        } 
     251        dev_dbg(I801_dev, "Transaction (post): CNT=%02x, CMD=%02x, " 
     252                "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 
     253                inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
     254                inb_p(SMBHSTDAT1)); 
    327255        return result; 
    328256} 
    329257 
    330258/* All-inclusive block transaction function */ 
    331 int i801_block_transaction(union i2c_smbus_data *data, char read_write,  
    332                            int command) 
     259static int i801_block_transaction(union i2c_smbus_data *data, char read_write, 
     260                                  int command) 
    333261{ 
    334262        int i, len; 
     
    337265        int result = 0; 
    338266        int timeout; 
    339         unsigned char hostc, errmask; 
    340  
    341         if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 
    342                 if (read_write == I2C_SMBUS_WRITE) { 
    343                         /* set I2C_EN bit in configuration register */ 
    344                         pci_read_config_byte(I801_dev, SMBHSTCFG, &hostc); 
    345                         pci_write_config_byte(I801_dev, SMBHSTCFG,  
    346                                               hostc | SMBHSTCFG_I2C_EN); 
    347                 } else { 
    348                         printk("i2c-i801.o: " 
    349                                "I2C_SMBUS_I2C_BLOCK_READ not supported!\n"); 
    350                         return -1; 
    351                 } 
    352         } 
     267        unsigned char hostc, errmask; 
     268 
     269        if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 
     270                if (read_write == I2C_SMBUS_WRITE) { 
     271                        /* set I2C_EN bit in configuration register */ 
     272                        pci_read_config_byte(I801_dev, SMBHSTCFG, &hostc); 
     273                        pci_write_config_byte(I801_dev, SMBHSTCFG, 
     274                                              hostc | SMBHSTCFG_I2C_EN); 
     275                } else { 
     276                        dev_err(I801_dev, 
     277                                "I2C_SMBUS_I2C_BLOCK_READ not DB!\n"); 
     278                        return -1; 
     279                } 
     280        } 
    353281 
    354282        if (read_write == I2C_SMBUS_WRITE) { 
     
    373301                else 
    374302                        smbcmd = I801_BLOCK_DATA; 
    375 #if 0 /* now using HW PEC */ 
    376                 if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) 
    377                         smbcmd |= I801_PEC_EN; 
    378 #endif 
    379303                outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT); 
    380304 
    381 #ifdef DEBUG 
    382                 printk 
    383                     (KERN_DEBUG "i2c-i801.o: Block (pre %d): CNT=%02x, CMD=%02x, ADD=%02x, " 
    384                      "DAT0=%02x, BLKDAT=%02x\n", i, inb_p(SMBHSTCNT), 
    385                      inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
    386                      inb_p(SMBBLKDAT)); 
    387 #endif 
     305                dev_dbg(I801_dev, "Block (pre %d): CNT=%02x, CMD=%02x, " 
     306                        "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i, 
     307                        inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), 
     308                        inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT)); 
    388309 
    389310                /* Make sure the SMBus host is ready to start transmitting */ 
    390311                temp = inb_p(SMBHSTSTS); 
    391                 if (i == 1) { 
    392                     /* Erronenous conditions before transaction:  
    393                     * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ 
    394                     errmask=0x9f;  
    395                 } else { 
    396                     /* Erronenous conditions during transaction:  
    397                     * Failed, Bus_Err, Dev_Err, Intr */ 
    398                     errmask=0x1e;  
    399                 } 
     312                if (i == 1) { 
     313                        /* Erronenous conditions before transaction:  
     314                        * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ 
     315                        errmask=0x9f;  
     316                } else { 
     317                        /* Erronenous conditions during transaction:  
     318                        * Failed, Bus_Err, Dev_Err, Intr */ 
     319                        errmask=0x1e;  
     320                } 
    400321                if (temp & errmask) { 
    401 #ifdef DEBUG 
    402                         printk 
    403                             (KERN_DEBUG "i2c-i801.o: SMBus busy (%02x). Resetting... \n", 
    404                              temp); 
    405 #endif 
     322                        dev_dbg(I801_dev, "SMBus busy (%02x). " 
     323                                "Resetting... \n", temp); 
    406324                        outb_p(temp, SMBHSTSTS); 
    407325                        if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) { 
    408                                 printk 
    409                                     (KERN_ERR "i2c-i801.o: Reset failed! (%02x)\n", 
    410                                      temp); 
     326                                dev_err(I801_dev, 
     327                                        "Reset failed! (%02x)\n", temp); 
    411328                                result = -1; 
    412329                                goto END; 
    413330                        } 
    414331                        if (i != 1) { 
    415                                 result = -1;  /* if die in middle of block transaction, fail */ 
    416                                 goto END; 
    417                         } 
    418                 } 
    419  
    420                 if (i == 1) { 
    421 #if 0 /* #ifdef HAVE_PEC (now using HW PEC) */ 
    422                         if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) { 
    423                                 if(read_write == I2C_SMBUS_WRITE) 
    424                                         outb_p(data->block[len + 1], SMBPEC); 
     332                                /* if die in middle of block transaction, fail */ 
     333                                result = -1; 
     334                                goto END; 
    425335                        } 
    426 #endif 
     336                } 
     337 
     338                if (i == 1) 
    427339                        outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT); 
    428                 } 
    429340 
    430341                /* We will always wait for a fraction of a second! */ 
     
    440351                if (timeout >= MAX_TIMEOUT) { 
    441352                        result = -1; 
    442 #ifdef DEBUG 
    443                         printk(KERN_DEBUG "i2c-i801.o: SMBus Timeout!\n"); 
    444 #endif 
     353                        dev_dbg(I801_dev, "SMBus Timeout!\n"); 
    445354                } 
    446355 
    447356                if (temp & 0x10) { 
    448357                        result = -1; 
    449 #ifdef DEBUG 
    450                         printk 
    451                             (KERN_DEBUG "i2c-i801.o: Error: Failed bus transaction\n"); 
    452 #endif 
     358                        dev_dbg(I801_dev, 
     359                                "Error: Failed bus transaction\n"); 
    453360                } else if (temp & 0x08) { 
    454361                        result = -1; 
    455                         printk(KERN_ERR "i2c-i801.o: Bus collision!\n"); 
     362                        dev_err(I801_dev, "Bus collision!\n"); 
    456363                } else if (temp & 0x04) { 
    457364                        result = -1; 
    458 #ifdef DEBUG 
    459                         printk(KERN_DEBUG "i2c-i801.o: Error: no response!\n"); 
    460 #endif 
     365                        dev_dbg(I801_dev, "Error: no response!\n"); 
    461366                } 
    462367 
     
    470375                } 
    471376 
    472                 /* Retrieve/store value in SMBBLKDAT */ 
     377                /* Retrieve/store value in SMBBLKDAT */ 
    473378                if (read_write == I2C_SMBUS_READ) 
    474379                        data->block[i] = inb_p(SMBBLKDAT); 
     
    478383                        outb_p(temp, SMBHSTSTS);  /* signals SMBBLKDAT ready */ 
    479384 
    480 #ifdef DEBUG 
    481385                if ((temp = (0x1e & inb_p(SMBHSTSTS))) != 0x00) { 
    482                         printk 
    483                             (KERN_DEBUG "i2c-i801.o: Bad status (%02x) at end of transaction\n", 
    484                              temp); 
    485                 } 
    486                 printk 
    487                     (KERN_DEBUG "i2c-i801.o: Block (post %d): CNT=%02x, CMD=%02x, ADD=%02x, " 
    488                      "DAT0=%02x, BLKDAT=%02x\n", i, inb_p(SMBHSTCNT), 
    489                      inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
    490                      inb_p(SMBBLKDAT)); 
    491 #endif 
     386                        dev_dbg(I801_dev, 
     387                                "Bad status (%02x) at end of transaction\n", 
     388                                temp); 
     389                } 
     390                dev_dbg(I801_dev, "Block (post %d): CNT=%02x, CMD=%02x, " 
     391                        "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i, 
     392                        inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), 
     393                        inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT)); 
    492394 
    493395                if (result < 0) 
     
    506408 
    507409                if (timeout >= MAX_TIMEOUT) { 
    508                         printk(KERN_DEBUG "i2c-i801.o: PEC Timeout!\n"); 
    509                 } 
    510 #if 0 /* now using HW PEC */ 
    511                 if(read_write == I2C_SMBUS_READ) { 
    512                         data->block[len + 1] = inb_p(SMBPEC); 
    513                 } 
     410                        dev_dbg(I801_dev, "PEC Timeout!\n"); 
     411                } 
     412                outb_p(temp, SMBHSTSTS);  
     413        } 
    514414#endif 
    515                 outb_p(temp, SMBHSTSTS);  
    516         } 
    517 #endif 
    518         result = 0; 
     415        result = 0; 
    519416END: 
    520         if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 
    521                 /* restore saved configuration register value */ 
     417        if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 
     418                /* restore saved configuration register value */ 
    522419                pci_write_config_byte(I801_dev, SMBHSTCFG, hostc); 
    523         } 
     420        } 
    524421        return result; 
    525422} 
    526423 
    527424/* Return -1 on error. */ 
    528 s32 i801_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, 
    529                 char read_write, u8 command, int size, 
    530                 union i2c_smbus_data * data) 
     425static s32 i801_access(struct i2c_adapter * adap, u16 addr, 
     426                       unsigned short flags, char read_write, u8 command, 
     427                       int size, union i2c_smbus_data * data) 
    531428{ 
    532429        int hwpec = 0; 
     
    584481        case I2C_SMBUS_PROC_CALL: 
    585482        default: 
    586                 printk(KERN_ERR "i2c-i801.o: Unsupported transaction %d\n", size); 
     483                dev_err(I801_dev, "Unsupported transaction %d\n", size); 
    587484                return -1; 
    588485        } 
     
    630527 
    631528 
    632 u32 i801_func(struct i2c_adapter *adapter) 
     529static u32 i801_func(struct i2c_adapter *adapter) 
    633530{ 
    634531        return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 
     
    652549static struct i2c_adapter i801_adapter = { 
    653550        .owner          = THIS_MODULE, 
    654         .name           = "unset", 
    655551        .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801, 
    656552        .algo           = &smbus_algorithm, 
     553        .name   = "unset", 
    657554}; 
    658555 
    659  
    660  
    661556static struct pci_device_id i801_ids[] __devinitdata = { 
     557        { 
     558                .vendor =       PCI_VENDOR_ID_INTEL, 
     559                .device =       PCI_DEVICE_ID_INTEL_82801AA_3, 
     560                .subvendor =    PCI_ANY_ID, 
     561                .subdevice =    PCI_ANY_ID, 
     562        }, 
     563        { 
     564                .vendor =       PCI_VENDOR_ID_INTEL, 
     565                .device =       PCI_DEVICE_ID_INTEL_82801AB_3, 
     566                .subvendor =    PCI_ANY_ID, 
     567                .subdevice =    PCI_ANY_ID, 
     568        }, 
     569        { 
     570                .vendor =       PCI_VENDOR_ID_INTEL, 
     571                .device =       PCI_DEVICE_ID_INTEL_82801BA_2, 
     572                .subvendor =    PCI_ANY_ID, 
     573                .subdevice =    PCI_ANY_ID, 
     574        }, 
     575        { 
     576                .vendor =       PCI_VENDOR_ID_INTEL, 
     577                .device =       PCI_DEVICE_ID_INTEL_82801CA_3, 
     578                .subvendor =    PCI_ANY_ID, 
     579                .subdevice =    PCI_ANY_ID, 
     580        }, 
     581        { 
     582                .vendor =       PCI_VENDOR_ID_INTEL, 
     583                .device =       PCI_DEVICE_ID_INTEL_82801DB_3, 
     584                .subvendor =    PCI_ANY_ID, 
     585                .subdevice =    PCI_ANY_ID, 
     586        }, 
    662587        { 0, } 
    663588}; 
     
    666591{ 
    667592 
    668         if (i801_setup()) { 
    669                 printk 
    670                     (KERN_WARNING "i2c-i801.o: I801 not detected, module not inserted.\n"); 
     593        if (i801_setup(dev)) { 
     594                dev_warn(dev, 
     595                        "I801 not detected, module not inserted.\n"); 
    671596                return -ENODEV; 
    672597        } 
    673598 
    674         sprintf(i801_adapter.name, "SMBus I801 adapter at %04x", 
    675                 i801_smba); 
    676         i2c_add_adapter(&i801_adapter); 
     599        snprintf(i801_adapter.name, 32, 
     600                "SMBus I801 adapter at %04x", i801_smba); 
     601        return i2c_add_adapter(&i801_adapter); 
    677602} 
    678603 
     
    691616static int __init i2c_i801_init(void) 
    692617{ 
    693         printk(KERN_INFO "i2c-i801.o version %s (%s)\n", LM_VERSION, LM_DATE); 
     618        printk(KERN_INFO "i2c-i801 version %s (%s)\n", LM_VERSION, LM_DATE); 
    694619        return pci_module_init(&i801_driver); 
    695620} 
    696  
    697621 
    698622static void __exit i2c_i801_exit(void) 
     
    702626} 
    703627 
    704  
    705  
    706 MODULE_AUTHOR 
    707     ("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>"); 
     628MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, " 
     629                "Philip Edelbrock <phil@netroedge.com>, " 
     630                "and Mark D. Studebaker <mdsxyz123@yahoo.com>"); 
    708631MODULE_DESCRIPTION("I801 SMBus driver"); 
     632MODULE_LICENSE("GPL"); 
    709633 
    710634module_init(i2c_i801_init);