Show
Ignore:
Timestamp:
12/08/04 05:55:45 (8 years ago)
Author:
mds
Message:

add i2c block read support for ich5 and higher. untested.

Files:
1 modified

Legend:

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

    r2791 r2792  
    3030    82801EB             24D3   (HW PEC supported, 32 byte buffer not supported) 
    3131    6300ESB             25A4   ("") 
    32     ICH6                266A 
     32    ICH6                266A   ("") 
    3333    This driver supports several versions of Intel's I/O Controller Hubs (ICH). 
    3434    For SMBus support, they are similar to the PIIX4 and are part 
    3535    of Intel's '810' and other chipsets. 
    3636    See the doc/busses/i2c-i801 file for details. 
    37     I2C Block Read and Process Call are not supported. 
     37    I2C Block Read supported for ICH5 and higher. 
     38    Block Process Call are not supported. 
    3839*/ 
    3940 
     
    9697#define I801_PROC_CALL          0x10    /* later chips only, unimplemented */ 
    9798#define I801_BLOCK_DATA         0x14 
    98 #define I801_I2C_BLOCK_DATA     0x18    /* unimplemented */ 
     99#define I801_I2C_BLOCK_DATA     0x18    /* ich4 and later */ 
    99100#define I801_BLOCK_LAST         0x34 
    100101#define I801_I2C_BLOCK_LAST     0x38    /* unimplemented */ 
    101102#define I801_START              0x40 
    102 #define I801_PEC_EN             0x80    /* ICH4 only */ 
     103#define I801_PEC_EN             0x80    /* ich4 and later */ 
    103104 
    104105/* insmod parameters */ 
     
    118119static unsigned short i801_smba; 
    119120static struct pci_dev *I801_dev; 
    120 static int isich4; 
     121static int isich4;      /* is PEC supported? */ 
     122static int isich5;      /* is i2c block read supported? */ 
    121123 
    122124static int i801_setup(struct pci_dev *dev) 
     
    137139        else 
    138140                isich4 = 0; 
     141        isich5 = isich4 && dev->device != PCI_DEVICE_ID_INTEL_82801DB_3; 
    139142 
    140143        /* Determine the address of the SMBus areas */ 
     
    276279                        pci_write_config_byte(I801_dev, SMBHSTCFG, 
    277280                                              hostc | SMBHSTCFG_I2C_EN); 
    278                 } else { 
     281                } else if (!isich5) { 
    279282                        dev_err(I801_dev, 
    280283                                "I2C_SMBUS_I2C_BLOCK_READ unsupported!\n"); 
     
    302305                if (i == len && read_write == I2C_SMBUS_READ) 
    303306                        smbcmd = I801_BLOCK_LAST; 
     307                else if (command == I2C_SMBUS_I2C_BLOCK_DATA && 
     308                         read_write == I2C_SMBUS_READ) 
     309                        smbcmd = I801_I2C_BLOCK_DATA; 
    304310                else 
    305311                        smbcmd = I801_BLOCK_DATA; 
     
    370376 
    371377                if (i == 1 && read_write == I2C_SMBUS_READ) { 
    372                         len = inb_p(SMBHSTDAT0); 
    373                         if (len < 1) 
    374                                 len = 1; 
    375                         if (len > 32) 
    376                                 len = 32; 
    377                         data->block[0] = len; 
     378                        if (command != I2C_SMBUS_I2C_BLOCK_DATA) { 
     379                                len = inb_p(SMBHSTDAT0); 
     380                                if (len < 1) 
     381                                        len = 1; 
     382                                if (len > 32) 
     383                                        len = 32; 
     384                                data->block[0] = len; 
     385                        } else { 
     386                                /* if slave returns < 32 bytes transaction will fail */ 
     387                                data->block[0] = 32; 
     388                        } 
    378389                } 
    379390 
     
    418429        result = 0; 
    419430END: 
    420         if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 
     431        if (command == I2C_SMBUS_I2C_BLOCK_DATA && 
     432            read_write == I2C_SMBUS_WRITE) { 
    421433                /* restore saved configuration register value */ 
    422434                pci_write_config_byte(I801_dev, SMBHSTCFG, hostc); 
     
    553565                       : 0) 
    554566#endif 
     567             | (isich5 ? I2C_FUNC_SMBUS_READ_I2C_BLOCK 
     568                       : 0) 
    555569            ; 
    556570}