Changeset 3388

Show
Ignore:
Timestamp:
09/27/99 13:33:18 (9 years ago)
Author:
frodo
Message:

New `functionality' (features) implemented

* A new callback `functionality' in the algorithm structure:

u32 (*functionality) (struct i2c_adapter *);

* New general purpose routines in i2c.h

/* Return functionality */
u32 i2c_get_functionality (struct i2c_adapter *adap);
/* Return 1 if all functionality is supported, 0 if not */
int i2c_check_functionality (struct i2c_adapter *adap, u32 func);

* New macros in i2c.h

#define I2C_FUNC_I2C 0x00000001
#define I2C_FUNC_10BIT_ADDR 0x00000002
#define I2C_FUNC_SMBUS_QUICK 0x00010000
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* New I2C-like block */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* transfers */

* A single define I2C_FUNC_SMBUS_EMUL with all SMBus things that can be

simulated on a plain i2c adapter;

* Implemented the call-back function in both i2c-algo-bit.c and i2c-algo-pcf.c
* Updated the documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • i2c/trunk/doc/writing-clients

    r3384 r3388  
    379379    const char *client_name = ""; /* For non-`sensors' drivers, put the real 
    380380                                     name here! */ 
     381    
     382    /* Let's see whether this adapter can support what we need. 
     383       Please substitute the things you need here! */ 
     384    if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_READ_WORD | 
     385                                          I2C_FUNC_SMBUS_WRITE_WORD)) 
     386       goto ERROR0; 
    381387 
    382388    /* SENSORS ONLY START */ 
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3372 r3388  
    519519} 
    520520 
     521static u32 bit_func(struct i2c_adapter *adap) 
     522{ 
     523        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 
     524} 
     525 
    521526 
    522527/* -----exported algorithm data: -------------------------------------  */ 
     
    530535        NULL,                           /* slave_recv           */ 
    531536        algo_control,                   /* ioctl                */ 
     537        bit_func,                       /* functionality        */ 
    532538}; 
    533539 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3372 r3388  
    493493} 
    494494 
     495static u32 pcf_func(struct i2c_adapter *adap) 
     496{ 
     497        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 
     498} 
    495499 
    496500/* -----exported algorithm data: -------------------------------------  */ 
     
    504508        NULL,                           /* slave_recv           */ 
    505509        algo_control,                   /* ioctl                */ 
     510        pcf_func,                       /* functionality        */ 
    506511}; 
    507512 
  • i2c/trunk/kernel/i2c-core.c

    r3384 r3388  
    11871187 
    11881188 
     1189/* You should always define `functionality'; the 'else' is just for 
     1190   backward compatibility. */  
     1191u32 i2c_get_functionality (struct i2c_adapter *adap) 
     1192{ 
     1193  if (adap->algo->functionality) 
     1194    return adap->algo->functionality(adap); 
     1195  else 
     1196    return 0xffffffff; 
     1197} 
     1198 
     1199int i2c_check_functionality (struct i2c_adapter *adap, u32 func) 
     1200{ 
     1201  u32 adap_func = i2c_get_functionality (adap); 
     1202  return (func & adap_func) == func; 
     1203} 
     1204 
     1205 
    11891206static int __init i2c_init(void) 
    11901207{ 
     
    13011318EXPORT_SYMBOL(i2c_smbus_write_block_data); 
    13021319 
     1320EXPORT_SYMBOL(i2c_get_functionality); 
     1321EXPORT_SYMBOL(i2c_check_functionality); 
     1322 
    13031323#ifdef MODULE 
    13041324MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
  • i2c/trunk/kernel/i2c.h

    r3384 r3388  
    233233        int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); 
    234234 
     235        /* To determine what the adapter supports */ 
     236        u32 (*functionality) (struct i2c_adapter *); 
    235237}; 
    236238 
     
    349351 */ 
    350352extern int i2c_adapter_id(struct i2c_adapter *adap); 
     353 
     354 
     355/* To determine what functionality is present */ 
     356 
     357#define I2C_FUNC_I2C                    0x00000001 
     358#define I2C_FUNC_10BIT_ADDR             0x00000002 
     359#define I2C_FUNC_SMBUS_QUICK            0x00010000  
     360#define I2C_FUNC_SMBUS_READ_BYTE        0x00020000  
     361#define I2C_FUNC_SMBUS_WRITE_BYTE       0x00040000  
     362#define I2C_FUNC_SMBUS_READ_BYTE_DATA   0x00080000  
     363#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA  0x00100000  
     364#define I2C_FUNC_SMBUS_READ_WORD_DATA   0x00200000  
     365#define I2C_FUNC_SMBUS_WRITE_WORD_DATA  0x00400000  
     366#define I2C_FUNC_SMBUS_PROC_CALL        0x00800000  
     367#define I2C_FUNC_SMBUS_READ_BLOCK_DATA  0x01000000  
     368#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000  
     369#define I2C_FUNC_SMBUS_READ_I2C_BLOCK   0x04000000 /* New I2C-like block */ 
     370#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK  0x08000000 /* transfers          */ 
     371#define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \ 
     372                            I2C_FUNC_SMBUS_READ_BYTE | \ 
     373                            I2C_FUNC_SMBUS_WRITE_BYTE | \ 
     374                            I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 
     375                            I2C_FUNC_SMBUS_WRITE_BYTE_DATA | \ 
     376                            I2C_FUNC_SMBUS_READ_WORD_DATA | \ 
     377                            I2C_FUNC_SMBUS_WRITE_WORD_DATA | \ 
     378                            I2C_FUNC_SMBUS_PROC_CALL | \ 
     379                            I2C_FUNC_SMBUS_READ_BLOCK_DATA 
     380 
     381 
     382/* Return the functionality mask */ 
     383extern u32 i2c_get_functionality (struct i2c_adapter *adap); 
     384 
     385/* Return 1 if adapter supports everything we need, 0 if not. */ 
     386extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func); 
     387 
     388/* The mask of functionality any plain i2c adapter has due to SMBus 
     389   emulation */ 
     390extern u32 i2c_smbus_emul_func; 
    351391 
    352392#endif /* __KERNEL__ */