Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_I2C_ALGO_PCA_H |
| 2 | #define _LINUX_I2C_ALGO_PCA_H |
| 3 | |
Marco Aurelio da Costa | eff9ec9 | 2009-03-28 21:34:44 +0100 | [diff] [blame] | 4 | /* Chips known to the pca algo */ |
| 5 | #define I2C_PCA_CHIP_9564 0x00 |
| 6 | #define I2C_PCA_CHIP_9665 0x01 |
| 7 | |
| 8 | /* Internal period for PCA9665 oscilator */ |
| 9 | #define I2C_PCA_OSC_PER 3 /* e10-8s */ |
| 10 | |
| 11 | /* Clock speeds for the bus for PCA9564*/ |
Wolfram Sang | c01b083 | 2008-04-22 22:16:46 +0200 | [diff] [blame] | 12 | #define I2C_PCA_CON_330kHz 0x00 |
| 13 | #define I2C_PCA_CON_288kHz 0x01 |
| 14 | #define I2C_PCA_CON_217kHz 0x02 |
| 15 | #define I2C_PCA_CON_146kHz 0x03 |
| 16 | #define I2C_PCA_CON_88kHz 0x04 |
| 17 | #define I2C_PCA_CON_59kHz 0x05 |
| 18 | #define I2C_PCA_CON_44kHz 0x06 |
| 19 | #define I2C_PCA_CON_36kHz 0x07 |
| 20 | |
| 21 | /* PCA9564 registers */ |
| 22 | #define I2C_PCA_STA 0x00 /* STATUS Read Only */ |
| 23 | #define I2C_PCA_TO 0x00 /* TIMEOUT Write Only */ |
| 24 | #define I2C_PCA_DAT 0x01 /* DATA Read/Write */ |
| 25 | #define I2C_PCA_ADR 0x02 /* OWN ADR Read/Write */ |
| 26 | #define I2C_PCA_CON 0x03 /* CONTROL Read/Write */ |
| 27 | |
Marco Aurelio da Costa | eff9ec9 | 2009-03-28 21:34:44 +0100 | [diff] [blame] | 28 | /* PCA9665 registers */ |
| 29 | #define I2C_PCA_INDPTR 0x00 /* INDIRECT Pointer Write Only */ |
| 30 | #define I2C_PCA_IND 0x02 /* INDIRECT Read/Write */ |
| 31 | |
| 32 | /* PCA9665 indirect registers */ |
| 33 | #define I2C_PCA_ICOUNT 0x00 /* Byte Count for buffered mode */ |
| 34 | #define I2C_PCA_IADR 0x01 /* OWN ADR */ |
| 35 | #define I2C_PCA_ISCLL 0x02 /* SCL LOW period */ |
| 36 | #define I2C_PCA_ISCLH 0x03 /* SCL HIGH period */ |
| 37 | #define I2C_PCA_ITO 0x04 /* TIMEOUT */ |
| 38 | #define I2C_PCA_IPRESET 0x05 /* Parallel bus reset */ |
| 39 | #define I2C_PCA_IMODE 0x06 /* I2C Bus mode */ |
| 40 | |
| 41 | /* PCA9665 I2C bus mode */ |
| 42 | #define I2C_PCA_MODE_STD 0x00 /* Standard mode */ |
| 43 | #define I2C_PCA_MODE_FAST 0x01 /* Fast mode */ |
| 44 | #define I2C_PCA_MODE_FASTP 0x02 /* Fast Plus mode */ |
| 45 | #define I2C_PCA_MODE_TURBO 0x03 /* Turbo mode */ |
| 46 | |
| 47 | |
Wolfram Sang | c01b083 | 2008-04-22 22:16:46 +0200 | [diff] [blame] | 48 | #define I2C_PCA_CON_AA 0x80 /* Assert Acknowledge */ |
| 49 | #define I2C_PCA_CON_ENSIO 0x40 /* Enable */ |
| 50 | #define I2C_PCA_CON_STA 0x20 /* Start */ |
| 51 | #define I2C_PCA_CON_STO 0x10 /* Stop */ |
| 52 | #define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */ |
| 53 | #define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */ |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | struct i2c_algo_pca_data { |
Wolfram Sang | c01b083 | 2008-04-22 22:16:46 +0200 | [diff] [blame] | 56 | void *data; /* private low level data */ |
| 57 | void (*write_byte) (void *data, int reg, int val); |
| 58 | int (*read_byte) (void *data, int reg); |
| 59 | int (*wait_for_completion) (void *data); |
| 60 | void (*reset_chip) (void *data); |
Marco Aurelio da Costa | eff9ec9 | 2009-03-28 21:34:44 +0100 | [diff] [blame] | 61 | /* For PCA9564, use one of the predefined frequencies: |
| 62 | * 330000, 288000, 217000, 146000, 88000, 59000, 44000, 36000 |
| 63 | * For PCA9665, use the frequency you want here. */ |
Wolfram Sang | c01b083 | 2008-04-22 22:16:46 +0200 | [diff] [blame] | 64 | unsigned int i2c_clock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | int i2c_pca_add_bus(struct i2c_adapter *); |
Wolfram Sang | c01b083 | 2008-04-22 22:16:46 +0200 | [diff] [blame] | 68 | int i2c_pca_add_numbered_bus(struct i2c_adapter *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | #endif /* _LINUX_I2C_ALGO_PCA_H */ |